libre-webui 0.16.1 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +232 -154
  2. package/backend/dist/db.d.ts.map +1 -1
  3. package/backend/dist/db.js +5 -0
  4. package/backend/dist/db.js.map +1 -1
  5. package/backend/dist/index.d.ts.map +1 -1
  6. package/backend/dist/index.js +2 -0
  7. package/backend/dist/index.js.map +1 -1
  8. package/backend/dist/routes/agentCli.d.ts +3 -0
  9. package/backend/dist/routes/agentCli.d.ts.map +1 -0
  10. package/backend/dist/routes/agentCli.js +33 -0
  11. package/backend/dist/routes/agentCli.js.map +1 -0
  12. package/backend/dist/routes/chat.d.ts.map +1 -1
  13. package/backend/dist/routes/chat.js +27 -0
  14. package/backend/dist/routes/chat.js.map +1 -1
  15. package/backend/dist/routes/work.d.ts.map +1 -1
  16. package/backend/dist/routes/work.js +23 -2
  17. package/backend/dist/routes/work.js.map +1 -1
  18. package/backend/dist/services/agentCliService.d.ts +30 -0
  19. package/backend/dist/services/agentCliService.d.ts.map +1 -0
  20. package/backend/dist/services/agentCliService.js +328 -0
  21. package/backend/dist/services/agentCliService.js.map +1 -0
  22. package/backend/dist/services/chatGenerationService.d.ts.map +1 -1
  23. package/backend/dist/services/chatGenerationService.js +19 -1
  24. package/backend/dist/services/chatGenerationService.js.map +1 -1
  25. package/backend/dist/services/workAgentGuidance.js +1 -1
  26. package/backend/dist/services/workAgentGuidance.js.map +1 -1
  27. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  28. package/backend/dist/services/workAgentService.js +37 -0
  29. package/backend/dist/services/workAgentService.js.map +1 -1
  30. package/backend/dist/services/workHostWorkspaceService.d.ts +22 -0
  31. package/backend/dist/services/workHostWorkspaceService.d.ts.map +1 -0
  32. package/backend/dist/services/workHostWorkspaceService.js +136 -0
  33. package/backend/dist/services/workHostWorkspaceService.js.map +1 -0
  34. package/backend/dist/services/workRuntimeService.d.ts +43 -2
  35. package/backend/dist/services/workRuntimeService.d.ts.map +1 -1
  36. package/backend/dist/services/workRuntimeService.js +249 -6
  37. package/backend/dist/services/workRuntimeService.js.map +1 -1
  38. package/backend/dist/services/workTaskService.d.ts +3 -3
  39. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  40. package/backend/dist/services/workTaskService.js +10 -6
  41. package/backend/dist/services/workTaskService.js.map +1 -1
  42. package/backend/dist/services/workTerminalService.d.ts +46 -0
  43. package/backend/dist/services/workTerminalService.d.ts.map +1 -0
  44. package/backend/dist/services/workTerminalService.js +241 -0
  45. package/backend/dist/services/workTerminalService.js.map +1 -0
  46. package/backend/dist/types/index.d.ts +1 -1
  47. package/backend/dist/types/index.d.ts.map +1 -1
  48. package/backend/dist/types/work.d.ts +22 -0
  49. package/backend/dist/types/work.d.ts.map +1 -1
  50. package/backend/dist/utils/chatProviderSelection.d.ts.map +1 -1
  51. package/backend/dist/utils/chatProviderSelection.js +7 -5
  52. package/backend/dist/utils/chatProviderSelection.js.map +1 -1
  53. package/backend/dist/websocketServer.d.ts.map +1 -1
  54. package/backend/dist/websocketServer.js +51 -14
  55. package/backend/dist/websocketServer.js.map +1 -1
  56. package/backend/dist/workTerminalServer.d.ts +17 -0
  57. package/backend/dist/workTerminalServer.d.ts.map +1 -0
  58. package/backend/dist/workTerminalServer.js +224 -0
  59. package/backend/dist/workTerminalServer.js.map +1 -0
  60. package/backend/package.json +1 -1
  61. package/frontend/dist/assets/index-BqI0kezz.css +1 -0
  62. package/frontend/dist/assets/index-CRC6g6bL.js +3 -0
  63. package/frontend/dist/assets/xterm-CmMoOwwu.css +1 -0
  64. package/frontend/dist/index.html +8 -6
  65. package/frontend/dist/js/ArtifactContainer-Cdy-973y.js +1 -0
  66. package/frontend/dist/js/{ArtifactDemoPage-CWDhGWrz.js → ArtifactDemoPage-B4qsvUnF.js} +1 -1
  67. package/frontend/dist/js/ArtifactSlideOutPanel-CmKgQ4eD.js +1 -0
  68. package/frontend/dist/js/{Button-DBk-AREB.js → Button-CRwzOaDZ.js} +1 -1
  69. package/frontend/dist/js/ChatPage-CYT69oBR.js +16 -0
  70. package/frontend/dist/js/FirstTimeSetup-C8LdLP5J.js +1 -0
  71. package/frontend/dist/js/GalleryPage-Bm89pnS8.js +1 -0
  72. package/frontend/dist/js/HomePage-CeCYnMUG.js +1 -0
  73. package/frontend/dist/js/{LibreClawPage-CHEfny1k.js → LibreClawPage-DGMEV6dm.js} +1 -1
  74. package/frontend/dist/js/{ModelManagerModals-DltRprHU.js → ModelManagerModals-DMoEav1l.js} +1 -1
  75. package/frontend/dist/js/ModelSelector-DXPdGdQ_.js +1 -0
  76. package/frontend/dist/js/ModelsPage-D-FIy2x-.js +2 -0
  77. package/frontend/dist/js/PersonasPage-CIrEVFo5.js +13 -0
  78. package/frontend/dist/js/RichMessageContent-BJ49VN9j.js +3 -0
  79. package/frontend/dist/js/SettingsModal-CxtOXPY7.js +1 -0
  80. package/frontend/dist/js/UserManagementPage-BfyYGGFQ.js +1 -0
  81. package/frontend/dist/js/WorkPage-C7bW6Hxx.js +4 -0
  82. package/frontend/dist/js/addon-fit-Cj0_dfHF.js +1 -0
  83. package/frontend/dist/js/api-DCD41-l9.js +19 -0
  84. package/frontend/dist/js/appStore-Bw-8Exsx.js +2 -0
  85. package/frontend/dist/js/ar-BAHlIvy0.js +2 -0
  86. package/frontend/dist/js/authStore-mOYH_AXI.js +4 -0
  87. package/frontend/dist/js/bn-BxquDVbd.js +2 -0
  88. package/frontend/dist/js/{cs-6UKhKj0A.js → cs-C4DoKzRm.js} +2 -2
  89. package/frontend/dist/js/da-CFslpGTw.js +2 -0
  90. package/frontend/dist/js/de-ChudoRh2.js +2 -0
  91. package/frontend/dist/js/es-B36fefE-.js +2 -0
  92. package/frontend/dist/js/{estree-BRklD62a.js → estree-0vwU39qX.js} +1 -1
  93. package/frontend/dist/js/fr-BSVeTM5W.js +2 -0
  94. package/frontend/dist/js/hi-BGoFbl5V.js +2 -0
  95. package/frontend/dist/js/{html-BgGIAGmn.js → html-CApr2Bvi.js} +1 -1
  96. package/frontend/dist/js/id-BfYs2p_j.js +2 -0
  97. package/frontend/dist/js/{is-BWSbAIoq.js → is-DZ1MS-5A.js} +2 -2
  98. package/frontend/dist/js/it-CXtrPCG1.js +2 -0
  99. package/frontend/dist/js/ja-FPJ_NK_y.js +2 -0
  100. package/frontend/dist/js/ko-DVwD4ZZF.js +2 -0
  101. package/frontend/dist/js/{markdown-CM2nBJJi.js → markdown-C78Qc6xu.js} +1 -1
  102. package/frontend/dist/js/ms-PKPP0RX3.js +2 -0
  103. package/frontend/dist/js/nl-DWM5HJZ8.js +2 -0
  104. package/frontend/dist/js/pl-B9va8Tuf.js +2 -0
  105. package/frontend/dist/js/pt-P0IQi-Zr.js +2 -0
  106. package/frontend/dist/js/ru-Ca2bxYnc.js +2 -0
  107. package/frontend/dist/js/{standalone-CUBo-NGt.js → standalone-DmLfI4Qj.js} +1 -1
  108. package/frontend/dist/js/sv-DI4RDwyZ.js +2 -0
  109. package/frontend/dist/js/th-DN0bDS9d.js +2 -0
  110. package/frontend/dist/js/tr-ChqMv5Q4.js +2 -0
  111. package/frontend/dist/js/{typescript-Dcy9qxSB.js → typescript-Bcq62agC.js} +1 -1
  112. package/frontend/dist/js/{ui-vendor-CAFEDSaO.js → ui-vendor-DohPFHDW.js} +1 -1
  113. package/frontend/dist/js/uk-Cr51h_XQ.js +2 -0
  114. package/frontend/dist/js/useBaseQuery-BAOlhjar.js +1 -0
  115. package/frontend/dist/js/useQuery-CcRqxveh.js +1 -0
  116. package/frontend/dist/js/utils-DmZD5uA3.js +1 -0
  117. package/frontend/dist/js/{vi-82JkwFsQ.js → vi-D4OhoVMH.js} +2 -2
  118. package/frontend/dist/js/work-DVgm81bJ.js +1 -0
  119. package/frontend/dist/js/xterm-DKl1QLiw.js +7 -0
  120. package/frontend/dist/js/zh-Bvau7hlR.js +2 -0
  121. package/package.json +3 -3
  122. package/frontend/dist/assets/index-BVgyQN3z.js +0 -5
  123. package/frontend/dist/assets/index-Dme2Ozol.css +0 -1
  124. package/frontend/dist/js/ArtifactContainer-CbMAYwvr.js +0 -1
  125. package/frontend/dist/js/ArtifactSlideOutPanel-CzUpDM59.js +0 -1
  126. package/frontend/dist/js/ChatPage-D0fdzy7a.js +0 -16
  127. package/frontend/dist/js/FirstTimeSetup-CfnOmy9w.js +0 -1
  128. package/frontend/dist/js/GalleryPage-CMkCur9v.js +0 -1
  129. package/frontend/dist/js/ModelSelector-COnlNsVM.js +0 -1
  130. package/frontend/dist/js/ModelsPage-nxheiYJp.js +0 -2
  131. package/frontend/dist/js/PersonasPage-C2pqDsWA.js +0 -13
  132. package/frontend/dist/js/RichMessageContent-Cz9y-bgl.js +0 -3
  133. package/frontend/dist/js/SettingsModal-B6Se68Hd.js +0 -1
  134. package/frontend/dist/js/UserManagementPage-DQeL-Twp.js +0 -1
  135. package/frontend/dist/js/WorkPage-AcZMp8OB.js +0 -2
  136. package/frontend/dist/js/api-Fi-lJlfu.js +0 -19
  137. package/frontend/dist/js/ar-KceI0PfT.js +0 -2
  138. package/frontend/dist/js/bn-DsKo2dzS.js +0 -2
  139. package/frontend/dist/js/da-CJgZ3YuL.js +0 -2
  140. package/frontend/dist/js/de-BZAmOuCT.js +0 -2
  141. package/frontend/dist/js/es-CD4u7no9.js +0 -2
  142. package/frontend/dist/js/fr-Cou2jOS3.js +0 -2
  143. package/frontend/dist/js/hi-ZxkbNCyB.js +0 -2
  144. package/frontend/dist/js/id-DT9CqaWQ.js +0 -2
  145. package/frontend/dist/js/it-CdNoTXm3.js +0 -2
  146. package/frontend/dist/js/ja-CIuQg0xv.js +0 -2
  147. package/frontend/dist/js/ko-BWRUjDOH.js +0 -2
  148. package/frontend/dist/js/ms-gJstIj2a.js +0 -2
  149. package/frontend/dist/js/nl-CydjVNUw.js +0 -2
  150. package/frontend/dist/js/pl-DPN9mAa5.js +0 -2
  151. package/frontend/dist/js/pt-MRXGqIjQ.js +0 -2
  152. package/frontend/dist/js/ru-CvQ9GkJF.js +0 -2
  153. package/frontend/dist/js/sv-BxS2fvhU.js +0 -2
  154. package/frontend/dist/js/th-DMxyn6e4.js +0 -2
  155. package/frontend/dist/js/tr-BTPldUaA.js +0 -2
  156. package/frontend/dist/js/uk-BGxZOKgp.js +0 -2
  157. package/frontend/dist/js/useBaseQuery-CFTidwqz.js +0 -1
  158. package/frontend/dist/js/useQuery-UsSBfWzs.js +0 -1
  159. package/frontend/dist/js/utils-pTFqSV8c.js +0 -1
  160. package/frontend/dist/js/zh-Bxxfwci3.js +0 -2
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/api-Fi-lJlfu.js","js/rolldown-runtime-QTnfLwEv.js","js/router-vendor-BjDI9mRe.js","js/markdown-core-GI9BPwrB.js","js/utils-vendor-Cbaj0BC5.js","js/demoMode-BhEpMVh5.js","js/logger-DbNs3-DK.js","js/RichMessageContent-Cz9y-bgl.js","js/utils-pTFqSV8c.js","js/markdown-math-E4O1gcxj.js","assets/markdown-math-CYlHEDRF.css","js/SettingsModal-B6Se68Hd.js","js/useQuery-UsSBfWzs.js","js/useBaseQuery-CFTidwqz.js","js/useTranslation-Cs6iTP4m.js","js/ui-vendor-CAFEDSaO.js","js/Button-DBk-AREB.js","js/ChatPage-D0fdzy7a.js","js/react-vendor-DyG_ODzn.js","js/artifactHtml-B7Oy2e__.js","js/ArtifactContainer-CbMAYwvr.js","js/OptimizedSyntaxHighlighter-Ci9sRc78.js","js/syntax-highlight-pM1xnNpY.js","js/ModelSelector-COnlNsVM.js","js/ModelsPage-nxheiYJp.js","js/PersonasPage-C2pqDsWA.js","js/GalleryPage-CMkCur9v.js","js/LibreClawPage-CHEfny1k.js","js/WorkPage-AcZMp8OB.js","js/UserManagementPage-DQeL-Twp.js","js/ArtifactDemoPage-CWDhGWrz.js","js/ArtifactSlideOutPanel-CzUpDM59.js","js/FirstTimeSetup-CfnOmy9w.js"])))=>i.map(i=>d[i]);
2
- import{n as e,r as t}from"../js/rolldown-runtime-QTnfLwEv.js";import{d as n,f as r}from"../js/markdown-core-GI9BPwrB.js";import{n as i,t as a}from"../js/react-vendor-DyG_ODzn.js";import{_ as o,a as s,c,d as l,g as u,h as d,i as f,m as p,n as m,o as h,p as g,r as _,s as v,t as y,u as b,v as x}from"../js/router-vendor-BjDI9mRe.js";import{r as S,t as C}from"../js/useTranslation-Cs6iTP4m.js";import{Bt as w,Dt as T,F as E,Ft as D,Jt as ee,Kt as O,M as te,Q as ne,R as re,Rt as ie,St as ae,T as oe,U as se,Ut as ce,V as le,Vt as ue,Xt as k,Yt as A,c as de,ct as fe,dt as pe,g as me,lt as he,n as j,o as ge,p as _e,pt as ve,s as ye,st as be,u as xe,v as Se,vt as Ce,wt as we,xt as Te,yt as Ee,z as De}from"../js/ui-vendor-CAFEDSaO.js";import{a as Oe,o as ke,t as Ae}from"../js/utils-vendor-Cbaj0BC5.js";import{n as je,t as Me}from"../js/demoMode-BhEpMVh5.js";import{t as M}from"../js/logger-DbNs3-DK.js";import{D as Ne,E as Pe,O as Fe,T as Ie,c as N,f as Le,l as Re,o as P,s as ze}from"../js/api-Fi-lJlfu.js";import{a as Be,n as Ve,r as He,t as F}from"../js/utils-pTFqSV8c.js";import{t as I}from"../js/Button-DBk-AREB.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ue,We,Ge={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ke=new(Ue=new WeakMap,We=new WeakMap,class{constructor(){o(this,Ue,Ge),o(this,We,!1)}setTimeoutProvider(e){p(Ue,this,e)}setTimeout(e,t){return d(Ue,this).setTimeout(e,t)}clearTimeout(e){d(Ue,this).clearTimeout(e)}setInterval(e,t){return d(Ue,this).setInterval(e,t)}clearInterval(e){d(Ue,this).clearInterval(e)}});function qe(e){setTimeout(e,0)}var Je=typeof window>`u`||`Deno`in globalThis;function L(){}function Ye(e,t){return typeof e==`function`?e(t):e}function Xe(e){return typeof e==`number`&&e>=0&&e!==1/0}function Ze(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Qe(e,t){return typeof e==`function`?e(t):e}function $e(e,t){return typeof e==`function`?e(t):e}function et(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==nt(o,t.options))return!1}else if(!it(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function tt(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(rt(t.options.mutationKey)!==rt(a))return!1}else if(!it(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function nt(e,t){return(t?.queryKeyHashFn||rt)(e)}function rt(e){return JSON.stringify(e,(e,t)=>lt(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function it(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>it(e[n],t[n])):!1}var at=Object.prototype.hasOwnProperty;function ot(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ct(e)&&ct(t);if(!r&&!(lt(e)&&lt(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:at.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=ot(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function st(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ct(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function lt(e){if(!ut(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ut(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ut(e){return Object.prototype.toString.call(e)===`[object Object]`}function dt(e){return new Promise(t=>{Ke.setTimeout(t,e)})}function ft(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ot(e,t)}function pt(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function mt(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ht=Symbol();function gt(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ht?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function _t(e,t){return typeof e==`function`?e(...t):!!e}function vt(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var yt=(()=>{let e=()=>Je;return{isServer(){return e()},setIsServer(t){e=t}}})(),bt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},xt,St,Ct,wt=new(xt=new WeakMap,St=new WeakMap,Ct=new WeakMap,class extends bt{constructor(){super(),o(this,xt,void 0),o(this,St,void 0),o(this,Ct,void 0),p(Ct,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}})}onSubscribe(){d(St,this)||this.setEventListener(d(Ct,this))}onUnsubscribe(){this.hasListeners()||(d(St,this)?.call(this),p(St,this,void 0))}setEventListener(e){p(Ct,this,e),d(St,this)?.call(this),p(St,this,e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()}))}setFocused(e){d(xt,this)!==e&&(p(xt,this,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof d(xt,this)==`boolean`?d(xt,this):globalThis.document?.visibilityState!==`hidden`}}),Tt=qe;function Et(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Tt,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var R=Et(),Dt,Ot,kt,At=new(Dt=new WeakMap,Ot=new WeakMap,kt=new WeakMap,class extends bt{constructor(){super(),o(this,Dt,!0),o(this,Ot,void 0),o(this,kt,void 0),p(kt,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}})}onSubscribe(){d(Ot,this)||this.setEventListener(d(kt,this))}onUnsubscribe(){this.hasListeners()||(d(Ot,this)?.call(this),p(Ot,this,void 0))}setEventListener(e){p(kt,this,e),d(Ot,this)?.call(this),p(Ot,this,e(this.setOnline.bind(this)))}setOnline(e){d(Dt,this)!==e&&(p(Dt,this,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return d(Dt,this)}});function jt(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function Mt(e){return Math.min(1e3*2**e,3e4)}function Nt(e){return(e??`online`)===`online`?At.isOnline():!0}var Pt=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Ft(e){let t=!1,n=0,r,i=jt(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Pt(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>wt.isFocused()&&(e.networkMode===`always`||At.isOnline())&&e.canRun(),u=()=>Nt(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(yt.isServer()?0:3),o=e.retryDelay??Mt,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),dt(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var It,Lt=(It=new WeakMap,class{constructor(){o(this,It,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Xe(this.gcTime)&&p(It,this,Ke.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(yt.isServer()?1/0:300*1e3))}clearGcTimeout(){d(It,this)!==void 0&&(Ke.clearTimeout(d(It,this)),p(It,this,void 0))}});function Rt(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{vt(e,()=>t.signal,()=>n=!0)},u=gt(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?mt:pt;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Bt:zt,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:zt(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function zt(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Bt(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Vt(e,t){return t?zt(e,t)!=null:!1}function Ht(e,t){return!t||!e.getPreviousPageParam?!1:Bt(e,t)!=null}function Ut(e,t){x(e,t),t.add(e)}var Wt,Gt,Kt,qt,Jt,z,Yt,Xt,Zt,Qt=(Wt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,qt=new WeakMap,Jt=new WeakMap,z=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Zt=new WeakSet,class extends Lt{constructor(e){super(),Ut(this,Zt),o(this,Wt,void 0),o(this,Gt,void 0),o(this,Kt,void 0),o(this,qt,void 0),o(this,Jt,void 0),o(this,z,void 0),o(this,Yt,void 0),o(this,Xt,void 0),p(Xt,this,!1),p(Yt,this,e.defaultOptions),this.setOptions(e.options),this.observers=[],p(Jt,this,e.client),p(qt,this,d(Jt,this).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,p(Gt,this,rn(this.options)),this.state=e.state??d(Gt,this),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return d(Wt,this)}get promise(){return d(z,this)?.promise}setOptions(e){if(this.options={...d(Yt,this),...e},e?._type&&p(Wt,this,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=rn(this.options);e.data!==void 0&&(this.setState(nn(e.data,e.dataUpdatedAt)),p(Gt,this,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&d(qt,this).remove(this)}setData(e,t){let n=ft(this.state.data,e,this.options);return u(Zt,this,en).call(this,{data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){u(Zt,this,en).call(this,{type:`setState`,state:e})}cancel(e){let t=d(z,this)?.promise;return d(z,this)?.cancel(e),t?t.then(L).catch(L):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return d(Gt,this)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>$e(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ht||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>Qe(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Ze(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),d(z,this)?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),d(z,this)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),d(qt,this).notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(d(z,this)&&(d(Xt,this)||u(Zt,this,$t).call(this)?d(z,this).cancel({revert:!0}):d(z,this).cancelRetry()),this.scheduleGc()),d(qt,this).notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||u(Zt,this,en).call(this,{type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&d(z,this)?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(d(z,this))return d(z,this).continueRetry(),d(z,this).promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(p(Xt,this,!0),n.signal)})},i=()=>{let e=gt(this.options,t),n=(()=>{let e={client:d(Jt,this),queryKey:this.queryKey,meta:this.meta};return r(e),e})();return p(Xt,this,!1),this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:d(Jt,this),state:this.state,fetchFn:i};return r(e),e})();(d(Wt,this)===`infinite`?Rt(this.options.pages):this.options.behavior)?.onFetch(a,this),p(Kt,this,this.state),(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&u(Zt,this,en).call(this,{type:`fetch`,meta:a.fetchOptions?.meta}),p(z,this,Ft({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Pt&&e.revert&&this.setState({...d(Kt,this),fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{u(Zt,this,en).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{u(Zt,this,en).call(this,{type:`pause`})},onContinue:()=>{u(Zt,this,en).call(this,{type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{let e=await d(z,this).start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),d(qt,this).config.onSuccess?.(e,this),d(qt,this).config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Pt){if(e.silent)return d(z,this).promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw u(Zt,this,en).call(this,{type:`error`,error:e}),d(qt,this).config.onError?.(e,this),d(qt,this).config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}});function $t(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}function en(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...tn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...nn(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return p(Kt,this,e.manual?n:void 0),n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),R.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),d(qt,this).notify({query:this,type:`updated`,action:e})})}function tn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Nt(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function nn(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function rn(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var an,on=(an=new WeakMap,class extends bt{constructor(e={}){super(),o(this,an,void 0),this.config=e,p(an,this,new Map)}build(e,t,n){let r=t.queryKey,i=t.queryHash??nt(r,t),a=this.get(i);return a||(a=new Qt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){d(an,this).has(e.queryHash)||(d(an,this).set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=d(an,this).get(e.queryHash);t&&(e.destroy(),t===e&&d(an,this).delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){R.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return d(an,this).get(e)}getAll(){return[...d(an,this).values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>et(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>et(e,t)):t}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){R.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){R.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}}),sn,cn,B,ln,un,dn=(sn=new WeakMap,cn=new WeakMap,B=new WeakMap,ln=new WeakMap,un=new WeakSet,class extends Lt{constructor(e){super(),Ut(this,un),o(this,sn,void 0),o(this,cn,void 0),o(this,B,void 0),o(this,ln,void 0),p(sn,this,e.client),this.mutationId=e.mutationId,p(B,this,e.mutationCache),p(cn,this,[]),this.state=e.state||pn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){d(cn,this).includes(e)||(d(cn,this).push(e),this.clearGcTimeout(),d(B,this).notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){p(cn,this,d(cn,this).filter(t=>t!==e)),this.scheduleGc(),d(B,this).notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){d(cn,this).length||(this.state.status===`pending`?this.scheduleGc():d(B,this).remove(this))}continue(){return d(ln,this)?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{u(un,this,fn).call(this,{type:`continue`})},n={client:d(sn,this),meta:this.options.meta,mutationKey:this.options.mutationKey};p(ln,this,Ft({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{u(un,this,fn).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{u(un,this,fn).call(this,{type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>d(B,this).canRun(this)}));let r=this.state.status===`pending`,i=!d(ln,this).canStart();try{if(r)t();else{u(un,this,fn).call(this,{type:`pending`,variables:e,isPaused:i}),d(B,this).config.onMutate&&await d(B,this).config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&u(un,this,fn).call(this,{type:`pending`,context:t,variables:e,isPaused:i})}let a=await d(ln,this).start();return await d(B,this).config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await d(B,this).config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),u(un,this,fn).call(this,{type:`success`,data:a}),a}catch(t){try{await d(B,this).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 d(B,this).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 u(un,this,fn).call(this,{type:`error`,error:t}),t}finally{d(B,this).runNext(this)}}});function fn(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),R.batch(()=>{d(cn,this).forEach(t=>{t.onMutationUpdate(e)}),d(B,this).notify({mutation:this,type:`updated`,action:e})})}function pn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var mn,hn,gn,_n=(mn=new WeakMap,hn=new WeakMap,gn=new WeakMap,class extends bt{constructor(e={}){super(),o(this,mn,void 0),o(this,hn,void 0),o(this,gn,void 0),this.config=e,p(mn,this,new Set),p(hn,this,new Map),p(gn,this,0)}build(e,t,n){var r;let i=new dn({client:e,mutationCache:this,mutationId:p(gn,this,(r=d(gn,this),++r)),options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){d(mn,this).add(e);let t=vn(e);if(typeof t==`string`){let n=d(hn,this).get(t);n?n.push(e):d(hn,this).set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(d(mn,this).delete(e)){let t=vn(e);if(typeof t==`string`){let n=d(hn,this).get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&d(hn,this).delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=vn(e);if(typeof t==`string`){let n=d(hn,this).get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=vn(e);return typeof t==`string`?(d(hn,this).get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){R.batch(()=>{d(mn,this).forEach(e=>{this.notify({type:`removed`,mutation:e})}),d(mn,this).clear(),d(hn,this).clear()})}getAll(){return Array.from(d(mn,this))}find(e){let t={exact:!0,...e};return this.getAll().find(e=>tt(t,e))}findAll(e={}){return this.getAll().filter(t=>tt(e,t))}notify(e){R.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return R.batch(()=>Promise.all(e.map(e=>e.continue().catch(L))))}});function vn(e){return e.options.scope?.id}var V,yn,bn,xn,Sn,Cn,wn,Tn,En=(V=new WeakMap,yn=new WeakMap,bn=new WeakMap,xn=new WeakMap,Sn=new WeakMap,Cn=new WeakMap,wn=new WeakMap,Tn=new WeakMap,class{constructor(e={}){o(this,V,void 0),o(this,yn,void 0),o(this,bn,void 0),o(this,xn,void 0),o(this,Sn,void 0),o(this,Cn,void 0),o(this,wn,void 0),o(this,Tn,void 0),p(V,this,e.queryCache||new on),p(yn,this,e.mutationCache||new _n),p(bn,this,e.defaultOptions||{}),p(xn,this,new Map),p(Sn,this,new Map),p(Cn,this,0)}mount(){var e;p(Cn,this,(e=d(Cn,this),e++,e)),d(Cn,this)===1&&(p(wn,this,wt.subscribe(async e=>{e&&(await this.resumePausedMutations(),d(V,this).onFocus())})),p(Tn,this,At.subscribe(async e=>{e&&(await this.resumePausedMutations(),d(V,this).onOnline())})))}unmount(){var e;p(Cn,this,(e=d(Cn,this),e--,e)),d(Cn,this)===0&&(d(wn,this)?.call(this),p(wn,this,void 0),d(Tn,this)?.call(this),p(Tn,this,void 0))}isFetching(e){return d(V,this).findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return d(yn,this).findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return d(V,this).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=d(V,this).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Qe(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return d(V,this).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=d(V,this).get(r.queryHash)?.state.data,a=Ye(t,i);if(a!==void 0)return d(V,this).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return R.batch(()=>d(V,this).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return d(V,this).get(t.queryHash)?.state}removeQueries(e){let t=d(V,this);R.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=d(V,this);return R.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=R.batch(()=>d(V,this).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(L).catch(L)}invalidateQueries(e,t={}){return R.batch(()=>(d(V,this).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=R.batch(()=>d(V,this).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(L)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(L)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=d(V,this).build(this,t);return n.isStaleByTime(Qe(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(L).catch(L)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(L).catch(L)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return At.isOnline()?d(yn,this).resumePausedMutations():Promise.resolve()}getQueryCache(){return d(V,this)}getMutationCache(){return d(yn,this)}getDefaultOptions(){return d(bn,this)}setDefaultOptions(e){p(bn,this,e)}setQueryDefaults(e,t){d(xn,this).set(rt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...d(xn,this).values()],n={};return t.forEach(t=>{it(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){d(Sn,this).set(rt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...d(Sn,this).values()],n={};return t.forEach(t=>{it(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...d(bn,this).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=nt(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===ht&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...d(bn,this).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){d(V,this).clear(),d(yn,this).clear()}}),H=t(r(),1),U=n(),Dn=H.createContext(void 0),On=e=>{let t=H.useContext(Dn);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},kn=({client:e,children:t})=>(H.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,U.jsx)(Dn.Provider,{value:e,children:t})),An=t(a(),1),W=e=>typeof e==`string`,jn=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},Mn=e=>e==null?``:String(e),Nn=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},Pn=/###/g,Fn=e=>e&&e.includes(`###`)?e.replace(Pn,`.`):e,In=e=>!e||W(e),Ln=(e,t,n)=>{let r=W(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(In(e))return{};let t=Fn(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return In(e)?{}:{obj:e,k:Fn(r[i])}},Rn=(e,t,n)=>{let{obj:r,k:i}=Ln(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=Ln(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=Ln(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},zn=(e,t,n,r)=>{let{obj:i,k:a}=Ln(e,t,Object);i[a]=i[a]||[],i[a].push(n)},Bn=(e,t)=>{let{obj:n,k:r}=Ln(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Vn=(e,t,n)=>{let r=Bn(e,n);return r===void 0?Bn(t,n):r},Hn=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(Object.prototype.hasOwnProperty.call(e,r)?W(e[r])||e[r]instanceof String||W(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):Hn(e[r],t[r],n):e[r]=t[r]);return e},Un=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),Wn={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},Gn=e=>W(e)?e.replace(/[&<>"'\/]/g,e=>Wn[e]):e,Kn=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},qn=[` `,`,`,`?`,`!`,`;`],Jn=new Kn(20),Yn=(e,t,n)=>{t=t||``,n=n||``;let r=qn.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=Jn.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},Xn=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},Zn=e=>e?.replace(/_/g,`-`),Qn={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},$n=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||Qn,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>W(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),W(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},er=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},tr=class extends er{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):W(n)&&i?o.push(...n.split(i)):o.push(n)));let s=Bn(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!W(n)?s:Xn(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),Rn(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(W(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=Bn(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?Hn(s,n,i):s={...s,...n},Rn(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||(t=this.options.defaultNS),this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},nr={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},rr=Symbol(`i18next/PATH_KEY`);function ir(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===rr?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function ar(e,t){let{[rr]:n}=e(ir()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var or=e=>!W(e)&&typeof e!=`boolean`&&typeof e!=`number`,sr=class e extends er{constructor(e,t={}){super(),Nn([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=$n.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=or(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Yn(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:W(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:W(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||(i={}),t==null)return``;typeof t==`function`&&(t=ar(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?ar(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!W(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let D=or(E),ee=Object.prototype.toString.apply(E);if(y&&E&&D&&!_.includes(ee)&&!(W(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;x&&!m?t[e]=this.translate(r,{...i,defaultValue:or(T)?T[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&W(v)&&Array.isArray(m))m=m.join(v),m&&(m=this.extendTranslation(m,t,i,r));else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=W(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!W(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=W(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=nr.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return W(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?ar(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!W(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(W(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!W(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},cr=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=$n.create(`languageUtils`)}getScriptPartFromCode(e){if(e=Zn(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=Zn(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(W(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),W(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return W(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):W(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.includes(e)||i(this.formatLanguageCode(e))}),r}},lr={zero:0,one:1,two:2,few:3,many:4,other:5},ur={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},dr=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=$n.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=Zn(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),ur;if(!e.match(/-|_/))return ur;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule(`dev`,t)),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||(n=this.getRule(`dev`,t)),n?n.resolvedOptions().pluralCategories.sort((e,t)=>lr[e]-lr[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},fr=(e,t,n,r=`.`,i=!0)=>{let a=Vn(e,t,n);return!a&&i&&W(n)&&(a=Xn(e,n,r),a===void 0&&(a=Xn(t,n,r))),a},pr=e=>e.replace(/\$/g,`$$$$`),mr=class{constructor(e={}){this.logger=$n.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?Gn:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?Un(i):a||`{{`,this.suffix=o?Un(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?Un(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?Un(l):``,this.nestingPrefix=d?Un(d):f||Un(`$t(`),this.nestingSuffix=p?Un(p):m||Un(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=fr(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(fr(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>pr(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?pr(this.escape(e)):pr(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=W(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else!W(a)&&!this.useRawValueToEscape&&(a=Mn(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${Un(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!W(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!W(i))return i;W(i)||(i=Mn(i)),i||(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),i=``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},hr=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||(n.currency=i.trim()):t===`relativetime`&&!i.includes(`:`)?n.range||(n.range=i.trim()):i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},gr=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(Zn(r),i),t[o]=s),s(n)}},_r=e=>(t,n,r)=>e(Zn(n),r)(t),vr=class{constructor(e={}){this.logger=$n.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?gr:_r;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=gr(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=hr(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},yr=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},br=class extends er{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=$n.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{zn(n.loaded,[i],a),yr(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();W(e)&&(e=this.languageUtils.toResolveHierarchy(e)),W(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},xr=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),W(e[1])&&(t.defaultValue=e[1]),W(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),Sr=e=>(W(e.ns)&&(e.ns=[e.ns]),W(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),W(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),Cr=()=>{},wr=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},G=class e extends er{constructor(e={},t){if(super(),this.options=Sr(e),this.services={},this.logger=$n,this.modules={external:[]},wr(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(W(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=xr();this.options={...n,...this.options,...Sr(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?$n.init(r(this.modules.logger),this.options):$n.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:vr;let t=new cr(this.options);this.store=new tr(this.options.resources,this.options);let n=this.services;n.logger=$n,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new dr(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new mr(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new br(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new sr(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||(t=Cr),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=jn(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=Cr){let n=t,r=W(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=jn();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||(e=this.languages),t||(t=this.options.ns),n||(n=Cr),this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&nr.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=jn();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=W(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(W(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=ar(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=ar(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=ar(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return W(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=jn();return this.options.ns?(W(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=jn();W(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||(e=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language)),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new cr(xr());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=Cr){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new tr(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...xr().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new mr(n)}return a.translator=new sr(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();G.createInstance,G.dir,G.init,G.loadResources,G.reloadResources,G.use,G.changeLanguage,G.getFixedT,G.t,G.exists,G.setDefaultNamespace,G.hasLoadedNamespace,G.loadNamespaces,G.loadLanguages;var{slice:Tr,forEach:Er}=[];function Dr(e){return Er.call(Tr.call(arguments,1),t=>{if(t)for(let n in t)e[n]===void 0&&(e[n]=t[n])}),e}function Or(e){return typeof e==`string`?[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(e)):!1}var kr=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Ar=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:`/`},r=`${e}=${encodeURIComponent(t)}`;if(n.maxAge>0){let e=n.maxAge-0;if(Number.isNaN(e))throw Error(`maxAge should be a Number`);r+=`; Max-Age=${Math.floor(e)}`}if(n.domain){if(!kr.test(n.domain))throw TypeError(`option domain is invalid`);r+=`; Domain=${n.domain}`}if(n.path){if(!kr.test(n.path))throw TypeError(`option path is invalid`);r+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!=`function`)throw TypeError(`option expires is invalid`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:r+=`; SameSite=Strict`;break;case`lax`:r+=`; SameSite=Lax`;break;case`strict`:r+=`; SameSite=Strict`;break;case`none`:r+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return n.partitioned&&(r+=`; Partitioned`),r},jr={create(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:`/`,sameSite:`strict`};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Ar(e,t,i)},read(e){let t=`${e}=`,n=document.cookie.split(`;`);for(let e=0;e<n.length;e++){let r=n[e];for(;r.charAt(0)===` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return r.substring(t.length,r.length)}return null},remove(e,t){this.create(e,``,-1,t)}},Mr={name:`cookie`,lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<`u`)return jr.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=t;n&&typeof document<`u`&&jr.create(n,e,r,i,a)}},Nr={name:`querystring`,lookup(e){let{lookupQuerystring:t}=e,n;if(typeof window<`u`){let{search:e}=window.location;!window.location.search&&window.location.hash?.indexOf(`?`)>-1&&(e=window.location.hash.substring(window.location.hash.indexOf(`?`)));let r=e.substring(1).split(`&`);for(let e=0;e<r.length;e++){let i=r[e].indexOf(`=`);i>0&&r[e].substring(0,i)===t&&(n=r[e].substring(i+1))}}return n}},Pr={name:`hash`,lookup(e){let{lookupHash:t,lookupFromHashIndex:n}=e,r;if(typeof window<`u`){let{hash:e}=window.location;if(e&&e.length>2){let i=e.substring(1);if(t){let e=i.split(`&`);for(let n=0;n<e.length;n++){let i=e[n].indexOf(`=`);i>0&&e[n].substring(0,i)===t&&(r=e[n].substring(i+1))}}if(r)return r;if(!r&&n>-1){let t=e.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof n==`number`?n:0]?.replace(`/`,``):void 0}}}return r}},Fr=null,Ir=()=>{if(Fr!==null)return Fr;try{if(Fr=typeof window<`u`&&window.localStorage!==null,!Fr)return!1;let e=`i18next.translate.boo`;window.localStorage.setItem(e,`foo`),window.localStorage.removeItem(e)}catch{Fr=!1}return Fr},Lr={name:`localStorage`,lookup(e){let{lookupLocalStorage:t}=e;if(t&&Ir())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:n}=t;n&&Ir()&&window.localStorage.setItem(n,e)}},Rr=null,zr=()=>{if(Rr!==null)return Rr;try{if(Rr=typeof window<`u`&&window.sessionStorage!==null,!Rr)return!1;let e=`i18next.translate.boo`;window.sessionStorage.setItem(e,`foo`),window.sessionStorage.removeItem(e)}catch{Rr=!1}return Rr},Br={name:`sessionStorage`,lookup(e){let{lookupSessionStorage:t}=e;if(t&&zr())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:n}=t;n&&zr()&&window.sessionStorage.setItem(n,e)}},Vr={name:`navigator`,lookup(e){let t=[];if(typeof navigator<`u`){let{languages:e,userLanguage:n,language:r}=navigator;if(e)for(let n=0;n<e.length;n++)t.push(e[n]);n&&t.push(n),r&&t.push(r)}return t.length>0?t:void 0}},Hr={name:`htmlTag`,lookup(e){let{htmlTag:t}=e,n,r=t||(typeof document<`u`?document.documentElement:null);return r&&typeof r.getAttribute==`function`&&(n=r.getAttribute(`lang`)),n}},Ur={name:`path`,lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>`u`)return;let n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(Array.isArray(n))return n[typeof t==`number`?t:0]?.replace(`/`,``)}},Wr={name:`subdomain`,lookup(e){let{lookupFromSubdomainIndex:t}=e,n=typeof t==`number`?t+1:1,r=typeof window<`u`&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},Gr=!1;try{document.cookie,Gr=!0}catch{}var Kr=[`querystring`,`cookie`,`localStorage`,`sessionStorage`,`navigator`,`htmlTag`];Gr||Kr.splice(1,1);var qr=()=>({order:Kr,lookupQuerystring:`lng`,lookupCookie:`i18next`,lookupLocalStorage:`i18nextLng`,lookupSessionStorage:`i18nextLng`,caches:[`localStorage`],excludeCacheFor:[`cimode`],convertDetectedLanguage:e=>e}),Jr=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type=`languageDetector`,this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=Dr(t,this.options||{},qr()),typeof this.options.convertDetectedLanguage==`string`&&this.options.convertDetectedLanguage.indexOf(`15897`)>-1&&(this.options.convertDetectedLanguage=e=>e.replace(`-`,`_`)),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(Mr),this.addDetector(Nr),this.addDetector(Lr),this.addDetector(Br),this.addDetector(Vr),this.addDetector(Hr),this.addDetector(Ur),this.addDetector(Wr),this.addDetector(Pr)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(e=>{if(this.detectors[e]){let n=this.detectors[e].lookup(this.options);n&&typeof n==`string`&&(n=[n]),n&&(t=t.concat(n))}}),t=t.filter(e=>e!=null&&!Or(e)).map(e=>this.options.convertDetectedLanguage(e)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(t=>{this.detectors[t]&&this.detectors[t].cacheUserLanguage(e,this.options)}))}};Jr.type=`languageDetector`;var Yr={common:{loading:`Loading...`,save:`Save`,saving:`Saving...`,cancel:`Cancel`,delete:`Delete`,edit:`Edit`,close:`Close`,back:`Back`,next:`Next`,confirm:`Confirm`,error:`Error`,success:`Success`,warning:`Warning`,or:`or`,optional:`optional`,enabled:`Enabled`,disabled:`Disabled`,on:`On`,off:`Off`,yes:`Yes`,no:`No`,search:`Search`,noResults:`No results found`,retry:`Retry`,refresh:`Refresh`,download:`Download`,upload:`Upload`,export:`Export`,import:`Import`,reset:`Reset`,apply:`Apply`,clear:`Clear`,all:`All`,none:`None`,default:`Default`,custom:`Custom`,remove:`Remove`},brand:{name:`Libre WebUI`,shortName:`Libre`},auth:{login:{title:`Welcome Back`,subtitle:`Sign in to your account to continue`,username:`Username`,usernamePlaceholder:`Enter your username`,password:`Password`,passwordPlaceholder:`Enter your password`,signIn:`Sign In`,signingIn:`Signing in...`,noAccount:`Don't have an account?`,signUpHere:`Sign up here`,loginSuccess:`Login successful!`,loginFailed:`Login failed`,checkCredentials:`Login failed. Please check your credentials.`,enterBoth:`Please enter both username and password`,githubSuccess:`GitHub login successful!`,githubFailed:`GitHub authentication failed`,githubVerifyFailed:`Failed to verify GitHub authentication`},signup:{title:`Create Account`,subtitle:`Sign up for your new account`,username:`Username`,usernamePlaceholder:`Choose a username`,email:`Email`,emailPlaceholder:`your@email.com`,password:`Password`,passwordPlaceholder:`Choose a password`,confirmPassword:`Confirm Password`,confirmPasswordPlaceholder:`Confirm your password`,createAccount:`Create Account`,creatingAccount:`Creating account...`,hasAccount:`Already have an account?`,signInHere:`Sign in here`,signupSuccess:`Account created successfully!`,signupFailed:`Signup failed`,tryAgain:`Signup failed. Please try again.`,usernameRequired:`Username and password are required`,passwordMismatch:`Passwords do not match`,passwordTooShort:`Password must be at least 6 characters long`},logout:{button:`Log out`,success:`Logged out successfully`},oauth:{continueWith:`Continue with {{provider}}`,connectingTo:`Connecting to {{provider}}...`,github:`GitHub`,huggingFace:`Hugging Face`},checkingAuth:`Checking authentication...`,welcome:`Welcome`,noEmail:`No email provided`,role:`Role`,id:`ID`,userId:`User ID`,signInDescription:`Sign in with your GitHub account to continue`,signInWithGitHub:`Sign in with GitHub`,jwtActive:`JWT Authentication Active`,jwtDescription:`JWT-based authentication with GitHub OAuth`,github:`GitHub`,provider:`Provider`},setup:{welcome:{title:`Welcome to Libre WebUI`,subtitle:`Let's Get Started`,description:`Set up your Libre WebUI instance in just a few steps`,createAdmin:`Create Admin Account`,features:{secure:{title:`Secure & Private`,description:`Your conversations stay on your device`},fast:{title:`Fast & Responsive`,description:`Optimized for speed and performance`},openSource:{title:`Open Source`,description:`Free and open source software`}}},admin:{title:`Create Admin Account`,subtitle:`Administrator Setup`,description:`Create the first admin account for your Libre WebUI instance`,usernamePlaceholder:`Enter admin username`,passwordPlaceholder:`Enter password (min 6 characters)`,confirmPlaceholder:`Confirm your password`,creating:`Creating...`,createAdmin:`Create Admin`,success:`Admin account created successfully!`,failed:`Failed to create admin account`,fillAllFields:`Please fill in all fields`,note:`This will be the primary administrator account for your Libre WebUI instance`},encryptionKey:{title:`Save Your Encryption Key`,subtitle:`Important: Save This Key`,description:`This encryption key protects your sensitive data. Store it securely - you'll need it if you ever need to restore your database.`,warning:`Warning`,warningText:`If you lose this key and need to restore your database, your encrypted data (API keys, preferences) will be unrecoverable.`,label:`Your Encryption Key`,loading:`Loading...`,copyToClipboard:`Copy to clipboard`,copied:`Encryption key copied to clipboard!`,copyFailed:`Failed to copy key to clipboard`,envNote:`This key is also saved in your backend/.env file as ENCRYPTION_KEY`,acknowledgment:`I have saved my encryption key in a secure location and understand that losing it may result in data loss.`,confirmRequired:`Please confirm that you have saved the encryption key`,continue:`Continue to Libre WebUI`}},chat:{greeting:{morning:`Good morning`,afternoon:`Good afternoon`,evening:`Good evening`,night:`Good night`},welcome:{helpToday:`What can I help with today?`,helpTonight:`What can I help with tonight?`,variety:{create:{title:`What should we make?`,subtitle:`Start with a thought, a sketch, or a stubborn problem.`},explore:{title:`Where should we begin?`,subtitle:`Bring the question you keep returning to.`},imagine:{title:`What are you imagining?`,subtitle:`We can shape it together.`},focus:{title:`What deserves your attention?`,subtitle:`Let's make the next step clear.`},untangle:{title:`What's tangled?`,subtitle:`Give me the messy version first.`},momentum:{title:`Ready when you are.`,subtitle:`Pick up an idea, plan, or unfinished thread.`},open:{title:`What's on your mind?`,subtitle:`Small thought or ambitious project. Both work.`},challenge:{title:`What are we solving?`,subtitle:`Tell me what isn't working yet.`},draft:{title:`Let's start somewhere.`,subtitle:`It doesn't have to be polished.`},possibility:{title:`What could this become?`,subtitle:`Show me the raw material.`},unexpected:{title:`Make something unexpected.`,subtitle:`Give me a constraint, a mood, or a half-formed idea.`}}},input:{placeholder:`Send a message`,messagePlaceholder:`Message...`,attachImages:`Attach images`,attachments:`Attachments and advanced features`,sendMessage:`Send message`,stopGeneration:`Stop generation`},session:{new:`New Chat`,work:`Work`,chat:`Chat`,private:`Private`,privateMode:`Private Mode`,privateDescription:`This conversation won't be saved`,privateTooltip:`Start a private conversation that won't be saved`,deleteConfirm:`Are you sure you want to delete this chat?`,generatingTitle:`Generating title`,noChats:`No chats yet`,createFirst:`Create your first chat above`,chats:`Chats`,renameChat:`Rename chat`,deleteChat:`Delete chat`},persona:{applied:`Persona applied`,label:`Persona`},model:{updated:`Model updated`,noModels:`No models available`,noModelsDescription:`No models available. Make sure Ollama is running and has models installed.`,pullCommand:`ollama pull llama3.2:3b`,noModelsTooltip:`No models available. Please ensure Ollama is running and models are installed.`},footer:{disclaimer:`LLM can make mistakes - verify important information`,images:`{{count}} image`,images_plural:`{{count}} images`,structuredOutput:`Structured output`},mediaUpload:{dropImagesHere:`Drop images here or`,supportedFormats:`Supports: JPG, PNG, GIF, WebP (max 10MB each)`,browse:`browse`},structuredOutput:{title:`Response Format`,none:`None (Natural Language)`,noneDescription:`Default natural language response`,json:`JSON`,jsonDescription:`Structured JSON format`,list:`List`,listDescription:`Array of items`,summary:`Summary`,summaryDescription:`Document summary with key points`,analysis:`Analysis`,analysisDescription:`Structured analysis with pros/cons`,custom:`Custom Schema`,customDescription:`Define your own JSON schema`,customSchema:`Custom JSON schema`,schemaPreview:`Schema Preview`,applySchema:`Apply Schema`,cancel:`Cancel`,enabled:`Structured output enabled`}},sidebar:{navigation:{chat:`Chat`,models:`Models`,personas:`Personas`,imagine:`Imagine`,agents:`Libre Claw`,work:`Work`,settings:`Settings`,userManagement:`User Management`,signOut:`Sign Out`},toggleSize:`Toggle sidebar size`,expandSidebar:`Expand sidebar`},user:{menu:{changePicture:`Change Picture`,settings:`Settings`,userManagement:`User Management`,logout:`Log out`},avatar:{title:`Change Profile Picture`,updated:`Profile picture updated`,updateFailed:`Failed to update profile picture`,saving:`Saving...`,label:`Avatar`,uploadAvatarImage:`Upload avatar image`,dragAndDrop:`Drag and drop an image or click to browse`,chooseImage:`Choose Image`,uploading:`Uploading...`,enterImageUrl:`Or enter image URL`,supportedFormats:`Supports: JPG, PNG, GIF, WebP (max 2MB). Square images work best.`,customAvatar:`Custom avatar image`,clickToChange:`Click to change or remove`,removed:`Avatar removed`,uploaded:`Avatar uploaded successfully`,invalidFile:`Please select a valid image file`,fileTooLarge:`Avatar image size must be less than 2MB`,readFailed:`Failed to read image file`,uploadFailed:`Failed to upload avatar image`},profile:{noEmail:`No email provided`}},settings:JSON.parse(`{"title":"Settings","tabs":{"appearance":"Appearance","model":"Model","systemMessage":"System Message","plugins":"Plugins","generation":"Generation","documents":"Documents","tts":"Text-to-Speech","imageGen":"Image Generation","data":"Data","about":"About"},"appearance":{"title":"Appearance","language":{"title":"Language","description":"Select your preferred language"},"theme":{"title":"Theme","light":"Light","dark":"Dark","amoled":"Pure Black","system":"System"},"accent":{"title":"Accent color","custom":"Custom color","useColor":"Use {{color}} accent","behaviorTitle":"Interface palette","behaviorDescription":"Choose whether the accent stays on controls or adapts the entire light or dark interface.","defaultStyle":"Default","defaultStyleDescription":"Keep the neutral light and dark surfaces.","adaptedStyle":"Adapt to accent","adaptedStyleDescription":"Tint surfaces, borders, and text with your accent."},"chatInterface":{"title":"Chat Interface","showUsername":"Show Username","showUsernameDescription":"Display username in chat messages"},"background":{"title":"Background Image","enable":"Enable background image","enableDescription":"Show custom background with blur effect","blur":"Blur","opacity":"Opacity","upload":"Upload background image","dragDrop":"Drag and drop an image or click to browse","chooseImage":"Choose Image"}},"saveSettings":"Save Settings","model":{"title":"Model Settings","defaultModel":"Default Model","defaultModelDescription":"This model will be used by default for new conversations","selectModel":"Select a model","persona":"Persona","updateAll":"Update All Models","updateAllDescription":"Check for updates and pull latest versions of all installed models","updateAllButton":"Update All","updating":"Updating models...","currentModelInfo":"Current Model Info","name":"Name","size":"Size","family":"Family","format":"Format","status":"Status","statusStarting":"Starting...","statusComplete":"Complete","statusError":"Error","bulkOperations":"Bulk Operations","autoTitle":{"title":"Auto Title Generation","enable":"Enable Auto Title","enableDescription":"Automatically generate titles for new conversations","taskModel":"Task Model","selectTaskModel":"Select task model","taskModelDescription":"Model used for generating conversation titles"},"updatingModel":"Updating {{name}} ({{current}}/{{total}})","modelsProgress":"{{current}} of {{total}} models","modelPullAccess":"Model Install Access","modelPullAccessDescription":"Allow non-admin users to pull and install new models.","modelPullAccessSaved":"Model install permissions updated","modelPullAccessSaveFailed":"Failed to update model install permissions"},"systemMessage":{"title":"System Message","description":"Set a custom system message that will be used for all new conversations.","placeholder":"Enter a system message...","saved":"System message saved","saveFailed":"Failed to save system message"},"plugins":{"title":"Plugins","description":"Manage your installed plugins","providerConnections":"Provider connections","providerConnectionsDescription":"Connect, configure, and inspect model providers through plugins.","providers":"Providers","searchProviders":"Search providers","noProvidersFound":"No providers match your search.","selectProvider":"Select a provider","selectProviderDescription":"Choose a provider to inspect its connection and model catalog.","addNew":"Add New Plugin","upload":"Upload Plugin","addJson":"Add JSON","uploading":"Uploading...","jsonPlaceholder":"Paste plugin JSON configuration...","install":"Install Plugin","noPlugins":"No plugins installed","noPluginsDescription":"Add a plugin to extend functionality","loading":"Loading plugins...","installed":"Installed Plugins","active":"Active Plugins","activeLabel":"Active","inactive":"Inactive","activate":"Activate","deactivate":"Deactivate","models":"models","apiKeySet":"API Key Set","apiKeyConfiguration":"API Key Configuration","apiKeyDescription":"Store a personal API key for {{name}}.","apiKeyEnvAlternative":"Alternatively, set the","environmentVariable":"environment variable","apiKeyConfigured":"API key configured","apiKeyPlaceholder":"Enter your API key...","saveApiKey":"Save API Key","showApiKey":"Show API key","hideApiKey":"Hide API key","configure":"Configure","providerSettings":"Provider settings","status":"Status","defaultEndpoint":"Default endpoint","modelCatalog":"Model catalog","modelCatalogDescription":"Discovered and configured models for this provider and its capabilities.","refreshModels":"Refresh models","noModelsConfigured":"No models are configured for this provider.","modelId":"Model ID","capabilities":"Capabilities","modelCatalogUpdated":"Model catalog updated: {{count}} models.","modelCatalogUnchanged":"Model catalog is already up to date.","modelCatalogNeedsApiKey":"Add a valid API key for this provider to load its live model list.","modelCatalogUnavailable":"Could not load the provider's model list.","modelCatalogRefreshFailed":"Failed to refresh the model catalog","capability":{"chat":"Chat","embedding":"Embedding","image":"Image","speech":"Speech","transcription":"Transcription"},"exportPlugin":"Export plugin","deletePlugin":"Delete plugin","apiKey":{"title":"API Key","placeholder":"Enter API key","save":"Save Key","remove":"Remove Key","configured":"API Key Configured","notConfigured":"API Key Required","saved":"API key saved successfully","removed":"API key removed","saveFailed":"Failed to save API key","removeFailed":"Failed to remove API key","enterKey":"Please enter an API key"},"variables":"Variables"},"generation":{"title":"Generation Options","description":"Configure how the AI generates responses","advancedSettings":"Advanced generation settings","advancedSettingsDescription":"Sampling, token limits, context, penalties, and stop sequences","coreParameters":"Core Parameters","temperature":"Temperature","temperatureDescription":"Controls randomness. Lower values are more focused, higher values more creative.","topP":"Top P","topPDescription":"Controls diversity via nucleus sampling. Lower values focus on likely tokens.","topK":"Top K","topKDescription":"Limits token selection to top K most likely. Set to 0 to disable.","minP":"Min P","minPDescription":"Minimum probability threshold for token selection.","generationControl":"Generation Control","maxTokens":"Max Tokens","maxTokensDescription":"Maximum number of tokens to generate in the response.","repeatPenalty":"Repeat Penalty","repeatPenaltyDescription":"Penalizes repeated tokens. Higher values reduce repetition.","contextLength":"Context Length","contextLengthDescription":"Maximum context window size for conversations.","seed":"Seed","optional":"optional","random":"Random","seedDescription":"Set a specific seed for reproducible outputs.","advancedOptions":"Advanced Options","presencePenalty":"Presence Penalty","presencePenaltyDescription":"Penalizes tokens that appear in the context.","frequencyPenalty":"Frequency Penalty","frequencyPenaltyDescription":"Penalizes frequently used tokens.","stopSequences":"Stop Sequences","commaSeparated":"comma separated","stopSequencesDescription":"Custom tokens that will stop generation when encountered.","resetDefaults":"Reset to Defaults","saveOptions":"Save Options","embeddingSettings":"Embedding Settings","enableEmbeddings":"Enable Document Embeddings"},"documents":{"title":"Document Settings","embeddings":{"title":"Embeddings","enable":"Enable document embeddings","model":"Embedding Model","modelDescription":"Select the model used for document embedding","chunkSize":"Chunk Size","chunkSizeInTokens":"(in tokens)","chunkSizeDescription":"Size of text chunks for embedding","chunkOverlap":"Chunk Overlap","chunkOverlapInTokens":"(in tokens)","chunkOverlapDescription":"Overlap between consecutive chunks","similarityThreshold":"Similarity Threshold","similarityDescription":"Minimum similarity score to include results","status":"Embedding Status","statusLabel":"Status","available":"Available","unavailable":"Unavailable","chunksWithEmbeddings":"Chunks with embeddings","coverage":"Coverage","regenerate":"Regenerate Embeddings","regenerating":"Regenerating..."}},"tts":{"title":"Text-to-Speech","description":"Configure text-to-speech settings for reading messages aloud","loadingProviders":"Loading TTS providers...","noProviders":"No TTS Providers","noProvidersDescription":"Configure a plugin with TTS support to enable text-to-speech","enable":"Enable TTS","enableDescription":"Allow text-to-speech for assistant messages","autoPlay":"Auto-play Responses","autoPlayDescription":"Automatically read new assistant messages aloud","streamSentences":"Stream Sentences","streamSentencesDescription":"Play audio sentence by sentence instead of waiting for the full message. Recommended for local TTS to avoid timeouts on long messages.","voiceConfiguration":"Voice Configuration","model":"TTS Model","modelDescription":"Select the model for text-to-speech generation","voice":"Voice","selectVoice":"Select a voice","voiceDescription":"Choose the voice for text-to-speech","speed":"Speed","speedSlow":"0.5x","speedNormal":"1.0x","speedFast":"2.0x","availableProviders":"Available Providers","models":"models","test":"Test","testing":"Testing...","stop":"Stop"},"imageGen":{"title":"Image Generation","description":"Configure image generation settings and providers","loadingProviders":"Loading image generation providers...","noProviders":"No Image Generation Providers","noProvidersDescription":"Configure a plugin with image generation support","enable":"Enable Image Generation","enableDescription":"Allow AI image generation in conversations","configuration":"Configuration","model":"Model","modelDescription":"Select the model for image generation","size":"Size","sizeDescription":"Resolution of generated images","quality":"Quality","qualityDescription":"Quality level of generated images","style":"Style","styleDescription":"Style preset for generated images","availableProviders":"Available Providers","models":"models"},"data":{"title":"Data Management","export":"Export Data","exportDescription":"Download all your data including preferences, sessions, and documents.","exportAll":"Export All Data","import":"Import Data","importDescription":"Import data from a previous export.","importData":"Import Data","importing":"Importing...","clearSessions":"Clear Sessions","clearSessionsDescription":"Delete all chat sessions. This action cannot be undone.","clearAll":"Clear All","clearing":"Clearing...","importOptions":"Import Options","importOptionsDescription":"Choose how to handle existing data","skipDuplicates":"Skip duplicates","overwrite":"Overwrite existing","importResults":"Import Results","preferences":"Preferences","imported":"Imported","failed":"Failed","sessions":"Sessions","importedLabel":"imported","skipped":"skipped","documents":"Documents","errors":"Errors"},"about":{"title":"About","versionLabel":"Version","ollama":{"title":"Ollama Status","version":"Version","healthy":"Healthy","unhealthy":"Unhealthy"},"stats":{"models":"Models","sessions":"Sessions"},"features":{"privacy":{"title":"Privacy First","description":"Your data stays on your device"},"openSource":{"title":"Open Source","description":"Free and open source software"},"localInference":{"title":"Local Inference","description":"Run AI models locally with Ollama"}},"openSourceBy":"Open source by {{company}}","links":{"title":"Links","github":"GitHub","githubDescription":"View source code and contribute","website":"Website","websiteDescription":"Visit our website","ollama":"Ollama","ollamaDescription":"Learn more about Ollama","documentation":"Documentation","reportIssue":"Report Issues","reportIssueDescription":"Bug reports & feature requests","gitlab":"GitLab Mirror","gitlabDescription":"Self-hosted GitLab repository","documentationDescription":"Guides, tutorials and API reference"},"version":"Version {{version}}"}}`),models:{title:`Models`,subtitle:`Pull, manage, and monitor your Ollama models`,installed:`Installed Models`,available:`Available Models`,pull:`Pull Model`,pulling:`Pulling...`,delete:`Delete Model`,deleting:`Deleting...`,size:`Size`,modified:`Modified`,family:`Family`,parameters:`Parameters`,quantization:`Quantization`,noModels:`No models installed`,pullFirst:`Pull a model to get started`,noModelsFound:`No models found`},personas:{title:`Personas`,create:`Create Persona`,edit:`Edit Persona`,delete:`Delete Persona`,name:`Name`,description:`Description`,systemPrompt:`System Prompt`,model:`Model`,avatar:`Avatar`,background:`Background`,noPersonas:`No personas created`,createFirst:`Create your first persona to customize your chat experience`},gallery:{title:`Gallery`,subtitle:`Your AI-generated image gallery`,imageCount:`{{count}} images`,generate:`Generate Image`,generateDescription:`Create images with AI`,generating:`Generating...`,prompt:`Prompt`,promptPlaceholder:`Describe the image you want to generate...`,noImages:`No images generated yet`,download:`Download`,delete:`Delete`,regenerate:`Regenerate`,model:`Model`,size:`Size`,quality:`Quality`,created:`Created`},errors:{generic:`An error occurred`,network:`Network error. Please check your connection.`,unauthorized:`You are not authorized to perform this action.`,notFound:`The requested resource was not found.`,serverError:`Server error. Please try again later.`,validation:`Please check your input and try again.`},keyboard:{title:`Keyboard Shortcuts`,toggleSidebar:`Toggle sidebar`,openSettings:`Open settings`,toggleDarkMode:`Toggle dark mode`,showShortcuts:`Show keyboard shortcuts`,closeModals:`Close modals`,groups:{navigation:`Navigation`,settings:`Settings`,general:`General`,chat:`Chat`},actions:{sendMessage:`Send message`,newLine:`New line in message`},footer:`Press {{key1}} or {{key2}} to show this help`,tooltip:`Keyboard shortcuts`},modelManager:{title:`Models`,loading:`Loading models...`,systemStatus:{online:`Ollama Online`,offline:`Ollama Offline`,models:`model`,models_plural:`models`,running:`running`,vram:`VRAM`},sections:{pull:`Pull New Model`,library:`Browse Library`,huggingface:`HuggingFace Hub`,running:`Running Models`,local:`Local Models`,advanced:`Advanced Actions`},pull:{placeholder:`Enter model name (e.g., llama3.2:3b, deepseek-r1:14b)`,button:`Pull`,cancel:`Cancel`,popular:`Popular models:`,browseAll:`Browse all models on ollama.com`,success:`Model {{name}} pulled successfully`,cancelled:`Model pull cancelled`,failed:`Failed to pull model`,enterName:`Please enter a model name`,restricted:`Model installation is restricted to administrators on this instance.`},progress:{starting:`Initializing...`,pulling:`Downloading model...`,pullingLayer:`pulling`,verifying:`Verifying integrity...`,verifyingDigest:`verifying sha256 digest`,writing:`Writing manifest...`,cleaning:`Cleaning up...`},library:{available:`available`,search:`Search models...`,noResults:`No models found matching your criteria`,installed:`Installed`,more:`+{{count}} more`,refresh:`Refresh Library`},huggingface:{browseAll:`Browse all on HuggingFace`,checkingGguf:`Checking for GGUF files...`,noGgufAvailable:`No GGUF files available for direct Ollama pull`,ggufFilesCount:`GGUF Files ({{count}}) - Pull directly to Ollama`,noModelsFound:`No models found`,noResults:`No models found. Try adjusting your search or filters.`,browseAllLink:`Browse all`,search:`Search HuggingFace models...`,by:`by`,gated:`Gated`,viewOnHF:`View on HuggingFace`,sortDownloads:`Downloads`,sortLikes:`Likes`,sortRecent:`Recent`,taskTextGeneration:`Text Generation`,taskTextToSpeech:`Text to Speech`,taskTextToImage:`Text to Image`,taskSpeechRecognition:`Speech Recognition`,tasks:{textGen:`Text Generation`,tts:`Text to Speech`,image:`Text to Image`,stt:`Speech Recognition`},sort:{downloads:`Most Downloads`,likes:`Most Liked`,recent:`Recently Updated`}},local:{noModels:`No models installed yet`,pullToStart:`Pull a model above to get started`,installed:`installed`,running:`Running`,info:`Info`,copy:`Copy`,delete:`Delete`,deleteConfirm:`Are you sure you want to delete model "{{name}}"?`,deleteSuccess:`Model {{name}} deleted successfully`,deleteFailed:`Failed to delete model`},advanced:{createModel:`Create Model`,fromModelfile:`From Modelfile`,copyModel:`Copy Model`,duplicateExisting:`Duplicate existing`,testEmbeddings:`Test Embeddings`,generateVectors:`Generate vectors`,healthCheck:`Health Check`,testConnection:`Test connection`,healthy:`Ollama is healthy!`},modals:{details:{title:`Model Details`,info:`Model Information`,family:`Family`,parameters:`Parameters`,quantization:`Quantization`,format:`Format`,systemPrompt:`System Prompt`,template:`Template`,license:`License`,modelfile:`Modelfile`,noDetails:`No details available`},copy:{title:`Copy Model`,source:`Source Model`,selectModel:`Select a model...`,newName:`New Model Name`,placeholder:`e.g., my-custom-model`,copying:`Copying...`,button:`Copy Model`,success:`Model copied to {{name}}`,failed:`Failed to copy model`,enterBoth:`Please enter both source and destination names`},create:{title:`Create Custom Model`,name:`Model Name`,namePlaceholder:`e.g., my-assistant`,modelfile:`Modelfile`,modelfilePlaceholder:`FROM llama3.2
3
- SYSTEM You are a helpful assistant.`,see:`See`,docs:`Modelfile docs`,docsLink:`for syntax reference`,creating:`Creating...`,button:`Create Model`,success:`Model {{name}} created successfully`,failed:`Failed to create model`,enterBoth:`Please enter model name and Modelfile content`},embeddings:{title:`Test Embeddings`,model:`Embedding Model`,selectModel:`Select a model...`,recommended:`Recommended: nomic-embed-text, mxbai-embed-large`,input:`Input Text`,placeholder:`Enter text to generate embeddings for...`,generating:`Generating...`,button:`Generate Embeddings`,result:`Result ({{count}} dimensions)`,success:`Generated {{count}}-dimensional embedding vector`,failed:`Failed to generate embeddings`,enterBoth:`Please select a model and enter text`}}},personaManager:{title:`Personas`,subtitle:`Create and manage AI personas with custom personalities, memories, and behaviors`,loading:`Loading personas...`,createButton:`Create Persona`,importExport:`Import/Export`,stats:{title:`Your Personas`,count:`{{count}} persona created`,count_plural:`{{count}} personas created`},empty:{title:`No personas yet`,description:`Create your first persona to get started with personalized AI interactions`,button:`Create Your First Persona`},deleteConfirm:`Are you sure you want to delete "{{name}}"?`,deleteSuccess:`Persona "{{name}}" deleted successfully`,downloadSuccess:`Persona "{{name}}" downloaded successfully`,failed:`Failed to {{action}} persona`},personaForm:{title:{create:`Create New Persona`,edit:`Edit Persona`},subtitle:{create:`Create a new AI persona with custom personality, memory systems, and adaptive learning capabilities`,edit:`Customize your AI persona with advanced memory, adaptive learning, and intelligent parameters`},loading:`Loading form...`,saved:`Saved`,tabs:{basic:`Basic`,parameters:`Parameters`,memory:`Memory & Learning`,advanced:`Advanced`},basic:{name:`Name`,namePlaceholder:`Enter persona name`,model:`Model`,selectModel:`Select a model`,description:`Description`,descriptionPlaceholder:`Describe your persona...`,systemPrompt:`System Prompt`,systemPromptPlaceholder:`Enter the system prompt that defines your persona behavior...`,systemPromptHint:`The system prompt defines how your persona will behave and respond.`},parameters:{temperature:`Temperature`,temperatureHint:`Controls creativity vs consistency`,topP:`Top-P`,topPHint:`Controls response diversity`,topK:`Top-K`,topKHint:`Limits vocabulary to top-k tokens`,contextWindow:`Context Window`,contextWindowHint:`Maximum conversation history length`,maxTokens:`Max Tokens`,maxTokensHint:`Maximum response length`,repeatPenalty:`Repeat Penalty`,repeatPenaltyHint:`Reduces repetitive responses`},memory:{title:`Memory System`,subtitle:`Persona remembers conversations over time`,enableHint:`Enable the memory system to let your persona remember conversations and build context over time.`,loading:`Loading memory status...`,noData:`No memory data yet`,memories:`Memories`,mbUsed:`MB Used`,lastBackup:`Last Backup`,never:`Never`,maxMemories:`Maximum Memories`,maxMemoriesHint:`How many memories this persona can store`,retention:`Memory Retention`,retentionHint:`Days to keep memories before cleanup`,autoCleanup:`Auto-cleanup old memories`,wipeAll:`Wipe All Memories`,wipeCannot:`This cannot be undone`,wipeButton:`Wipe`,wiping:`Wiping...`,wipeConfirm:`Are you sure you want to wipe all memories? This cannot be undone.`,wipeSuccess:`Wiped {{count}} memories`},learning:{title:`Adaptive Learning`,subtitle:`Persona evolves based on interactions`,enableHint:`Enable adaptive learning to let your persona evolve and personalize responses based on your interactions.`,speed:`Learning Speed`,slow:`Slow`,slowDesc:`Gradual changes`,balanced:`Balanced`,balancedDesc:`Moderate pace`,fast:`Fast`,fastDesc:`Quick adaptation`,autoAdapt:`Auto-adapt to user preferences`,whatLearns:`What the persona learns:`,conversationTone:`Conversation tone`,responseStyle:`Response style`,userPreferences:`User preferences`,topicInterests:`Topic interests`},advanced:{embeddingModel:`Embedding Model`,embeddingHint:`Select the model used for memory encoding and semantic search. Embedding models are shown first, followed by other available models.`,noModels:`No models found`,embeddingModels:`Embedding Models`,otherModels:`Other Models`,installHint:`Install an embedding model:`,recommended:`Recommended: nomic-embed-text, mxbai-embed-large, bge-m3, snowflake-arctic-embed`,aboutTitle:`About Advanced Settings`,aboutDescription:`The embedding model is used by the memory system to understand semantic meaning and find relevant memories during conversations. Choose a model that matches your use case and available resources.`},actions:{cancel:`Cancel`,save:`Save`,saving:`Saving...`,saveClose:`Save & Close`,create:`Create`},success:{created:`Persona created`,updated:`Persona updated`},error:{saveFailed:`Failed to save`}},personaCard:{enhanced:`Enhanced`,systemPrompt:`System Prompt`,memories:`memories`,use:`Use`,editTooltip:`Edit persona`,downloadTooltip:`Download persona`,backup:`Backup`,exportDNA:`Export DNA`,wipeMemories:`Wipe Memories`,wipeConfirm:`Are you sure you want to wipe all memories for this persona? This action cannot be undone.`,wipeSuccess:`Wiped {{count}} memories`,backupSuccess:`Persona backup downloaded successfully`,dnaSuccess:`Persona DNA exported successfully`,failed:`Failed to {{action}}`},userManager:{title:`User Management`,subtitle:`Manage user accounts and permissions`,pageDescription:`Manage user accounts, permissions, and access controls for your Libre WebUI instance.`,loading:`Loading users...`,createUser:`Create User`,search:`Search users...`,noUsers:`No users found`,noUsersMatching:`No users matching your search`,columns:{user:`User`,email:`Email`,role:`Role`,created:`Created`,actions:`Actions`},roles:{admin:`Admin`,user:`User`},noEmail:`No email`,deleteConfirm:`Are you sure you want to delete user "{{name}}"?`,deleteSuccess:`User deleted successfully`,deleteFailed:`Failed to delete user`,cannotDeleteSelf:`You cannot delete your own account`,form:{title:{create:`Create User`,edit:`Edit User`},username:`Username`,usernamePlaceholder:`Enter username`,email:`Email`,emailPlaceholder:`Enter email (optional)`,password:`Password`,passwordPlaceholder:`Enter password`,passwordHint:`Leave blank to keep current password`,role:`Role`,creating:`Creating...`,updating:`Updating...`,createButton:`Create User`,updateButton:`Update User`,createSuccess:`User created successfully`,updateSuccess:`User updated successfully`,createFailed:`Failed to create user`,updateFailed:`Failed to update user`}},chatHistory:{label:`Conversation history`,jumpToTurn:`Jump to turn {{index}} of {{total}}`},chatMessage:{you:`You`,assistant:`Assistant`,system:`System`,copy:`Copy`,copyMessage:`Copy message`,copied:`Copied!`,regenerate:`Regenerate`,regenerateResponse:`Regenerate response`,edit:`Edit`,editSystemMessage:`Edit system message`,saveChanges:`Save changes`,cancelEditing:`Cancel editing`,delete:`Delete`,deleteConfirm:`Delete this message?`,branch:`Branch`,speaking:`Speaking...`,speakMessage:`Speak message`,stopSpeaking:`Stop speaking`,showMore:`Show more`,showLess:`Show less`,thinking:`Thinking`,systemMessagePlaceholder:`Enter your system message...`,fullSizeImage:`Full size image`,startConversation:`Start a conversation`,startConversationDescription:`Send a message to begin chatting with your AI assistant. Ask questions, get help with code, or have a natural conversation.`,scrollToBottom:`Scroll to bottom`,newMessages:`New messages`},imageGallery:{title:`Image Gallery`,noImages:`No images yet`,noImagesHint:`Generate your first image using the panel on the right`,delete:`Delete`,download:`Download`,deleteConfirm:`Are you sure you want to delete this image?`,deleteSuccess:`Image deleted`,deleteFailed:`Failed to delete image`,downloadFailed:`Failed to download image`,loadMore:`Load More ({{current}} of {{total}})`,loadFailed:`Failed to load gallery`},imageGeneration:{title:`Generate Image`,prompt:`Prompt`,promptPlaceholder:`Describe the image you want to create...`,model:`Model`,selectModel:`Select model`,noModels:`No image generation models available`,configurePlugin:`Configure a plugin with image generation support`,size:`Size`,quality:`Quality`,style:`Style`,generate:`Generate`,generating:`Generating...`,success:`Image generated successfully`,failed:`Failed to generate image`,enterPrompt:`Please enter a prompt`,promptTooLong:`Prompt exceeds maximum length of {{max}} characters`},errorBoundary:{title:`Something went wrong`,description:`We encountered an unexpected error. Please try refreshing the page.`,tryAgain:`Refresh Page`,goHome:`Go to Home`,errorDetails:`Error Details (Development)`},documents:{title:`Documents`,upload:`Upload Document`,uploading:`Uploading...`,noDocuments:`No documents uploaded`,uploadHint:`Upload documents to use in your conversations`,delete:`Delete`,deleteConfirm:`Are you sure you want to delete this document?`,deleteSuccess:`Document deleted`,deleteFailed:`Failed to delete document`,uploadSuccess:`Document uploaded successfully`,uploadFailed:`Failed to upload document`,types:`Supported: PDF, TXT, MD, DOCX`,unsupportedFileType:`Only PDF and TXT files are supported`,fileSizeTooLarge:`File size must be less than 10MB`,uploadSuccessWithName:`Document "{{name}}" uploaded successfully`,removeSuccess:`Document removed successfully`,removeFailed:`Failed to remove document`,removeError:`An error occurred while removing the document`,clickToUpload:`Click to upload`,orDragAndDrop:`or drag and drop`,fileTypesAndSize:`PDF or TXT files up to 10MB`,uploadedDocuments:`Uploaded Documents`,removeDocument:`Remove document`},ttsButton:{speak:`Speak`,stop:`Stop`,speaking:`Speaking...`,generateFailed:`Failed to generate speech`,playbackFailed:`Audio playback failed`,stopSpeaking:`Stop speaking`,generatingSpeech:`Generating speech...`,readAloud:`Read aloud`},artifacts:{title:`Artifacts`,code:`Code`,preview:`Preview`,copy:`Copy code`,copied:`Copied!`,download:`Download`,expand:`Expand`,collapse:`Collapse`,openInNewTab:`Open in new tab`,invalidSvg:`Invalid SVG content`,invalidJson:`Invalid JSON content`,previewMode:`Preview mode`,codeMode:`Code mode`,copyContent:`Copy content`,openInPanel:`Open in panel`,openInNewWindow:`Open in new window`,created:`Created`,closePanelEsc:`Close panel (Esc)`,copyButton:`Copy`,open:`Open`,dragEdgeToResize:`Drag edge to resize`,previewUnavailable:`Preview unavailable`,previewUnavailableDescription:`This artifact does not contain renderable preview content. Switch to code view to inspect the source.`},personaImportExport:{title:`Import & Export Personas`,description:`Export your personas to share them or import personas from others`,exportPersonas:`Export Personas`,importPersonas:`Import Personas`,noPersonasToExport:`No personas to export`,personasAvailable:`{{count}} persona available`,personasAvailable_plural:`{{count}} personas available`,exportAll:`Export All`,uploadJsonFile:`Upload JSON File`,pasteJsonLabel:`Paste JSON Data`,pasteJsonPlaceholder:`Paste persona JSON data here...`,importing:`Importing...`,importButton:`Import Persona(s)`,expectedFormat:`Expected JSON Format:`,exportSuccess:`Persona "{{name}}" exported successfully`,exportFailed:`Failed to export persona`,exportAllSuccess:`All {{count}} personas exported successfully`,exportAllFailed:`Failed to export personas`,pasteJsonData:`Please paste the persona JSON data`,importMultipleSuccess:`Successfully imported {{count}} personas`,importMultipleFailed:`Failed to import {{count}} personas`,importNoneFailed:`Failed to import any personas`,importSuccess:`Persona imported successfully`,importFailed:`Failed to import persona`},generationStats:{details:`Details`,promptTokens:`Prompt tokens:`,generatedTokens:`Generated tokens:`,totalTokens:`Total tokens:`,speed:`Speed:`,promptEval:`Prompt eval:`,generation:`Generation:`,modelLoad:`Model load:`,totalTime:`Total time:`,generatedAt:`Generated at:`},userMenu:{loggedOut:`Logged out successfully`,pictureUpdated:`Profile picture updated`,failedUpdateAvatar:`Failed to update avatar`,failedUpdatePicture:`Failed to update profile picture`,noEmail:`No email provided`,changePicture:`Change Picture`,settings:`Settings`,userManagement:`User Management`,signOut:`Sign Out`,changeProfilePicture:`Change Profile Picture`},pluginManager:{title:`Plugin Manager`,upload:`Upload`,addJson:`Add JSON`,browseHF:`Browse HF Hub`,confirmDelete:`Are you sure you want to delete this plugin?`,uploading:`Uploading plugin...`,pasteJson:`Paste plugin JSON here...`,installPlugin:`Install Plugin`,loading:`Loading plugins...`,noPlugins:`No Plugins Installed`,noPluginsDescription:`Upload a plugin file or add a plugin from JSON to get started.`,active:`Active`,id:`ID`,endpoint:`Endpoint`,activate:`Activate`,deactivate:`Deactivate`,activePlugin:`Active Plugin`,activePluginDescription:`All chat requests will be routed through this plugin`,variables:{title:`Variables`,save:`Save`,saving:`Saving...`,saved:`Variables saved`,saveFailed:`Failed to save variables`,resetDefaults:`Reset to Defaults`,reset:`Variables reset to defaults`,resetFailed:`Failed to reset variables`,sensitiveSet:`Value is set (enter new value to change)`,showValue:`Show {{label}} value`,hideValue:`Hide {{label}} value`,connection:`Connection`,advanced:`Advanced parameters`,inherited:`Use provider default`,inheritedValue:`Use provider default ({{value}})`,enabled:`Enabled`,disabled:`Disabled`,required:`A value is required`,fullApiEndpoint:`Full API endpoint URL`,endpointHelp:`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`,invalidUrl:`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`,insecureUrl:`API endpoints must use HTTP or HTTPS.`,httpWarning:`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`,invalidBaseUrl:`Base URLs cannot contain a query string or fragment.`,invalidApiPath:`Must start with / and contain no URL, query, fragment, or .. segment`,tooLong:`Value is too long`}},huggingface:{title:`HuggingFace Model Browser`,subtitle:`Browse and select models from the Hub`,searchPlaceholder:`Search models...`,filters:`Filters`,task:`Task`,sortBy:`Sort By`,noModels:`No models found`,adjustSearch:`Try adjusting your search or filters`,gated:`Gated`,selected:`Selected`,select:`Select`,refresh:`Refresh`,modelsFound:`models found`},demoMode:{title:`Demo Mode`,github:`GitHub`},libreClaw:{title:`Libre Claw`,subtitle:`Local agent runs, approvals, schedules, memory, tools, and usage.`,dashboard:`Dashboard`,connection:{disconnectedTitle:`Libre Claw daemon is not connected`,disconnectedDescription:`Start it locally with <command>libre-claw start</command> or set <env>LIBRE_CLAW_BASE_URL</env> in the backend environment.`},status:{connected:`Connected`,disconnected:`Disconnected`,activeRuns:`{{count}} active`,activeRuns_plural:`{{count}} active`},states:{queued:`Queued`,running:`Running`,blocked:`Blocked`,done:`Done`,failed:`Failed`,cancelled:`Cancelled`},startRun:{title:`Start Agent Run`,placeholder:`Ask Libre Claw to inspect a repo, fix a bug, run a review, schedule a report...`,chatRun:`Chat run`,goalMode:`Goal mode`,providerOverride:`Provider override`,modelOverride:`Model override`,run:`Run`},modelRoute:{title:`Model Route`,providerPlaceholder:`provider`,modelPlaceholder:`model`,persistGlobal:`Persist to Libre Claw global config`,saveModel:`Save model`,theme:`Libre Claw theme`,saveTheme:`Save theme`},runs:{title:`Runs`,empty:`No Libre Claw runs yet.`},timeline:{title:`Run Timeline`,empty:`Select a run to inspect its events.`,streaming:`Streaming...`,assistantResponse:`Assistant response`,resultOk:`ok`,resultError:`error`,labels:{userMessage:`User message`,toolCall:`Tool call`,toolResult:`Tool result`,approvalRequest:`Approval request`,approvalResponse:`Approval response`,runStarted:`Run started`,runFinished:`Run finished`,usage:`Usage`,error:`Error`}},approvals:{needed:`Approval needed`,allowOnce:`Allow once`,alwaysAllowTool:`Always allow tool`,deny:`Deny`,toolApprovalRequested:`Tool approval requested`},automations:{title:`Automations`,namePlaceholder:`Name`,schedulePlaceholder:`daily 09:00`,promptPlaceholder:`Automation prompt`,create:`Create`,empty:`No scheduled Libre Claw automations.`,runNow:`Run now`,pause:`Pause`,resume:`Resume`,routes:{report:`Report`,telegram:`Telegram`},status:{active:`Active`,paused:`Paused`}},usageFallback:{title:`Usage And Fallback`,usage:`Usage`,fallbackRoute:`Fallback Route`,noUsage:`No usage records yet.`},metrics:{provider:`Provider`,model:`Model`,input:`Input`,output:`Output`,cached:`Cached`,reasoning:`Reasoning`,cost:`Cost`,tool:`Tool`,resolution:`Resolution`,state:`State`,stopReason:`Stop reason`,tokens:`{{formatted}} token`,tokens_plural:`{{formatted}} tokens`},fallbacks:{tool:`tool`,unknown:`unknown`,resolved:`resolved`,unknownError:`Unknown error`},toasts:{loadStatusFailed:`Could not load Libre Claw status`,enterTask:`Enter a task for Libre Claw`,runStarted:`Libre Claw run started`,startRunFailed:`Could not start Libre Claw run`,runCancelled:`Run cancelled`,cancelRunFailed:`Could not cancel run`,approved:`Approved`,denied:`Denied`,resolvePermissionFailed:`Could not resolve permission`,providerModelRequired:`Provider and model are required`,modelUpdated:`Libre Claw model updated`,updateModelFailed:`Could not update model`,themeUpdated:`Libre Claw theme updated`,updateThemeFailed:`Could not update theme`,automationRequired:`Automation name, schedule, and prompt are required`,automationCreated:`Automation created`,createAutomationFailed:`Could not create automation`,automationUpdated:`Automation updated`,updateAutomationFailed:`Could not update automation`}},work:{title:`Work`,subtitle:`Isolated model workspaces`,tasks:{title:`Work tasks`,subtitle:`Persistent local workspaces`,new:`New task`,emptyTitle:`No Work tasks yet`,empty:`Your Work tasks will appear here after you send the first message.`,untitled:`Untitled task`,actions:`Task actions`,delete:`Delete task`,deleteNamed:`Delete {{title}}`,deleteConfirm:`Delete “{{title}}” and its workspace permanently?`,close:`Close Work tasks`,open:`Open Work tasks`,rename:`Task title`,loading:`Loading task…`,notFound:`This Work task is unavailable`,back:`Start a new task`,status:`Status: {{status}}`},landing:{title:`Start a new Work task`,description:`Give a local or configured provider model a durable, isolated workspace. It can inspect files, run tools, and continue where it left off when you return.`,isolated:`Isolated`,isolatedBody:`Every task gets its own container and files.`,durable:`Durable`,durableBody:`Return to its conversation and workspace later.`,controlled:`Controlled`,controlledBody:`The runtime and task files stay isolated from the host.`},composer:{placeholder:`Describe what you want to build or change…`,model:`Work model`,noModels:`No Work-compatible models`,cancel:`Stop`,send:`Run`,hint:`Each task keeps its own files and history. Review model output before using it.`,remoteTitle:`Remote provider`,remoteHint:`Conversation and tool output are sent to the configured service. One autonomous run can make multiple provider calls and may incur charges. Workspace files stay local unless a tool returns their contents.`,remoteDismiss:`Dismiss`,remoteDismissLabel:`Dismiss remote provider notice`,remoteDismissFailed:`Could not save the remote provider preference.`,noModelSelected:`No Work-compatible model is selected.`},conversation:{ready:`Workspace ready`,empty:`Continue the task below. This conversation and its files stay attached to this workspace.`,loadOlder:`Load older messages`},status:{preparing:`Preparing isolated workspace…`,running:`Working in the local workspace…`},statusLabels:{idle:`Idle`,thinking:`Thinking`,complete:`Complete`,needsInput:`Needs input`,error:`Error`},live:{connecting:`Connecting to live updates…`,reconnecting:`Reconnecting to live updates…`,unavailable:`Live updates unavailable`,newActivity:`New activity`,skillsLoaded:`Workspace skills · {{count}}`},runtime:{unavailable:`Runtime unavailable`,ready:`Runtime ready`,readyOllama:`Docker ready`,readyPlugin:`Docker + plugin ready`,readyHybrid:`Docker + models ready`,reason:`Docker and an available Ollama or plugin model provider are required.`},workspace:{label:`Workspace views`,files:`Files`,activity:`Activity`,preview:`Preview`,resize:`Resize conversation and workspace`,resizeHint:`Drag to resize. Use arrow keys for precise control. Double-click or press Enter to reset.`,splitSize:`Conversation {{conversation}}%, workspace {{workspace}}%`},files:{discard:`Discard unsaved file changes?`,leaveWithDraft:`Leave this file? Your unsaved edit will remain as a browser draft.`,up:`Parent folder`,back:`Back to files`,empty:`No files in this folder yet.`,select:`Select a file to inspect and edit it.`,editorLabel:`File editor: {{path}}`,format:`Format`,formatted:`Code formatted.`,formatFailed:`Could not format this file.`,formatShortcut:`Format (Shift+Alt+F)`,formatTooLarge:`Formatting is limited to files under 100,000 characters and 4,000 lines.`,formatUnsupported:`Formatting is not available for this file type.`,saveShortcut:`Save (⌘/Ctrl+S)`,highlightPaused:`Live highlighting is paused for large files to keep editing responsive.`,plainTextLarge:`Plain text · large file`},activity:{empty:`Commands, file operations, and tool results will appear here.`,toolActivity:`Tool activity`,details:`Details`,kinds:{message:`Message`,toolCall:`Tool call`,toolResult:`Tool result`,error:`Error`}},preview:{command:`Optional start command`,start:`Start preview`,stop:`Stop preview`,open:`Open`,starting:`Starting preview…`,frameTitle:`Workspace preview`,failed:`The preview could not start. Check Activity, then try another command.`,empty:`Start the app inside this workspace to inspect it here.`},mobile:{surface:`Task surface`,conversation:`Conversation`,workspace:`Workspace`},toasts:{runFailed:`Could not start the Work task.`,updateFailed:`Could not update this task.`,renameFailed:`Could not rename this task.`,cancelled:`Work run stopped.`,cancelFailed:`Could not stop the Work run.`,deleteFailed:`Could not delete this Work task.`,saveFailed:`Could not save this file.`,saved:`File saved.`,previewFailed:`Could not start the preview.`,previewStopFailed:`Could not stop the preview.`}},personaBackground:{label:`Background Image`,uploadBackgroundImage:`Upload background image`,dragAndDrop:`Drag and drop an image or click to browse`,chooseImage:`Choose Image`,uploading:`Uploading...`,enterImageUrl:`Or enter image URL`,supportedFormats:`Supports: JPG, PNG, GIF, WebP (max 5MB). Wide landscape images work best.`,customBackground:`Custom background image`,clickToChange:`Click to change or remove`,removed:`Background removed`,uploaded:`Background uploaded successfully`,invalidFile:`Please select a valid image file`,fileTooLarge:`Background image size must be less than 5MB`,readFailed:`Failed to read image file`,uploadFailed:`Failed to upload background image`},modelSelector:{searchInstalled:`Search installed models...`,searchOllama:`Search Ollama library...`,searchHuggingFace:`Search HuggingFace...`,selectModel:`Select a model`,personas:`Personas`,ollamaModels:`Ollama Models`,pluginModels:`Plugin Models`,actions:`Actions`,installed:`Installed`,use:`Use`,pull:`Pull`,pullRestricted:`Model installation is restricted to administrators on this instance.`,adminOnlyPull:`Admins only`}},Xr={en:{translation:Yr}},Zr=[{code:`en`,name:`English`,nativeName:`English`,dir:`ltr`},{code:`ar`,name:`Arabic`,nativeName:`العربية`,dir:`rtl`},{code:`bn`,name:`Bengali`,nativeName:`বাংলা`,dir:`ltr`},{code:`cs`,name:`Czech`,nativeName:`Čeština`,dir:`ltr`},{code:`da`,name:`Danish`,nativeName:`Dansk`,dir:`ltr`},{code:`de`,name:`German`,nativeName:`Deutsch`,dir:`ltr`},{code:`es`,name:`Spanish`,nativeName:`Español`,dir:`ltr`},{code:`fr`,name:`French`,nativeName:`Français`,dir:`ltr`},{code:`hi`,name:`Hindi`,nativeName:`हिन्दी`,dir:`ltr`},{code:`id`,name:`Indonesian`,nativeName:`Bahasa Indonesia`,dir:`ltr`},{code:`is`,name:`Icelandic`,nativeName:`Íslenska`,dir:`ltr`},{code:`it`,name:`Italian`,nativeName:`Italiano`,dir:`ltr`},{code:`ja`,name:`Japanese`,nativeName:`日本語`,dir:`ltr`},{code:`ko`,name:`Korean`,nativeName:`한국어`,dir:`ltr`},{code:`ms`,name:`Malay`,nativeName:`Bahasa Melayu`,dir:`ltr`},{code:`nl`,name:`Dutch`,nativeName:`Nederlands`,dir:`ltr`},{code:`pl`,name:`Polish`,nativeName:`Polski`,dir:`ltr`},{code:`pt`,name:`Portuguese`,nativeName:`Português`,dir:`ltr`},{code:`ru`,name:`Russian`,nativeName:`Русский`,dir:`ltr`},{code:`sv`,name:`Swedish`,nativeName:`Svenska`,dir:`ltr`},{code:`th`,name:`Thai`,nativeName:`ไทย`,dir:`ltr`},{code:`tr`,name:`Turkish`,nativeName:`Türkçe`,dir:`ltr`},{code:`uk`,name:`Ukrainian`,nativeName:`Українська`,dir:`ltr`},{code:`vi`,name:`Vietnamese`,nativeName:`Tiếng Việt`,dir:`ltr`},{code:`zh`,name:`Chinese`,nativeName:`中文`,dir:`ltr`}],Qr=[`ar`,`he`,`fa`,`ur`],$r=Zr.map(e=>e.code),ei={en:()=>Promise.resolve(Yr),ar:()=>f(()=>import(`../js/ar-KceI0PfT.js`).then(e=>e.default),[]),bn:()=>f(()=>import(`../js/bn-DsKo2dzS.js`).then(e=>e.default),[]),cs:()=>f(()=>import(`../js/cs-6UKhKj0A.js`).then(e=>e.default),[]),da:()=>f(()=>import(`../js/da-CJgZ3YuL.js`).then(e=>e.default),[]),de:()=>f(()=>import(`../js/de-BZAmOuCT.js`).then(e=>e.default),[]),es:()=>f(()=>import(`../js/es-CD4u7no9.js`).then(e=>e.default),[]),fr:()=>f(()=>import(`../js/fr-Cou2jOS3.js`).then(e=>e.default),[]),hi:()=>f(()=>import(`../js/hi-ZxkbNCyB.js`).then(e=>e.default),[]),id:()=>f(()=>import(`../js/id-DT9CqaWQ.js`).then(e=>e.default),[]),is:()=>f(()=>import(`../js/is-BWSbAIoq.js`).then(e=>e.default),[]),it:()=>f(()=>import(`../js/it-CdNoTXm3.js`).then(e=>e.default),[]),ja:()=>f(()=>import(`../js/ja-CIuQg0xv.js`).then(e=>e.default),[]),ko:()=>f(()=>import(`../js/ko-BWRUjDOH.js`).then(e=>e.default),[]),ms:()=>f(()=>import(`../js/ms-gJstIj2a.js`).then(e=>e.default),[]),nl:()=>f(()=>import(`../js/nl-CydjVNUw.js`).then(e=>e.default),[]),pl:()=>f(()=>import(`../js/pl-DPN9mAa5.js`).then(e=>e.default),[]),pt:()=>f(()=>import(`../js/pt-MRXGqIjQ.js`).then(e=>e.default),[]),ru:()=>f(()=>import(`../js/ru-CvQ9GkJF.js`).then(e=>e.default),[]),sv:()=>f(()=>import(`../js/sv-BxS2fvhU.js`).then(e=>e.default),[]),th:()=>f(()=>import(`../js/th-DMxyn6e4.js`).then(e=>e.default),[]),tr:()=>f(()=>import(`../js/tr-BTPldUaA.js`).then(e=>e.default),[]),uk:()=>f(()=>import(`../js/uk-BGxZOKgp.js`).then(e=>e.default),[]),vi:()=>f(()=>import(`../js/vi-82JkwFsQ.js`).then(e=>e.default),[]),zh:()=>f(()=>import(`../js/zh-Bxxfwci3.js`).then(e=>e.default),[])},ti=e=>{let t=e?.toLowerCase().split(`-`)[0];return $r.includes(t)?t:`en`},ni=e=>Qr.includes(ti(e)),ri=e=>{if(typeof document>`u`)return;let t=ti(e);document.documentElement.lang=t,document.documentElement.dir=ni(t)?`rtl`:`ltr`},ii=async e=>{let t=ti(e);if(!G.hasResourceBundle(t,`translation`)){let e=await ei[t]();G.addResourceBundle(t,`translation`,e,!0,!0)}return t},ai=async e=>{let t=await ii(e);return await G.changeLanguage(t),t};if(typeof window<`u`){let e=navigator.language;try{e=window.localStorage.getItem(`i18nextLng`)||e}catch{}ri(e),G.on(`languageChanged`,ri)}var oi=(async()=>{G.isInitialized||await G.use(Jr).use(S).init({resources:Xr,fallbackLng:`en`,supportedLngs:$r,nonExplicitSupportedLngs:!0,load:`languageOnly`,debug:!1,interpolation:{escapeValue:!1},detection:{order:[`localStorage`,`navigator`,`htmlTag`],caches:[`localStorage`],lookupLocalStorage:`i18nextLng`}});let e=ti(G.language||G.resolvedLanguage);if(e!==`en`)try{await ii(e),ti(G.language)===e&&await G.changeLanguage(e)}catch{await G.changeLanguage(`en`)}ri(G.resolvedLanguage||G.language||`en`)})(),si=[`Chat`,`Image`,`Speech`,`Transcription`,`Embedding`],ci={chat:`Chat`,completion:`Chat`,embedding:`Embedding`,image:`Image`,stt:`Transcription`,tts:`Speech`},li={completion:`Chat`,embedding:`Embedding`,image:`Image`,stt:`Transcription`,tts:`Speech`};function ui(e){let t=new Map,n=(e,n)=>{for(let r of e||[]){if(typeof r!=`string`||!r.trim())continue;let e=r.trim(),i=t.get(e)??new Set;i.add(n),t.set(e,i)}};n(e.model_map,ci[e.type]);for(let t of Object.keys(e.capabilities||{}))n(e.capabilities?.[t]?.model_map,li[t]);return Array.from(t,([e,t])=>({id:e,capabilities:si.filter(e=>t.has(e))}))}function di(e){return e.type===`chat`||e.type===`completion`}var fi=[`dall-e`,`embed`,`gpt-image`,`moderation`,`rerank`,`sora`,`stable-diffusion`,`text-to-speech`,`tts`,`whisper`];function pi(e){let t=e.toLocaleLowerCase();return!fi.some(e=>t.includes(e))}function mi(e){let t=new Set;for(let[n,r]of Object.entries(e.capabilities||{}))if(n!==`completion`)for(let e of r?.model_map||[])t.add(e.trim());return(e.model_map||[]).filter(e=>typeof e==`string`&&e.trim().length>0&&!t.has(e.trim())&&pi(e))}function hi(e,t){let n=t.trim().toLocaleLowerCase();return n?[e.name,e.id,e.type,...ui(e).map(e=>e.id)].some(e=>e?.toLocaleLowerCase().includes(n)):!0}var K=(e,t)=>{if(e&&typeof e==`object`&&`response`in e){let t=e;if(t.response?.data?.error)return t.response.data.error}return e instanceof Error?e.message:t};function gi(e){return{...e,id:e.id||He(),timestamp:Date.now()}}function _i(e,t){return e.currentSession?.isPrivate&&e.currentSession?.id===t}function vi(e,t){return e.sessions.some(e=>e.id===t)}function yi(e,t){return!!e.currentSession&&(_i(e,t)||vi(e,e.currentSession.id))}function bi(e,t,n){if(_i(e,t))return e.currentSession.messages.find(e=>e.id===n.id)?e:{currentSession:{...e.currentSession,messages:[...e.currentSession.messages,n],updatedAt:Date.now()},sessions:e.sessions};if(e.sessions.find(e=>e.id===t)?.messages.some(e=>e.id===n.id))return e;let r=e.sessions.map(e=>{if(e.id!==t)return e;let r=[...e.messages];if(n.parentId){let e=n.parentId;r=r.map(t=>t.id===e||t.parentId===e?{...t,isActive:!1,branchIndex:t.branchIndex??0,siblingCount:(n.branchIndex||0)+1}:t)}return{...e,messages:[...r,n],updatedAt:Date.now()}});return{sessions:r,currentSession:e.currentSession?.id===t&&r.find(e=>e.id===t)||e.currentSession}}function xi(e,t,n,r){if(e.currentSession?.id!==t)return e;if(e.currentSession?.isPrivate){let t=e.currentSession.messages.find(e=>e.id===n);return!t||t.content===r?e:{sessions:e.sessions,currentSession:{...e.currentSession,messages:e.currentSession.messages.map(e=>e.id===n?{...e,content:r}:e),updatedAt:Date.now()}}}let i=e.sessions.find(e=>e.id===t),a=i?.messages.find(e=>e.id===n);if(!i||!a||a.content===r)return e;let o=e.sessions.map(e=>e.id===t?{...e,messages:e.messages.map(e=>e.id===n?{...e,content:r}:e),updatedAt:Date.now()}:e);return{sessions:o,currentSession:e.currentSession?.id===t&&o.find(e=>e.id===t)||e.currentSession}}function Si(e,t,n,r,i,a){if(e.currentSession?.id!==t)return e;if(e.currentSession?.isPrivate)return{sessions:e.sessions,currentSession:{...e.currentSession,messages:e.currentSession.messages.map(e=>e.id===n?{...e,content:r,statistics:i,...a?{providerMetadata:a}:{}}:e),updatedAt:Date.now()}};let o=e.sessions.map(e=>e.id===t?{...e,messages:e.messages.map(e=>e.id===n?{...e,content:r,statistics:i,...a?{providerMetadata:a}:{}}:e),updatedAt:Date.now()}:e);return{sessions:o,currentSession:e.currentSession?.id===t&&o.find(e=>e.id===t)||e.currentSession}}function Ci(e){return e.reduce((e,t)=>(e[t.id]=t,e),{})}function wi(e){return e.map(e=>({name:`persona:${e.id}`,model:e.model,size:0,digest:``,details:{parent_model:e.model,format:`persona`,family:`persona`,families:[`persona`],parameter_size:``,quantization_level:``},modified_at:new Date(e.updated_at).toISOString(),expires_at:new Date().toISOString(),size_vram:0,isPersona:!0,personaName:e.name,personaDescription:e.description}))}function Ti(e){return e.filter(e=>e.active&&e.type!==`tts`&&e.type!==`image`).flatMap(e=>mi(e).map(t=>({name:t,model:t,size:0,digest:``,details:{parent_model:``,format:``,family:``,families:[],parameter_size:``,quantization_level:``},modified_at:new Date().toISOString(),expires_at:new Date().toISOString(),size_vram:0,isPlugin:!0,pluginId:e.id,pluginName:e.name})))}var Ei=`persona:`,Di=`plugin:`,Oi=`ollama:`,ki=`legacy:`,Ai=e=>{try{return decodeURIComponent(e)}catch{return null}};function ji(e){return e.isLegacySelection?{model:e.name,providerType:null,providerId:null}:e.isPersona?{model:e.name,providerType:`ollama`,providerId:null}:e.isPlugin&&e.pluginId?{model:e.name,providerType:`plugin`,providerId:e.pluginId}:{model:e.name,providerType:`ollama`,providerId:null}}function Mi(e){return e.providerType?e.providerType===`plugin`&&e.providerId?`${Di}${encodeURIComponent(e.providerId)}:${encodeURIComponent(e.model)}`:e.providerType===`ollama`&&e.model.startsWith(Ei)?`${Ei}${encodeURIComponent(e.model.slice(8))}`:e.providerType===`ollama`?`${Oi}${encodeURIComponent(e.model)}`:`${ki}${encodeURIComponent(e.model)}`:`${ki}${encodeURIComponent(e.model)}`}function Ni(e){return Mi(ji(e))}function Pi(e){if(e.startsWith(Ei)){let t=Ai(e.slice(8));return t===null?null:{model:`${Ei}${t}`,providerType:`ollama`,providerId:null}}if(e.startsWith(Di)){let t=e.slice(7),n=t.indexOf(`:`);if(n<1)return null;let r=Ai(t.slice(0,n)),i=Ai(t.slice(n+1));return r&&i?{model:i,providerType:`plugin`,providerId:r}:null}if(e.startsWith(Oi)){let t=Ai(e.slice(7));return t?{model:t,providerType:`ollama`,providerId:null}:null}if(e.startsWith(ki)){let t=Ai(e.slice(7));return t?{model:t,providerType:null,providerId:null}:null}return null}function Fi(e,t){return t.providerType===`plugin`?e.find(e=>e.isPlugin&&e.pluginId===t.providerId&&e.name===t.model):t.providerType===`ollama`?t.model.startsWith(Ei)?e.find(e=>e.isPersona&&e.name===t.model):e.find(e=>!e.isPlugin&&!e.isPersona&&e.name===t.model):e.find(e=>e.isLegacySelection&&e.name===t.model)??e.find(e=>e.name===t.model)}function Ii(e,t){if(!t.providerType)return Mi(t);let n=Fi(e,t);return n?Ni(n):Mi(t)}function Li(e,t){let n=e.find(e=>Ni(e)===t);return n?ji(n):Pi(t)}function Ri(e){return!e.isPlugin&&!e.isPersona&&!e.isLegacySelection&&!e.isUnavailable}function zi(e,t){return t.model?!!Fi(e.filter(e=>!e.isLegacySelection&&!e.isUnavailable),t):!1}function Bi(e,t){if(!t.model)return e;if(!t.providerType){if(e.some(e=>e.isLegacySelection&&e.name===t.model))return e;let n=!!Fi(e,t);return[...e,{name:t.model,model:t.model,size:0,digest:``,modified_at:``,details:{},isLegacySelection:!0,isUnavailable:!n}]}if(Fi(e,t))return e;let n=t.providerType,r=n===`ollama`&&t.model.startsWith(Ei),i=n===`plugin`&&t.providerId||void 0;return[...e,{name:t.model,model:t.model,size:0,digest:``,modified_at:``,details:{},isPlugin:n===`plugin`,pluginId:i,pluginName:i,isPersona:r,personaName:r?t.model.slice(8):void 0,isUnavailable:!0}]}var q=M(`chat-store`),Vi=ke((e,t)=>({sessions:[],currentSession:null,setCurrentSession:t=>{e({currentSession:t})},createSession:async(t,n,r,i,a)=>{try{e({loading:!0,error:null});let o=await Ie.createSession(t,n,r,i,a);if(o.success&&o.data){let t=o.data;return e(e=>({sessions:[t,...e.sessions],currentSession:t,loading:!1})),k.success(`New chat created`),t}}catch(t){let n=K(t,`Failed to create session`);e({error:n,loading:!1}),k.error(n)}},loadSessions:async()=>{try{e({loading:!0,error:null});let t=await Ie.getSessions();t.success&&t.data&&e(e=>{let n=t.data||[],r=n.map(e=>e.id),i=null;return e.currentSession&&r.includes(e.currentSession.id)?i=n.find(t=>t.id===e.currentSession.id)||null:n.length>0&&(i=n[0],e.currentSession&&q.warn(`Previous currentSession not found in backend sessions:`,e.currentSession.id)),{sessions:n,currentSession:i,loading:!1}})}catch(t){let n=K(t,`Failed to load sessions`);e({error:n,loading:!1}),k.error(n)}},deleteSession:async t=>{try{let n=await Ie.deleteSession(t);n.success?(e(e=>{let n=e.sessions.filter(e=>e.id!==t),r=e.currentSession?.id===t?n[0]||null:e.currentSession;return q.debug(`Store: Updating state, sessions count:`,n.length),{sessions:n,currentSession:r}}),k.success(`Chat deleted`)):(q.error(`Store: deleteSession failed:`,n),k.error(`Failed to delete chat`))}catch(e){q.error(`Store: deleteSession error:`,e);let t=K(e,`Failed to delete session`);k.error(t)}},clearAllSessions:async()=>{try{e({loading:!0,error:null});let t=await Ie.clearAllSessions();t.success?(e({sessions:[],currentSession:null,loading:!1}),k.success(`All chat history cleared`)):(q.error(`Store: clearAllSessions failed:`,t),k.error(`Failed to clear chat history`),e({loading:!1}))}catch(t){q.error(`Store: clearAllSessions error:`,t);let n=K(t,`Failed to clear chat history`);k.error(n),e({loading:!1})}},clearAllState:()=>{e({sessions:[],currentSession:null,models:[],selectedModel:``,selectedProviderType:null,selectedProviderId:null,systemMessage:``,loading:!1,error:null})},applySessionTitle:(t,n,r=Date.now())=>{e(e=>({sessions:e.sessions.map(e=>e.id===t?{...e,title:n,updatedAt:r}:e),currentSession:e.currentSession?.id===t?{...e.currentSession,title:n,updatedAt:r}:e.currentSession}))},updateSessionTitle:async(e,n)=>{try{let r=await Ie.updateSession(e,{title:n});if(r.success&&r.data){let n=r.data.title,i=r.data.updatedAt??Date.now();t().applySessionTitle(e,n,i),k.success(`Chat title updated`)}}catch(e){let t=K(e,`Failed to update session`);k.error(t)}},addMessage:(n,r)=>{let i=t(),a=_i(i,n);if(!yi(i,n)){k.error(`No valid chat session. Please create or select a chat.`),q.error(`addMessage blocked: currentSession is not valid`,i.currentSession?.id);return}if(!a&&!vi(i,n)){k.error(`Session not found or invalid. Please select or create a valid chat session.`),q.error(`addMessage blocked: sessionId not found in sessions`,n);return}let o=gi(r);e(e=>bi(e,n,o))},updateMessage:(t,n,r)=>{e(e=>xi(e,t,n,r))},updateMessageWithStatistics:(t,n,r,i,a)=>{e(e=>Si(e,t,n,r,i,a))},models:[],loadModels:async()=>{try{e({loading:!0,error:null}),q.debug(`Loading models from API...`);let n=[],r;try{let e=await Le.getModels();e.success&&e.data?(n=[...e.data],q.debug(`Ollama models loaded:`,e.data.length)):r=Error(e.error||e.message||`Ollama models are unavailable.`)}catch(e){r=e,q.warn(`Ollama models are unavailable; continuing with plugin models:`,e)}try{let e=await N.getAllPlugins();if(e.success&&e.data){let t=e.data.filter(e=>e.active&&e.type!==`tts`&&e.type!==`image`);q.debug(`🔌 Active plugins found:`,t.map(e=>e.name));let r=Ti(t);n.push(...r),q.debug(`Plugin models added:`,r.length)}}catch(e){q.error(`❌ Failed to load plugin models:`,e),e instanceof Error&&q.error(`❌ Plugin error details:`,{message:e.message,response:e.response?.data,status:e.response?.status,url:e.config?.url})}let i=n.length;try{let{personaApi:t}=await f(async()=>{let{personaApi:e}=await import(`../js/api-Fi-lJlfu.js`).then(e=>e.t);return{personaApi:e}},__vite__mapDeps([0,1,2,3,4,5,6])),r=await t.getPersonas();if(r.success&&r.data){let t=Ci(r.data),i=wi(r.data);n.push(...i),e(e=>({...e,personas:t}))}}catch(e){q.error(`❌ Failed to load personas:`,e)}q.debug(`Total models loaded:`,n.length);let a=i===0&&r?K(r,`No model provider is available`):null,o=t(),s=o.selectedModel,c={model:s,providerType:o.selectedProviderType,providerId:o.selectedProviderId},l=!!Fi(n,c),u=o.selectedProviderType===`ollama`||o.selectedProviderType===`plugin`;if(s&&!l&&u){let t=`Selected model "${s}" is unavailable from ${o.selectedProviderType===`plugin`?o.selectedProviderId||`plugin`:`Ollama`}. Reactivate that provider or select another model.`;e({models:n,loading:!1,error:t}),k.error(t);return}if(s&&!l&&n.length>0){let t=ji(n[0]);q.debug(`⚠️ Legacy selected model "${s}" no longer available, falling back to "${t.model}"`),e({models:n,loading:!1,selectedModel:t.model,selectedProviderType:t.providerType||null,selectedProviderId:t.providerId||null,error:a}),ze.setDefaultModel(t.model,t.providerType,t.providerId).catch(e=>{q.warn(`Failed to save fallback default model:`,e)}),k.success(`Switched to ${t.model} (previous model no longer available)`)}else e({models:n,loading:!1,error:a});a&&k.error(a)}catch(t){q.error(`Error loading models:`,t);let n=K(t,`Failed to load models`);e({error:n,loading:!1}),k.error(n)}},loadPreferences:async()=>{try{let t=await ze.getPreferences();if(t.success&&t.data){let{defaultModel:n,defaultProviderType:r,defaultProviderId:i,systemMessage:a}=t.data;n&&(e({selectedModel:n,selectedProviderType:r||null,selectedProviderId:r===`plugin`&&i||null}),q.debug(`✅ Loaded default model from backend:`,n)),a!==void 0&&(e({systemMessage:a}),q.debug(`✅ Loaded system message from backend`))}}catch(e){q.warn(`❌ Failed to load preferences from backend:`,e)}},selectedModel:``,selectedProviderType:null,selectedProviderId:null,setSelectedModel:(t,n=null,r=null)=>{let i=n===`plugin`&&r||null;e({selectedModel:t,selectedProviderType:n,selectedProviderId:i}),ze.setDefaultModel(t,n,i).catch(e=>{q.warn(`Failed to save default model to backend:`,e)})},updateCurrentSessionModel:async(n,r=null,i=null)=>{let a=t();if(!a.currentSession)throw Error(`No current session to update`);try{let t=await Ie.updateSession(a.currentSession.id,{model:n,providerType:r,providerId:r===`plugin`?i:null});t.success&&t.data&&(e(e=>({sessions:e.sessions.map(n=>n.id===e.currentSession?.id?t.data:n),currentSession:t.data,selectedModel:n,selectedProviderType:r,selectedProviderId:r===`plugin`&&i||null})),k.success(`Model updated for current chat`))}catch(e){let t=K(e,`Failed to update session model`);throw k.error(t),e}},personas:{},loadPersonas:async()=>{try{e({loading:!0,error:null});let t=await Re.getPersonas();if(t.success&&t.data){let n=t.data;e({personas:Ci(n),loading:!1}),q.debug(`✅ Personas loaded:`,n.length)}}catch(t){let n=K(t,`Failed to load personas`);e({error:n,loading:!1}),q.error(`❌ Failed to load personas:`,n)}},getCurrentPersona:()=>{let e=t();if(!e.currentSession||!e.currentSession.model?.startsWith(`persona:`))return null;let n=e.currentSession.model.replace(`persona:`,``);return e.personas[n]||null},systemMessage:``,setSystemMessage:n=>{let r=t();if(e({systemMessage:n}),ze.setSystemMessage(n).catch(e=>{q.warn(`Failed to save system message to backend:`,e)}),r.currentSession){let t=r.currentSession.messages.findIndex(e=>e.role===`system`);if(t!==-1){e(e=>{let r=e.sessions.map(r=>{if(r.id===e.currentSession?.id){let e=r.messages.map((e,r)=>r===t&&e.role===`system`?{...e,content:n,timestamp:Date.now()}:e);return{...r,messages:e,updatedAt:Date.now()}}return r});return{sessions:r,currentSession:e.currentSession?r.find(t=>t.id===e.currentSession.id)||e.currentSession:null}});let i=r.currentSession.messages[t];Ie.updateMessage(r.currentSession.id,i.id,{content:n}).catch(e=>{q.warn(`Failed to sync system message update to backend:`,e)}),q.debug(`✅ Updated system message in current session`)}}},loading:!1,error:null,setError:t=>e({error:t}),generatingTitleForSession:null,setGeneratingTitleForSession:t=>e({generatingTitleForSession:t}),...typeof window<`u`&&{testPluginApi:async()=>{try{q.debug(`🧪 Testing plugin API...`);let e=await N.getAllPlugins();return q.debug(`✅ Plugin API test result:`,e),e}catch(e){return q.error(`❌ Plugin API test failed:`,e),{error:e}}}}})),Hi=1e5,Ui=`[Earlier live output omitted]
4
-
5
- `,J=e=>e&&typeof e==`object`&&!Array.isArray(e)?e:void 0,Y=(e,...t)=>{for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim())return t}},X=(e,...t)=>{for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t!=`string`||!t.trim())continue;let r=Number(t);if(Number.isFinite(r))return r}},Wi=(e,t)=>{let n=String(e||``).trim().toLowerCase().replace(/[\s-]+/g,`_`);return n===`queued`?`queued`:n===`preparing`||n===`starting`?`preparing`:n===`thinking`||n===`running`||n===`working`?`thinking`:n===`using_tool`||n===`tool`||n===`tool_call`?`using_tool`:n===`responding`||n===`streaming`||n===`assistant`?`responding`:n===`completed`||n===`complete`||n===`done`?`completed`:n===`needs_input`||n===`needsinput`||n===`blocked`?`needs_input`:n===`failed`||n===`error`?`failed`:n===`cancelled`||n===`canceled`||n===`stopped`?`cancelled`:t},Gi=(e,t)=>{let n=Y(t,`total`);if(n!==void 0)return Ki(n);let r=Y(t,`text`,`content`,`delta`,`reasoning`)||``;return t.replace===!0||t.cumulative===!0?Ki(r):Ki(e+r)},Ki=e=>{let t=e.startsWith(Ui),n=t?e.slice(31):e,r=Hi-31;return!t&&n.length<=Hi?n:t&&n.length<=r?Ui+n:Ui+n.slice(-99969)},qi=(e,t)=>{let n=J(e.usage)||e,r={...t};for(let[e,t]of[[`inputTokens`,[`inputTokens`,`input_tokens`,`promptTokens`,`prompt_tokens`]],[`outputTokens`,[`outputTokens`,`output_tokens`,`completionTokens`,`completion_tokens`]],[`reasoningTokens`,[`reasoningTokens`,`reasoning_tokens`]],[`cachedTokens`,[`cachedTokens`,`cached_tokens`]],[`totalTokens`,[`totalTokens`,`total_tokens`]],[`tokensPerSecond`,[`tokensPerSecond`,`tokens_per_second`]],[`durationMs`,[`durationMs`,`duration_ms`]]]){let i=X(n,...t);i!==void 0&&(r[e]=i)}return r.totalTokens===void 0&&(r.inputTokens!==void 0||r.outputTokens!==void 0)&&(r.totalTokens=(r.inputTokens||0)+(r.outputTokens||0)),r},Ji=(e,t)=>{let n=J(e.skill)||e,r=Y(n,`name`,`title`,`skill`)||`Skill`;return{id:Y(n,`id`,`skillId`,`skill_id`)||`${r}-${t}`,name:r,description:Y(n,`description`,`summary`)}},Yi=(e,t,n)=>{let r=J(e.tool)||e,i=J(r.message),a=i?J(i.metadata):void 0,o=a?{...a,...r}:r,s=Y(o,`name`,`toolName`,`tool_name`,`function`)||`tool`;return{id:Y(o,`id`,`toolCallId`,`tool_call_id`,`callId`)||`${s}-${n}`,name:s,status:o.isError===!0||o.is_error===!0?`error`:`running`,arguments:o.arguments??o.input??o.args??o.parameters??void 0,metadata:J(o.metadata)||a,startedAt:X(o,`startedAt`,`started_at`,`timestamp`)||t}},Xi=(e,t)=>Array.isArray(e)?e.flatMap((e,n)=>{let r=J(e);if(!r)return[];let i=Yi(r,t,n),a=Y(r,`output`,`content`,`result`),o=Wi(r.status,`using_tool`);return[{...i,status:r.isError===!0||r.is_error===!0?`error`:o===`completed`?`completed`:i.status,output:a,finishedAt:X(r,`finishedAt`,`finished_at`),durationMs:X(r,`durationMs`,`duration_ms`)}]}):[],Zi=(e,t,n)=>({taskId:e,runId:t,connection:`idle`,phase:`queued`,lastEventId:0,reasoning:``,response:``,tools:[],skills:[],startedAt:n,terminal:!1}),Qi=(e,t)=>{let n=J(t.data.liveRun)||J(t.data.live_run)||J(t.data.run)||t.data,r=J(t.data.task)||J(t.data.detail),i=r?J(r.activeRun):void 0,a=Y(n,`reasoning`,`thinking`),o=Y(n,`response`,`assistant`,`content`),s=Wi(n.phase??n.status??i?.status??r?.status,e.phase),c=e.lastEventId>0&&s!==`completed`&&s!==`needs_input`&&s!==`failed`&&s!==`cancelled`&&n.phase===void 0?e.phase:s,l=Xi(n.tools??n.toolActivities??n.tool_activities,t.timestamp),u=n.skills,d=Array.isArray(u)?u.flatMap((e,t)=>{let n=J(e);return n?[Ji(n,t)]:[]}):e.skills,f=n.terminal===!0||c===`completed`||c===`needs_input`||c===`failed`||c===`cancelled`;return{...e,phase:c,reasoning:a===void 0?e.reasoning:Ki(a),response:o===void 0?e.response:Ki(o),tools:l.length>0?l:e.tools,skills:d,usage:J(n.usage)?qi(n,e.usage):e.usage,round:X(n,`round`,`roundIndex`,`round_index`)??e.round,roundLimit:X(n,`roundLimit`,`round_limit`)??e.roundLimit,startedAt:X(n,`startedAt`,`started_at`)??(i?X(i,`startedAt`,`started_at`):void 0)??e.startedAt,finishedAt:X(n,`finishedAt`,`finished_at`)??e.finishedAt,error:Y(n,`error`,`message`)??e.error,terminal:f}},$i=(e,t)=>{let n=e.findIndex(e=>e.id===t.id);if(n===-1)return[...e,t];let r=[...e];return r[n]={...e[n],...t},r},ea=(e,t)=>{let n=e?.taskId===t.taskId&&e.runId===t.runId?e:Zi(t.taskId,t.runId,t.timestamp);if(t.type!==`snapshot`&&t.id<=n.lastEventId)return n;let r={...n,connection:`connected`,connectionError:void 0,lastEventId:Math.max(n.lastEventId,t.id)};if(t.type===`snapshot`)r=Qi(r,t);else if(t.type===`run_state`){let e=Wi(t.data.phase??t.data.status??t.data.state,r.phase);r={...r,phase:e,round:X(t.data,`round`,`roundIndex`,`round_index`)??r.round,roundLimit:X(t.data,`roundLimit`,`round_limit`)??r.roundLimit,startedAt:X(t.data,`startedAt`,`started_at`)??r.startedAt,terminal:r.terminal||e===`completed`||e===`needs_input`||e===`failed`||e===`cancelled`}}else if(t.type===`reasoning_delta`)r={...r,phase:`thinking`,reasoning:Gi(r.reasoning,t.data)};else if(t.type===`assistant_delta`)r={...r,phase:`responding`,response:Gi(r.response,t.data)};else if(t.type===`tool_call`)r={...r,phase:`using_tool`,tools:$i(r.tools,Yi(t.data,t.timestamp,r.tools.length))};else if(t.type===`tool_result`){let e=Yi(t.data,t.timestamp,r.tools.length),n=r.tools.find(t=>t.id===e.id),i=t.data.isError===!0||t.data.is_error===!0||t.data.error===!0;r={...r,phase:`thinking`,tools:$i(r.tools,{...n,...e,status:i?`error`:`completed`,arguments:n?.arguments??e.arguments,startedAt:n?.startedAt??e.startedAt,output:Y(t.data,`output`,`content`,`result`,`message`)||``,finishedAt:X(t.data,`finishedAt`,`finished_at`)||t.timestamp,durationMs:X(t.data,`durationMs`,`duration_ms`)})}}else if(t.type===`usage`)r={...r,usage:qi(t.data,r.usage)};else if(t.type===`skill_loaded`){let e=Ji(t.data,r.skills.length);r={...r,skills:r.skills.some(t=>t.id===e.id)?r.skills:[...r.skills,e]}}else if(t.type===`error`)r={...r,phase:`failed`,error:Y(t.data,`message`,`error`)||`The Work run stopped unexpectedly.`,finishedAt:X(t.data,`finishedAt`,`finished_at`)||t.timestamp,terminal:t.data.terminal!==!1};else if(t.type===`done`){let e=Wi(t.data.status??t.data.state??t.data.phase,`completed`);r={...r,phase:e,error:Y(t.data,`error`,`message`)??r.error,usage:J(t.data.usage)?qi(t.data,r.usage):r.usage,finishedAt:X(t.data,`finishedAt`,`finished_at`)||t.timestamp,terminal:!0}}return r},ta=(e,t)=>Error(t?.error||t?.message||e),na=(e,t)=>{if(typeof e==`object`&&e&&`response`in e){let t=e.response,n=t?.data?.error||t?.data?.message;if(n)return n}return e instanceof Error&&e.message?e.message:t},ra=e=>[...e].sort((e,t)=>t.updatedAt-e.updatedAt||t.createdAt-e.createdAt||e.id.localeCompare(t.id)),ia=({messages:e,messageCursor:t,hasMoreMessages:n,...r})=>r,aa=(e,t)=>{let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return[...n.values()].sort((e,t)=>e.messageIndex-t.messageIndex||e.createdAt-t.createdAt||e.id.localeCompare(t.id))},oa=(e,t)=>{if(!e||e.id!==t.id)return t;let n=e.updatedAt>t.updatedAt?{...t,...e}:{...e,...t};if(e.messages.length===0)return{...n,messages:t.messages,messageCursor:t.messageCursor,hasMoreMessages:t.hasMoreMessages};let r=Math.max(...e.messages.map(e=>e.messageIndex)),i=Math.min(...t.messages.map(e=>e.messageIndex)),a=t.messages.length>0&&r+1<i;return{...n,messages:aa(e.messages,t.messages),messageCursor:a?t.messageCursor:e.messageCursor,hasMoreMessages:a?t.hasMoreMessages:e.hasMoreMessages}},sa=(e,t)=>{let n=e.find(e=>e.id===t.id);if(n&&n.updatedAt>t.updatedAt)return e;let r=ia(t),i=e.findIndex(e=>e.id===t.id);if(i===-1)return[r,...e];let a=[...e];return a[i]=r,a},ca=(e,t)=>{let n=new Map(t.map(e=>[e.id,e])),r=new Set(e.map(e=>e.id)),i=ra(t.filter(e=>!r.has(e.id))),a=e.flatMap(e=>{let t=n.get(e.id);return t?[e.updatedAt>t.updatedAt?e:t]:[]});return[...i,...a]},la=ke((e,t)=>{let n=0,r=0,i=0,a=0,o=0,s=null,c=0,l=0,u=0,d=null,f=0,p=new Set,m=new Set,h=new Map,g=(e,t)=>`${e}\u0000${t}`,_=e=>e===n,v=e=>{if(!_(e))throw Error(`Work session changed.`)},y=()=>{l+=1,u+=1,d=null,m.clear()},b=()=>{let t=++c;return m.add(t),e({loadingFiles:!0}),t},x=(n,r,i)=>{m.delete(n),_(r)&&t().selectedTaskId===i&&e({loadingFiles:m.size>0})},S=e=>t().selectedTaskId===e,C=t=>{let n=++f;return h.set(n,t),S(t)&&e({actionLoading:!0,error:null}),n},w=(n,r)=>{if(h.delete(n),!_(r))return;let i=t().selectedTaskId;e({actionLoading:[...h.values()].some(e=>e===i)})},T=(t,n,r)=>{_(n)&&S(t)&&e({error:r})},E=(t,r=n,i=!1)=>{_(r)&&(i&&(o+=1),e(e=>({tasks:sa(e.tasks,t),selectedTask:e.selectedTaskId===t.id?oa(e.selectedTask,t):e.selectedTask})))},D=async(e,t,r)=>{let i=n,a=C(r);try{let n=await e();if(v(i),!n.success||!n.data)throw ta(t,n);return E(n.data,i,!0),n.data}catch(e){let n=na(e,t);throw T(r,i,n),Error(n)}finally{w(a,i)}};return{capabilities:null,tasks:[],selectedTaskId:null,selectedTask:null,files:[],selectedFile:null,liveRuns:{},loadingTasks:!1,loadingTask:!1,loadingOlderMessages:!1,loadingFiles:!1,actionLoading:!1,error:null,loadCapabilities:async()=>{let t=n;try{let n=await P.capabilities();if(v(t),!n.success||!n.data)throw ta(`Could not inspect the Work runtime.`,n);e({capabilities:n.data})}catch(n){_(t)&&e({capabilities:{available:!1,runtime:`docker`,image:``,reason:na(n,`The Work runtime is unavailable.`)}})}},loadTasks:async(t=!1)=>{let c=n,l=++r,u=o;t||(i=l,p.add(l),e({loadingTasks:!0,error:null}));try{let t=await P.listTasks();if(v(c),!t.success||!t.data)throw ta(`Could not load Work tasks.`,t);let n=ra(t.data);if(l<=a||u!==o)return;a=l,e(e=>{let t=ca(e.tasks,n),r=e.selectedTaskId?t.find(t=>t.id===e.selectedTaskId):void 0,i=r&&e.selectedTask?{...e.selectedTask,...r,messages:e.selectedTask.messages,messageCursor:e.selectedTask.messageCursor,hasMoreMessages:e.selectedTask.hasMoreMessages}:e.selectedTask,a=s,o=a!==null&&l>a.requestId;return o&&(s=null),{tasks:t,selectedTask:i,...o&&e.error===a.message?{error:null}:{}}})}catch(n){let r=na(n,`Could not load Work tasks.`);!t&&_(c)&&l===i&&l>a&&u===o&&(s={requestId:l,message:r},e({error:r}))}finally{p.delete(l),!t&&_(c)&&e({loadingTasks:p.size>0})}},selectTask:t=>{y(),e(e=>({selectedTaskId:t,selectedTask:t&&e.selectedTask?.id===t?e.selectedTask:null,files:[],selectedFile:null,loadingFiles:!1,loadingOlderMessages:!1,actionLoading:[...h.values()].some(e=>e===t),error:null}))},loadTask:async(t,r=!1)=>{let i=n;r||e({loadingTask:!0,error:null});try{let e=await P.getTask(t);if(v(i),!e.success||!e.data)throw ta(`Could not load this Work task.`,e);return E(e.data,i),e.data}catch(t){let n=na(t,`Could not load this Work task.`);throw!r&&_(i)&&e({error:n}),Error(n)}finally{!r&&_(i)&&e({loadingTask:!1})}},loadOlderMessages:async r=>{let i=n,a=t().selectedTask,o=a?.id===r?a.messageCursor:void 0;if(!a||a.id!==r||!a.hasMoreMessages||o===void 0)return[];e({loadingOlderMessages:!0,error:null});try{let t=await P.getMessages(r,o);if(v(i),!t.success||!t.data)throw ta(`Could not load older Work messages.`,t);let n=t.data;return e(e=>{if(e.selectedTask?.id!==r)return{};let t=e.selectedTask.messageCursor===o;return{selectedTask:{...e.selectedTask,messages:aa(e.selectedTask.messages,n.messages),messageCursor:t?n.cursor:e.selectedTask.messageCursor,hasMoreMessages:t?n.hasMore:e.selectedTask.hasMoreMessages}}}),n.messages}catch(n){let a=na(n,`Could not load older Work messages.`);throw _(i)&&t().selectedTaskId===r&&e({error:a}),Error(a)}finally{_(i)&&t().selectedTaskId===r&&e({loadingOlderMessages:!1})}},createTask:e=>D(()=>P.createTask(e),`Could not create the Work task.`,null),updateTask:(e,t)=>D(()=>P.updateTask(e,t),`Could not update the Work task.`,e),deleteTask:async r=>{let i=n,a=C(r);try{let n=await P.deleteTask(r);if(v(i),!n.success)throw ta(`Could not delete the Work task.`,n);t().selectedTaskId===r&&y(),o+=1,e(e=>({tasks:e.tasks.filter(e=>e.id!==r),selectedTaskId:e.selectedTaskId===r?null:e.selectedTaskId,selectedTask:e.selectedTaskId===r?null:e.selectedTask,files:e.selectedTaskId===r?[]:e.files,selectedFile:e.selectedTaskId===r?null:e.selectedFile,liveRuns:Object.fromEntries(Object.entries(e.liveRuns).filter(([e])=>e!==r))}))}catch(e){let t=na(e,`Could not delete the Work task.`);throw T(r,i,t),Error(t)}finally{w(a,i)}},startRun:async(e,t)=>{let r=n,i=C(e);try{let n=await P.startRun(e,t);if(v(r),!n.success||!n.data)throw ta(`Could not start the Work run.`,n);return E(n.data,r,!0),n.data}catch(t){let n=na(t,`Could not start the Work run.`);throw T(e,r,n),Error(n)}finally{w(i,r)}},cancelRun:async e=>{let r=n,i=C(e);try{let n=await P.cancelRun(e);if(v(r),!n.success)throw ta(`Could not cancel the Work run.`,n);return n.data?(E(n.data,r,!0),n.data):(o+=1,await t().loadTask(e,!0))}catch(t){let n=na(t,`Could not cancel the Work run.`);throw T(e,r,n),Error(n)}finally{w(i,r)}},beginLiveRun:(t,n,r)=>{e(e=>{let i=e.liveRuns[t];return{liveRuns:{...e.liveRuns,[t]:i?.runId===n?{...i,startedAt:i.startedAt??r}:Zi(t,n,r)}}})},applyRunEvent:e=>{t().applyRunEvents([e])},applyRunEvents:t=>{t.length!==0&&e(e=>{let n={...e.liveRuns},r=e.tasks,i=e.selectedTask;for(let a of t){n[a.taskId]=ea(n[a.taskId],a);let t=a.type===`snapshot`?a.data.task??a.data.detail:void 0,o=t&&typeof t==`object`&&!Array.isArray(t)&&t.id===a.taskId&&Array.isArray(t.messages)?t:void 0;o&&(r=sa(r,o),e.selectedTaskId===o.id&&(i=oa(i,o)))}return{liveRuns:n,tasks:r,selectedTask:i}})},setLiveRunConnection:(t,n,r,i)=>{e(e=>{let a=e.liveRuns[t];return!a||a.runId!==n?{}:{liveRuns:{...e.liveRuns,[t]:{...a,connection:r,connectionError:i}}}})},clearLiveRun:(t,n)=>{e(e=>{if(n&&e.liveRuns[t]?.runId!==n)return{};let r={...e.liveRuns};return delete r[t],{liveRuns:r}})},loadFiles:async(r,i=``)=>{let a=n,o=++l,s=b();try{let n=await P.listFiles(r,i);if(v(a),!n.success||!n.data)throw ta(`Could not load workspace files.`,n);return o===l&&t().selectedTaskId===r&&e({files:n.data}),n.data}catch(n){let i=na(n,`Could not load workspace files.`);throw o===l&&_(a)&&t().selectedTaskId===r&&e({error:i}),Error(i)}finally{x(s,a,r)}},loadFile:async(r,i)=>{let a=n,o=++u,s=g(r,i);d=s;let c=b();try{let n=await P.getFile(r,i);if(v(a),!n.success||!n.data)throw ta(`Could not open this workspace file.`,n);if(o!==u||d!==s||!_(a)||t().selectedTaskId!==r)throw Error(`Work file request was superseded.`);return e({selectedFile:n.data}),n.data}catch(n){let i=na(n,`Could not open this file.`);throw o===u&&_(a)&&t().selectedTaskId===r&&e({error:i}),Error(i)}finally{x(c,a,r)}},clearSelectedFile:()=>{u+=1,d=null,e({selectedFile:null})},saveFile:async(r,i,a,o)=>{let s=n,c=C(r),l=g(r,i);d===l&&(u+=1,d=null);try{let n=await P.saveFile(r,i,a,o);if(v(s),!n.success||!n.data)throw ta(`Could not save this workspace file.`,n);return t().selectedTaskId===r&&t().selectedFile?.path===i&&(d===l&&(u+=1,d=null),e({selectedFile:n.data})),n.data}catch(e){let t=na(e,`Could not save this file.`);throw T(r,s,t),Error(t)}finally{w(c,s)}},startPreview:(e,t)=>D(()=>P.startPreview(e,t),`Could not start the workspace preview.`,e),stopPreview:e=>D(()=>P.stopPreview(e),`Could not stop the workspace preview.`,e),clearError:()=>e({error:null}),clearAllState:()=>{n+=1,i=++r,a=i,o+=1,s=null,p.clear(),h.clear(),y(),e({capabilities:null,tasks:[],selectedTaskId:null,selectedTask:null,files:[],selectedFile:null,liveRuns:{},loadingTasks:!1,loadingTask:!1,loadingOlderMessages:!1,loadingFiles:!1,actionLoading:!1,error:null})}}}),ua=`blue`,da=`#2563eb`,fa=[{id:`violet`,label:`Violet`,color:`#7c3aed`,foreground:`#ffffff`},{id:`blue`,label:`Blue`,color:`#2563eb`,foreground:`#ffffff`},{id:`cyan`,label:`Cyan`,color:`#0e7490`,foreground:`#ffffff`},{id:`teal`,label:`Teal`,color:`#0f766e`,foreground:`#ffffff`},{id:`emerald`,label:`Emerald`,color:`#15803d`,foreground:`#ffffff`},{id:`amber`,label:`Coral`,color:`#ff7b52`,foreground:`#3d120c`},{id:`rose`,label:`Rose`,color:`#e11d48`,foreground:`#ffffff`},{id:`slate`,label:`Slate`,color:`#475569`,foreground:`#ffffff`}],pa=[`50`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`,`950`],ma=[`25`,...pa],ha=[`canvas`,`surface`,`surface-subtle`,`surface-raised`,`surface-overlay`,`surface-inverse`,`ink`,`ink-muted`,`ink-subtle`,`ink-inverse`,`line`,`line-strong`],ga={multiplier:.24,minimum:6,maximum:24},_a={multiplier:.36,minimum:6,maximum:32},va={25:99,50:97,100:94,200:88,300:80,400:66,500:48,600:36,700:27,800:18,900:11,950:6},ya={25:13,50:4,100:7,200:10,300:16,400:27,500:46,600:65,700:82,800:89,900:95,950:99},ba={canvas:{lightness:96,saturationFactor:1},surface:{lightness:98,saturationFactor:.9},"surface-subtle":{lightness:93,saturationFactor:1},"surface-raised":{lightness:99,saturationFactor:.8},"surface-overlay":{lightness:100,saturationFactor:0},"surface-inverse":{lightness:10,saturationFactor:.7},ink:{lightness:10,saturationFactor:.45},"ink-muted":{lightness:38,saturationFactor:.35},"ink-subtle":{lightness:54,saturationFactor:.4},"ink-inverse":{lightness:98,saturationFactor:.4},line:{lightness:86,saturationFactor:.8},"line-strong":{lightness:75,saturationFactor:.65}},xa={canvas:{lightness:5,saturationFactor:.9},surface:{lightness:7,saturationFactor:.9},"surface-subtle":{lightness:9,saturationFactor:1},"surface-raised":{lightness:11,saturationFactor:1},"surface-overlay":{lightness:13,saturationFactor:1},"surface-inverse":{lightness:96,saturationFactor:.35},ink:{lightness:96,saturationFactor:.3},"ink-muted":{lightness:67,saturationFactor:.35},"ink-subtle":{lightness:48,saturationFactor:.4},"ink-inverse":{lightness:7,saturationFactor:.45},line:{lightness:18,saturationFactor:.8},"line-strong":{lightness:28,saturationFactor:.65}},Sa={violet:{50:`#f5f3ff`,100:`#ede9fe`,200:`#ddd6fe`,300:`#c4b5fd`,400:`#a78bfa`,500:`#7c3aed`,600:`#6d28d9`,700:`#5b21b6`,800:`#4c1d95`,900:`#3b0764`,950:`#2e1065`},blue:{50:`#eff6ff`,100:`#dbeafe`,200:`#bfdbfe`,300:`#93c5fd`,400:`#60a5fa`,500:`#2563eb`,600:`#1d4ed8`,700:`#1e40af`,800:`#1e3a8a`,900:`#172554`,950:`#0f172a`},cyan:{50:`#ecfeff`,100:`#cffafe`,200:`#a5f3fc`,300:`#67e8f9`,400:`#22d3ee`,500:`#0e7490`,600:`#155e75`,700:`#164e63`,800:`#083344`,900:`#092f3f`,950:`#062634`},teal:{50:`#f0fdfa`,100:`#ccfbf1`,200:`#99f6e4`,300:`#5eead4`,400:`#2dd4bf`,500:`#0f766e`,600:`#0f625d`,700:`#115e59`,800:`#134e4a`,900:`#042f2e`,950:`#022c22`},emerald:{50:`#ecfdf5`,100:`#d1fae5`,200:`#a7f3d0`,300:`#6ee7b7`,400:`#34d399`,500:`#15803d`,600:`#166534`,700:`#14532d`,800:`#064e3b`,900:`#052e16`,950:`#022c22`},amber:{50:`#fff5f1`,100:`#ffe8df`,200:`#ffd0c2`,300:`#ffae96`,400:`#ff9273`,500:`#ff7b52`,600:`#c94a27`,700:`#a83a1f`,800:`#87301f`,900:`#70291e`,950:`#3d120c`},rose:{50:`#fff1f2`,100:`#ffe4e6`,200:`#fecdd3`,300:`#fda4af`,400:`#fb7185`,500:`#e11d48`,600:`#be123c`,700:`#9f1239`,800:`#881337`,900:`#4c0519`,950:`#2d0714`},slate:{50:`#f8fafc`,100:`#f1f5f9`,200:`#e2e8f0`,300:`#cbd5e1`,400:`#94a3b8`,500:`#475569`,600:`#334155`,700:`#1e293b`,800:`#0f172a`,900:`#020617`,950:`#010313`}},Ca={50:97,100:94,200:88,300:76,400:64,500:42,600:34,700:27,800:21,900:16,950:10},wa=(e,t,n)=>Math.min(Math.max(e,t),n),Ta=e=>{if(!e)return null;let t=e.trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);if(!t)return null;let n=t[1];return`#${(n.length===3?n.split(``).map(e=>`${e}${e}`).join(``):n).toLowerCase()}`},Ea=e=>{let t=Ta(e)||`#2563eb`,n=parseInt(t.slice(1),16);return{r:n>>16&255,g:n>>8&255,b:n&255}},Da=(e,t,n)=>`#${[e,t,n].map(e=>wa(Math.round(e),0,255).toString(16).padStart(2,`0`)).join(``)}`,Oa=(e,t,n)=>{let r=e/255,i=t/255,a=n/255,o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2;if(o===s)return{h:0,s:0,l:c*100};let l=o-s,u=c>.5?l/(2-o-s):l/(o+s),d=0;return d=o===r?(i-a)/l+(i<a?6:0):o===i?(a-r)/l+2:(r-i)/l+4,{h:d*60,s:u*100,l:c*100}},ka=(e,t,n)=>{let r=wa(t,0,100)/100,i=wa(n,0,100)/100,a=(1-Math.abs(2*i-1))*r,o=(e%360+360)%360,s=a*(1-Math.abs(o/60%2-1)),c=i-a/2,l=0,u=0,d=0;return o<60?(l=a,u=s):o<120?(l=s,u=a):o<180?(u=a,d=s):o<240?(u=s,d=a):o<300?(l=s,d=a):(l=a,d=s),Da((l+c)*255,(u+c)*255,(d+c)*255)},Aa=e=>{let{r:t,g:n,b:r}=Ea(e),i=[t,n,r].map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return i[0]*.2126+i[1]*.7152+i[2]*.0722},ja=(e,t)=>{let n=Aa(e),r=Aa(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)},Ma=(e,t,n)=>{let r=n,i=ka(e,t,r);for(;ja(`#ffffff`,i)<4.5&&r>12;)r-=2,i=ka(e,t,r);return i},Na=e=>{let{r:t,g:n,b:r}=Ea(Ta(e)||`#2563eb`),{h:i,s:a}=Oa(t,n,r),o=a<8?a:wa(a,42,88);return pa.reduce((e,t)=>{let n=Ca[t],r=Number(t)<300?o*.72:o;return e[t]=t===`500`||t===`600`?Ma(i,r,n):ka(i,r,n),e},{})},Z=e=>{let t=e?.mode===`dark`?`dark`:`light`,n=e?.accent===`custom`?`custom`:e?.accent,r=fa.some(e=>e.id===n)?n:ua,i=Ta(e?.customAccent)||`#2563eb`;return{mode:t,adaptToAccent:e?.adaptToAccent===!0,accent:n===`custom`?`custom`:r,customAccent:i}},Pa=e=>{let t=Z(e);return t.accent===`custom`?Na(t.customAccent):Sa[t.accent||`blue`]},Fa=e=>{let t=Z(e);return t.accent===`custom`?t.customAccent||`#2563eb`:fa.find(e=>e.id===t.accent)?.color||`#2563eb`},Ia=(e,t,n)=>t===0||e<8?e*t:wa(e*n.multiplier*t,n.minimum*t,n.maximum*t),La=(e,t,n,r)=>ma.reduce((i,a)=>(i[a]=ka(e,Ia(t,1,r),n[a]),i),{}),Ra=(e,t,n,r)=>ha.reduce((i,a)=>{let o=n[a];return i[a]=ka(e,Ia(t,o.saturationFactor,r),o.lightness),i},{}),za=(e,t,n)=>{let{r,g:i,b:a}=Ea(n);e.style.setProperty(t,`${r} ${i} ${a}`)},Ba=e=>{for(let t of ma)e.style.removeProperty(`--color-gray-${t}`),e.style.removeProperty(`--color-dark-${t}`);for(let t of ha)e.style.removeProperty(`--color-${t}`)},Va=(e,t)=>{let{r:n,g:r,b:i}=Ea(Fa(t)),{h:a,s:o}=Oa(n,r,i),s=t.mode===`light`?_a:ga,c=La(a,o,va,s),l=La(a,o,ya,ga),u=Ra(a,o,t.mode===`dark`?xa:ba,s);for(let t of ma)za(e,`--color-gray-${t}`,c[t]),za(e,`--color-dark-${t}`,l[t]);for(let t of ha)za(e,`--color-${t}`,u[t])},Ha=e=>{if(typeof document>`u`)return;let t=Z(e),n=document.documentElement,r=Pa(t);n.classList.remove(`dark`,`ophelia`),t.mode===`dark`&&n.classList.add(`dark`),n.style.colorScheme=t.mode,n.dataset.accent=t.accent||`blue`,n.dataset.themeStyle=t.adaptToAccent?`accent`:`default`;for(let e of pa){let{r:t,g:i,b:a}=Ea(r[e]),o=`${t} ${i} ${a}`;n.style.setProperty(`--color-primary-${e}`,o),n.style.setProperty(`--color-accent-${e}`,o)}t.adaptToAccent?Va(n,t):Ba(n)},Ua=M(`store:app-store`),Wa=250,Ga=null,Ka=ke()(Ae((e,t)=>({theme:{mode:`light`,adaptToAccent:!1,accent:ua,customAccent:da},themeSyncPending:!1,syncThemePreference:async n=>{if(Ga&&(clearTimeout(Ga),Ga=null),!(!je()&&!localStorage.getItem(`auth-token`)))try{let{preferencesApi:r}=await f(async()=>{let{preferencesApi:e}=await import(`../js/api-Fi-lJlfu.js`).then(e=>e.t);return{preferencesApi:e}},__vite__mapDeps([0,1,2,3,4,5,6]));if(!(await r.updatePreferences({theme:n})).success){Ua.warn(`Failed to save theme preference to backend`);return}let i=Z(t().theme),a=Z(n);i.mode===a.mode&&i.adaptToAccent===a.adaptToAccent&&i.accent===a.accent&&i.customAccent===a.customAccent?e({themeSyncPending:!1}):(e({themeSyncPending:!0}),t().scheduleThemePreferenceSync())}catch(e){Ua.warn(`Failed to save theme preference to backend:`,e)}},scheduleThemePreferenceSync:()=>{Ga&&clearTimeout(Ga),Ga=setTimeout(()=>{Ga=null,t().syncThemePreference(Z(t().theme))},Wa)},setTheme:t=>{let n=Z(t);e(e=>({theme:n,preferences:{...e.preferences,theme:n}})),Ha(n)},updateTheme:n=>{let r=Z(n);t().setTheme(r),e({themeSyncPending:!0}),t().scheduleThemePreferenceSync()},toggleTheme:()=>{let e=t().theme,n=e.mode===`dark`?`light`:`dark`;t().updateTheme({...e,mode:n})},sidebarOpen:!0,sidebarCompact:!1,setSidebarOpen:t=>e({sidebarOpen:t}),setSidebarCompact:t=>e({sidebarCompact:t}),toggleSidebar:()=>e(e=>({sidebarOpen:!e.sidebarOpen})),toggleSidebarCompact:()=>e(e=>({sidebarCompact:!e.sidebarCompact})),artifactPanelOpen:!1,artifactPanelArtifact:null,openArtifactPanel:t=>e({artifactPanelOpen:!0,artifactPanelArtifact:t}),closeArtifactPanel:()=>e({artifactPanelOpen:!1,artifactPanelArtifact:null}),preferences:{theme:{mode:`light`,adaptToAccent:!1,accent:ua,customAccent:da},defaultModel:``,defaultProviderType:null,defaultProviderId:null,systemMessage:``,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.3},titleSettings:{autoTitle:!1,taskModel:``,taskProviderType:null,taskProviderId:null},showUsername:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}},setPreferences:t=>{let n=t.theme?Z(t.theme):null;e(e=>({...n&&{theme:n},preferences:{...e.preferences,...t,...n&&{theme:n}}})),n&&Ha(n)},loadPreferences:async()=>{try{let{preferencesApi:n}=await f(async()=>{let{preferencesApi:e}=await import(`../js/api-Fi-lJlfu.js`).then(e=>e.t);return{preferencesApi:e}},__vite__mapDeps([0,1,2,3,4,5,6])),r=await n.getPreferences();if(r.success&&r.data){let n=r.data,i=t().themeSyncPending?Z(t().theme):null;t().setPreferences(i?{...n,theme:i}:n),e({backgroundImage:n.backgroundSettings?.imageUrl||null}),i&&t().syncThemePreference(i)}}catch(e){Ua.warn(`Failed to load preferences from backend:`,e)}},isGenerating:!1,setIsGenerating:t=>e({isGenerating:t}),hasSeenSettingsNotification:!1,markSettingsNotificationAsSeen:()=>e({hasSeenSettingsNotification:!0}),isDemoMode:je(),demoConfig:Me(),setDemoMode:t=>{e({isDemoMode:t,demoConfig:Me()})},backgroundImage:null,setBackgroundImage:async n=>{if(e({backgroundImage:n}),n){let e=t(),r={...e.preferences,backgroundSettings:{enabled:!0,imageUrl:n,blurAmount:e.preferences.backgroundSettings?.blurAmount||10,opacity:e.preferences.backgroundSettings?.opacity||.6}};e.setPreferences(r);try{let{preferencesApi:e}=await f(async()=>{let{preferencesApi:e}=await import(`../js/api-Fi-lJlfu.js`).then(e=>e.t);return{preferencesApi:e}},__vite__mapDeps([0,1,2,3,4,5,6]));await e.updatePreferences({backgroundSettings:r.backgroundSettings})}catch(e){Ua.warn(`Failed to save background settings to backend:`,e)}}},uploadBackgroundImage:async e=>{try{let n=new FileReader;return new Promise((r,i)=>{n.onload=async e=>{try{let n=e.target?.result;await t().setBackgroundImage(n),r()}catch(e){i(e)}},n.onerror=i,n.readAsDataURL(e)})}catch(e){throw Ua.error(`Failed to upload background image:`,e),e}},removeBackgroundImage:async()=>{e({backgroundImage:null});let n=t(),r={enabled:!1,imageUrl:``,blurAmount:n.preferences.backgroundSettings?.blurAmount||10,opacity:n.preferences.backgroundSettings?.opacity||.6};n.setPreferences({backgroundSettings:r});try{let{preferencesApi:e}=await f(async()=>{let{preferencesApi:e}=await import(`../js/api-Fi-lJlfu.js`).then(e=>e.t);return{preferencesApi:e}},__vite__mapDeps([0,1,2,3,4,5,6]));await e.updatePreferences({backgroundSettings:r})}catch(e){Ua.warn(`Failed to save background removal to backend:`,e)}},clearUserState:()=>{let t=Z({mode:`light`,adaptToAccent:!1,accent:ua,customAccent:da});Ga&&(clearTimeout(Ga),Ga=null),e({theme:t,themeSyncPending:!1,backgroundImage:null,preferences:{theme:t,defaultModel:``,defaultProviderType:null,defaultProviderId:null,systemMessage:``,generationOptions:{temperature:.7,top_p:.9,top_k:40,num_predict:1024},embeddingSettings:{enabled:!1,model:`nomic-embed-text`,chunkSize:1e3,chunkOverlap:200,similarityThreshold:.3},titleSettings:{autoTitle:!1,taskModel:``,taskProviderType:null,taskProviderId:null},showUsername:!1,workRemoteProviderDisclosureDismissed:!1,backgroundSettings:{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6}}}),Ha(t)}}),{name:`libre-webui-app-state`,onRehydrateStorage:()=>e=>{e&&e.setTheme(Z(e.theme))},partialize:e=>{let{backgroundSettings:t,...n}=e.preferences;return{theme:e.theme,themeSyncPending:e.themeSyncPending,sidebarOpen:e.sidebarOpen,sidebarCompact:e.sidebarCompact,preferences:n,hasSeenSettingsNotification:e.hasSeenSettingsNotification}}}));typeof window<`u`&&(()=>{let{theme:e,setTheme:t}=Ka.getState();t(e)})();var qa=async(e,t,n)=>{let r=await t(e);return r.success&&await n(),r},Ja=M(`store:plugin-store`),Ya=ke((e,t)=>({plugins:[],pluginStatus:[],pluginVariables:{},isLoading:!1,isUploading:!1,error:null,loadPlugins:async()=>{e({isLoading:!0,error:null});try{let t=await N.getAllPlugins();t.success&&t.data?e({plugins:t.data}):e({error:t.error||`Failed to load plugins`})}catch(t){e({error:K(t,`Failed to load plugins`)})}finally{e({isLoading:!1})}},uploadPlugin:async n=>{e({isUploading:!0,error:null});try{let r=await N.uploadPlugin(n);r.success&&r.data?await t().loadPlugins():e({error:r.error||`Failed to upload plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to upload plugin`})}finally{e({isUploading:!1})}},installPlugin:async n=>{e({isLoading:!0,error:null});try{let r=await N.installPlugin(n);r.success&&r.data?await t().loadPlugins():e({error:r.error||`Failed to install plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to install plugin`})}finally{e({isLoading:!1})}},updatePlugin:async(n,r)=>{e({isLoading:!0,error:null});try{let i=await N.updatePlugin(n,r);i.success&&i.data?await t().loadPlugins():e({error:i.error||`Failed to update plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to update plugin`})}finally{e({isLoading:!1})}},deletePlugin:async n=>{e({isLoading:!0,error:null});try{let r=await N.deletePlugin(n);r.success?await t().loadPlugins():e({error:r.error||`Failed to delete plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to delete plugin`})}finally{e({isLoading:!1})}},activatePlugin:async n=>{e({isLoading:!0,error:null});try{let r=await qa(n,N.activatePlugin,()=>t().loadPlugins());r.success||e({error:r.error||`Failed to activate plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to activate plugin`})}finally{e({isLoading:!1})}},deactivatePlugin:async n=>{e({isLoading:!0,error:null});try{let r=await N.deactivatePlugin(n);r.success?await t().loadPlugins():e({error:r.error||`Failed to deactivate plugin`})}catch(t){e({error:t instanceof Error?t.message:`Failed to deactivate plugin`})}finally{e({isLoading:!1})}},loadPluginStatus:async()=>{try{let t=await N.getPluginStatus();t.success&&t.data&&e({pluginStatus:t.data})}catch(e){Ja.error(`Failed to load plugin status:`,e)}},exportPlugin:async t=>{e({isLoading:!0,error:null});try{let e=await N.exportPlugin(t),n=window.URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=`${t}.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n)}catch(t){e({error:t instanceof Error?t.message:`Failed to export plugin`})}finally{e({isLoading:!1})}},fetchPluginVariables:async t=>{try{let n=await N.getVariables(t);n.success&&n.data&&e(e=>({pluginVariables:{...e.pluginVariables,[t]:n.data}}))}catch(e){Ja.error(`Failed to fetch plugin variables:`,e)}},updatePluginVariables:async(e,n,r=[])=>{try{return(await N.setVariables(e,n,r)).success?(await t().fetchPluginVariables(e),!0):!1}catch(e){return Ja.error(`Failed to update plugin variables:`,e),!1}},resetPluginVariables:async t=>{try{let n=await N.resetVariables(t);return n.success&&n.data===!0?(e(e=>{let n={...e.pluginVariables};return delete n[t],{pluginVariables:n}}),!0):!1}catch(e){return Ja.error(`Failed to reset plugin variables:`,e),!1}},clearError:()=>e({error:null}),setError:t=>e({error:t})})),Xa=`libre-webui:work-draft:`,Za=(e,t)=>`${Xa}${e}:${t}`,Qa=(e,t)=>{try{let n=window.sessionStorage.getItem(Za(e,t));if(!n)return null;let r=JSON.parse(n);return typeof r.content==`string`?{content:r.content,baseUpdatedAt:typeof r.baseUpdatedAt==`number`?r.baseUpdatedAt:void 0}:null}catch{return null}},$a=(e,t,n)=>{try{return window.sessionStorage.setItem(Za(e,t),JSON.stringify(n)),!0}catch{return!1}},eo=(e,t)=>{try{window.sessionStorage.removeItem(Za(e,t))}catch{}},to=e=>{let t=`${Xa}${e}:`;try{for(let e=window.sessionStorage.length-1;e>=0;e--){let n=window.sessionStorage.key(e);n?.startsWith(t)&&window.sessionStorage.removeItem(n)}}catch{}},no=()=>{try{for(let e=window.sessionStorage.length-1;e>=0;e--){let t=window.sessionStorage.key(e);t?.startsWith(Xa)&&window.sessionStorage.removeItem(t)}}catch{}},Q=M(`websocket`),ro=new class{constructor(){g(this,`ws`,null),g(this,`url`,void 0),g(this,`reconnectAttempts`,0),g(this,`maxReconnectAttempts`,5),g(this,`reconnectDelay`,1e3),g(this,`messageHandlers`,new Map);let e;e=window.location.protocol===`file:`?`ws://localhost:3001`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`,this.url=`${e}/ws`,Q.debug(`WebSocket URL constructed:`,this.url)}connect(){return je()?(Q.debug(`Demo mode active: skipping WebSocket connection.`),Promise.resolve()):(Q.debug(`WebSocket: Attempting to connect to:`,this.url),new Promise((e,t)=>{try{let n=localStorage.getItem(`auth-token`),r=n?`${this.url}?token=${encodeURIComponent(n)}`:this.url;Q.debug(`WebSocket: Connecting to:`,r.replace(/token=[^&]+/,`token=***`)),this.ws=new WebSocket(r),this.ws.onopen=()=>{Q.debug(`WebSocket connected successfully`),this.reconnectAttempts=0,e()},this.ws.onmessage=e=>{try{let t=JSON.parse(e.data),n=this.messageHandlers.get(t.type);n?n(t.data):t.type===`connected`?Q.debug(`WebSocket: Server confirmed connection`):Q.warn(`WebSocket: No handler for message type:`,t.type)}catch(e){Q.error(`Failed to parse WebSocket message:`,e)}},this.ws.onclose=()=>{Q.debug(`WebSocket disconnected`),this.ws=null,this.attemptReconnect()},this.ws.onerror=e=>{Q.error(`WebSocket error:`,e),t(e)}}catch(e){t(e)}}))}disconnect(){this.ws&&(this.ws.close(),this.ws=null)}send(e){this.ws&&this.ws.readyState===WebSocket.OPEN?(Q.debug(`WebSocket: Sending message:`,e),this.ws.send(JSON.stringify(e))):Q.warn(`WebSocket is not connected. ReadyState:`,this.ws?.readyState)}onMessage(e,t){this.messageHandlers.delete(e),this.messageHandlers.set(e,t)}offMessage(e){this.messageHandlers.delete(e)}attemptReconnect(){if(je()){Q.debug(`Demo mode active: skipping WebSocket reconnection.`);return}this.reconnectAttempts<this.maxReconnectAttempts?(this.reconnectAttempts++,Q.debug(`Attempting to reconnect... (${this.reconnectAttempts}/${this.maxReconnectAttempts})`),setTimeout(()=>{this.connect().catch(()=>{})},this.reconnectDelay*this.reconnectAttempts)):Q.error(`Max reconnection attempts reached`)}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}},io=e({useAuthStore:()=>$}),ao=M(`auth-store`),$=ke()(Ae((e,t)=>({user:null,token:null,systemInfo:null,isAuthenticated:!1,isLoading:!1,login:(n,r,i)=>{let a=t().user?.id===n.id;localStorage.setItem(`auth-token`,r);let o=Vi.getState();o.clearAllState&&o.clearAllState(),la.getState().clearAllState(),a||(no(),Ka.getState().clearUserState()),e({user:n,token:r,systemInfo:i,isAuthenticated:!0,isLoading:!1}),setTimeout(async()=>{try{let e=Ya.getState();ao.debug(`Reinitializing app after login...`),ao.debug(`Reconnecting WebSocket with auth token...`),ro.disconnect(),await ro.connect();try{!(await Le.checkHealth()).success&&!je()&&ao.warn(`Ollama service not available after login`)}catch(e){ao.warn(`Ollama health check failed after login; continuing provider initialization:`,e)}let t=Ka.getState();await Promise.all([o.loadModels(),o.loadSessions(),o.loadPreferences(),t.loadPreferences(),e.loadPlugins()]),ao.debug(`Reinitialized app after login`)}catch(e){ao.error(`Failed to reinitialize app after login:`,e)}},100)},logout:()=>{localStorage.removeItem(`auth-token`),ao.debug(`Disconnecting WebSocket on logout...`),ro.disconnect();let t=Vi.getState();t.clearAllState&&t.clearAllState(),la.getState().clearAllState(),no(),Ka.getState().clearUserState(),e({user:null,token:null,isAuthenticated:!1,isLoading:!1})},setUser:t=>{e({user:t})},setSystemInfo:t=>{e({systemInfo:t})},setLoading:t=>{e({isLoading:t})},isAdmin:()=>{let{user:e}=t();return e?.role===`admin`},requiresAuth:()=>{let{systemInfo:e}=t();return e?.requiresAuth??!1}}),{name:`auth-store`,partialize:e=>({user:e.user,token:e.token,systemInfo:e.systemInfo,isAuthenticated:e.isAuthenticated})})),oo=`welcomePromptIndex`,so=`libre:welcome-prompt-change`,co=[`time`,`create`,`explore`,`imagine`,`focus`,`untangle`,`momentum`,`open`,`challenge`,`draft`,`possibility`,`unexpected`],lo=0,uo=e=>Number.isInteger(e)&&e>=0&&e<co.length,fo=()=>{if(typeof window>`u`)return lo;try{let e=window.sessionStorage.getItem(oo),t=Number(e);e!==null&&uo(t)&&(lo=t)}catch{}return lo},po=()=>{let e=(fo()+1)%co.length;if(lo=e,typeof window<`u`){try{window.sessionStorage.setItem(oo,String(e))}catch{}window.dispatchEvent(new Event(so))}return e},mo=e=>co[e]??`time`,ho=i(),go=({label:e,error:t,helper:n,className:r,id:i,...a})=>{let o=(0,H.useId)(),s=i||`input-${o}`;return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,U.jsx)(`label`,{htmlFor:s,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,U.jsx)(`input`,{id:s,className:F(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a}),t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},_o=H.forwardRef(({label:e,error:t,helper:n,className:r,id:i,...a},o)=>{let s=(0,H.useId)(),c=i||`textarea-${s}`;return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,U.jsx)(`label`,{htmlFor:c,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,U.jsx)(`textarea`,{ref:o,id:c,className:F(`block w-full resize-none rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`placeholder:text-ink-subtle transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,r),...a}),t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-muted`,children:n})]})});_o.displayName=`Textarea`;var vo=({label:e,error:t,helper:n,options:r,className:i,id:a,...o})=>{let s=(0,H.useId)(),c=a||`select-${s}`;return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[e&&(0,U.jsx)(`label`,{htmlFor:c,className:`block text-sm font-medium tracking-[-0.005em] text-ink-muted`,children:e}),(0,U.jsx)(`select`,{id:c,className:F(`block w-full rounded-xl border border-line bg-surface-raised px-3.5 py-2.5 text-base text-ink shadow-none`,`transition-[background-color,border-color,box-shadow,color] duration-150 ease-out`,`focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20 focus-visible:outline-none dark:focus:border-primary-400 dark:focus:ring-primary-400/20`,`disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-subtle disabled:opacity-70`,t&&`border-error-500 focus:border-error-500 focus:ring-error-500/20`,i),...o,children:r.map((e,t)=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.key??`${e.value}-${t}`))}),t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-error-600 dark:text-error-400`,children:t}),n&&!t&&(0,U.jsx)(`p`,{className:`text-xs leading-relaxed text-ink-muted`,children:n})]})},yo=[/^ {0,3}(?:`{3,}|~{3,})/m,/`[^`\n]+`/,/^\s{0,3}#{1,6}\s/m,/^\s{0,3}[-*+]\s/m,/^\s{0,3}\d+\.\s/m,/^\s{0,3}>\s/m,/\[[^\]]+\]\([^)]+\)/,/!\[[^\]]*]\([^)]+\)/,/\|.*\|/,/\*\*[^*]+\*\*/,/__[^_]+__/,/~~[^~]+~~/,/\\\[[\s\S]*?\\\]/,/\\\([\s\S]*?\\\)/,/\$\$[\s\S]*?\$\$/,/(^|[^$])\$[^$\n]+\$/],bo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function xo(e){let t=[],n=/^( {0,3})(`{3,}|~{3,})([^\n\r]*)(?:\r?\n|$)/gm,r;for(;r=n.exec(e);){let i=r[1].length,a=r[2],o=a[0],s=r[3].trim();if(o==="`"&&s.includes("`"))continue;let c=n.lastIndex,l=RegExp(`^ {0,3}${bo(o)}{${a.length},}[ \\t]*(?:\\r?\\n|$)`,`gm`);l.lastIndex=c;let u=l.exec(e),d=s.split(/\s+/)[0]||null;if(!u){t.push({start:r.index,end:e.length,codeStart:c,codeEnd:e.length,indent:i,language:d,complete:!1});break}t.push({start:r.index,end:l.lastIndex,codeStart:c,codeEnd:u.index,indent:i,language:d,complete:!0}),n.lastIndex=l.lastIndex}return t}function So(e){return/<(?:html|head|body)(?:\s|>)|<\/(?:head|body|html)\s*>/i.test(e)}function Co(e,t){return e.start<t.end&&t.start<e.end}function wo(e,t){let n=/^( {0,3})(<!doctype\s+html(?:\s|>|$)|<html(?:\s[^>\n\r]*)?>)/gim,r;for(;r=n.exec(e);){let n=r.index+r[1].length;if(t.some(e=>n>=e.start&&n<e.end))continue;let i=e.slice(n);if(!So(i.slice(r[2].length)))continue;let a=/<\/html\s*>/i.exec(i),o=a?n+a.index+a[0].length:e.length;return{start:r.index,end:o,codeStart:n,codeEnd:o,indent:0,language:`html`,complete:!!a}}return null}function To(e){let t=xo(e),n=wo(e,t);return n?[...t.filter(e=>!Co(e,n)),n].sort((e,t)=>e.start-t.start):t}function Eo(e,t){return t===0?e:e.replace(RegExp(`^ {1,${t}}`,`gm`),``)}function Do(e){return yo.some(t=>t.test(e))}function Oo(e){let t=[],n=To(e),r=0;for(let i of n){let n=e.slice(r,i.start);n&&t.push({type:`text`,content:n}),t.push({type:`code`,language:i.language,content:Eo(e.slice(i.codeStart,i.codeEnd),i.indent),complete:i.complete}),r=i.end}let i=e.slice(r);return(i||t.length===0)&&t.push({type:`text`,content:i}),t}function ko(e){let t=e=>e.replace(/\\\[([\s\S]*?)\\\]/g,(e,t)=>`$$${t}$$`).replace(/\\\(([\s\S]*?)\\\)/g,(e,t)=>`$${t}$`),n=e=>{let n=/`[^`\n]+`/g,r=``,i=0,a;for(;a=n.exec(e);)r+=t(e.slice(i,a.index)),r+=a[0],i=n.lastIndex;return r+t(e.slice(i))},r=xo(e),i=``,a=0;for(let t of r)i+=n(e.slice(a,t.start)),i+=e.slice(t.start,t.end),a=t.end;return i+=n(e.slice(a)),i}var Ao=M(`components:ui:message-code-block`);function jo({code:e,language:t,state:n,children:r}){let{t:i}=C(),[a,o]=H.useState(null),s=H.useRef(null),c=a===e,l=t||`text`,u=i(c?`artifacts.copied`:`artifacts.copy`),d=`${u}: ${l}`;return H.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]),(0,U.jsxs)(`div`,{dir:`ltr`,"data-testid":`code-block`,"data-state":n,"data-language":l,className:`group relative my-4 overflow-hidden rounded-xl border border-line bg-surface-subtle text-left text-ink shadow-[0_12px_32px_rgba(13,17,23,0.1)] dark:border-white/10 dark:bg-[#0D1117] dark:text-[#E6EDF3] dark:shadow-[0_12px_32px_rgba(13,17,23,0.16)]`,children:[(0,U.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b border-line bg-surface-raised/70 px-3.5 dark:border-white/10 dark:bg-white/[0.035]`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(O,{className:`h-3.5 w-3.5 shrink-0 text-ink-subtle dark:text-[#8B949E]`}),(0,U.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium lowercase tracking-[-0.01em] text-ink-muted dark:text-[#B1BAC4]`,children:l})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n===`streaming`&&(0,U.jsx)(`span`,{role:`status`,"aria-label":i(`common.loading`),className:`flex h-7 w-7 items-center justify-center`,children:(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-primary-400`})}),(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{if(e)try{await navigator.clipboard.writeText(e),o(e),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(null),s.current=null},2e3)}catch(e){Ao.error(`Failed to copy code:`,e)}},disabled:!e,className:`flex h-7 w-7 items-center justify-center rounded-md text-ink-subtle transition-colors hover:bg-surface-subtle hover:text-ink focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-400/70 disabled:cursor-default disabled:opacity-35 dark:text-[#8B949E] dark:hover:bg-white/[0.08] dark:hover:text-[#E6EDF3]`,title:u,"aria-label":d,children:c?(0,U.jsx)(Te,{className:`h-3.5 w-3.5 text-green-400`}):(0,U.jsx)(ve,{className:`h-3.5 w-3.5`})}),(0,U.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:c?d:``})]})]}),r]})}var Mo=`#0D1117`,No=`rgb(var(--color-surface-subtle))`,Po=`max-h-[60vh] min-h-12 overflow-auto bg-surface-subtle p-4 text-left font-mono text-[14px] leading-6 text-ink whitespace-pre tabular-nums dark:bg-[#0D1117] dark:text-[#E6EDF3]`,Fo={maxHeight:`60vh`,minHeight:`3rem`,overflow:`auto`,padding:`1rem`,fontSize:`14px`,lineHeight:`1.5rem`,fontFamily:`"JetBrains Mono", ui-monospace, SFMono-Regular, monospace`,whiteSpace:`pre`};function Io({content:e}){return e?(0,U.jsx)(`div`,{dir:`auto`,className:`whitespace-pre-wrap break-words leading-relaxed`,children:e}):null}function Lo({content:e,language:t,complete:n}){let r=n?e.replace(/\r?\n$/,``):e,i=H.useRef(null),a=H.useRef(!0);return H.useLayoutEffect(()=>{let e=i.current;e&&a.current&&(e.scrollTop=e.scrollHeight)},[r]),(0,U.jsx)(jo,{code:r,language:t,state:n?`complete`:`streaming`,children:(0,U.jsx)(`pre`,{ref:i,onScroll:()=>{let e=i.current;e&&(a.current=e.scrollHeight-e.scrollTop-e.clientHeight<24)},className:Po,children:(0,U.jsx)(`code`,{children:r})})})}var Ro=({content:e,className:t,segments:n,isStreaming:r=!0})=>{let i=H.useMemo(()=>n??Oo(e),[e,n]),a=i[i.length-1],o=a?.type===`code`&&!a.complete;return(0,U.jsxs)(`div`,{className:F(`text-sm leading-relaxed text-gray-700 dark:text-dark-700`,t),children:[i.map((e,t)=>e.type===`code`?(0,U.jsx)(Lo,{...e},`${e.type}-${t}`):(0,U.jsx)(Io,{content:e.content},`${e.type}-${t}`)),r&&!o&&(0,U.jsx)(`span`,{"data-testid":`message-streaming-cursor`,"aria-hidden":`true`,className:`ms-1 inline-block h-5 w-1 animate-pulse rounded-full bg-primary-500 align-text-bottom`})]})},zo=H.lazy(()=>f(()=>import(`../js/RichMessageContent-Cz9y-bgl.js`).then(e=>e.n),__vite__mapDeps([7,1,3,2,8,4,9,10])));function Bo({content:e,className:t}){return(0,U.jsx)(`div`,{dir:`auto`,className:F(`text-sm leading-relaxed text-gray-700 dark:text-dark-700 whitespace-pre-wrap break-words`,t),children:e})}var Vo=({content:e,className:t,isStreaming:n=!1})=>{let r=H.useMemo(()=>n?Oo(e):[],[e,n]),i=r.some(e=>e.type===`code`);if(n&&i)return(0,U.jsx)(Ro,{content:e,className:t,segments:r});let a;return a=Do(e)?(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(Ro,{content:e,className:t,isStreaming:!1}),children:(0,U.jsx)(zo,{content:e,className:t})}):(0,U.jsx)(Bo,{content:e,className:t}),(0,U.jsxs)(U.Fragment,{children:[a,n&&(0,U.jsx)(`span`,{"data-testid":`message-streaming-cursor`,"aria-hidden":`true`,className:`ms-1 inline-block h-5 w-1 animate-pulse rounded-full bg-primary-500 align-text-bottom`})]})},Ho=({children:e,htmlFor:t,className:n=``})=>(0,U.jsx)(`label`,{htmlFor:t,className:F(`text-sm font-medium tracking-[-0.005em] text-ink-muted`,n),children:e}),Uo=({children:e,className:t=``})=>(0,U.jsx)(`div`,{className:F(`rounded-2xl border border-line bg-surface-raised shadow-card`,t),children:e}),Wo=({children:e,className:t=``})=>(0,U.jsx)(`div`,{className:F(`flex flex-col space-y-1.5 p-6`,t),children:e}),Go=({children:e,className:t=``})=>(0,U.jsx)(`h3`,{className:F(`text-lg font-semibold leading-tight tracking-[-0.02em] text-ink`,t),children:e}),Ko=({children:e,className:t=``})=>(0,U.jsx)(`p`,{className:F(`text-sm leading-relaxed text-ink-muted`,t),children:e}),qo=({children:e,className:t=``})=>(0,U.jsx)(`div`,{className:F(`p-6 pt-0`,t),children:e}),Jo={narrow:`max-w-4xl`,default:`max-w-6xl`,wide:`max-w-7xl`},Yo=({children:e,width:t=`default`,className:n,contentClassName:r,...i})=>(0,U.jsx)(`div`,{"data-testid":`page-scroll-region`,className:F(`scroll-region h-full min-h-0 scrollbar-thin`,n),...i,children:(0,U.jsx)(`div`,{className:F(`mx-auto w-full px-4 pb-16 pt-7 sm:px-6 sm:pb-20 sm:pt-10 lg:px-8`,Jo[t],r),children:e})}),Xo=({title:e,description:t,eyebrow:n,actions:r,meta:i,className:a,...o})=>(0,U.jsxs)(`header`,{className:F(`mb-8 flex flex-col gap-6 border-b border-gray-200/70 pb-7 text-start dark:border-white/[0.08] sm:mb-10 sm:pb-9 md:flex-row md:items-end md:justify-between`,a),...o,children:[(0,U.jsxs)(`div`,{className:`min-w-0 max-w-3xl`,children:[n&&(0,U.jsx)(`div`,{className:`mb-3 text-[11px] font-medium uppercase tracking-[0.18em] text-gray-500 dark:text-dark-500 rtl:tracking-normal`,children:n}),(0,U.jsx)(`h1`,{className:`text-balance text-3xl font-normal leading-[1.02] tracking-[-0.04em] text-gray-950 dark:text-dark-950 sm:text-5xl rtl:leading-[1.15] rtl:tracking-normal`,children:e}),t&&(0,U.jsx)(`p`,{className:`mt-4 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600 sm:text-base sm:leading-7`,children:t}),i&&(0,U.jsx)(`div`,{className:`mt-4`,children:i})]}),r&&(0,U.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 md:justify-end`,children:r})]}),Zo=M(`components:avatar-upload`),Qo=({value:e,onChange:t,className:n=``})=>{let{t:r}=C(),i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),l=async e=>{if(!e.type.startsWith(`image/`)){k.error(r(`user.avatar.invalidFile`));return}if(e.size>2*1024*1024){k.error(r(`user.avatar.fileTooLarge`));return}o(!0);try{let n=new FileReader;n.onload=e=>{let n=e.target?.result;t(n),k.success(r(`user.avatar.uploaded`))},n.onerror=()=>{k.error(r(`user.avatar.readFailed`))},n.readAsDataURL(e)}catch(e){Zo.error(`Failed to upload avatar:`,e),k.error(r(`user.avatar.uploadFailed`))}finally{o(!1)}},u=e=>{let t=e.target.files?.[0];t&&l(t)},d=e=>{e.preventDefault(),c(!0)},f=e=>{e.preventDefault(),c(!1)},p=e=>{e.preventDefault(),c(!1);let t=e.dataTransfer.files?.[0];t&&l(t)},m=()=>{t(``),k.success(r(`user.avatar.removed`))},h=()=>e||null;return(0,U.jsx)(`div`,{className:`space-y-4 ${n}`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-dark-600 mb-2`,children:r(`user.avatar.label`)}),(0,U.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,U.jsx)(`div`,{className:`flex-shrink-0`,children:(0,U.jsx)(`div`,{className:`w-20 h-20 rounded-full overflow-hidden bg-gray-100 dark:bg-dark-200 border-2 border-gray-300 dark:border-dark-300 flex items-center justify-center`,children:h()?(0,U.jsx)(`img`,{src:h(),alt:`Avatar preview`,className:`w-full h-full object-cover`}):(0,U.jsx)(ge,{className:`h-8 w-8 text-gray-400 dark:text-gray-500`})})}),(0,U.jsxs)(`div`,{className:`flex-1 space-y-3`,children:[e?(0,U.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:r(`user.avatar.customAvatar`)}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`user.avatar.clickToChange`)})]}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:m,className:`text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400 dark:hover:text-red-300 dark:hover:bg-red-900/20`,children:(0,U.jsx)(j,{className:`h-4 w-4`})})]}):(0,U.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-4 text-center cursor-pointer transition-colors ${s?`border-primary-500 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:d,onDragLeave:f,onDrop:p,onClick:()=>i.current?.click(),children:[(0,U.jsx)(de,{className:`h-8 w-8 mx-auto text-gray-400 dark:text-gray-500 mb-2`}),(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:r(`user.avatar.uploadAvatarImage`)}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:r(`user.avatar.dragAndDrop`)}),(0,U.jsxs)(I,{variant:`outline`,size:`sm`,disabled:a,className:`mx-auto`,children:[(0,U.jsx)(de,{className:`h-4 w-4 mr-2`}),r(a?`user.avatar.uploading`:`user.avatar.chooseImage`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-gray-600 dark:text-gray-400 mb-1`,children:r(`user.avatar.enterImageUrl`)}),(0,U.jsx)(`input`,{type:`url`,value:e,onChange:e=>t(e.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-50 text-gray-900 dark:text-dark-800`,placeholder:`https://example.com/avatar.jpg`})]})]})]}),(0,U.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,onChange:u,className:`hidden`}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:r(`user.avatar.supportedFormats`)})]})})};function $o({open:e,value:t,saving:n,onChange:r,onClose:i,onSave:a}){let{t:o}=C();return e?(0,ho.createPortal)((0,U.jsx)(`div`,{className:`fixed inset-0 z-[2147483647] flex items-center justify-center bg-gray-950/55 p-4 backdrop-blur-md`,onClick:i,children:(0,U.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`avatar-modal-title`,className:`bg-white dark:bg-dark-25 rounded-3xl shadow-[0_24px_80px_rgba(0,0,0,0.24)] p-6 w-full max-w-md border border-black/[0.07] dark:border-white/[0.08] animate-scale-in`,onClick:e=>e.stopPropagation(),children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,U.jsx)(`h3`,{id:`avatar-modal-title`,className:`text-lg font-medium tracking-[-0.02em] text-gray-950 dark:text-dark-950`,children:o(`user.avatar.title`)}),(0,U.jsx)(`button`,{onClick:i,className:`p-2 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:(0,U.jsx)(j,{size:20,className:`text-gray-500`})})]}),(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(Qo,{value:t,onChange:r}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,U.jsx)(`button`,{onClick:i,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-dark-700 hover:bg-gray-100 dark:hover:bg-dark-200 rounded-xl transition-colors`,children:o(`common.cancel`)}),(0,U.jsx)(`button`,{onClick:a,disabled:n,className:`px-4 py-2 text-sm font-medium text-white bg-gray-950 hover:bg-gray-800 dark:bg-white dark:text-gray-950 dark:hover:bg-gray-100 disabled:opacity-50 disabled:cursor-not-allowed rounded-xl transition-colors`,children:o(n?`common.saving`:`common.save`)})]})]})]})}),document.body):null}var es={sm:`text-[1.0625rem] leading-none`,md:`text-[1.625rem] leading-none`,lg:`text-[2.5rem] leading-none`},ts=({className:e,size:t=`md`,wordmark:n=!0})=>(0,U.jsxs)(`span`,{dir:`ltr`,className:F(`libre-brand inline-flex items-baseline whitespace-nowrap`,es[t],e),children:[`Libre`,n&&(0,U.jsx)(`span`,{className:`ms-1 font-normal tracking-[-0.035em]`,children:`WebUI`})]}),ns=()=>{let{theme:e,toggleTheme:t}=Ka(),n=e.mode===`light`?`dark`:`light`,r=e.mode===`light`?(0,U.jsx)(te,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}):(0,U.jsx)(_e,{className:`h-4 w-4 text-ink-muted transition-colors duration-150 group-hover:text-ink motion-reduce:transition-none`,strokeWidth:1.75,"aria-hidden":`true`}),i=`Switch to ${n} mode`;return(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:t,className:`h-9 w-9 rounded-full p-0`,"aria-label":i,title:`${i} (⌘D)`,children:r})};function rs({sidebarCompact:e,isElectron:t,showWork:n,activeMode:r,selectedModel:i,modelCount:a,onToggleCompact:o,onStartWork:s,onCreateSession:c}){let{t:l}=C(),u=!i||a===0,d=u?l(`chat.model.noModelsTooltip`):``;return(0,U.jsxs)(`div`,{className:F(e?`px-2 pb-3 pt-3`:`px-4 pb-4 pt-4`,t&&`pt-10`),children:[(0,U.jsx)(`div`,{className:F(`flex items-center`,e?`justify-center mb-3`:`justify-between mb-4`),children:e?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,U.jsx)(ts,{size:`sm`,wordmark:!1,className:`text-gray-950 dark:text-dark-950 text-base tracking-[-0.035em]`}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:o,className:`h-9 w-9 p-0 rounded-xl text-gray-500 dark:text-dark-600 hover:bg-white/80 dark:hover:bg-dark-200 hover:text-gray-950 dark:hover:text-dark-950 touch-manipulation`,title:l(`sidebar.expandSidebar`),"aria-label":l(`sidebar.expandSidebar`),children:(0,U.jsx)(Ce,{className:`h-4 w-4 rtl:rotate-180`})}),(0,U.jsx)(ns,{})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ts,{size:`sm`,className:`text-gray-950 dark:text-dark-950 tracking-[-0.035em]`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,U.jsx)(ns,{}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:o,className:`h-9 w-9 p-0 rounded-xl text-gray-500 dark:text-dark-600 hover:bg-white/80 dark:hover:bg-dark-200 hover:text-gray-950 dark:hover:text-dark-950 touch-manipulation`,title:l(`sidebar.toggleSize`),"aria-label":l(`sidebar.toggleSize`),children:(0,U.jsx)(Ee,{className:`h-4 w-4 rtl:rotate-180`})})]})]})}),(0,U.jsxs)(`div`,{className:F(`grid w-full gap-2`,e||!n?`grid-cols-1`:`grid-cols-2`),"data-testid":`sidebar-create-actions`,children:[n&&(0,U.jsxs)(I,{variant:r===`work`?`primary`:`secondary`,onClick:s,className:F(`h-10 rounded-xl shadow-none touch-manipulation`,e&&`w-full p-0`),size:`sm`,title:l(`chat.session.work`),"aria-label":l(`chat.session.work`),"aria-pressed":r===`work`,"data-testid":`sidebar-work-button`,children:[(0,U.jsx)(we,{className:`h-4 w-4`}),!e&&l(`chat.session.work`)]}),(0,U.jsxs)(I,{variant:r===`chat`?`primary`:`secondary`,onClick:c,disabled:u,className:F(`h-10 rounded-xl shadow-none touch-manipulation`,e&&`w-full p-0`),size:`sm`,title:u?d:l(`chat.session.chat`),"aria-label":l(`chat.session.chat`),"aria-pressed":r===`chat`,"data-testid":`sidebar-chat-button`,children:[(0,U.jsx)(E,{className:`h-4 w-4`}),!e&&l(`chat.session.chat`)]})]})]})}function is({sidebarCompact:e,activePath:t,showWork:n,onChatClick:r,onMobileNavigate:i}){let{t:a}=C(),o=t=>F(`flex items-center gap-3 rounded-xl text-[13px] font-medium transition-colors duration-150 touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,e?`w-11 h-11 justify-center p-0`:`w-full px-3 py-2.5`,t?`bg-white text-gray-950 ring-1 ring-black/[0.04] dark:bg-dark-200 dark:text-dark-950 dark:ring-white/[0.06]`:`text-gray-600 dark:text-dark-600 hover:bg-white/60 dark:hover:bg-dark-200/60 hover:text-gray-950 dark:hover:text-dark-950 active:bg-white dark:active:bg-dark-200`),s=t===`/chat`||t===`/`||t.startsWith(`/c/`);return(0,U.jsx)(`div`,{className:F(`pb-3`,e?`px-2`:`px-3`),children:(0,U.jsxs)(`nav`,{"data-testid":`sidebar-navigation`,className:F(`space-y-0.5`,e&&`flex flex-col items-center`),children:[(0,U.jsxs)(`button`,{onClick:r,className:F(o(s),`text-start`),title:e?a(`sidebar.navigation.chat`):void 0,"aria-current":s?`page`:void 0,children:[(0,U.jsx)(E,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.chat`)]}),(0,U.jsxs)(y,{to:`/models`,onClick:i,className:o(t===`/models`),title:e?a(`sidebar.navigation.models`):void 0,"aria-current":t===`/models`?`page`:void 0,children:[(0,U.jsx)(pe,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.models`)]}),(0,U.jsxs)(y,{to:`/personas`,onClick:i,className:o(t===`/personas`),title:e?a(`sidebar.navigation.personas`):void 0,"aria-current":t===`/personas`?`page`:void 0,children:[(0,U.jsx)(ge,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.personas`)]}),(0,U.jsxs)(y,{to:`/gallery`,onClick:i,className:o(t===`/gallery`),title:e?a(`sidebar.navigation.imagine`):void 0,"aria-current":t===`/gallery`?`page`:void 0,children:[(0,U.jsx)(ie,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.imagine`)]}),n&&(0,U.jsxs)(y,{to:`/work`,onClick:i,className:o(t===`/work`||t.startsWith(`/work/`)),title:e?a(`sidebar.navigation.work`,{defaultValue:`Work`}):void 0,"aria-current":t===`/work`||t.startsWith(`/work/`)?`page`:void 0,children:[(0,U.jsx)(we,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.work`,{defaultValue:`Work`})]}),(0,U.jsxs)(y,{to:`/agents`,onClick:i,className:o(t===`/agents`),title:e?a(`sidebar.navigation.agents`):void 0,"aria-current":t===`/agents`?`page`:void 0,children:[(0,U.jsx)(T,{className:`h-[18px] w-[18px] shrink-0`}),!e&&a(`sidebar.navigation.agents`)]})]})})}function as({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}){let{t:p,i18n:m}=C();return(0,U.jsx)(`div`,{"data-testid":`sidebar-session-scroll-region`,className:`scroll-region min-h-0 flex-1 scrollbar-thin border-t border-black/[0.05] dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:(0,U.jsxs)(`div`,{className:F(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-2 px-1`,children:[(0,U.jsx)(`h3`,{className:`text-[10px] font-semibold text-gray-500 dark:text-dark-500 uppercase tracking-[0.16em] rtl:tracking-normal`,children:p(`chat.session.chats`)}),(0,U.jsx)(`span`,{className:`text-[10px] tabular-nums text-gray-400 dark:text-dark-500 font-medium`,children:e.length})]}),e.length===0?(0,U.jsxs)(`div`,{className:F(`text-center py-8`,i?`px-1`:`px-2`),children:[(0,U.jsx)(`div`,{className:F(`mx-auto mb-3 bg-white/70 dark:bg-dark-200 rounded-xl flex items-center justify-center ring-1 ring-black/[0.04] dark:ring-white/[0.05]`,i?`w-8 h-8`:`w-12 h-12`),children:(0,U.jsx)(E,{className:F(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:p(`chat.session.noChats`)}),(0,U.jsx)(`p`,{className:`text-xs mt-1 text-gray-400 dark:text-dark-500`,children:p(`chat.session.createFirst`)})]})]}):(0,U.jsx)(`div`,{className:F(`space-y-0.5`,i&&`space-y-1`),children:e.map(e=>{let h=n===e.id,g=e.personaId?t[e.personaId]:null;return(0,U.jsx)(`div`,{className:F(`group relative cursor-pointer transition-colors duration-150 touch-manipulation outline-none`,i?`rounded-xl p-1 flex items-center justify-center`:`rounded-xl px-3 py-2.5`,h?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),onClick:()=>c(e),title:i?`${e.title} - ${e.model}`:void 0,children:i?(0,U.jsx)(`div`,{className:`flex items-center justify-center w-full h-10`,children:(0,U.jsx)(`div`,{className:F(`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`:h?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:e.title.trim().charAt(0)||`•`})}):a===e.id?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(go,{value:o,onChange:e=>s(e.target.value),onKeyDown:t=>{t.key===`Enter`?u(e.id):t.key===`Escape`&&d()},className:`text-sm h-8`,autoFocus:!0}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>u(e.id),className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,U.jsx)(Te,{className:`h-3 w-3`})}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:d,className:`h-8 w-8 p-0 shrink-0 hover:bg-gray-100 dark:hover:bg-dark-300 active:bg-gray-200 dark:active:bg-dark-400 touch-manipulation`,children:(0,U.jsx)(j,{className:`h-3 w-3`})})]}):(0,U.jsxs)(`div`,{className:`flex items-center justify-between w-full`,children:[(0,U.jsxs)(`div`,{className:`flex-1 min-w-0 me-2`,children:[(0,U.jsx)(`h3`,{className:`text-[13px] font-medium truncate leading-tight text-gray-900 dark:text-dark-900`,children:r===e.id?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`animate-pulse`,children:p(`chat.session.generatingTitle`)}),(0,U.jsxs)(`span`,{className:`inline-flex`,children:[(0,U.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`0ms`},children:`.`}),(0,U.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`150ms`},children:`.`}),(0,U.jsx)(`span`,{className:`animate-bounce`,style:{animationDelay:`300ms`},children:`.`})]})]}):Be(e.title,32)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[(0,U.jsx)(`span`,{dir:`auto`,className:F(`text-[11px] tabular-nums`,h?`text-gray-500 dark:text-dark-600`:`text-gray-400 dark:text-dark-500`),children:Ve(e.updatedAt,m.language)}),(0,U.jsx)(`span`,{className:`text-gray-300 dark:text-dark-400`,children:`•`}),e.personaId?g?(0,U.jsxs)(`span`,{className:F(`flex items-center gap-1 text-[11px] font-medium`,h?`text-primary-600 dark:text-primary-400`:`text-primary-500 dark:text-primary-500`),title:g.description||g.name,children:[g.avatar&&!g.avatar.startsWith(`data:`)&&(0,U.jsx)(`span`,{className:`text-[10px]`,children:g.avatar}),(0,U.jsx)(`span`,{className:`truncate max-w-[100px]`,children:g.name})]}):(0,U.jsx)(`span`,{className:F(`text-[11px] font-medium italic`,h?`text-gray-500 dark:text-gray-500`:`text-gray-400 dark:text-gray-600`),children:`Persona`}):(0,U.jsx)(`span`,{dir:`ltr`,className:F(`text-[11px] font-medium truncate max-w-[108px]`,h?`text-gray-700 dark:text-gray-300`:`text-gray-600 dark:text-gray-400`),title:e.model,children:e.model})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100 transition-opacity duration-150 shrink-0`,children:[(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:t=>l(e,t),className:`h-7 w-7 sm:h-7 sm:w-7 p-0 hover:bg-gray-100 dark:hover:bg-dark-300 rounded-lg touch-manipulation`,title:p(`chat.session.renameChat`),children:(0,U.jsx)(w,{className:`h-3 w-3`})}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:t=>f(e.id,t),className:`h-7 w-7 sm:h-7 sm:w-7 p-0 text-red-500 hover:text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-lg touch-manipulation`,title:p(`chat.session.deleteChat`),children:(0,U.jsx)(xe,{className:`h-3 w-3`})})]})]})},e.id)})})]})})}function os({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,U.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,U.jsx)(`div`,{className:`${n} bg-gray-950 dark:bg-white rounded-full flex items-center justify-center`,title:`${e.username} (${e.role})`,children:(0,U.jsx)(`span`,{className:`text-white dark:text-gray-950 ${r} font-medium`,children:e.username.charAt(0).toUpperCase()})})}function ss({requiresAuth:e,user:t,isAdmin:n,sidebarCompact:r,userMenuOpen:i,userMenuRef:a,onToggleUserMenu:o,onOpenSettings:s,onOpenAvatar:c,onLogout:l,onMobileNavigate:u,onCloseUserMenu:d}){let{t:f}=C();return!e||!t?null:(0,U.jsx)(`div`,{className:F(`border-t border-black/[0.05] dark:border-white/[0.05]`,r?`p-2`:`p-3`),children:r?(0,U.jsxs)(`div`,{className:`flex flex-col items-center space-y-2`,children:[(0,U.jsx)(os,{user:t,size:`sm`}),(0,U.jsx)(`button`,{onClick:s,className:`w-10 h-10 flex items-center justify-center rounded-xl text-gray-600 dark:text-dark-600 hover:bg-white/70 dark:hover:bg-dark-200 hover:text-gray-950 dark:hover:text-dark-950 touch-manipulation transition-colors duration-150`,title:f(`sidebar.navigation.settings`),children:(0,U.jsx)(Se,{className:`h-4 w-4`})}),n&&(0,U.jsx)(y,{to:`/users`,onClick:u,className:`w-10 h-10 flex items-center justify-center rounded-xl text-gray-600 dark:text-dark-600 hover:bg-white/70 dark:hover:bg-dark-200 hover:text-gray-950 dark:hover:text-dark-950 touch-manipulation transition-colors duration-150`,title:f(`sidebar.navigation.userManagement`),children:(0,U.jsx)(ge,{className:`h-4 w-4`})}),(0,U.jsx)(`button`,{onClick:l,className:`w-10 h-10 flex items-center justify-center rounded-xl text-gray-500 dark:text-dark-500 hover:bg-red-50 dark:hover:bg-red-900/20 hover:text-red-600 dark:hover:text-red-400 touch-manipulation transition-colors duration-150`,title:f(`sidebar.navigation.signOut`),children:(0,U.jsx)(re,{className:`h-4 w-4`})})]}):(0,U.jsxs)(`div`,{className:`relative`,ref:a,children:[(0,U.jsx)(`button`,{onClick:o,className:`w-full p-2.5 rounded-xl hover:bg-white/70 dark:hover:bg-dark-200 transition-colors duration-150 text-start touch-manipulation outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(os,{user:t,size:`sm`}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,U.jsxs)(`div`,{className:`flex items-center mt-0.5`,children:[t.role===`admin`&&(0,U.jsx)(me,{size:10,className:`text-primary-500 me-1`}),(0,U.jsx)(`span`,{className:`text-[11px] text-gray-500 dark:text-dark-500 capitalize`,children:t.role})]})]}),(0,U.jsx)(Ce,{className:F(`h-4 w-4 text-gray-400 dark:text-dark-500 transition-transform duration-150 rtl:rotate-180`,i&&`rotate-90 rtl:rotate-90`)})]})}),i&&(0,U.jsxs)(`div`,{className:`scroll-region absolute bottom-full left-0 right-0 z-50 mb-2 max-h-[calc(100dvh-1rem)] rounded-2xl border border-black/[0.07] bg-white/95 py-2 shadow-[0_18px_60px_rgba(15,23,42,0.16)] backdrop-blur-xl animate-scale-in scrollbar-thin dark:border-white/[0.08] dark:bg-dark-25/95`,children:[(0,U.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-100 dark:border-dark-200/50`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(os,{user:t,size:`md`}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:t.username}),(0,U.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:t.email||f(`user.profile.noEmail`)})]})]})}),(0,U.jsxs)(`div`,{className:`py-1`,children:[(0,U.jsxs)(`button`,{onClick:()=>{c(t.avatar||``),d()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-gray-700 dark:text-dark-700 hover:bg-gray-100/70 dark:hover:bg-dark-200/70 transition-colors duration-150 text-start`,children:[(0,U.jsx)(ae,{className:`h-4 w-4 shrink-0`}),f(`user.menu.changePicture`)]}),(0,U.jsxs)(`button`,{onClick:()=>{s(),d()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-gray-700 dark:text-dark-700 hover:bg-gray-100/70 dark:hover:bg-dark-200/70 transition-colors duration-150 text-start`,children:[(0,U.jsx)(Se,{className:`h-4 w-4 shrink-0`}),f(`user.menu.settings`)]}),n&&(0,U.jsxs)(y,{to:`/users`,onClick:()=>{d(),u()},className:`w-full flex items-center gap-3 px-3 py-2.5 text-[13px] text-gray-700 dark:text-dark-700 hover:bg-gray-100/70 dark:hover:bg-dark-200/70 transition-colors duration-150`,children:[(0,U.jsx)(ge,{className:`h-4 w-4 shrink-0`}),f(`user.menu.userManagement`)]}),(0,U.jsx)(`div`,{className:`border-t border-gray-100 dark:border-dark-200/50 my-1`}),(0,U.jsxs)(`button`,{onClick:()=>{l(),d()},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,U.jsx)(re,{className:`h-4 w-4 shrink-0`}),f(`user.menu.logout`)]})]})]})]})})}var cs={idle:{labelKey:`work.statusLabels.idle`,label:`Idle`,color:`rgb(255, 255, 255)`,animated:!1},preparing:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},running:{labelKey:`work.statusLabels.thinking`,label:`Thinking`,color:`rgb(48, 121, 255)`,animated:!0},completed:{labelKey:`work.statusLabels.complete`,label:`Complete`,color:`rgb(76, 212, 117)`,animated:!1},needs_input:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},cancelled:{labelKey:`work.statusLabels.needsInput`,label:`Needs input`,color:`rgb(255, 204, 0)`,animated:!1},failed:{labelKey:`work.statusLabels.error`,label:`Error`,color:`rgb(255, 61, 129)`,animated:!1}};function ls({tasks:e,currentTaskId:t,loading:n,actionLoading:r,sidebarCompact:i,onSelectTask:a,onDeleteTask:o}){let{t:s,i18n:c}=C();return(0,U.jsx)(`div`,{"data-testid":`sidebar-work-task-scroll-region`,className:`scroll-region min-h-0 flex-1 border-t border-black/[0.05] scrollbar-thin dark:border-white/[0.05]`,style:{willChange:`scroll-position`},children:(0,U.jsxs)(`div`,{className:F(`px-3 py-3`,i&&`px-2`),children:[!i&&e.length>0&&(0,U.jsxs)(`div`,{className:`mb-2 flex items-center justify-between px-1`,children:[(0,U.jsx)(`h3`,{className:`text-[10px] font-semibold uppercase tracking-[0.16em] text-gray-500 dark:text-dark-500 rtl:tracking-normal`,children:s(`work.tasks.title`,{defaultValue:`Work tasks`})}),(0,U.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums text-gray-400 dark:text-dark-500`,children:e.length})]}),n&&e.length===0?(0,U.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`flex items-center justify-center py-10 text-gray-400 dark:text-dark-500`,children:[(0,U.jsx)(ue,{"aria-hidden":`true`,className:`h-5 w-5 animate-spin`}),(0,U.jsx)(`span`,{className:`sr-only`,children:s(`work.tasks.loading`,{defaultValue:`Loading Work tasks`})})]}):e.length===0?(0,U.jsxs)(`div`,{className:F(`py-8 text-center`,i?`px-1`:`px-2`),children:[(0,U.jsx)(`div`,{className:F(`mx-auto mb-3 flex items-center justify-center rounded-xl bg-white/70 ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`,i?`h-8 w-8`:`h-12 w-12`),children:(0,U.jsx)(we,{className:F(`text-gray-400 dark:text-gray-500`,i?`h-4 w-4`:`h-5 w-5`)})}),!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-gray-600 dark:text-dark-600`,children:s(`work.tasks.emptyTitle`,{defaultValue:`No Work tasks yet`})}),(0,U.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-dark-500`,children:s(`work.tasks.empty`,{defaultValue:`Your Work tasks will appear here after you send the first message.`})})]})]}):(0,U.jsx)(`div`,{"data-testid":`sidebar-work-task-list`,className:F(`space-y-0.5`,i&&`space-y-1`),children:e.map(e=>{let n=t===e.id,l=cs[e.status],u=s(l.labelKey,{defaultValue:l.label});return(0,U.jsxs)(`div`,{"data-testid":`sidebar-work-task-item`,"data-task-id":e.id,className:F(`group relative transition-colors duration-150 outline-none`,i?`flex items-center justify-center rounded-xl p-1`:`rounded-xl px-3 py-2.5`,n?`bg-white ring-1 ring-black/[0.04] dark:bg-dark-200 dark:ring-white/[0.05]`:`hover:bg-white/60 dark:hover:bg-dark-200/60`),children:[(0,U.jsxs)(`button`,{type:`button`,"aria-current":n?`page`:void 0,className:F(`w-full text-start outline-none focus-visible:ring-2 focus-visible:ring-primary-500/30`,i?`flex h-10 items-center justify-center`:`pe-8`),title:i?`${e.title} · ${e.model}`:void 0,onClick:()=>a(e.id),children:[i?(0,U.jsxs)(`span`,{className:F(`relative flex h-9 w-9 items-center justify-center rounded-xl text-[11px] font-semibold uppercase transition-colors`,n?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`bg-white/70 text-gray-500 ring-1 ring-black/[0.04] dark:bg-dark-200/70 dark:text-dark-600 dark:ring-white/[0.05]`),children:[e.title.trim().charAt(0)||`•`,(0,U.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":u,className:F(`absolute -bottom-0.5 -end-0.5 h-2.5 w-2.5 rounded-full border-2 border-gray-100 dark:border-dark-50`,l.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:l.color}})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,"data-testid":`sidebar-work-task-status`,"data-status-label":u,className:F(`h-2 w-2 shrink-0 rounded-full`,l.animated&&`animate-pulse`,e.status===`idle`&&`ring-1 ring-black/20 dark:ring-white/20`),style:{backgroundColor:l.color}}),(0,U.jsx)(`span`,{dir:`auto`,className:`min-w-0 flex-1 truncate text-[13px] font-medium leading-tight text-gray-900 dark:text-dark-900`,children:Be(e.title||s(`work.tasks.untitled`,{defaultValue:`Untitled task`}),32)})]}),(0,U.jsxs)(`span`,{className:`mt-1 flex items-center gap-1.5 ps-4 text-[11px] text-gray-400 dark:text-dark-500`,children:[(0,U.jsx)(`span`,{className:`tabular-nums`,children:Ve(e.updatedAt,c.language)}),(0,U.jsx)(`span`,{className:`text-gray-300 dark:text-dark-400`,children:`•`}),(0,U.jsx)(`span`,{dir:`ltr`,className:`min-w-0 truncate font-medium text-gray-600 dark:text-gray-400`,title:e.model,children:e.model})]})]}),(0,U.jsx)(`span`,{className:`sr-only`,children:s(`work.tasks.status`,{defaultValue:`Status: {{status}}`,status:u})})]}),!i&&(0,U.jsx)(`button`,{type:`button`,"data-testid":`sidebar-work-task-delete`,disabled:r,className:F(`absolute end-2 top-1/2 -translate-y-1/2 rounded-lg p-1.5 text-gray-400 transition-[color,background-color,opacity] hover:bg-error-500/10 hover:text-error-600 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-error-500/30 disabled:cursor-not-allowed disabled:opacity-40 group-focus-within:opacity-100 group-hover:opacity-100 dark:text-dark-500`,n?`opacity-100`:`opacity-0`),"aria-label":s(`work.tasks.deleteNamed`,{defaultValue:`Delete {{title}}`,title:e.title||s(`work.tasks.untitled`,{defaultValue:`Untitled task`})}),onClick:t=>{t.stopPropagation(),o(e)},children:(0,U.jsx)(xe,{"aria-hidden":`true`,className:`h-3.5 w-3.5`})})]},e.id)})})]})})}var us=M(`components:sidebar`),ds=H.lazy(()=>f(()=>import(`../js/SettingsModal-B6Se68Hd.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([11,1,3,12,13,2,14,15,6,5,0,4,8,16]))),fs=({isOpen:e,onClose:t,className:n})=>{let{t:r}=C(),i=b(),a=l(),{sessions:o,deleteSession:s,updateSessionTitle:c,selectedModel:u,models:d,currentSession:f,generatingTitleForSession:p,personas:m}=Vi(),h=la(e=>e.tasks),g=la(e=>e.loadingTasks),_=la(e=>e.actionLoading),v=la(e=>e.deleteTask),{user:y,isAdmin:x,systemInfo:S,setUser:w}=$(),{backgroundImage:T,sidebarCompact:E,toggleSidebarCompact:D}=Ka(),[ee,O]=(0,H.useState)(null),[te,ne]=(0,H.useState)(``),[re,ie]=(0,H.useState)(!1),[ae,oe]=(0,H.useState)(!1),[se,ce]=(0,H.useState)(!1),[le,ue]=(0,H.useState)(``),[k,de]=(0,H.useState)(!1),fe=(0,H.useRef)(null),pe=(0,H.useRef)(null),me=i.pathname.match(/^\/c\/([^/]+)$/)?.[1]||null,he=f?.id||me,j=()=>{window.innerWidth<768&&!E&&D()},ge=()=>{let{setCurrentSession:e}=Vi.getState();po(),e(null),sessionStorage.setItem(`forceWelcomeScreen`,`true`)};(0,H.useEffect)(()=>{let e=e=>{fe.current&&!fe.current.contains(e.target)&&oe(!1)};if(ae)return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[ae]),(0,H.useEffect)(()=>{let t=t=>{pe.current&&!pe.current.contains(t.target)&&window.innerWidth<768&&e&&!E&&D()};if(e&&!E&&window.innerWidth<768)return document.addEventListener(`mousedown`,t),()=>document.removeEventListener(`mousedown`,t)},[e,E,D]);let _e=async()=>{de(!0);try{let e=await Ne.updateMyAvatar(le||null);e.success&&e.data?(w(e.data),A.success(r(`user.avatar.updated`)),ce(!1)):A.error(e.message||r(`user.avatar.updateFailed`))}catch(e){us.error(`Failed to update avatar:`,e),A.error(r(`user.avatar.updateFailed`))}finally{de(!1)}},ve=()=>{ge(),a(`/chat`,{replace:!0}),j()},ye=()=>{la.getState().clearError(),a(`/work`),j()},be=()=>{ge(),a(`/chat`,{replace:!0}),j()},xe=e=>{a(`/c/${e.id}`,{replace:!0}),j()},Se=e=>{a(`/work/${e}`,{replace:!0}),j()},Ce=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`})})))try{await v(e.id),to(e.id),M===e.id&&a(`/work`,{replace:!0,state:{deletedWorkTaskId:e.id}})}catch(e){us.error(`Failed to delete Work task:`,e),A.error(r(`work.toasts.deleteFailed`,{defaultValue:`Could not delete this Work task.`}))}},we=async(e,t)=>{if(t.stopPropagation(),us.debug(`Delete session clicked:`,e),window.confirm(r(`chat.session.deleteConfirm`)))try{us.debug(`Attempting to delete session:`,e);let t=he===e;if(await s(e),us.debug(`Session deleted successfully`),t){let t=o.filter(t=>t.id!==e);t.length>0?a(`/c/${t[0].id}`,{replace:!0}):a(`/`,{replace:!0})}}catch(e){us.error(`Error deleting session:`,e)}},Te=(e,t)=>{t.stopPropagation(),O(e.id),ne(e.title)},Ee=async e=>{te.trim()&&await c(e,te.trim()),O(null),ne(``)},De=()=>{O(null),ne(``)},Oe=async()=>{try{await Pe.logout();let{logout:e}=$.getState();e(),a(`/login`),A.success(r(`auth.logout.success`))}catch(e){us.error(`Logout error:`,e);let{logout:t}=$.getState();t(),a(`/login`)}},ke=()=>{ie(!0),j()},Ae=e=>{ue(e),ce(!0)},je=window.location.protocol===`file:`,Me=i.pathname===`/work`||i.pathname.startsWith(`/work/`),M=i.pathname.match(/^\/work\/([^/]+)$/)?.[1]||null,Fe=i.pathname===`/`||i.pathname===`/chat`||i.pathname.startsWith(`/c/`),Ie=S?.requiresAuth===!1||x();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{ref:pe,"data-testid":`sidebar`,className:F(`fixed inset-y-0 start-0 z-50 border-e border-black/[0.06] dark:border-white/[0.06] transform transition-[width,transform,background-color] duration-200 ease-out shadow-[0_24px_80px_rgba(15,23,42,0.12)]`,E?`w-18`:`w-72 max-sm:w-64`,e?`translate-x-0`:`ltr:-translate-x-full rtl:translate-x-full`,`lg:shadow-none`,T?`bg-gray-100/75 dark:bg-dark-50/75 backdrop-blur-xl`:`bg-gray-100 dark:bg-dark-50`,`overscroll-behavior-contain`,n),style:{WebkitOverflowScrolling:`touch`},children:[je&&(0,U.jsx)(`div`,{className:`absolute top-0 start-16 end-0 h-8 z-[60]`,style:{WebkitAppRegion:`drag`}}),(0,U.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,U.jsx)(rs,{sidebarCompact:E,isElectron:je,showWork:Ie,activeMode:Me?`work`:Fe?`chat`:null,selectedModel:u,modelCount:d.length,onToggleCompact:D,onStartWork:ye,onCreateSession:ve}),(0,U.jsx)(is,{sidebarCompact:E,activePath:i.pathname,showWork:Ie,onChatClick:be,onMobileNavigate:j}),Me&&Ie?(0,U.jsx)(ls,{tasks:h,currentTaskId:M,loading:g,actionLoading:_,sidebarCompact:E,onSelectTask:Se,onDeleteTask:e=>void Ce(e)}):(0,U.jsx)(as,{sessions:o,personas:m,currentSessionId:he,generatingTitleForSession:p,sidebarCompact:E,editingSessionId:ee,editingTitle:te,onEditingTitleChange:ne,onSelectSession:xe,onStartEditing:Te,onSaveEdit:Ee,onCancelEdit:De,onDeleteSession:we}),(0,U.jsx)(ss,{requiresAuth:S?.requiresAuth,user:y,isAdmin:x(),sidebarCompact:E,userMenuOpen:ae,userMenuRef:fe,onToggleUserMenu:()=>oe(e=>!e),onOpenSettings:ke,onOpenAvatar:Ae,onLogout:Oe,onMobileNavigate:j,onCloseUserMenu:()=>oe(!1)})]})]}),re&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(ds,{isOpen:re,onClose:()=>ie(!1)})}),(0,U.jsx)($o,{open:se,value:le,saving:k,onChange:ue,onClose:()=>ce(!1),onSave:_e})]})},ps=({children:e,requireAuth:t=!0,requireAdmin:n=!1})=>{let{isAuthenticated:r,user:i,systemInfo:a,isLoading:o}=$();return b(),o?(0,U.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-dark-50`,children:(0,U.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`})}):a&&!a.requiresAuth?(0,U.jsx)(U.Fragment,{children:e}):t&&!r?(0,U.jsx)(s,{to:`/login`,replace:!0}):n&&(!i||i.role!==`admin`)?(0,U.jsx)(s,{to:`/`,replace:!0}):(0,U.jsx)(U.Fragment,{children:e})},ms=M(`components:error-boundary`),hs=({error:e})=>{let{t}=C();return(0,U.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4 text-gray-900 dark:text-dark-800`,children:(0,U.jsx)(`div`,{className:`w-full max-w-md rounded-2xl border border-gray-200 dark:border-dark-300 bg-white/95 dark:bg-dark-100/95 shadow-card backdrop-blur-sm`,children:(0,U.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,U.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-2xl bg-primary-100 text-primary-700 dark:bg-primary-900/35 dark:text-primary-300 ring-1 ring-primary-200 dark:ring-primary-800/60`,children:(0,U.jsx)(D,{className:`h-6 w-6`})}),(0,U.jsx)(`h1`,{className:`mb-2 text-xl font-semibold text-gray-950 dark:text-dark-950`,children:t(`errorBoundary.title`)}),(0,U.jsx)(`p`,{className:`mb-5 text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t(`errorBoundary.description`)}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:justify-center`,children:[(0,U.jsxs)(`button`,{onClick:()=>window.location.reload(),className:`inline-flex items-center justify-center gap-2 rounded-xl bg-primary-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm transition-all hover:bg-primary-700 hover:shadow-md focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:focus:ring-offset-dark-100`,children:[(0,U.jsx)(oe,{className:`h-4 w-4`}),t(`errorBoundary.tryAgain`)]}),(0,U.jsxs)(`button`,{onClick:()=>{window.location.assign(`/`)},className:`inline-flex items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm transition-all hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:ring-offset-2 dark:border-dark-300 dark:bg-dark-50 dark:text-dark-700 dark:hover:bg-dark-200 dark:focus:ring-offset-dark-100`,children:[(0,U.jsx)(ce,{className:`h-4 w-4`}),t(`common.home`,`Home`)]})]}),!1]})})})},gs=class extends H.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){ms.error(`ErrorBoundary caught an error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,U.jsx)(hs,{error:this.state.error}):this.props.children}},_s=(e,t=!0)=>{let n=(0,H.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===`?`||e.key===`h`);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:!0,o=e.ctrlKey?n.ctrlKey:!0,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,H.useEffect)(()=>{if(t)return document.addEventListener(`keydown`,n),()=>{document.removeEventListener(`keydown`,n)}},[n,t])},vs=e=>{let t=[];e.metaKey&&t.push(navigator.platform.includes(`Mac`)?`⌘`:`Ctrl`),e.ctrlKey&&t.push(`Ctrl`),e.shiftKey&&t.push(`⇧`),e.altKey&&t.push(navigator.platform.includes(`Mac`)?`⌥`:`Alt`);let n=e.key.toUpperCase();return e.key===`,`&&(n=`,`),e.key===` `&&(n=`Space`),e.key===`Enter`&&(n=`↩`),e.key===`Escape`&&(n=`Esc`),t.push(n),t.join(`+`)},ys=({isOpen:e,onClose:t,shortcuts:n})=>{let{t:r}=C();if(!e)return null;let i={navigation:n.filter(e=>e.description.includes(`sidebar`)||e.description.includes(`Toggle`)),settings:n.filter(e=>e.description.includes(`settings`)||e.description.includes(`dark mode`)),general:n.filter(e=>!e.description.includes(`sidebar`)&&!e.description.includes(`settings`)&&!e.description.includes(`dark mode`)&&!e.description.includes(`Toggle`))};return(0,U.jsx)(`div`,{className:`fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4`,children:(0,U.jsxs)(`div`,{className:`flex max-h-[calc(100dvh-2rem)] min-h-0 w-full max-w-md flex-col overflow-hidden rounded-xl bg-white shadow-2xl dark:bg-dark-100 sm:max-h-[80dvh]`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-gray-200 dark:border-dark-300`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(le,{className:`h-5 w-5 text-gray-700 dark:text-dark-600`}),(0,U.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-dark-800`,children:r(`keyboard.title`)})]}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:t,className:`h-8 w-8 p-0 hover:bg-gray-100 dark:hover:bg-dark-200`,children:(0,U.jsx)(j,{className:`h-4 w-4`})})]}),(0,U.jsxs)(`div`,{className:`scroll-region min-h-0 flex-1 space-y-6 p-6 scrollbar-thin`,children:[Object.entries(i).map(([e,t])=>t.length===0?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 dark:text-dark-600 mb-3`,children:r(`keyboard.groups.${e}`)}),(0,U.jsx)(`div`,{className:`space-y-2`,children:t.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:e.description}),(0,U.jsx)(`kbd`,{className:`px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 text-gray-700 dark:text-dark-600 rounded border border-gray-300 dark:border-dark-400`,children:vs(e)})]},t))})]},e)),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-medium text-gray-700 dark:text-dark-600 mb-3`,children:r(`keyboard.groups.chat`)}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:r(`keyboard.actions.sendMessage`)}),(0,U.jsx)(`kbd`,{className:`px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 text-gray-700 dark:text-dark-600 rounded border border-gray-300 dark:border-dark-400`,children:`Enter`})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-dark-500`,children:r(`keyboard.actions.newLine`)}),(0,U.jsx)(`kbd`,{className:`px-2 py-1 text-xs font-mono bg-gray-100 dark:bg-dark-200 text-gray-700 dark:text-dark-600 rounded border border-gray-300 dark:border-dark-400`,children:`Shift+Enter`})]})]})]})]}),(0,U.jsx)(`div`,{className:`px-6 py-4 bg-gray-50 dark:bg-dark-200 border-t border-gray-200 dark:border-dark-300`,children:(0,U.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-dark-400 text-center`,children:[r(`keyboard.footer`,{key1:`?`,key2:`H`}).split(`?`)[0],(0,U.jsx)(`kbd`,{className:`px-1 py-0.5 text-xs font-mono bg-gray-200 dark:bg-dark-300 rounded`,children:`?`}),r(`keyboard.footer`,{key1:`?`,key2:`H`}).split(`?`)[1].split(`H`)[0],(0,U.jsx)(`kbd`,{className:`px-1 py-0.5 text-xs font-mono bg-gray-200 dark:bg-dark-300 rounded`,children:`H`}),r(`keyboard.footer`,{key1:`?`,key2:`H`}).split(`H`)[1]]})})]})})},bs=({onClick:e,className:t})=>{let{t:n}=C(),[r,i]=(0,H.useState)(!1);return(0,U.jsxs)(I,{variant:`ghost`,size:`sm`,onClick:e,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),className:F(`fixed bottom-4 end-4 h-10 w-10 p-0 bg-white/80 dark:bg-dark-100/80 backdrop-blur-sm border border-gray-200 dark:border-dark-300 shadow-lg hover:shadow-xl transition-all duration-200 z-50`,`hover:bg-white dark:hover:bg-dark-100`,t),title:n(`keyboard.tooltip`),children:[(0,U.jsx)(le,{className:`h-4 w-4`}),r&&(0,U.jsx)(`div`,{className:`absolute bottom-full mb-2 end-0 px-2 py-1 text-xs bg-gray-900 text-white rounded whitespace-nowrap`,children:n(`keyboard.tooltip`)})]})},xs=({message:e=`This is a demo version for presentation purposes only. The Ollama backend is not connected.`,onDismiss:t,className:n})=>{let[r,i]=(0,H.useState)(!1),{t:a}=C();return r?null:(0,U.jsx)(`div`,{className:F(`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,U.jsxs)(`div`,{className:`flex items-center justify-between max-w-6xl mx-auto gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,U.jsx)(`div`,{className:`flex-shrink-0`,children:(0,U.jsx)(se,{className:`h-4 w-4 text-white/65 dark:text-gray-950/60`})}),(0,U.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,U.jsx)(`p`,{className:`shrink-0 text-xs font-semibold tracking-wide`,children:a(`demoMode.title`)}),(0,U.jsx)(`p`,{className:`hidden truncate text-xs text-white/60 dark:text-gray-950/60 sm:block`,children:e})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 ml-4`,children:[(0,U.jsxs)(I,{variant:`ghost`,size:`sm`,className:`h-8 px-2 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,onClick:()=>window.open(`https://github.com/libre-webui/libre-webui`,`_blank`),title:`View on GitHub`,children:[(0,U.jsx)(he,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`ml-1 hidden sm:inline`,children:a(`demoMode.github`)})]}),(0,U.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>{i(!0),t?.()},className:`h-8 w-8 p-0 text-white/70 hover:bg-white/10 hover:text-white dark:text-gray-950/70 dark:hover:bg-black/[0.06] dark:hover:text-gray-950`,title:`Dismiss`,children:(0,U.jsx)(j,{className:`h-4 w-4`})})]})]})})},Ss=()=>{let{preferences:e,backgroundImage:t}=Ka(),n=e.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},r=t||n.imageUrl;return!n.enabled||!r?null:(0,U.jsx)(`div`,{className:`fixed inset-0 pointer-events-none z-0`,style:{backgroundImage:`url(${r})`,backgroundSize:`cover`,backgroundPosition:`center`,backgroundRepeat:`no-repeat`,filter:`blur(${n.blurAmount}px)`,opacity:n.opacity,transform:`scale(1.1)`}})},Cs=M(`user-service`),ws=class{static async initializeAuth(){let{setLoading:e,setSystemInfo:t,login:n}=$.getState();try{e(!0),Cs.debug(`Starting auth initialization...`),Cs.debug(`Fetching system info...`);let r=await Pe.getSystemInfo();Cs.debug(`System info response:`,r),r.success&&r.data?(Cs.debug(`Setting system info:`,r.data),t(r.data)):Cs.error(`System info response failed:`,r);let i=localStorage.getItem(`auth-token`);if(i)try{let e=(await f(async()=>{let{default:e}=await import(`../js/utils-vendor-Cbaj0BC5.js`).then(e=>e.i);return{default:e}},__vite__mapDeps([4,1,3]))).default,t=e.defaults.headers.common;e.defaults.headers.common.Authorization=`Bearer ${i}`;let r=await Pe.verifyToken();if(r.success&&r.data){let e=$.getState().systemInfo;e&&n(r.data,i,e)}e.defaults.headers.common=t}catch(e){Cs.error(`Token verification failed:`,e),localStorage.removeItem(`auth-token`)}}catch(e){Cs.error(`Auth initialization error:`,e)}finally{e(!1)}}};Oe.interceptors.request.use(e=>{let t=localStorage.getItem(`auth-token`);return t&&(e.headers.Authorization=`Bearer ${t}`),e},e=>Promise.reject(e)),Oe.interceptors.response.use(e=>e,e=>{if(e.response?.status===401){localStorage.removeItem(`auth-token`);let{logout:e}=$.getState();e();let t=window.location.protocol===`file:`;window.location.href=t?`#/login`:`/login`}return Promise.reject(e)});var Ts=M(`initialize`),Es=()=>{let e=(0,H.useRef)(!1),t=(0,H.useRef)(!1),{loadSessions:n,loadModels:r,loadPreferences:i,setSelectedModel:a,models:o}=Vi(),{loadPreferences:s}=Ka(),{loadPlugins:c,plugins:l}=Ya();(0,H.useEffect)(()=>{e.current||t.current||(async()=>{t.current=!0;try{Ts.debug(`Initializing Libre WebUI...`),await ws.initializeAuth();try{!(await Le.checkHealth()).success&&!je()&&k.error(`Ollama service is not available. Plugin models may still be used.`)}catch(e){Ts.warn(`Ollama health check failed; continuing provider initialization:`,e),je()||k.error(`Ollama service is not available. Plugin models may still be used.`)}await Promise.all([s(),i()]),await Promise.all([r(),n(),c()]),e.current=!0,Ts.debug(`Libre WebUI initialized successfully`)}catch(t){je()?(await Promise.all([s(),i()]),await Promise.all([r(),n(),c()]),e.current=!0):(Ts.error(`Failed to initialize app:`,t),k.error(`Failed to connect to the backend service`))}finally{t.current=!1}})()},[s,i,r,n,c]),(0,H.useEffect)(()=>{if(o.length>0){let e=o.filter(e=>!e.name.includes(`embed`))[0]||o[0],{selectedModel:t,selectedProviderType:n,selectedProviderId:r}=Vi.getState();if(t){if(!Fi(o,{model:t,providerType:n,providerId:r})&&n!==`ollama`&&n!==`plugin`){let t=ji(e);Ts.debug(`Legacy selected model not available, falling back to:`,t.model),a(t.model,t.providerType,t.providerId)}}else{let t=ji(e);Ts.debug(`No model selected, using first available:`,t.model),a(t.model,t.providerType,t.providerId)}}},[o,a]),(0,H.useEffect)(()=>{e.current&&(Ts.debug(`Plugin availability changed, reloading models...`),r())},[l,r])},Ds=M(`components:git-hub-auth-button`),Os=()=>{let{t:e}=C(),[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{(async()=>{try{let e=await fetch(`${Fe}/auth/oauth/github/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),Ds.debug(`GitHub OAuth configured:`,t.configured)}else Ds.debug(`GitHub OAuth status check failed`),i(!1)}catch(e){Ds.debug(`GitHub OAuth not configured:`,e),i(!1)}})()},[]),r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${Fe}/auth/oauth/github`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(ue,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.github`)})]}):(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(ne,{size:16,className:`me-2`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.github`)})]})}):null},ks=M(`components:hugging-face-auth-button`),As=()=>{let{t:e}=C(),[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{(async()=>{try{let e=await fetch(`${Fe}/auth/oauth/huggingface/status`,{method:`GET`,credentials:`include`});if(e.ok){let t=await e.json();i(t.configured||!1),ks.debug(`Hugging Face OAuth configured:`,t.configured)}else ks.debug(`Hugging Face OAuth status check failed`),i(!1)}catch(e){ks.debug(`Hugging Face OAuth not configured:`,e),i(!1)}})()},[]),r?(0,U.jsx)(`button`,{type:`button`,onClick:()=>{if(!r||t)return;n(!0);let e=`${Fe}/auth/oauth/huggingface`;window.location.href=e},disabled:t,className:`flex h-11 w-full items-center justify-center rounded-xl border border-line bg-surface-raised px-4 text-sm font-medium text-ink shadow-subtle transition-colors hover:border-line-strong hover:bg-surface-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:t?(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(ue,{size:16,className:`me-2 animate-spin`}),e(`auth.oauth.connectingTo`,{provider:e(`auth.oauth.huggingFace`)})]}):(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(`span`,{className:`me-2 text-base`,children:`🤗`}),e(`auth.oauth.continueWith`,{provider:e(`auth.oauth.huggingFace`)})]})}):null},js=M(`components:login-form`),Ms={username:`demo`,password:`demo`},Ns=({onLogin:e,onShowSignup:t})=>{let{t:n}=C(),r=je(),[i,a]=(0,H.useState)(r?Ms.username:``),[o,s]=(0,H.useState)(r?Ms.password:``),[c,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),p=l(),{login:m}=$(),h=async t=>{t.preventDefault();let a=r?Ms.username:i.trim(),s=r?Ms.password:o.trim();if(!a||!s){A.error(n(`auth.login.enterBoth`));return}f(!0);try{localStorage.removeItem(`auth-token`);let t=await Pe.login({username:a,password:s});t.success&&t.data?(m(t.data.user,t.data.token,t.data.systemInfo),A.success(n(`auth.login.loginSuccess`)),e?.(),p(`/`)):A.error(t.message||n(`auth.login.loginFailed`))}catch(e){js.error(`Login error:`,e),A.error(n(`auth.login.checkCredentials`))}finally{f(!1)}},g=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-md rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`,children:[(0,U.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:n(`auth.login.title`)}),(0,U.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:n(`auth.login.subtitle`)})]}),(0,U.jsxs)(`form`,{onSubmit:h,className:`space-y-5`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:n(`auth.login.username`)}),(0,U.jsx)(`input`,{id:`username`,type:`text`,value:i,onChange:e=>a(e.target.value),onKeyDown:g,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:n(`auth.login.usernamePlaceholder`),required:!0,disabled:d||r})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:n(`auth.login.password`)}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`input`,{id:`password`,type:c?`text`:`password`,value:o,onChange:e=>s(e.target.value),onKeyDown:g,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:bg-surface-subtle disabled:text-ink-muted motion-reduce:transition-none`,placeholder:n(`auth.login.passwordPlaceholder`),required:!0,disabled:d||r}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(!c),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:d||r,"aria-label":c?`Hide characters`:`Reveal characters`,children:c?(0,U.jsx)(be,{size:20}):(0,U.jsx)(fe,{size:20})})]})]}),(0,U.jsx)(`button`,{type:`submit`,disabled: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-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:d?(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),n(`auth.login.signingIn`)]}):(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(De,{size:16,className:`me-2`}),n(`auth.login.signIn`)]})})]}),!r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-6`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,U.jsx)(`div`,{className:`w-full border-t border-line`})}),(0,U.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,U.jsx)(`span`,{className:`bg-surface-raised px-2 text-ink-muted`,children:n(`common.or`)})})]}),(0,U.jsxs)(`div`,{className:`mt-6 space-y-3`,children:[(0,U.jsx)(Os,{}),(0,U.jsx)(As,{})]})]}),(0,U.jsx)(`div`,{className:`mt-6 text-center`,children:(0,U.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[n(`auth.login.noAccount`),` `,(0,U.jsx)(`button`,{onClick:()=>t?.(),className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:n(`auth.login.signUpHere`)})]})})]})]})},Ps=M(`components:turnstile-widget`),Fs=`https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit`,Is=null,Ls=()=>window.turnstile?Promise.resolve():Is||(Is=new Promise((e,t)=>{let n=document.querySelector(`script[src="${Fs}"]`);if(n){n.addEventListener(`load`,()=>e(),{once:!0}),n.addEventListener(`error`,t,{once:!0});return}let r=document.createElement(`script`);r.src=Fs,r.async=!0,r.defer=!0,r.onload=()=>e(),r.onerror=t,document.head.appendChild(r)}),Is),Rs=({siteKey:e,disabled:t=!1,errorMessage:n,onTokenChange:r})=>{let i=(0,H.useRef)(null),a=(0,H.useRef)(null),[o,s]=(0,H.useState)(!1);return(0,H.useEffect)(()=>{let t=!1,n=i.current;return r(``),Ls().then(()=>{t||!n||!window.turnstile||(n.innerHTML=``,a.current=window.turnstile.render(n,{sitekey:e,theme:`auto`,callback:e=>r(e),"expired-callback":()=>r(``),"error-callback":()=>r(``)}))}).catch(e=>{Ps.error(`Turnstile script failed to load:`,e),t||s(!0)}),()=>{t=!0,r(``),a.current&&window.turnstile?.remove?window.turnstile.remove(a.current):n&&(n.innerHTML=``),a.current=null}},[r,e]),(0,H.useEffect)(()=>{t&&a.current&&(window.turnstile?.reset(a.current),r(``))},[t,r]),o?(0,U.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300`,children:n}):(0,U.jsx)(`div`,{className:`rounded-lg border border-accent-200 bg-accent-50/40 p-3 transition-opacity dark:border-accent-800/70 dark:bg-accent-950/20 ${t?`pointer-events-none opacity-60`:``}`,"aria-label":`Security verification`,children:(0,U.jsx)(`div`,{ref:i,className:`min-h-[65px]`})})},zs=M(`components:signup-form`),Bs=({onSignup:e,onBackToLogin:t})=>{let{t:n}=C(),[r,i]=(0,H.useState)(``),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(``),b=l(),{login:x,systemInfo:S}=$(),w=S?.turnstile?.siteKey,T=!!(S?.turnstile?.enabled&&w),E=(0,H.useCallback)(e=>{y(e)},[]),D=(0,H.useMemo)(()=>g||T&&!v,[g,T,v]),ee=async t=>{if(t.preventDefault(),!r.trim()||!s.trim()){A.error(n(`auth.signup.usernameRequired`));return}if(s!==u){A.error(n(`auth.signup.passwordMismatch`));return}if(s.length<6){A.error(n(`auth.signup.passwordTooShort`));return}if(T&&!v){A.error(n(`auth.signup.tryAgain`));return}_(!0);try{let t=await Pe.signup({username:r,password:s,email:a,turnstileToken:v});t.success&&t.data?(x(t.data.user,t.data.token,t.data.systemInfo),A.success(n(`auth.signup.signupSuccess`)),e?.(),b(`/`)):A.error(t.message||n(`auth.signup.signupFailed`))}catch(e){zs.error(`Signup error:`,e),A.error(n(`auth.signup.tryAgain`))}finally{y(``),_(!1)}},O=e=>{if(e.key===`Enter`){let t=e.currentTarget.form;t&&t.requestSubmit()}};return(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-md rounded-3xl border border-line bg-surface-raised p-6 shadow-card sm:p-8`,children:[(0,U.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,U.jsx)(`h1`,{className:`mb-2 text-3xl font-light tracking-[-0.04em] text-ink`,children:n(`auth.signup.title`)}),(0,U.jsx)(`p`,{className:`text-sm leading-6 text-ink-muted`,children:n(`auth.signup.subtitle`)})]}),(0,U.jsxs)(`form`,{onSubmit:ee,className:`space-y-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`username`,className:`mb-2 block text-sm font-medium text-ink`,children:n(`auth.signup.username`)}),(0,U.jsx)(`input`,{id:`username`,type:`text`,value:r,onChange:e=>i(e.target.value),onKeyDown:O,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:n(`auth.signup.usernamePlaceholder`),required:!0,disabled:g})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{htmlFor:`email`,className:`mb-2 block text-sm font-medium text-ink`,children:[n(`auth.signup.email`),` `,(0,U.jsxs)(`span`,{className:`text-ink-muted`,children:[`(`,n(`common.optional`),`)`]})]}),(0,U.jsx)(`input`,{id:`email`,type:`email`,value:a,onChange:e=>o(e.target.value),onKeyDown:O,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:n(`auth.signup.emailPlaceholder`),disabled:g})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`password`,className:`mb-2 block text-sm font-medium text-ink`,children:n(`auth.signup.password`)}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`input`,{id:`password`,type:f?`text`:`password`,value:s,onChange:e=>c(e.target.value),onKeyDown:O,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:n(`auth.signup.passwordPlaceholder`),required:!0,disabled:g}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:g,"aria-label":f?`Hide characters`:`Reveal characters`,children:f?(0,U.jsx)(be,{size:20}):(0,U.jsx)(fe,{size:20})})]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{htmlFor:`confirmPassword`,className:`mb-2 block text-sm font-medium text-ink`,children:n(`auth.signup.confirmPassword`)}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`input`,{id:`confirmPassword`,type:m?`text`:`password`,value:u,onChange:e=>d(e.target.value),onKeyDown:O,className:`h-11 w-full rounded-xl border border-line bg-surface px-3 pe-11 text-sm text-ink shadow-subtle outline-none transition-[border-color,box-shadow,background-color] placeholder:text-ink-muted focus:border-line-strong focus:ring-2 focus:ring-primary-500/35 disabled:cursor-not-allowed disabled:opacity-50 motion-reduce:transition-none`,placeholder:n(`auth.signup.confirmPasswordPlaceholder`),required:!0,disabled:g}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>h(!m),className:`absolute inset-y-0 end-0 flex items-center pe-3 text-ink-muted transition-colors hover:text-ink disabled:cursor-not-allowed disabled:opacity-50`,disabled:g,"aria-label":m?`Hide confirmation`:`Reveal confirmation`,children:m?(0,U.jsx)(be,{size:20}):(0,U.jsx)(fe,{size:20})})]})]}),T&&w&&(0,U.jsx)(Rs,{siteKey:w,disabled:g,errorMessage:n(`auth.signup.tryAgain`),onTokenChange:E}),(0,U.jsx)(`button`,{type:`submit`,disabled: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-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-40 motion-reduce:transition-none`,children:g?(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(`div`,{className:`me-2 h-4 w-4 animate-spin rounded-full border-b-2 border-current`}),n(`auth.signup.creatingAccount`)]}):(0,U.jsxs)(`div`,{className:`flex items-center`,children:[(0,U.jsx)(ye,{size:16,className:`me-2`}),n(`auth.signup.createAccount`)]})})]}),(0,U.jsx)(Os,{}),(0,U.jsx)(`div`,{className:`mt-6 text-center`,children:(0,U.jsxs)(`p`,{className:`text-sm text-ink-muted`,children:[n(`auth.signup.hasAccount`),` `,(0,U.jsx)(`button`,{onClick:t,className:`font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:n(`auth.signup.signInHere`)})]})})]})},Vs=()=>{let{t:e}=C(),t=l(),{isAuthenticated:n,requiresAuth:r}=$(),[i,a]=(0,H.useState)(!1),o=r();return(0,H.useEffect)(()=>{(n||!o)&&t(`/`)},[o,n,t]),n||!o?null:(0,U.jsxs)(`div`,{className:`relative min-h-screen overflow-y-auto bg-gray-50 text-gray-950 dark:bg-dark-50 dark:text-dark-950`,children:[(0,U.jsxs)(`header`,{className:`absolute inset-x-0 top-0 z-10 flex h-16 items-center justify-between border-b border-gray-200/70 px-5 dark:border-white/[0.08] sm:px-8`,children:[(0,U.jsx)(ts,{size:`sm`,className:`text-gray-950 dark:text-dark-950 lg:invisible`}),(0,U.jsx)(ns,{})]}),(0,U.jsxs)(`main`,{className:`grid min-h-screen pt-16 lg:grid-cols-[minmax(20rem,0.9fr)_minmax(32rem,1.1fr)]`,children:[(0,U.jsxs)(`section`,{className:`relative hidden overflow-hidden border-e border-gray-200/70 p-10 dark:border-white/[0.08] lg:flex lg:flex-col lg:justify-between xl:p-16`,children:[(0,U.jsx)(ts,{size:`lg`,className:`relative z-10 text-gray-950 dark:text-dark-950`}),(0,U.jsx)(`div`,{className:`relative z-10 max-w-xl border-s border-gray-300 ps-6 dark:border-white/15`,children:(0,U.jsx)(`p`,{className:`text-4xl font-light leading-[1.08] tracking-[-0.04em] text-gray-900 dark:text-dark-900 xl:text-5xl`,children:e(`setup.welcome.features.secure.description`)})})]}),(0,U.jsx)(`section`,{className:`flex items-center justify-center px-4 py-12 sm:px-8 lg:py-16`,children:(0,U.jsx)(`div`,{className:`w-full max-w-md [&>div]:!max-w-none [&>div]:!rounded-none [&>div]:!border-0 [&>div]:!bg-transparent [&>div]:!p-0 [&>div]:!shadow-none`,children:i?(0,U.jsx)(Bs,{onBackToLogin:()=>a(!1),onSignup:()=>a(!1)}):(0,U.jsx)(Ns,{onShowSignup:()=>a(!0)})})})]})]})},Hs=window.location.protocol===`file:`,Us=()=>Hs?(0,U.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-8 z-50`,style:{WebkitAppRegion:`drag`}}):null,Ws=M(`app`),Gs=H.lazy(()=>f(()=>import(`../js/ChatPage-D0fdzy7a.js`),__vite__mapDeps([17,1,3,18,2,14,15,5,6,0,4,8,16,19,20,21,22,23,12,13]))),Ks=H.lazy(()=>f(()=>import(`../js/ModelsPage-nxheiYJp.js`),__vite__mapDeps([24,1,3,2,12,13,14,15,6,5,0,4,8,16]))),qs=H.lazy(()=>f(()=>import(`../js/PersonasPage-C2pqDsWA.js`),__vite__mapDeps([25,1,3,12,13,2,14,15,6,5,0,4,8,16]))),Js=H.lazy(()=>f(()=>import(`../js/GalleryPage-CMkCur9v.js`),__vite__mapDeps([26,1,3,18,13,2,14,15,6,5,0,4,8,16]))),Ys=H.lazy(()=>f(()=>import(`../js/LibreClawPage-CHEfny1k.js`),__vite__mapDeps([27,1,3,14,15,6,5,0,2,4,8,16]))),Xs=H.lazy(()=>f(()=>import(`../js/WorkPage-AcZMp8OB.js`),__vite__mapDeps([28,1,3,2,14,15,0,4,5,6,8,16,7,9,10,23,18,12,13]))),Zs=H.lazy(()=>f(()=>import(`../js/UserManagementPage-DQeL-Twp.js`),__vite__mapDeps([29,1,3,12,13,2,14,15,6,5,0,4,16,8]))),Qs=H.lazy(()=>f(()=>import(`../js/ArtifactDemoPage-CWDhGWrz.js`),__vite__mapDeps([30,1,3,16,8,4,20,14,15,6,5,21,22,19]))),$s=H.lazy(()=>f(()=>import(`../js/SettingsModal-B6Se68Hd.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([11,1,3,12,13,2,14,15,6,5,0,4,8,16]))),ec=H.lazy(()=>f(()=>import(`../js/ArtifactSlideOutPanel-CzUpDM59.js`).then(e=>({default:e.ArtifactSlideOutPanel})),__vite__mapDeps([31,1,3,18,14,15,6,5,8,4,16,21,22,19]))),tc=H.lazy(()=>f(()=>import(`../js/FirstTimeSetup-CfnOmy9w.js`).then(e=>({default:e.FirstTimeSetup})),__vite__mapDeps([32,1,3,14,15,6,5,0,2,4]))),nc=()=>{let{t:e}=C();return(0,U.jsx)(`div`,{className:`flex h-full min-h-screen items-center justify-center bg-gray-50 dark:bg-dark-100`,children:(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,U.jsx)(`div`,{className:`h-8 w-8 rounded-full border-4 border-gray-200 border-t-primary-500 animate-spin dark:border-dark-300 dark:border-t-primary-400`}),(0,U.jsx)(`div`,{className:`text-gray-600 dark:text-dark-600`,children:e(`common.loading`)})]})})},rc=({isOpen:e,compact:t})=>(0,U.jsx)(`div`,{"aria-hidden":`true`,className:F(`hidden lg:block flex-shrink-0 transition-[width] duration-200 ease-out`,e?t?`w-18`:`w-72`:`w-0`)}),ic=({onClick:e})=>{let t=b();return t.pathname===`/`||t.pathname===`/chat`||t.pathname.startsWith(`/c/`)?(0,U.jsx)(`div`,{className:`hidden lg:block`,children:(0,U.jsx)(bs,{onClick:e})}):null},ac=()=>{let{t:e,i18n:t}=C(),[n,r]=(0,H.useState)(!1),[i,a]=(0,H.useState)(!1),[o,s]=(0,H.useState)(0),[l,u]=(0,H.useState)(!1),{sidebarOpen:d,sidebarCompact:f,setSidebarOpen:p,setSidebarCompact:m,toggleSidebar:g,toggleSidebarCompact:_,toggleTheme:v,backgroundImage:y,preferences:b,artifactPanelOpen:x}=Ka(),{systemInfo:S,isLoading:w,user:T,isAuthenticated:E}=$(),{isDemoMode:D,demoConfig:O}=Ka(),[te,ne]=H.useState(!1),re=H.useRef(!1);H.useEffect(()=>{(async()=>{if(re.current){Ws.debug(`OAuth already processing, skipping...`);return}Ws.debug(`Starting OAuth callback processing...`),re.current=!0;let e=new URLSearchParams(window.location.search),t=e.get(`token`),n=e.get(`auth`);if(t&&n===`success`){try{let e=await fetch(`${Fe}/auth/me`,{headers:{Authorization:`Bearer ${t}`},credentials:`include`});if(e.ok){let n=await e.json();if(n.success&&n.data){let{login:e,systemInfo:r}=$.getState();e(n.data,t,r||{requiresAuth:!0,hasUsers:!0,userCount:1,version:`0.1.6`}),Ws.debug(`OAuth login successful, showing toast`),k.success(`GitHub login successful!`)}else k.error(`Failed to verify GitHub authentication`)}else k.error(`GitHub authentication verification failed`)}catch(e){Ws.error(`OAuth processing error:`,e),k.error(`GitHub authentication failed`)}window.history.replaceState({},document.title,window.location.pathname)}Ws.debug(`OAuth processing completed`),ne(!0),re.current=!1})()},[]),Es();let ie=()=>{if(y)return!0;let e=b.backgroundSettings;return e?.enabled&&e?.imageUrl},ae=[{key:`b`,metaKey:!0,action:()=>{window.innerWidth>=1024?d?_():(m(!1),g()):(!d&&f&&m(!1),g())},description:e(`keyboard.toggleSidebar`)},{key:`,`,metaKey:!0,action:()=>r(!0),description:e(`keyboard.openSettings`)},{key:`d`,metaKey:!0,action:v,description:e(`keyboard.toggleDarkMode`)},{key:`h`,action:()=>a(!0),description:e(`keyboard.showShortcuts`)},{key:`Escape`,action:()=>{r(!1),a(!1)},description:e(`keyboard.closeModals`)}];_s(ae),H.useEffect(()=>(ro.connect().catch(Ws.error),()=>{ro.disconnect()}),[]),H.useEffect(()=>{if(!S&&!w&&o<15){let e=setTimeout(async()=>{s(e=>e+1);try{await ws.initializeAuth()}catch{}},2e3);return()=>clearTimeout(e)}},[S,w,o]);let oe=!l&&S?.requiresAuth===!0&&S?.hasUsers===!1;return w?(0,U.jsxs)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8`,children:[(0,U.jsx)(`div`,{className:`sm:mx-auto sm:w-full sm:max-w-md`,children:(0,U.jsx)(`div`,{className:`flex flex-col items-center`,children:(0,U.jsx)(ts,{className:`text-gray-900 dark:text-gray-100`})})}),(0,U.jsx)(`div`,{className:`mt-8 flex flex-col items-center gap-4`,children:(0,U.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})})]}):S?oe&&!l?(0,U.jsx)(gs,{children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(nc,{}),children:(0,U.jsx)(tc,{onComplete:()=>{u(!0)}})})}):te?(0,U.jsxs)(U.Fragment,{children:[S&&!S.requiresAuth?(0,U.jsxs)(`div`,{className:F(`flex h-dvh min-h-0 text-gray-950 dark:text-dark-900 relative overflow-hidden`,ie()?`bg-gray-100/60 dark:bg-dark-50/60`:`bg-gray-100 dark:bg-dark-50`),children:[(0,U.jsx)(Us,{}),(0,U.jsx)(Ss,{}),(0,U.jsx)(fs,{isOpen:d,onClose:()=>p(!1)}),(0,U.jsx)(rc,{isOpen:d,compact:f}),(0,U.jsxs)(`div`,{"data-testid":`app-shell-content`,className:F(`flex-1 basis-0 flex min-h-0 flex-col min-w-0 transition-[margin,background-color] duration-200 ease-out relative z-10 lg:py-2 lg:pe-2`,d&&f?`max-lg:ms-18`:`max-lg:ms-0`,ie()?`bg-white/10 dark:bg-dark-50/10`:`bg-transparent`),children:[D&&O.showBanner&&(0,U.jsx)(xs,{message:O.message}),(0,U.jsx)(`main`,{className:F(`min-h-0 flex-1 overflow-hidden lg:rounded-[1.5rem] lg:border lg:border-black/[0.06] dark:lg:border-white/[0.07] lg:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_60px_rgba(15,23,42,0.04)]`,ie()?`bg-white/30 dark:bg-dark-100/35 backdrop-blur-sm`:`bg-gray-50 dark:bg-dark-100`),children:(0,U.jsx)(gs,{children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(nc,{}),children:(0,U.jsxs)(c,{children:[(0,U.jsx)(h,{path:`/`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/chat`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/c/:sessionId`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/models`,element:(0,U.jsx)(Ks,{})}),(0,U.jsx)(h,{path:`/personas`,element:(0,U.jsx)(qs,{})}),(0,U.jsx)(h,{path:`/gallery`,element:(0,U.jsx)(Js,{})}),(0,U.jsx)(h,{path:`/work`,element:(0,U.jsx)(ps,{requireAdmin:!0,children:(0,U.jsx)(Xs,{})})}),(0,U.jsx)(h,{path:`/work/:taskId`,element:(0,U.jsx)(ps,{requireAdmin:!0,children:(0,U.jsx)(Xs,{})})}),(0,U.jsx)(h,{path:`/agents`,element:(0,U.jsx)(Ys,{})}),(0,U.jsx)(h,{path:`/login`,element:(0,U.jsx)(Vs,{})})]})})})})]})]}):(0,U.jsxs)(c,{children:[(0,U.jsx)(h,{path:`/login`,element:(0,U.jsx)(Vs,{})}),(0,U.jsx)(h,{path:`/*`,element:(0,U.jsx)(ps,{children:(0,U.jsxs)(`div`,{className:F(`flex h-dvh min-h-0 text-gray-950 dark:text-dark-900 relative overflow-hidden`,ie()?`bg-gray-100/60 dark:bg-dark-50/60`:`bg-gray-100 dark:bg-dark-50`),children:[(0,U.jsx)(Us,{}),(0,U.jsx)(Ss,{}),(0,U.jsx)(fs,{isOpen:d,onClose:()=>p(!1)}),(0,U.jsx)(rc,{isOpen:d,compact:f}),(0,U.jsxs)(`div`,{"data-testid":`app-shell-content`,className:F(`flex-1 basis-0 flex min-h-0 flex-col min-w-0 transition-[margin,background-color] duration-200 ease-out relative z-10 lg:py-2 lg:pe-2`,d&&f?`max-lg:ms-18`:`max-lg:ms-0`,ie()?`bg-white/10 dark:bg-dark-50/10`:`bg-transparent`),children:[D&&O.showBanner&&(0,U.jsx)(xs,{message:O.message}),(0,U.jsx)(`main`,{className:F(`min-h-0 flex-1 overflow-hidden lg:rounded-[1.5rem] lg:border lg:border-black/[0.06] dark:lg:border-white/[0.07] lg:shadow-[0_1px_2px_rgba(0,0,0,0.03),0_18px_60px_rgba(15,23,42,0.04)]`,ie()?`bg-white/30 dark:bg-dark-100/35 backdrop-blur-sm`:`bg-gray-50 dark:bg-dark-100`),children:(0,U.jsx)(gs,{children:(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(nc,{}),children:(0,U.jsxs)(c,{children:[(0,U.jsx)(h,{path:`/`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/chat`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/c/:sessionId`,element:(0,U.jsx)(Gs,{})}),(0,U.jsx)(h,{path:`/models`,element:(0,U.jsx)(Ks,{})}),(0,U.jsx)(h,{path:`/personas`,element:(0,U.jsx)(qs,{})}),(0,U.jsx)(h,{path:`/gallery`,element:(0,U.jsx)(Js,{})}),(0,U.jsx)(h,{path:`/work`,element:(0,U.jsx)(ps,{requireAdmin:!0,children:(0,U.jsx)(Xs,{})})}),(0,U.jsx)(h,{path:`/work/:taskId`,element:(0,U.jsx)(ps,{requireAdmin:!0,children:(0,U.jsx)(Xs,{})})}),(0,U.jsx)(h,{path:`/agents`,element:(0,U.jsx)(Ys,{})}),(0,U.jsx)(h,{path:`/artifacts`,element:(0,U.jsx)(Qs,{})}),(0,U.jsx)(h,{path:`/users`,element:(0,U.jsx)(ps,{requireAdmin:!0,children:(0,U.jsx)(Zs,{})})})]})})})})]})]})})})]}),n&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)($s,{isOpen:n,onClose:()=>r(!1)})}),(0,U.jsx)(ys,{isOpen:i,onClose:()=>a(!1),shortcuts:ae}),(0,U.jsx)(ic,{onClick:()=>a(!0)}),x&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(ec,{})}),(0,U.jsx)(ee,{position:ni(t.language)?`top-left`:`top-right`,toastOptions:{duration:4e3,className:`animate-slide-up`,style:{background:`var(--toast-bg)`,color:`var(--toast-color)`,border:`1px solid var(--toast-border)`,borderRadius:`0.75rem`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,cursor:`pointer`},success:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}},error:{iconTheme:{primary:`rgb(var(--color-primary-600))`,secondary:`#ffffff`}}},containerStyle:{top:80,insetInlineEnd:20}})]}):(0,U.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center`,children:(0,U.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-gray-600 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}):(0,U.jsx)(`div`,{className:`min-h-screen bg-gray-50 dark:bg-dark-50 flex items-center justify-center p-4`,children:(0,U.jsxs)(`div`,{className:`text-center`,children:[(0,U.jsx)(`div`,{className:`mb-8`,children:(0,U.jsx)(ts,{className:`text-gray-900 dark:text-white`})}),(0,U.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,U.jsx)(`div`,{className:`w-8 h-8 border-4 border-gray-300 dark:border-dark-300 border-t-primary-500 dark:border-t-primary-400 rounded-full animate-spin`})}),(0,U.jsx)(`p`,{className:`text-gray-600 dark:text-dark-600 text-sm`,children:o>0?`Connecting to backend... (${o}/15)`:`Starting up...`})]})})},oc=Hs?_([{path:`*`,element:(0,U.jsx)(ac,{})}]):m([{path:`*`,element:(0,U.jsx)(ac,{})}]),sc=()=>(0,U.jsx)(gs,{children:(0,U.jsx)(v,{router:oc})}),cc=new En({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});oi.catch(()=>{ri(`en`)}).then(()=>{An.createRoot(document.getElementById(`root`)).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(kn,{client:cc,children:(0,U.jsx)(sc,{})})}))});export{hi as $,eo as A,Z as B,go as C,Ze as Ct,io as D,fo as E,Ka as F,ji as G,Vi as H,fa as I,Ri as J,Ii as K,ua as L,Qa as M,$a as N,$ as O,Ya as P,ui as Q,da as R,_o as S,_t as St,mo as T,Ni as U,la as V,Li as W,Bi as X,zi as Y,K as Z,Po as _,L as _t,Xo as a,ar as at,ko as b,Qe as bt,qo as c,Ut as ct,Go as d,jt as dt,di as et,Ho as f,R as ft,No as g,Xe as gt,Mo as h,yt as ht,Qo as i,Zr as it,to as j,ro as k,Ko as l,Vt as lt,Ro as m,bt as mt,cs as n,ni as nt,Yo as o,On as ot,Vo as p,wt as pt,Fi as q,ts as r,ti as rt,Uo as s,tn as st,Rs as t,ai as tt,Wo as u,Ht as ut,Fo as v,ft as vt,so as w,Ke as wt,vo as x,st as xt,jo as y,$e as yt,Fa as z};