libre-webui 0.29.0 → 0.30.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.
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts +9 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js +38 -0
- package/backend/dist/persistence/postgresAutomationWebhooksMigration.js.map +1 -0
- package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
- package/backend/dist/persistence/postgresMigrationRegistry.js +4 -0
- package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/postgresResourceRepositories.js +5 -0
- package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts +13 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts.map +1 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js +69 -0
- package/backend/dist/persistence/postgresWorkApprovalsMigration.js.map +1 -0
- package/backend/dist/persistence/resourceTypes.d.ts +4 -0
- package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
- package/backend/dist/persistence/resourceTypes.js.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.d.ts +3 -0
- package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteMigrations.js +149 -0
- package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteResourceRepositories.js +7 -0
- package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js +32 -1
- package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +85 -5
- package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +10 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +67 -7
- package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
- package/backend/dist/platform/workPersistence/types.d.ts +37 -0
- package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
- package/backend/dist/platform/workPersistence/types.js.map +1 -1
- package/backend/dist/routes/automations.d.ts.map +1 -1
- package/backend/dist/routes/automations.js +83 -1
- package/backend/dist/routes/automations.js.map +1 -1
- package/backend/dist/routes/work.d.ts.map +1 -1
- package/backend/dist/routes/work.js +72 -0
- package/backend/dist/routes/work.js.map +1 -1
- package/backend/dist/services/automationService.d.ts +13 -1
- package/backend/dist/services/automationService.d.ts.map +1 -1
- package/backend/dist/services/automationService.js +31 -0
- package/backend/dist/services/automationService.js.map +1 -1
- package/backend/dist/services/notificationService.d.ts.map +1 -1
- package/backend/dist/services/notificationService.js +1 -0
- package/backend/dist/services/notificationService.js.map +1 -1
- package/backend/dist/services/workAgentGuidance.d.ts +11 -0
- package/backend/dist/services/workAgentGuidance.d.ts.map +1 -1
- package/backend/dist/services/workAgentGuidance.js +16 -2
- package/backend/dist/services/workAgentGuidance.js.map +1 -1
- package/backend/dist/services/workAgentService.d.ts +55 -0
- package/backend/dist/services/workAgentService.d.ts.map +1 -1
- package/backend/dist/services/workAgentService.js +425 -13
- package/backend/dist/services/workAgentService.js.map +1 -1
- package/backend/dist/services/workApprovalService.d.ts +67 -0
- package/backend/dist/services/workApprovalService.d.ts.map +1 -0
- package/backend/dist/services/workApprovalService.js +273 -0
- package/backend/dist/services/workApprovalService.js.map +1 -0
- package/backend/dist/services/workEventService.d.ts.map +1 -1
- package/backend/dist/services/workEventService.js +25 -0
- package/backend/dist/services/workEventService.js.map +1 -1
- package/backend/dist/services/workPolicyService.d.ts +4 -0
- package/backend/dist/services/workPolicyService.d.ts.map +1 -1
- package/backend/dist/services/workPolicyService.js +19 -0
- package/backend/dist/services/workPolicyService.js.map +1 -1
- package/backend/dist/services/workRuntimeShared.d.ts +2 -0
- package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
- package/backend/dist/services/workRuntimeShared.js.map +1 -1
- package/backend/dist/services/workTaskService.d.ts +3 -1
- package/backend/dist/services/workTaskService.d.ts.map +1 -1
- package/backend/dist/services/workTaskService.js +21 -4
- package/backend/dist/services/workTaskService.js.map +1 -1
- package/backend/dist/types/index.d.ts +3 -1
- package/backend/dist/types/index.d.ts.map +1 -1
- package/backend/dist/types/index.js.map +1 -1
- package/backend/dist/types/work.d.ts +32 -11
- package/backend/dist/types/work.d.ts.map +1 -1
- package/backend/package.json +1 -1
- package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
- package/frontend/dist/assets/{index-f1s6QpC5.js → index-C04eLDsy.js} +63 -78
- package/frontend/dist/index.html +15 -15
- package/frontend/dist/js/{ArtifactContainer-CTXxnWRo.js → ArtifactContainer-ivbLUiBh.js} +1 -1
- package/frontend/dist/js/{ArtifactDemoPage-CEYuIhJA.js → ArtifactDemoPage-BmOteTzj.js} +1 -1
- package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-CFIXhQGP.js} +1 -1
- package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-DTGX1bsD.js} +1 -1
- package/frontend/dist/js/AutomationModal-DWjiyu3B.js +1 -0
- package/frontend/dist/js/{AutomationsPage-D3v0Cra1.js → AutomationsPage-DA9uLEG2.js} +1 -1
- package/frontend/dist/js/{AvatarUpload-DzL00yOL.js → AvatarUpload-26z_BlGH.js} +1 -1
- package/frontend/dist/js/{CalendarPage-Bls3TBeZ.js → CalendarPage-CFU2zsFJ.js} +1 -1
- package/frontend/dist/js/{ChannelsPage-BnoCniNf.js → ChannelsPage-BqUJMmjD.js} +1 -1
- package/frontend/dist/js/ChatPage-D8I4CNtg.js +14 -0
- package/frontend/dist/js/{EvaluationsPage-DSgj9dT5.js → EvaluationsPage-jmb_F4xz.js} +1 -1
- package/frontend/dist/js/{FirstTimeSetup-BRysXCjP.js → FirstTimeSetup-DcOvjDh4.js} +1 -1
- package/frontend/dist/js/{GalleryPage-DUcM4dg0.js → GalleryPage-CFYgjwey.js} +1 -1
- package/frontend/dist/js/{HomePage-BebX3v-x.js → HomePage-DDt6s4Ya.js} +1 -1
- package/frontend/dist/js/{LibreClawPage-A37KF9_G.js → LibreClawPage-BqtLshHp.js} +1 -1
- package/frontend/dist/js/{NotesPage-CXSz7Hde.js → NotesPage-wdPw2owK.js} +1 -1
- package/frontend/dist/js/{PersonasPage-CiOBffF3.js → PersonasPage-DMJ3MioQ.js} +1 -1
- package/frontend/dist/js/{PluginUsagePage-jMrpL2Jb.js → PluginUsagePage-Di_B_DJQ.js} +1 -1
- package/frontend/dist/js/RichMessageContent-S1-4RhLW.js +1 -0
- package/frontend/dist/js/{RichMessageContent-CC9QZQKd.js → RichMessageContent-wk0Eyab_.js} +1 -1
- package/frontend/dist/js/{SettingsModal-DP_wKehV.js → SettingsModal-d7I_FVJY.js} +1 -1
- package/frontend/dist/js/{ShareDialog-BW8iGd_i.js → ShareDialog-buTN0EBc.js} +1 -1
- package/frontend/dist/js/{SystemPage-Drd1neLN.js → SystemPage-CmgxjTS5.js} +1 -1
- package/frontend/dist/js/{UserManagementPage-CquciWKV.js → UserManagementPage-u2r5f_uX.js} +1 -1
- package/frontend/dist/js/WorkPage-CYth3I8M.js +7 -0
- package/frontend/dist/js/{api-2DulPtq1.js → api-IiXPQ8se.js} +2 -2
- package/frontend/dist/js/api-gEytqqET.js +1 -0
- package/frontend/dist/js/{appNavigation-DAGh98Yj.js → appNavigation-Bsk9DwFY.js} +1 -1
- package/frontend/dist/js/{appStore-Ci1X0yA-.js → appStore-D_3JwBEY.js} +2 -2
- package/frontend/dist/js/appVersion-Chg_Ru57.js +1 -0
- package/frontend/dist/js/{ar-CpmN0TY8.js → ar-BKsbznj2.js} +1 -1
- package/frontend/dist/js/authStore-BiWhwkJN.js +1 -0
- package/frontend/dist/js/authStore-jbmnSGyL.js +4 -0
- package/frontend/dist/js/{bn-BwrMg_Oh.js → bn-DXd4s3g6.js} +1 -1
- package/frontend/dist/js/{chatStore-DkpmZLOG.js → chatStore-BXWiKI6E.js} +3 -3
- package/frontend/dist/js/{config-Ckn9cand.js → config-CtVytjAm.js} +1 -1
- package/frontend/dist/js/cs-CtvHHZ6D.js +2 -0
- package/frontend/dist/js/da-CRCQinmr.js +2 -0
- package/frontend/dist/js/de-DKjz-eJm.js +2 -0
- package/frontend/dist/js/es-K0j99jVL.js +2 -0
- package/frontend/dist/js/{evaluationsApi-Cu5PH_qi.js → evaluationsApi-CNcvUpmS.js} +1 -1
- package/frontend/dist/js/{fr-BY5aUofi.js → fr-BcQtHFjN.js} +1 -1
- package/frontend/dist/js/{hi-KCn9gIiT.js → hi-B69aSfMV.js} +1 -1
- package/frontend/dist/js/id-DlEUyPF3.js +2 -0
- package/frontend/dist/js/is-DhIcxuEq.js +2 -0
- package/frontend/dist/js/{it-CqaqWB8D.js → it-BE6UfTtm.js} +1 -1
- package/frontend/dist/js/ja-BNmjqYW2.js +2 -0
- package/frontend/dist/js/ko-bnvJ-aG1.js +2 -0
- package/frontend/dist/js/{messageCodeStyles-DKq3DH1W.js → messageCodeStyles-D1-WsF_0.js} +1 -1
- package/frontend/dist/js/ms-BHlYr228.js +2 -0
- package/frontend/dist/js/nl-B0dJJcU_.js +2 -0
- package/frontend/dist/js/pl-BQQOCUBv.js +2 -0
- package/frontend/dist/js/pt-CeCixlV6.js +2 -0
- package/frontend/dist/js/ru-CtbW6bcV.js +2 -0
- package/frontend/dist/js/sv-DvyO144q.js +2 -0
- package/frontend/dist/js/{teamEventStream-C4u_py2D.js → teamEventStream-B8hMmTgC.js} +1 -1
- package/frontend/dist/js/{th-dOxm2Hhl.js → th-Bsila0Wp.js} +1 -1
- package/frontend/dist/js/tr-CJ9yyiQZ.js +2 -0
- package/frontend/dist/js/{ui-DUzqxWMk.js → ui-BxB90kIo.js} +2 -2
- package/frontend/dist/js/{uk-Cl7Pk0Yf.js → uk-BZnidh3w.js} +1 -1
- package/frontend/dist/js/{useChat-6yDWZSTz.js → useChat-CP1Bi10i.js} +1 -1
- package/frontend/dist/js/useDictation-DF16QY6J.js +1 -0
- package/frontend/dist/js/vi-DgnSoExN.js +2 -0
- package/frontend/dist/js/{workApi-BwDBwG62.js → workApi-BUxESSmH.js} +3 -3
- package/frontend/dist/js/workApi-DrTI8jZw.js +1 -0
- package/frontend/dist/js/zh-C3NMIgKz.js +2 -0
- package/package.json +3 -3
- package/frontend/dist/js/AutomationModal-DB3lrK2K.js +0 -1
- package/frontend/dist/js/ChatPage-BMcigJWr.js +0 -14
- package/frontend/dist/js/ModelSelector-C1ipX-44.js +0 -1
- package/frontend/dist/js/RichMessageContent-CU6WTuOs.js +0 -1
- package/frontend/dist/js/WorkPage-BgASwAGs.js +0 -6
- package/frontend/dist/js/api-BmIdrQfK.js +0 -1
- package/frontend/dist/js/appVersion-BRMnr50t.js +0 -1
- package/frontend/dist/js/authStore-DIvsSaOt.js +0 -4
- package/frontend/dist/js/authStore-DoxafXFR.js +0 -1
- package/frontend/dist/js/cs-f72Fnxz3.js +0 -2
- package/frontend/dist/js/da-qp8lOgkJ.js +0 -2
- package/frontend/dist/js/de-CpcLHr97.js +0 -2
- package/frontend/dist/js/es-gZHsxjG4.js +0 -2
- package/frontend/dist/js/id-C7U6kS0J.js +0 -2
- package/frontend/dist/js/is-N9Ek-Usz.js +0 -2
- package/frontend/dist/js/ja-C5f9HAm1.js +0 -2
- package/frontend/dist/js/ko-BuoboDvb.js +0 -2
- package/frontend/dist/js/ms-Cu-UWc6j.js +0 -2
- package/frontend/dist/js/nl-nOUc4C_i.js +0 -2
- package/frontend/dist/js/pl-BKKwFhxj.js +0 -2
- package/frontend/dist/js/pt-B18-KYtS.js +0 -2
- package/frontend/dist/js/ru-DflEWNyb.js +0 -2
- package/frontend/dist/js/sv-CU-nPjr8.js +0 -2
- package/frontend/dist/js/tr-7ThM4F8q.js +0 -2
- package/frontend/dist/js/vi-eljYUBOk.js +0 -2
- package/frontend/dist/js/workApi-uXUZSjsf.js +0 -1
- package/frontend/dist/js/zh-B0sinUfQ.js +0 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/ModelManagerModals-CpWAltRA.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-CsTEqgp1.js","js/react-vendor-BsJBHRYW.js","js/useTranslation-DrnYb6Cx.js","js/utils-D9UstwTG.js","js/utils-vendor-DtsgPwcz.js","js/ui-vendor-C0KwbTD4.js","js/Button--pDOakZx.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{i as r,t as i}from"./useQuery-CoWV2PmJ.js";import{a}from"./router-vendor-BGP0k6Y2.js";import{t as o}from"./useTranslation-DrnYb6Cx.js";import{a as s,n as c,r as l,t as u}from"./utils-D9UstwTG.js";import{C as d,D as f,E as p,_ as m,b as h,c as g,l as _,m as v,p as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./chatStore-DkpmZLOG.js";import{$ as E,$t as D,An as O,At as k,Cn as A,E as j,Ft as M,G as ee,Gn as N,Ht as P,I as te,In as ne,It as re,Jt as ie,K as ae,Kt as oe,L as F,Ln as se,Lt as ce,Nt as le,Pt as I,Qt as ue,R as de,Rt as fe,Sn as pe,St as me,T as he,Tt as ge,U as _e,Un as ve,Ut as ye,V as be,Vn as xe,W as Se,Wn as Ce,Wt as we,X as Te,Y as Ee,Yt as De,Z as Oe,_n as ke,_r as L,_t as Ae,ct as je,dn as Me,g as Ne,gn as Pe,gr as R,in as Fe,ir as Ie,j as Le,jn as Re,jt as z,mn as ze,mr as Be,mt as Ve,n as He,nn as Ue,nr as We,nt as Ge,o as Ke,or as qe,p as Je,pr as Ye,pt as Xe,q as Ze,qt as Qe,r as $e,rr as et,t as tt,tn as nt,un as rt,v as B,vn as it,w as at,wn as ot,x as st,xn as ct,z as lt,zt as ut}from"./ui-vendor-C0KwbTD4.js";import{t as V}from"./logger-CpCQz3Vi.js";import{n as dt}from"./workApi-BwDBwG62.js";import{C as ft,F as pt,I as mt,M as ht,N as gt,S as _t,a as vt,c as yt,d as H,f as U,i as bt,j as xt,l as St,n as Ct,p as wt,r as Tt,s as W,u as Et,w as Dt,y as G}from"./api-2DulPtq1.js";import{a as K,o as Ot,s as kt,t as At}from"./imageGenModels-Dx_QMLJQ.js";import{t as jt,u as Mt}from"./authStore-DIvsSaOt.js";import{a as Nt,n as Pt,o as Ft,t as It}from"./appStore-Ci1X0yA-.js";import{l as Lt}from"./messageCodeStyles-DKq3DH1W.js";import{t as q}from"./Button--pDOakZx.js";import{_ as Rt,g as zt,i as Bt,n as Vt,r as J,s as Ht,t as Ut,v as Wt}from"./ui-DUzqxWMk.js";import{t as Gt}from"./Logo-BE9SvCC5.js";import{t as Kt}from"./LogoMark-C8x1yyP3.js";import{t as qt}from"./ShareDialog-BW8iGd_i.js";import{s as Jt}from"./ttsBatching-C9kQXFB1.js";import{r as Y,t as Yt}from"./webauthnClient-CPSq528Q.js";import{t as Xt}from"./appVersion-BRMnr50t.js";import{t as X}from"./SettingsToggle-C16gtVyi.js";import{i as Zt,r as Qt,t as $t}from"./thinking-DwlkTfPX.js";var Z=e(t(),1),Q=n();function en(e){let t=e.match(/^v?(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function tn(e,t){for(let n=0;n<3;n++)if(e[n]!==t[n])return e[n]-t[n];return 0}function nn(e){let[t,n]=(0,Z.useState)(`checking`),[r,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1,r=en(e),a=e.includes(`-dev`);return(async()=>{try{let e=await fetch(`https://api.github.com/repos/libre-webui/libre-webui/releases/latest`,{headers:{Accept:`application/vnd.github+json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let o=en((await e.json()).tag_name??``);if(t)return;if(!r||!o){n(`error`);return}i(o.join(`.`));let s=tn(r,o);n(s<0?`behind`:s>0||a?`ahead`:`latest`)}catch{t||n(`error`)}})(),()=>{t=!0}},[e]),{status:t,latestVersion:r}}var $=[{href:`https://github.com/libre-webui/libre-webui`,icon:D,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://github.com/libre-webui/libre-webui`,icon:he,labelKey:`settings.about.links.star`,descriptionKey:`settings.about.links.starDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:De,labelKey:`settings.about.links.forgejo`,descriptionKey:`settings.about.links.forgejoDescription`},{href:`https://librewebui.org`,icon:it,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:Ie,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://github.com/sponsors/libre-webui`,icon:P,labelKey:`settings.about.links.sponsor`,descriptionKey:`settings.about.links.sponsorDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:me,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],rn=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function an({status:e,latestVersion:t}){let{t:n}=o();return e===`checking`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-500 dark:text-dark-500`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),n(`settings.about.updates.checking`)]}):e===`latest`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-success-600 dark:text-success-400`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.upToDate`)]}):e===`ahead`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(ue,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.ahead`,{version:t??``})]}):e===`behind`?(0,Q.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:[(0,Q.jsx)(se,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.updateAvailable`,{version:t??``}),(0,Q.jsx)(it,{className:`h-3 w-3`})]}):(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:n(`settings.about.updates.checkFailed`)})}function on({appVersion:e}){let{t}=o(),{status:n,latestVersion:r}=nn(e);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2.5 text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Kt,{size:`md`,label:null}),(0,Q.jsx)(Gt,{})]}),(0,Q.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,Q.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:rn.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,Q.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,Q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:$.map(e=>{let n=e.icon;return(0,Q.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,Q.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,Q.jsx)(it,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.labelKey)})})]}),(0,Q.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e.includes(`-dev`)?(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:t(`settings.about.version`,{version:e})}):(0,Q.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,Q.jsx)(an,{status:n,latestVersion:r}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-whats-new`)),className:`inline-flex items-center gap-1.5 text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-dark-900`,"data-testid":`about-view-changelog`,children:[(0,Q.jsx)(Se,{className:`h-3.5 w-3.5`}),t(`settings.about.updates.viewChangelog`)]})]}),(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[t(`settings.about.openSourceBy`,{company:``}),(0,Q.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var sn=V(`components:background-upload`),cn=({className:e=``})=>{let{t}=o(),{preferences:n,setPreferences:r,backgroundImage:i,uploadBackgroundImage:a,removeBackgroundImage:s}=It(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){L.error(t(`personaBackground.invalidFile`));return}if(e.size>5242880){L.error(t(`personaBackground.fileTooLarge`));return}u(!0);try{await a(e),L.success(t(`personaBackground.uploaded`))}catch(e){sn.error(`Failed to upload background:`,e),L.error(t(`personaBackground.uploadFailed`))}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},g=e=>{e.preventDefault(),f(!0)},_=e=>{e.preventDefault(),f(!1)},v=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},y=()=>{s(),L.success(t(`personaBackground.removed`))},b=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(r({backgroundSettings:n}),t||!e)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}},x=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(r({backgroundSettings:n}),t)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}},S=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(r({backgroundSettings:n}),t)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}};return(0,Q.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,Q.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>b(e.target.checked)}),(0,Q.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(`img`,{src:i,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:y,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,Q.jsx)(He,{className:`h-4 w-4`})})]})}):(0,Q.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`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:g,onDragLeave:_,onDrop:v,onClick:()=>c.current?.click(),children:[(0,Q.jsx)(ut,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,Q.jsx)(Je,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,Q.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),i&&(0,Q.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,Q.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>x(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,Q.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>S(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},ln=()=>{let{t:e,i18n:t}=o();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:e(`settings.appearance.language.title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:e(`settings.appearance.language.description`)})]}),(0,Q.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Q.jsx)(`select`,{"data-testid":`language-switcher-select`,value:p(t.language),onChange:e=>{let t=e.target.value;d(t)},className:`h-9 max-w-[220px] cursor-pointer appearance-none rounded-full bg-surface-subtle pe-9 ps-3.5 text-sm text-ink transition-colors hover:bg-hover-solid focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:f.map(e=>(0,Q.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,Q.jsx)(Ce,{className:`pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-ink-muted`})]})]})};function un({title:e,description:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:n})]})}function dn({checked:e,onChange:t,label:n,testId:r}){return(0,Q.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":r,"aria-label":n,className:`peer sr-only`,checked:e,onChange:e=>t(e.target.checked)}),(0,Q.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-line-strong transition-colors peer-focus:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500/40 peer-checked:bg-primary-500 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-all after:content-[''] peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full`})]})}function fn({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:i,onAdaptToAccentChange:a,onShowUsernameChange:s,onShowFollowUpsChange:c,onAutoOpenArtifactsChange:l,onHapticFeedbackChange:d}){let{t:f}=o(),p=e.accent||`blue`,m=e.customAccent||`#4176e6`,h=Nt(e),g=(t,r,i)=>{let a=e.mode===t;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(t),"aria-pressed":a,className:u(`flex flex-1 basis-[180px] flex-col items-center justify-center gap-1 rounded-2xl border px-8 py-5 text-sm leading-[22px] text-ink transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,a?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(r,{className:`h-4 w-4`}),i]})};return(0,Q.jsxs)(`div`,{className:`divide-y divide-line`,children:[(0,Q.jsx)(ln,{}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.title`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[g(`light`,at,f(`settings.appearance.theme.light`)),g(`dark`,Xe,f(`settings.appearance.theme.dark`)),g(`amoled`,Ve,f(`settings.appearance.theme.amoled`))]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.title`,{defaultValue:`Accent color`})}),(0,Q.jsx)(`div`,{className:`h-6 w-6 flex-shrink-0 rounded-full border border-line`,style:{backgroundColor:h},"aria-hidden":`true`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[Pt.map(e=>{let t=p===e.id;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:u(`relative h-9 w-9 rounded-full transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),style:{backgroundColor:e.color},"aria-label":f(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,Q.jsx)(N,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,Q.jsxs)(`label`,{className:u(`relative h-9 w-9 cursor-pointer overflow-hidden rounded-full transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500/40`,p===`custom`?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),title:f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,Q.jsx)(`input`,{type:`color`,value:m,onInput:e=>i(e.currentTarget.value),onChange:e=>i(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:m},"aria-hidden":`true`}),(0,Q.jsx)(je,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.behaviorTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:f(`settings.appearance.accent.behaviorDescription`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-stretch gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>a(!1),className:u(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line hover:bg-interactive-hover`:`border-line-strong bg-surface-subtle`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.defaultStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>a(!0),className:u(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.adaptedStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.showUsername`),description:f(`settings.appearance.chatInterface.showUsernameDescription`),children:(0,Q.jsx)(dn,{checked:t.showUsername,onChange:s,label:f(`settings.appearance.chatInterface.showUsername`)})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.followUpSuggestions`),description:f(`settings.appearance.chatInterface.followUpSuggestionsDescription`),children:(0,Q.jsx)(dn,{checked:t.showFollowUpSuggestions!==!1,onChange:c,label:f(`settings.appearance.chatInterface.followUpSuggestions`)})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.autoOpenArtifacts`),description:f(`settings.appearance.chatInterface.autoOpenArtifactsDescription`),children:(0,Q.jsx)(dn,{checked:t.autoOpenArtifactPanel!==!1,onChange:l,label:f(`settings.appearance.chatInterface.autoOpenArtifacts`),testId:`auto-open-artifacts-toggle`})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),description:f(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`}),children:(0,Q.jsx)(dn,{checked:t.hapticFeedbackEnabled===!0,onChange:d,label:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),testId:`haptic-feedback-toggle`})}),(0,Q.jsx)(`div`,{className:`py-4`,children:(0,Q.jsx)(cn,{})})]})}function pn(){let{t:e,i18n:t}=o(),{sessions:n,setSessionArchived:r,deleteSession:i}=x(),a=n.filter(e=>e.archived);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),a.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:a.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:l(n.updatedAt,t.language)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&i(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,Q.jsx)(B,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function mn({sessionCount:e,loading:t,importing:n,preflighting:r,preflight:i,showImportOptions:a,mergeStrategy:s,importResult:c,importFileInputRef:l,onExportData:u,onImportFileSelect:d,onClearAllHistory:f,onMergeStrategyChange:p,onConfirmImport:m,onCancelImport:h,onDismissImportResult:g}){let{t:_}=o();return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:_(`settings.data.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.export`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.exportDescription`)}),(0,Q.jsx)(`p`,{className:`mb-3 text-[11px] text-amber-700 dark:text-amber-300`,children:_(`settings.data.archiveScopeV3`,{defaultValue:`Includes preferences, chats, folders, Notes, knowledge collections, and extracted document text. Excludes accounts and secrets, biometric cloned voices, generated media, personas and memory, and Work data or volumes.`})}),(0,Q.jsx)(q,{onClick:u,variant:`outline`,size:`sm`,className:`w-full`,children:_(`settings.data.exportAll`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.import`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.importDescription`)}),(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json`,onChange:d,className:`hidden`}),(0,Q.jsx)(q,{onClick:()=>l.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:_(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.clearSessions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.clearSessionsDescription`)}),(0,Q.jsx)(q,{onClick:f,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?_(`settings.data.clearing`):_(`settings.data.clearAll`,{count:e})})]})]}),a&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:_(`settings.data.importOptions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:_(`settings.data.importOptionsDescription`)}),(0,Q.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:s===`skip`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.skipDuplicates`)})]}),(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:s===`overwrite`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.overwrite`)})]})]}),r&&(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-gray-600 dark:text-gray-300`,children:_(`settings.data.validatingArchive`,{defaultValue:`Validating archive and calculating changes…`})}),i&&!r&&(0,Q.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-gray-200 bg-white p-3 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-gray-300`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:_(`settings.data.preflightReport`,{defaultValue:`Import preview`})}),(0,Q.jsx)(`p`,{children:_(`settings.data.preflightIncoming`,{defaultValue:`{{folders}} folders · {{sessions}} chats · {{messages}} messages · {{notes}} Notes · {{collections}} collections · {{documents}} documents · {{chunks}} chunks`,folders:i.incoming.sessionFolders,sessions:i.incoming.sessions,messages:i.incoming.messages,notes:i.incoming.notes,collections:i.incoming.knowledgeCollections,documents:i.incoming.documents,chunks:i.incoming.documentChunks})}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:[[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),i.result.sessionFolders],[_(`settings.data.sessions`),i.result.sessions],[_(`settings.data.notes`,{defaultValue:`Notes`}),i.result.notes],[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),i.result.knowledgeCollections],[_(`settings.data.documents`),i.result.documents]].map(([e,t])=>(0,Q.jsxs)(`p`,{children:[e,`: `,t.imported,` `,_(`settings.data.toCreate`,{defaultValue:`to create`}),`, `,t.overwritten,` `,_(`settings.data.toOverwrite`,{defaultValue:`to overwrite`}),`, `,t.skipped,` `,_(`settings.data.toSkip`,{defaultValue:`to skip`})]},e))}),i.result.remappedIds>0&&(0,Q.jsx)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:_(`settings.data.preflightRemappedIds`,{defaultValue:`{{count}} IDs will be remapped to protect another account's data.`,count:i.result.remappedIds})}),i.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`preflight-warning-${t}`))]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{onClick:m,size:`sm`,disabled:n||r||!i||i.strategy!==s,children:_(n?`settings.data.importing`:`settings.data.import`)}),(0,Q.jsx)(q,{onClick:h,variant:`outline`,size:`sm`,children:_(`common.cancel`)})]})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:_(`settings.data.importResults`)}),(0,Q.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[_(`settings.data.preferences`),`:`,` `,c.preferences.imported?_(`settings.data.imported`):_(`settings.data.failed`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessions`),`:`,` `,c.sessions.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessions.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessions.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.documents`),`:`,` `,c.documents.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.documents.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.documents.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.notes`,{defaultValue:`Notes`}),`:`,` `,c.notes.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.notes.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.notes.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),`: `,c.sessionFolders.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessionFolders.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessionFolders.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),`: `,c.knowledgeCollections.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.knowledgeCollections.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.knowledgeCollections.skipped,` `,_(`settings.data.skipped`)]}),c.warnings.length>0&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[_(`settings.data.warnings`,{defaultValue:`Warnings`}),`:`]}),c.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`warning-${t}`))]})]}),(0,Q.jsx)(q,{onClick:g,variant:`outline`,size:`sm`,className:`mt-2`,children:_(`common.close`)})]})]})]}),(0,Q.jsx)(pn,{})]})}function hn({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:i,onSettingChange:a,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=o();return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,Q.jsx)(X,{checked:e.enabled,onChange:e=>a(`enabled`,e)})]}),e.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,Q.jsx)(zt,{value:t.model,onChange:e=>a(`model`,e.target.value),options:n}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>a(`chunkSize`,e)}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>a(`chunkOverlap`,e)}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>a(`similarityThreshold`,e)})]})]}),r&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,Q.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,Q.jsx)(`span`,{className:r.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:r.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,Q.jsxs)(q,{onClick:c,disabled:i,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,Q.jsx)(pe,{size:16}),u(i?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,Q.jsxs)(q,{onClick:l,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),u(`settings.saveSettings`)]})]}),(0,Q.jsx)(gn,{})]})})}function gn(){let{t:e}=o(),t=r(),[n,a]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),{data:m}=i({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([xt.getCollections(),xt.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:h=[],documents:g=[]}=m??{},_=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),v=async()=>{let t=n.trim();if(t){a(``);try{let e=await xt.createCollection(t);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.createFailed`))}}},y=async t=>{l(null);try{let e=await xt.deleteCollection(t);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.deleteFailed`))}},b=async t=>{p(null);try{let e=await xt.deleteDocument(t);if(!e.success)throw Error(e.error);window.dispatchEvent(new Event(`libre:documents-updated`)),await _()}catch{R.error(e(`settings.documents.library.deleteFailed`))}},x=async(t,n)=>{try{let e=await xt.setDocumentCollection(t,n);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.assignFailed`))}};return(0,Q.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,Q.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void v(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),h.length>0&&(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:h.map(t=>s===t.id?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-red-200 bg-red-50 px-2.5 py-1 text-xs text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300`,children:[e(`settings.documents.collections.deleteConfirm`),(0,Q.jsx)(`button`,{onClick:()=>void y(t.id),className:`font-medium underline decoration-red-400 underline-offset-2 hover:text-red-800 dark:hover:text-red-200`,children:e(`common.delete`)}),(0,Q.jsx)(`button`,{onClick:()=>l(null),className:`text-red-400 hover:text-red-600 dark:hover:text-red-300`,title:e(`common.cancel`),children:(0,Q.jsx)(He,{className:`h-3 w-3`})})]},t.id):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:[(0,Q.jsx)(Ie,{className:`h-3 w-3`}),t.name,(0,Q.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),t.shared?(0,Q.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`settings.documents.collections.shared`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>d({id:t.id,name:t.name}),className:`text-gray-400 transition-colors hover:text-primary-500 dark:text-dark-500`,title:e(`settings.documents.collections.share`),"data-testid":`collection-share`,children:(0,Q.jsx)(de,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:()=>l(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(He,{className:`h-3 w-3`})})]})]},t.id))}),(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.library.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.library.description`)}),g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.documents.library.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:g.map(t=>(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:f===t.id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-red-700 dark:text-red-300`,children:e(`settings.documents.library.deleteConfirm`,{name:t.filename})}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,className:`text-red-600 border-red-200 hover:bg-red-50 dark:text-red-400 dark:border-red-800 dark:hover:bg-red-900/20`,onClick:()=>void b(t.id),children:e(`common.delete`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>p(null),children:e(`common.cancel`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rt,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:[c(t.size),` · `,t.sessionId?e(`settings.documents.library.chatScope`):e(`settings.documents.library.everyChatScope`)]})]}),t.processingStatus===`failed`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-red-100 px-2 py-0.5 text-xs font-medium text-red-700 dark:bg-red-900/30 dark:text-red-300`,title:t.processingError||e(`settings.documents.library.extractionFailed`),children:e(`settings.documents.library.extractionFailed`)}),t.processingStatus===`queued`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-dark-200 dark:text-dark-700`,children:e(`settings.documents.library.extractionQueued`)}),h.length>0&&(0,Q.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void x(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,Q.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),h.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Q.jsx)(`button`,{onClick:()=>p(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]})},t.id))}),u&&(0,Q.jsx)(qt,{resourceType:`knowledge-collection`,resourceId:u.id,resourceLabel:u.name,onClose:()=>d(null)})]})}function _n({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,Q.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function vn({generationOptions:e,generationScope:t,scopedModel:n,onGenerationScopeChange:r,embeddingSettings:i,effectiveEmbeddingSettings:a,embeddingModelOptions:s,embeddingStatus:c,onGenerationOptionChange:l,onEmbeddingSettingsChange:d,onResetGenerationOptions:f,onSaveGenerationOptions:p,onResetEmbeddingSettings:m,onSaveEmbeddingSettings:h}){let{t:g}=o(),[_,v]=(0,Z.useState)(!1),y=(0,Z.useId)(),b=(0,Z.useId)(),x=(0,Z.useId)(),S=[{value:`global`,label:g(`settings.generation.scopeAll`)},...n?[{value:`model`,label:g(`settings.generation.scopeModel`,{model:n})}]:[]];return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.generation.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:g(`settings.generation.description`)}),(0,Q.jsxs)(`div`,{className:`mb-6 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`label`,{htmlFor:b,className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.scopeLabel`)}),(0,Q.jsx)(zt,{id:b,value:t,onChange:e=>r(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:g(t===`model`?`settings.generation.scopeModelHint`:`settings.generation.scopeAllHint`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":_,"aria-controls":y,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.advancedSettings`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:g(`settings.generation.advancedSettingsDescription`)})]}),(0,Q.jsx)(Ce,{className:u(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,_&&`rotate-180`)})]}),_&&(0,Q.jsxs)(`div`,{id:y,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(bn,{title:g(`settings.generation.coreParameters`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:g(`settings.generation.temperatureDescription`),onChange:e=>l(`temperature`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:g(`settings.generation.topPDescription`),onChange:e=>l(`top_p`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:g(`settings.generation.topKDescription`),onChange:e=>l(`top_k`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:g(`settings.generation.minPDescription`),onChange:e=>l(`min_p`,e)})]}),(0,Q.jsxs)(bn,{title:g(`settings.generation.generationControl`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:g(`settings.generation.maxTokensDescription`),onChange:e=>l(`num_predict`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:g(`settings.generation.repeatPenaltyDescription`),onChange:e=>l(`repeat_penalty`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:g(`settings.generation.contextLengthDescription`),onChange:e=>l(`num_ctx`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.seed`),hint:`(${g(`settings.generation.optional`)})`,value:e.seed,placeholder:g(`settings.generation.random`),integer:!0,description:g(`settings.generation.seedDescription`),onChange:e=>l(`seed`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsx)(`label`,{htmlFor:x,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.generation.thinking`)}),(0,Q.jsx)(zt,{id:x,value:Qt(e.think),onChange:e=>l(`think`,Zt(e.target.value)),options:$t.map(e=>({value:e,label:g(`settings.generation.thinkingLevels.${e}`)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.thinkingDescription`)})]})]}),(0,Q.jsxs)(bn,{title:g(`settings.generation.advancedOptions`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:g(`settings.generation.presencePenaltyDescription`),onChange:e=>l(`presence_penalty`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:g(`settings.generation.frequencyPenaltyDescription`),onChange:e=>l(`frequency_penalty`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[g(`settings.generation.stopSequences`),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,g(`settings.generation.commaSeparated`),`)`]})]}),(0,Q.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>l(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.stopSequencesDescription`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:p,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),g(`settings.generation.saveOptions`)]})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:g(`settings.generation.embeddingSettings`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:g(`settings.generation.enableEmbeddings`)}),(0,Q.jsx)(X,{checked:i.enabled,onChange:e=>d(`enabled`,e)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.documents.embeddings.model`)}),(0,Q.jsx)(zt,{value:a.model,onChange:e=>d(`model`,e.target.value),options:s,disabled:!i.enabled})]}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.chunkSize`),hint:g(`settings.documents.embeddings.chunkSizeInTokens`),value:i.chunkSize,min:1,disabled:!i.enabled,onChange:e=>d(`chunkSize`,e)}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.chunkOverlap`),hint:g(`settings.documents.embeddings.chunkOverlapInTokens`),value:i.chunkOverlap,min:0,disabled:!i.enabled,onChange:e=>d(`chunkOverlap`,e)}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.similarityThreshold`),value:i.similarityThreshold,min:0,max:1,step:.01,disabled:!i.enabled,onChange:e=>d(`similarityThreshold`,e)})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.status`),`:`]}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:c.available?g(`settings.documents.embeddings.available`):g(`settings.documents.embeddings.unavailable`)})]}),c.available&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,Q.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[c.chunksWithEmbeddings,` /`,` `,c.totalChunks]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,Q.jsxs)(q,{onClick:m,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:h,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),g(`settings.saveSettings`)]})]})]})}),(0,Q.jsx)(yn,{})]})})}function yn(){let{t:e}=o(),t=jt(e=>e.user),n=jt(e=>e.systemInfo),r=t?.role===`admin`||n?.requiresAuth===!1,i=x(e=>e.models),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`8000`),[u,d]=(0,Z.useState)(`8`),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!r)return;let t=!1;return gt.getCompactionConfig().then(e=>{t||!e.success||!e.data||(s(e.data.enabled),l(String(e.data.thresholdTokens)),d(String(e.data.keepRecentMessages)),p(e.data.model),h(e.data.prompt),_(!0))}).catch(()=>{t||R.error(e(`settings.compaction.loadFailed`))}),()=>{t=!0}},[r,e]),!r)return null;let b=i.filter(e=>!e.isPersona&&!e.isAgent),S=[{value:``,label:e(`settings.compaction.sessionModelOption`)},...b.map(e=>({value:e.name,label:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}`:`${e.name} · Ollama`})),...f&&!b.some(e=>e.name===f)?[{value:f,label:`${f} (current)`}]:[]],C=async(t=a)=>{let n=Number(c);if(!Number.isInteger(n)||n<500||n>1e6){R.error(e(`settings.compaction.thresholdInvalid`));return}let r=Number(u);if(!Number.isInteger(r)||r<2||r>200){R.error(e(`settings.compaction.keepRecentInvalid`));return}y(!0);try{let i=await gt.setCompactionConfig({enabled:t,thresholdTokens:n,keepRecentMessages:r,model:f,prompt:m});if(!i.success||!i.data)throw Error(i.error||e(`settings.compaction.saveFailed`));s(i.data.enabled),l(String(i.data.thresholdTokens)),d(String(i.data.keepRecentMessages)),p(i.data.model),h(i.data.prompt),R.success(e(`settings.compaction.saved`))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.compaction.saveFailed`))}finally{y(!1)}};return(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-1`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(`settings.compaction.title`)}),(0,Q.jsx)(X,{checked:a,onChange:e=>{C(e)},disabled:v||!g})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:e(`settings.compaction.description`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.thresholdLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:500,max:1e6,step:500,value:c,onChange:e=>l(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.thresholdDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.keepRecentLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:2,max:200,value:u,onChange:e=>d(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.keepRecentDescription`)})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.modelLabel`)}),(0,Q.jsx)(zt,{value:f,onChange:e=>p(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.promptLabel`)}),(0,Q.jsx)(Rt,{value:m,onChange:e=>h(e.target.value),rows:5,placeholder:e(`settings.compaction.promptPlaceholder`),spellCheck:!1}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.promptDescription`,{previousSummaryVariable:`{{PREVIOUS_SUMMARY}}`,messagesVariable:`{{MESSAGES}}`})})]})]}),(0,Q.jsx)(`div`,{className:`flex justify-end items-center mt-4`,children:(0,Q.jsxs)(q,{onClick:()=>void C(),disabled:v||!g,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),e(`settings.saveSettings`)]})})]})})}function bn({title:e,children:t}){return(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function xn({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,Q.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function Sn({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,Q.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function Cn({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,sizes:a,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:f}){let{t:p}=o(),m=At(r,n.model,n.pluginId);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(z,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(ut,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.imageGen.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,Q.jsx)(zt,{value:m?K(m):``,onChange:e=>{let t=r.find(t=>K(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...r.map(e=>({value:K(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m?.config?.size_label||p(`settings.imageGen.size`)}),(0,Q.jsx)(zt,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||a.length===0,options:[...a.length>0?a.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,Q.jsx)(zt,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,Q.jsx)(zt,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),p(`common.reset`)]}),(0,Q.jsxs)(q,{onClick:f,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}var wn=192e3,Tn=(e,t)=>e.isPlugin&&e.pluginId?e.pluginId:t,En=()=>{let{t:e}=o(),t=x(e=>e.models),n=x(e=>e.loadModels),[r,i]=(0,Z.useState)([]),[a,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)({}),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(`all`),[v,y]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)(null),j=(0,Z.useMemo)(()=>t.filter(e=>!e.isPersona&&!e.isAgent),[t]);(0,Z.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await G.getModelVisibility();if(e||!t.success||!t.data)return;let{hidden:n,order:r,starred:a,metadata:o}=t.data;i(n??[]),s(r??[]),l(a??[]),f(o??{})}catch{}})(),()=>{e=!0}},[]);let M=(0,Z.useMemo)(()=>new Set(r),[r]),ee=(0,Z.useMemo)(()=>new Set(c),[c]),N=(0,Z.useMemo)(()=>g(j,a,c),[j,a,c]),P=(0,Z.useMemo)(()=>{let e=p.trim().toLowerCase();return N.filter(t=>{let n=b(t);if(h===`local`&&t.isPlugin||h===`provider`&&!t.isPlugin||h===`hidden`&&!M.has(n))return!1;if(!e)return!0;let r=d[n]?.label??``;return t.name.toLowerCase().includes(e)||r.toLowerCase().includes(e)||Tn(t,`ollama`).toLowerCase().includes(e)})},[N,p,h,M,d]),te=async(e,t)=>{let n=r,a=t?n.filter(t=>t!==e):[...n,e];i(a),await le({hidden:a},()=>i(n))},ne=e=>{let t=new Set(P.map(b)),n=r,a=e?n.filter(e=>!t.has(e)):[...new Set([...n,...t])];i(a),le({hidden:a},()=>i(n))},re=(e,t)=>{let n=c,r=t?[e,...n.filter(t=>t!==e)]:n.filter(t=>t!==e);l(r),le({starred:r},()=>l(n))},ie=(e,t,n)=>{if(e===t)return;let r=N.map(b),i=r.indexOf(e);if(i===-1)return;r.splice(i,1);let o=r.indexOf(t);if(o===-1)return;r.splice(n===`after`?o+1:o,0,e);let c=a;s(r),le({order:r},()=>s(c))},ae=(e,t,n)=>{let r={...e,[t]:{...e[t],...n}};return!r[t].label&&!r[t].avatar&&delete r[t],r},F=(e,t,n=!1)=>{let r=d,i=ae(r,e,t);f(i),n&&le({metadata:i},()=>f(r))},se=e=>{A.current=e,k.current?.click()},ce=t=>{let n=t.target.files?.[0],r=A.current;if(t.target.value=``,!n||!r)return;if(!n.type.startsWith(`image/`)){R.error(e(`modelManager.catalog.pictureInvalid`));return}if(n.size>wn){R.error(e(`modelManager.catalog.pictureTooLarge`));return}let i=new FileReader;i.onload=()=>{typeof i.result==`string`&&F(r,{avatar:i.result},!0)},i.readAsDataURL(n)},le=async(t,r)=>{w(!0);try{let i=await G.setModelVisibility(t);if(!i.success){r(),R.error(i.error??e(`modelManager.catalog.visibilityFailed`));return}await n()}catch(t){r(),R.error(C(t,e(`modelManager.catalog.visibilityFailed`)))}finally{w(!1)}},I=[{id:`all`,label:e(`modelManager.catalog.filterAll`)},{id:`local`,label:e(`modelManager.catalog.filterLocal`)},{id:`provider`,label:e(`modelManager.catalog.filterProviders`)},{id:`hidden`,label:e(`modelManager.catalog.filterHidden`)}];return(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`model-catalog`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsxs)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:[e(`modelManager.sections.catalog`),(0,Q.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:j.length})]}),S&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`modelManager.catalog.saving`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-[180px] flex-1`,children:[(0,Q.jsx)(_e,{className:`pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(Wt,{value:p,onChange:e=>m(e.target.value),placeholder:e(`modelManager.catalog.searchPlaceholder`),className:`ps-9`})]}),(0,Q.jsx)(`select`,{value:h,onChange:e=>_(e.target.value),className:`h-9 rounded-lg border border-gray-200 bg-white px-2 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-100 dark:text-gray-200`,"aria-label":e(`modelManager.catalog.filterAll`),children:I.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>ne(!0),children:e(`modelManager.catalog.enableAll`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>ne(!1),children:e(`modelManager.catalog.disableAll`)})]}),(0,Q.jsx)(`input`,{ref:k,type:`file`,accept:`image/*`,onChange:ce,className:`hidden`}),(0,Q.jsxs)(`div`,{className:`divide-y divide-gray-100 rounded-lg border border-gray-200 dark:divide-dark-200/60 dark:border-dark-300`,children:[P.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-gray-500 dark:text-gray-400`,children:j.length===0?e(`modelManager.catalog.noModels`):e(`modelManager.catalog.empty`)}),P.map(t=>{let n=b(t),r=d[n]??{},i=!M.has(n),a=ee.has(n),o=v===n,s=e(a?`modelManager.catalog.unstar`:`modelManager.catalog.star`,{name:r.label||t.name});return(0,Q.jsxs)(`div`,{"data-testid":`model-catalog-row`,draggable:!0,onDragStart:()=>E(n),onDragEnd:()=>{E(null),O(null)},onDragOver:e=>{if(e.preventDefault(),!T||T===n)return;let t=e.currentTarget.getBoundingClientRect(),r=e.clientY-t.top<t.height/2?`before`:`after`;O(e=>e?.key===n&&e.edge===r?e:{key:n,edge:r})},onDrop:e=>{e.preventDefault(),T&&ie(T,n,D?.key===n?D.edge:`before`),E(null),O(null)},className:u(`relative flex flex-col gap-2 px-3 py-2`,T===n&&`opacity-50`),children:[D?.key===n&&T&&T!==n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:u(`pointer-events-none absolute inset-x-0 h-0.5 bg-primary-500`,D.edge===`before`?`top-0`:`bottom-0`)}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 pe-1`,children:[(0,Q.jsx)(oe,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300 dark:text-dark-500`,"aria-hidden":`true`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>se(n),title:e(`modelManager.catalog.setPicture`),className:`flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-full border border-gray-200 bg-gray-50 text-gray-400 dark:border-dark-300 dark:bg-dark-200`,children:r.avatar?(0,Q.jsx)(`img`,{src:r.avatar,alt:``,className:`h-full w-full object-cover`}):(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-gray-900 dark:text-gray-100`,children:r.label||t.name}),(0,Q.jsxs)(`span`,{className:`block truncate text-[11px] text-gray-500 dark:text-gray-400`,children:[r.label?`${t.name} · `:``,Tn(t,e(`modelManager.catalog.providerOllama`))]})]}),!i&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-dark-200 dark:text-gray-400`,children:e(`modelManager.catalog.hidden`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>re(n,!a),"aria-pressed":a,title:s,"aria-label":s,className:u(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-1 dark:hover:bg-dark-200 dark:focus-visible:ring-offset-dark-100`,a?`text-primary-600 dark:text-primary-400`:`text-gray-400 hover:text-gray-700 dark:hover:text-gray-200`),children:(0,Q.jsx)(he,{className:u(`h-4 w-4`,a&&`fill-current`),"aria-hidden":`true`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(o?null:n),title:e(`modelManager.catalog.rename`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`,children:o?(0,Q.jsx)(He,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void te(n,!i),"aria-pressed":!i,title:e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),"aria-label":e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),className:u(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors`,i?`text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`:`text-warning-600 hover:bg-gray-100 dark:text-warning-500 dark:hover:bg-dark-200`),children:i?(0,Q.jsx)(Pe,{className:`h-4 w-4`}):(0,Q.jsx)(ke,{className:`h-4 w-4`})})]}),o&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ps-8`,children:[(0,Q.jsx)(Wt,{value:r.label??``,onChange:e=>F(n,{label:e.target.value}),onBlur:e=>F(n,{label:e.target.value},!0),placeholder:t.name,className:`h-8 max-w-xs text-xs`}),r.avatar&&(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>F(n,{avatar:``},!0),children:e(`modelManager.catalog.clearPicture`)})]})]},n)})]})]})};function Dn({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:r,systemMessage:i,tempSystemMessage:a,loading:s,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:f,onModelChange:p,onSystemMessageChange:h,onSystemMessageSave:g,onAutoTitleChange:b,onAutoTitleTaskModelChange:x,onVisionModelChange:S}){let{user:C,systemInfo:w}=jt(),T=C?.role===`admin`||w?.requiresAuth===!1,{t:E}=o(),D={model:t,providerType:n,providerId:r},O=m(e,D),k=t?y(O,D):``,A=v(O,D);return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.model.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.defaultModel`)}),(0,Q.jsx)(zt,{value:k,onChange:p,options:[{value:``,label:E(`settings.model.selectModel`)},...O.map(e=>({value:_(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${E(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.defaultModelDescription`)})]}),t&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.currentModelInfo`)}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsx)(On,{label:`${E(`settings.model.name`)}:`,value:t,truncate:!0}),A?.details&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(On,{label:`${E(`settings.model.size`)}:`,value:A.details.parameter_size}),(0,Q.jsx)(On,{label:`${E(`settings.model.family`)}:`,value:A.details.family}),(0,Q.jsx)(On,{label:`${E(`settings.model.format`)}:`,value:A.details.format})]})]})})]}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.systemMessage.title`)}),(0,Q.jsx)(Rt,{value:a,onChange:h,placeholder:E(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.systemMessage.description`)}),(0,Q.jsx)(q,{onClick:g,size:`sm`,disabled:s||a===i,children:E(`common.save`)})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,Q.jsx)(zt,{"data-testid":`vision-model-select`,value:l,onChange:e=>S(e.target.value),options:u}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,Q.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.model.autoTitle.enable`)}),(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.model.autoTitle.enableDescription`)})]}),(0,Q.jsx)(X,{checked:c.titleSettings?.autoTitle||!1,onChange:b})]}),c.titleSettings?.autoTitle&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.autoTitle.taskModel`)}),(0,Q.jsx)(zt,{value:d,onChange:e=>x(e.target.value),options:f}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})})]}),T&&(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsx)(En,{})})]})}function On({label:e,value:t,truncate:n=!1}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,Q.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}var kn=[{titleKey:`keyboard.groups.general`,rows:[{labelKey:`keyboard.openPalette`,keys:[`mod`,`K`]},{labelKey:`keyboard.openSettings`,keys:[`mod`,`,`]},{labelKey:`keyboard.toggleDarkMode`,keys:[`mod`,`D`]},{labelKey:`keyboard.showShortcuts`,keys:[`?`]},{labelKey:`keyboard.closeModals`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.navigation`,rows:[{labelKey:`keyboard.toggleSidebar`,keys:[`mod`,`B`]},{labelKey:`keyboard.newChat`,keys:[`mod`,`⇧`,`O`]},{labelKey:`keyboard.newWork`,keys:[`mod`,`⇧`,`U`]}]},{titleKey:`keyboard.groups.chat`,rows:[{labelKey:`keyboard.actions.sendMessage`,keys:[`↩`]},{labelKey:`keyboard.actions.newLine`,keys:[`⇧`,`↩`]},{labelKey:`keyboard.actions.saveEdit`,keys:[`↩`]},{labelKey:`keyboard.actions.cancelEdit`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.workspace`,rows:[{labelKey:`keyboard.actions.saveFile`,keys:[`mod`,`S`]},{labelKey:`keyboard.actions.formatCode`,keys:[`⌥`,`⇧`,`F`]}]}];function An(){let{t:e}=o(),t=s()?`⌘`:`Ctrl`,n=s()?`⌥`:`Alt`,r=e=>e===`mod`?t:e===`⌥`?n:e;return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`keyboard.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`keyboard.description`)})]}),kn.map(t=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:e(t.titleKey)}),(0,Q.jsx)(`div`,{className:`divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:t.rows.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 bg-white px-4 py-2.5 dark:bg-dark-100`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:n.keys.map((e,t)=>(0,Q.jsx)(`kbd`,{className:`rounded border border-gray-300 bg-gray-100 px-2 py-1 font-mono text-xs text-gray-700 dark:border-dark-400 dark:bg-dark-200 dark:text-gray-300`,children:r(e)},`${n.labelKey}-${e}-${t}`))})]},`${t.titleKey}-${n.labelKey}`))})]},t.titleKey))]})}var jn=8;function Mn(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function Nn(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function Pn(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function Fn(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=jn;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===jn)return!1;n=t}return!1}var In=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function Ln(e){let t=new Set(In),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function Rn(e,t){return Ln(t).has(e)}function zn(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function Bn(e,t){let n=[],r=[];for(let i of e)(Rn(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function Vn(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function Hn(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=zn(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}V(`components:hugging-face-model-browser`);var Un=({plugin:e})=>{let{t}=o(),n=r(),i=jt(e=>e.user),a=jt(e=>e.systemInfo)?.requiresAuth===!1||i?.role===`admin`,{pluginVariables:s,fetchPluginVariables:c,updatePluginVariables:l,resetPluginVariables:d,loadPlugins:f}=Mt(),[p,m]=(0,Z.useState)({}),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(new Set),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)(new Set),[T,E]=(0,Z.useState)(!1),D=Z.useId(),O=Z.useId(),k=(0,Z.useMemo)(()=>e.variables||[],[e.variables]),A=(0,Z.useMemo)(()=>Ln(e),[e]),j=(0,Z.useMemo)(()=>a?k:k.filter(e=>!A.has(e.name)),[a,A,k]),M=(0,Z.useMemo)(()=>s[e.id]||{},[s,e.id]),N=(0,Z.useMemo)(()=>Bn(j,e),[e,j]);(0,Z.useEffect)(()=>{c(e.id)},[c,e.id]);let P=JSON.stringify(M),te=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let t=j.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${P}`;if(te.current===n)return;te.current=n;let r=JSON.parse(P);m(e=>{let t=Vn(j,r);for(let n of C)n in e&&(t[n]=e[n]);return t})},[C,e.id,j,P]);let ne=async()=>{let r={};for(let n of j){if(!C.has(n.name))continue;let i=p[n.name],a=typeof i==`string`&&i.trim().length===0,o=M[n.name],s=zn(n,e);if(a&&n.required&&s===void 0&&!(n.sensitive&&o?.has_value)){r[n.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(Pn(n.name)&&typeof i==`string`&&!a){let e=Mn(i,n.name);e===`invalid-url`?r[n.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?r[n.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(r[n.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(n.name===`api_path`&&typeof i==`string`&&i.length>0&&!Fn(i)&&(r[n.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),n.type===`number`&&!a){let e=Number(i);n.min!==void 0&&e<n.min&&(r[n.name]=`Min: ${n.min}`),n.max!==void 0&&e>n.max&&(r[n.name]=`Max: ${n.max}`)}n.type===`string`&&typeof i==`string`&&i.length>2048&&(r[n.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(S(r),Object.keys(r).length>0)return;let i=Hn(j,p,C,M,e),a=new Set(C),o=Object.fromEntries([...Object.keys(i.variables).map(e=>[e,!0]),...i.unset.map(e=>[e,!0])]);if(Object.keys(i.variables).length===0&&i.unset.length===0){w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),L.success(t(`pluginManager.variables.saved`,`Variables saved`));return}g(!0);try{await l(e.id,i.variables,i.unset)?(Object.keys(o).some(e=>A.has(e))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(e=>{let t={...e};for(let e of j)e.sensitive&&a.has(e.name)&&(t[e.name]=``);return t}),b(e=>{let t=new Set(e);for(let e of j)e.sensitive&&a.has(e.name)&&t.delete(e.name);return t}),w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),L.success(t(`pluginManager.variables.saved`,`Variables saved`))):L.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{g(!1)}},re=async()=>{v(!0);try{if(!await d(e.id)){L.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}j.some(e=>A.has(e.name))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(Vn(j,{})),w(new Set),S({}),b(new Set),L.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{v(!1)}},ie=(e,t)=>{m(n=>({...n,[e]:t})),w(t=>new Set(t).add(e)),S(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},oe=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=e=>{let t=j.indexOf(e),n=`${O}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},se=t=>{if(!Pn(t.name))return!1;let n=p[t.name],r=zn(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&Nn(i)},ce=n=>{let r=p[n.name],i=n.sensitive??!1,a=y.has(n.name),o=M[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:d}=F(n),f=!!x[n.name],m=se(n),g=n.name===`endpoint`||n.name===`api_url`,v=[n.description||g?c:void 0,m?d:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,b=zn(n,e),S=b===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(b)}),C=u(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,Q.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>ie(n.name,e.target.value===``?``:e.target.value===`true`),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(0,Q.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,Q.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,Q.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>ie(n.name,e.target.value),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(n.options||[]).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,Q.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:S,onChange:e=>ie(n.name,e.target.value===``?``:Number(e.target.value)),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_});default:return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):S,onChange:e=>ie(n.name,e.target.value),className:u(C,i&&`pr-10`),"aria-invalid":f,"aria-describedby":v,disabled:h||_}),i&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>oe(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:h||_,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,Q.jsx)(ke,{className:`w-4 h-4`}):(0,Q.jsx)(Pe,{className:`w-4 h-4`})})]})}},le=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=F(e),o=e.name===`endpoint`||e.name===`api_url`,s=se(e);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,Q.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),ce(e),s&&(0,Q.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,Q.jsx)(Ne,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),x[e.name]&&(0,Q.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:x[e.name]})]},e.name)};return(0,Q.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[N.connection.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),N.connection.map(le)]}),N.advanced.length>0&&(0,Q.jsxs)(`div`,{className:u(N.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":D,onClick:()=>E(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,Q.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,N.advanced.length,`)`]}),(0,Q.jsx)(Ce,{className:u(`h-4 w-4 transition-transform`,T&&`rotate-180`)})]}),T&&(0,Q.jsx)(`div`,{id:D,className:`mt-3 space-y-3`,children:N.advanced.map(le)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,Q.jsxs)(q,{size:`sm`,onClick:ne,disabled:h||_||C.size===0,className:`gap-1.5`,children:[(0,Q.jsx)(ee,{className:`w-3.5 h-3.5`}),h?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:re,disabled:h||_,className:`gap-1.5`,children:[(0,Q.jsx)(ae,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function Wn({plugins:e,loading:t,uploading:n,error:r,hasKeys:i,showUploadForm:a,showJsonForm:s,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:p,refreshingPluginIds:m,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:S,onPluginApiKeyChange:C,onShowApiKeyChange:w,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:O,onSaveApiKey:k,onDeleteApiKey:A,onRefreshModels:j}){let{t:M}=o(),ee=jt(e=>e.user),N=jt(e=>e.systemInfo)?.requiresAuth===!1||ee?.role===`admin`,[P,te]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(null),ie=(0,Z.useId)(),ae=(0,Z.useMemo)(()=>e.filter(e=>h(e,P)),[e,P]),oe=ne&&e.some(e=>e.id===ne)?ne:e[0]?.id??null,F=e.find(e=>e.id===oe)??null,se=e=>{e!==oe&&(S(null),re(e))};return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),r&&(0,Q.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,Q.jsx)(He,{className:`h-4 w-4`})})]})}),N&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.addNew`)}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!a),disabled:t||n,children:[(0,Q.jsx)(Je,{className:`h-4 w-4 me-2`}),M(`settings.plugins.upload`)]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>v(!s),disabled:t,children:M(`settings.plugins.addJson`)})]})]}),a&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:M(`common.cancel`)})]}),n&&(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:M(`settings.plugins.uploading`)})]}),s&&(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:M(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:M(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:M(`settings.plugins.install`)})]})]})})]}),(0,Q.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,Q.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,Q.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":M(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:flex lg:min-h-0 lg:flex-col lg:border-b-0 lg:border-e`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,Q.jsx)(`label`,{htmlFor:ie,className:`sr-only`,children:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(_e,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(`input`,{id:ie,type:`search`,value:P,onChange:e=>te(e.target.value),placeholder:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,Q.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3 lg:min-h-0 lg:max-h-none lg:flex-1`,children:t&&e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),M(`settings.plugins.loading`)]}):e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,Q.jsx)(Te,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noPlugins`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:M(`settings.plugins.noPluginsDescription`)})]}):ae.length===0?(0,Q.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):ae.map(e=>{let t=oe===e.id,n=T(e).length;return(0,Q.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>se(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[e.active?M(`settings.plugins.activeLabel`):M(`settings.plugins.inactive`),`.`,` `]}),(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,Q.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,M(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,Q.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:F?(0,Q.jsx)(Gn,{plugin:F,loading:t,hasApiKey:i[F.id]||!1,expanded:u===F.id,apiKey:d[F.id]||``,showApiKey:f[F.id]||!1,savingApiKey:p===F.id,refreshingModels:!!m[F.id],canManagePlugin:N,onExpand:()=>S(u===F.id?null:F.id),onActivate:()=>E(F.id),onExport:()=>O(F.id),onDelete:()=>D(F.id),onRefreshModels:()=>j(F.id),onApiKeyChange:e=>C(F.id,e),onShowApiKeyChange:e=>w(F.id,e),onSaveApiKey:()=>k(F.id),onDeleteApiKey:()=>A(F.id)}):(0,Q.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(Te,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function Gn({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:i,showApiKey:a,savingApiKey:s,refreshingModels:c,canManagePlugin:l,onExpand:u,onActivate:d,onExport:f,onDelete:p,onRefreshModels:m,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}){let{t:y}=o(),b=!!(e.auth?.header||e.auth?.key_env),x=Ln(e),S=l?e.variables||[]:(e.variables||[]).filter(e=>!x.has(e.name)),C=S.length>0,E=b||C,D=(0,Z.useId)(),O=T(e),k=e.base_url||e.endpoint;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,Q.jsx)(`span`,{className:`capitalize`,children:e.type}),b&&n&&(0,Q.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,y(`settings.plugins.apiKeySet`)]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[E&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:u,"aria-expanded":r,"aria-controls":D,title:y(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[b?(0,Q.jsx)(re,{className:`h-4 w-4`}):(0,Q.jsx)(Le,{className:`h-4 w-4`}),y(`settings.plugins.configure`),r?(0,Q.jsx)(xe,{className:`h-3 w-3`}):(0,Q.jsx)(Ce,{className:`h-3 w-3`})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N,{className:`h-4 w-4`}),y(`settings.plugins.deactivate`)]}):y(`settings.plugins.activate`)}),l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:f,disabled:t,title:y(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,Q.jsx)(ct,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:p,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:y(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.status`,{defaultValue:`Status`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?y(`settings.plugins.activeLabel`):y(`settings.plugins.inactive`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.models`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:O.length})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:k,children:k})]})]})]}),r&&E&&(0,Q.jsxs)(`div`,{id:D,children:[b&&(0,Q.jsx)(qn,{plugin:e,hasApiKey:n,apiKey:i,showApiKey:a,savingApiKey:s,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}),C&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Q.jsx)(Le,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[y(`settings.plugins.providerSettings`),` (`,S.length,`)`]})]}),(0,Q.jsx)(Un,{plugin:e},e.id)]})]}),(0,Q.jsx)(Kn,{catalog:O,canRefresh:w(e),refreshing:c,onRefresh:m})]})}function Kn({catalog:e,canRefresh:t,refreshing:n,onRefresh:r}){let{t:i}=o();return(0,Q.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:i(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:i(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:r,disabled:n,"aria-busy":n,children:[n?(0,Q.jsx)(z,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Ee,{className:`h-4 w-4`}),i(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:i(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,Q.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,Q.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,Q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:i(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function qn({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:i,onApiKeyChange:a,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=o(),d=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Q.jsx)(re,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,Q.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,Q.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{className:`h-4 w-4 text-green-600`}),(0,Q.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:l,disabled:i,className:`text-red-600 border-red-300 hover:bg-red-50`,children:i?(0,Q.jsx)(z,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,Q.jsx)(`input`,{id:d,type:r?`text`:`password`,value:n,onChange:e=>a(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:i,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(!r),"aria-controls":d,"aria-label":u(r?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:i,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:r?(0,Q.jsx)(ke,{className:`h-4 w-4`}):(0,Q.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,onClick:c,disabled:i||!n.trim(),children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}var Jn=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(``),[a,s]=(0,Z.useState)(`6`),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=!1;return Dt.getConfig().then(t=>{e||!t.success||!t.data||(n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),d(!0))}).catch(()=>{}),()=>{e=!0}},[]);let g=async(o=t)=>{let u=Number(a);if(!Number.isInteger(u)||u<1||u>100){R.error(e(`settings.search.maxResultsInvalid`));return}p(!0);try{let t=await Dt.setConfig(o,r.trim(),{maxResults:u,safeSearch:c});if(!t.success||!t.data)throw Error(t.error||e(`settings.search.saveFailed`));n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),R.success(e(`settings.search.saved`))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.search.saveFailed`))}finally{p(!1)}},_=async()=>{h(!0);try{let t=await Dt.test();if(!t.success||!t.data?.ok)throw Error(t.error||e(`settings.search.testFailed`));R.success(e(`settings.search.testOk`,{results:t.data.results}))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.search.testFailed`))}finally{h(!1)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ie,{className:`h-5 w-5 text-primary-500`}),e(`settings.search.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.search.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.enableLabel`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.search.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t,onChange:e=>{n(e),g(e)},disabled:f||!u||!t&&!r.trim()})]})}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.urlLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.urlDescription`)}),(0,Q.jsx)(Wt,{value:r,onChange:e=>i(e.target.value),placeholder:`http://searxng:8080`,spellCheck:!1,dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.maxResultsLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.maxResultsDescription`)}),(0,Q.jsx)(Wt,{type:`number`,min:1,max:100,value:a,onChange:e=>s(e.target.value),dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.safeSearchLabel`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.safeSearchDescription`)})]}),(0,Q.jsx)(X,{checked:c,onChange:l,disabled:f||!u})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void _(),disabled:m||f||!t,children:e(m?`settings.search.testing`:`settings.search.test`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void g(),disabled:f||!u,children:e(`settings.search.save`)})]})]})]})},Yn=e=>e.response?.data?.message,Xn=e=>e?new Date(e).toLocaleString():`—`,Zn=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async()=>{i(!0);try{let e=await mt.getMfaStatus();e.success&&e.data&&n(e.data)}catch{}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void g(),0);return()=>clearTimeout(e)},[g]);let _=async()=>{s(!0);try{let t=await mt.mfaEnroll();t.success&&t.data?(l(t.data),d(``)):R.error(t.message||e(`auth.mfa.enrollFailed`))}catch(t){R.error(Yn(t)||e(`auth.mfa.enrollFailed`))}finally{s(!1)}},v=async t=>{if(t.preventDefault(),u.trim()){s(!0);try{let t=await mt.mfaActivate({code:u.trim()});t.success&&t.data?(l(null),p(t.data.recoveryCodes),R.success(e(`auth.mfa.enabled`)),await g()):R.error(t.message||e(`auth.mfa.invalidCode`))}catch(t){R.error(Yn(t)||e(`auth.mfa.invalidCode`))}finally{d(``),s(!1)}}},y=async t=>{if(t.preventDefault(),!(!u.trim()||!m)){s(!0);try{if(m===`disable`){let t=await mt.mfaDisable({code:u.trim()});t.success?(R.success(e(`auth.mfa.disabled`)),p(null)):R.error(t.message||e(`auth.mfa.invalidCode`))}else{let t=await mt.mfaRegenerateRecoveryCodes({code:u.trim()});t.success&&t.data?(p(t.data.recoveryCodes),R.success(e(`auth.mfa.recoveryCodesRegenerated`))):R.error(t.message||e(`auth.mfa.invalidCode`))}h(null),await g()}catch(t){R.error(Yn(t)||e(`auth.mfa.invalidCode`))}finally{d(``),s(!1)}}},b=async()=>{s(!0);try{let t=await mt.passkeyRegisterOptions();if(!t.success||!t.data){R.error(t.message||e(`auth.passkeys.registerFailed`));return}let n=await Yt(t.data.publicKey),r=await mt.passkeyRegister({challengeToken:t.data.challengeToken,credential:n});r.success?(R.success(e(`auth.passkeys.registered`)),await g()):R.error(r.message||e(`auth.passkeys.registerFailed`))}catch(t){let n=t;if(n.name===`NotAllowedError`||n.name===`AbortError`)return;R.error(Yn(t)||e(`auth.passkeys.registerFailed`))}finally{s(!1)}},x=async t=>{s(!0);try{let n=await mt.deletePasskey(t);n.success?(R.success(e(`auth.passkeys.removed`)),await g()):R.error(n.message||e(`auth.passkeys.removeFailed`))}catch(t){R.error(Yn(t)||e(`auth.passkeys.removeFailed`))}finally{s(!1)}};if(r||!t)return null;let S=`h-9 w-40 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 px-3 text-sm text-gray-900 dark:text-gray-100 outline-none focus:ring-2 focus:ring-primary-500/35`;return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-mfa-section`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(F,{className:`h-5 w-5 text-primary-500`}),e(`auth.mfa.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.sectionDescription`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.totpTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:t.totpEnabled?e(`auth.mfa.totpEnabledHint`,{count:t.recoveryCodesRemaining}):e(`auth.mfa.totpDisabledHint`)})]}),t.totpEnabled?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`regenerate`),d(``)},children:e(`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`disable`),d(``)},children:e(`auth.mfa.disableButton`)})]}):!c&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:_,children:e(`auth.mfa.enableButton`)})]}),c&&(0,Q.jsxs)(`form`,{onSubmit:v,className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.secretHint`)}),(0,Q.jsx)(`code`,{dir:`ltr`,className:`block break-all rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:c.secret}),(0,Q.jsx)(`a`,{href:c.otpauthUrl,dir:`ltr`,className:`inline-block text-xs font-medium text-primary-600 hover:text-primary-700 dark:text-primary-400`,children:e(`auth.mfa.openAuthenticator`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(`auth.mfa.activateButton`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>l(null),children:e(`common.cancel`)})]})]}),m&&(0,Q.jsxs)(`form`,{onSubmit:y,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.confirmWithCode`)}),(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(m===`disable`?`auth.mfa.disableButton`:`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>h(null),children:e(`common.cancel`)})]}),f&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.recoveryCodesTitle`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.recoveryCodesHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:f.map(e=>(0,Q.jsx)(`span`,{dir:`ltr`,children:e},e))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>p(null),children:e(`auth.mfa.recoveryCodesSaved`)})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ce,{className:`h-4 w-4 text-primary-500`}),e(`auth.passkeys.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.sectionDescription`)})]}),Y()&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:b,children:e(`auth.passkeys.addButton`)})]}),t.passkeys.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.passkeys.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-gray-50 dark:bg-dark-200 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:t.name||e(`auth.passkeys.unnamed`)}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`auth.passkeys.createdAt`),`:`,` `,Xn(t.createdAt),` · `,e(`auth.passkeys.lastUsedAt`),`:`,` `,Xn(t.lastUsedAt)]})]}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>void x(t.id),"aria-label":e(`auth.passkeys.removeButton`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]},t.id))})]})]})},Qn=e=>e?new Date(e).toLocaleString():`—`,$n=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!0),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(async()=>{i(!0),s(!1);try{let e=await mt.getSessions();if(!e.success||!e.data)throw Error(e.error||`Failed to load sessions.`);n(e.data)}catch{s(!0)}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void f(),0);return()=>clearTimeout(e)},[f]);let p=async t=>{l(t.id);try{let n=await mt.revokeSession(t.id);if(!n.success)throw Error(n.error||e(`settings.sessions.revokeFailed`));R.success(e(`settings.sessions.revoked`,`Session signed out.`)),await f()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{l(null)}},m=async()=>{d(!0);try{let t=await mt.revokeOtherSessions();if(!t.success||!t.data)throw Error(t.error||e(`settings.sessions.revokeFailed`));R.success(e(`settings.sessions.othersRevoked`,{count:t.data.revokedCount,defaultValue:`Other sessions signed out: {{count}}`})),await f()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{d(!1)}},h=t.filter(e=>!e.current&&!e.revokedAt);return(0,Q.jsxs)(`div`,{className:`space-y-8`,children:[(0,Q.jsx)(Zn,{}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Ae,{className:`h-5 w-5 text-primary-500`}),e(`settings.sessions.title`,`Sessions`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.description`,`Everywhere this account is signed in. Signing a session out takes effect immediately; signing in again restores access.`)})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void m(),disabled:u||r||h.length===0,children:u?e(`settings.sessions.signingOutOthers`,`Signing out…`):e(`settings.sessions.signOutOthers`,`Sign out other sessions`)})}),r?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.loadFailed`,`The sessions could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void f(),children:e(`common.retry`)})]}):t.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.empty`,`No sessions found.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:t.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.kind}),t.current&&(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs font-medium text-primary-700 dark:text-primary-300`,children:e(`settings.sessions.current`,`This session`)}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.revokedBadge`,`Signed out`)})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-gray-400`,children:t.userAgent||e(`settings.sessions.unknownDevice`,`Unknown device`)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.sessions.createdAt`,`Signed in`),`:`,` `,Qn(t.createdAt),` · `,e(`settings.sessions.lastSeenAt`,`Last active`),`:`,` `,Qn(t.lastSeenAt),t.expiresAt&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e(`settings.sessions.expiresAt`,`Expires`),`:`,` `,Qn(t.expiresAt)]})]})]}),!t.current&&!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void p(t),disabled:c===t.id||u,children:c===t.id?e(`settings.sessions.signingOut`,`Signing out…`):e(`settings.sessions.signOut`,`Sign out`)})})]},t.id))})]})},er={getPublicKey:()=>dt.get(`/push/public-key`).then(e=>e.data),listSubscriptions:()=>dt.get(`/push/subscriptions`).then(e=>e.data),subscribe:e=>dt.post(`/push/subscriptions`,e).then(e=>e.data),unsubscribe:e=>dt.delete(`/push/subscriptions`,{data:{endpoint:e}}).then(e=>e.data)},tr=V(`components:settings-notifications`),nr=()=>typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,rr=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i},ir=()=>{let{t:e}=o(),[t]=(0,Z.useState)(nr),[n,r]=(0,Z.useState)(typeof Notification<`u`?Notification.permission:`denied`),[i,a]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useCallback)(async()=>{if(t)try{let e=await navigator.serviceWorker.getRegistration();if(!e){u(!1),a(!1);return}u(!0);let t=await e.pushManager.getSubscription();a(!!t)}catch(e){tr.debug(`Push state read failed`,e)}},[t]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void d(),0);return()=>clearTimeout(e)},[d]);let f=async()=>{let t=await navigator.serviceWorker.getRegistration();if(!t){R.error(e(`settings.notifications.workerMissing`));return}let n=await Notification.requestPermission();if(r(n),n!==`granted`){R.error(e(`settings.notifications.permissionDenied`));return}let i=await er.getPublicKey();if(!i.success||!i.data){R.error(i.message||e(`settings.notifications.enableFailed`));return}let o=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:rr(i.data.publicKey)}),s=await er.subscribe(o.toJSON());if(!s.success){await o.unsubscribe().catch(()=>void 0),R.error(s.message||e(`settings.notifications.enableFailed`));return}a(!0),R.success(e(`settings.notifications.enabled`))},p=async()=>{let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();t&&(await er.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>void 0)),a(!1),R.success(e(`settings.notifications.disabled`))},m=async t=>{c(!0);try{t?await f():await p()}catch(t){tr.error(`Push toggle failed`,t),R.error(e(`settings.notifications.enableFailed`))}finally{c(!1)}},h=t?l?n===`denied`?e(`settings.notifications.permissionDenied`):null:e(`settings.notifications.workerMissing`):e(`settings.notifications.unsupported`);return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-notifications-tab`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(qe,{className:`h-5 w-5 text-primary-500`}),e(`settings.notifications.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.notifications.pushTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:h??e(`settings.notifications.pushHint`)})]}),(0,Q.jsx)(X,{checked:i,disabled:s||!!(h&&!i),onChange:m})]})}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.deviceNote`)})]})},ar=e=>e?new Date(e).toLocaleString():`—`,or=()=>{let{t:e}=o(),t=jt(e=>e.isAdmin)(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=pt.filter(e=>e!==`admin`||t),S=(0,Z.useCallback)(async()=>{a(!0),c(!1);try{let e=await mt.listApiTokens();if(!e.success||!e.data)throw Error(e.error||`Failed to load API keys.`);r(e.data)}catch{c(!0)}finally{a(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void S(),0);return()=>clearTimeout(e)},[S]);let C=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async t=>{if(t.preventDefault(),!d.trim()){R.error(e(`settings.apiKeys.nameRequired`,`Give the key a name.`));return}if(p.length===0){R.error(e(`settings.apiKeys.scopesRequired`,`Select at least one scope.`));return}let n;if(h.trim()){let t=Number(h);if(!Number.isInteger(t)||t<1){R.error(e(`settings.apiKeys.expiryInvalid`,`Expiry must be a whole number of days.`));return}n=t}v(!0);try{let t=await mt.createApiToken({name:d.trim(),scopes:p,expiresInDays:n});if(!t.success||!t.data)throw Error(t.error||e(`settings.apiKeys.createFailed`));b(t.data.token),f(``),m([]),g(``),R.success(e(`settings.apiKeys.created`,`API key created.`)),await S()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.createFailed`,`The API key could not be created.`))}finally{v(!1)}},T=async()=>{if(y)try{await navigator.clipboard.writeText(y),R.success(e(`settings.apiKeys.copied`,`Copied to clipboard.`))}catch{R.error(e(`settings.apiKeys.copyFailed`,`Copy failed.`))}},E=async t=>{u(t.id);try{let n=await mt.revokeApiToken(t.id);if(!n.success)throw Error(n.error||e(`settings.apiKeys.revokeFailed`));R.success(e(`settings.apiKeys.revoked`,`API key revoked.`)),await S()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.revokeFailed`,`The API key could not be revoked.`))}finally{u(null)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ce,{className:`h-5 w-5 text-primary-500`}),e(`settings.apiKeys.title`,`API keys`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.description`,`Scoped tokens for scripts and integrations. Each key only has access to the scopes you pick.`)})]}),y&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/40 bg-primary-50 dark:bg-primary-900/20 p-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.newKeyTitle`,`Your new API key`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`code`,{dir:`ltr`,className:`min-w-0 flex-1 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 px-3 py-2 text-xs text-gray-900 dark:text-gray-100`,"data-testid":`new-api-key`,children:y}),(0,Q.jsxs)(q,{size:`sm`,variant:`outline`,onClick:()=>void T(),className:`shrink-0 gap-1.5`,children:[(0,Q.jsx)(ot,{size:14}),e(`settings.apiKeys.copy`,`Copy`)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-warning-700 dark:text-warning-400`,children:e(`settings.apiKeys.showOnceWarning`,`Copy it now — it will not be shown again.`)}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:e(`settings.apiKeys.dismiss`,`Done`)})})]}),(0,Q.jsxs)(`form`,{onSubmit:w,className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.createTitle`,`Create a key`)}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.nameLabel`,`Name`)}),(0,Q.jsx)(Wt,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.apiKeys.namePlaceholder`,`e.g. CI pipeline`)})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.expiryLabel`,`Expires in days (optional)`)}),(0,Q.jsx)(Wt,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.apiKeys.expiryPlaceholder`,`Never`),dir:`ltr`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.scopesLabel`,`Scopes`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:x.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:p.includes(e),onChange:()=>C(e),className:`h-4 w-4 rounded border-gray-300 dark:border-dark-300 text-primary-600 focus:ring-primary-500`}),e]},e))})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:_,children:_?e(`settings.apiKeys.creating`,`Creating…`):e(`settings.apiKeys.create`,`Create key`)})})]}),i?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):s?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.loadFailed`,`The API keys could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void S(),children:e(`common.retry`)})]}):n.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.empty`,`No API keys yet.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:n.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Q.jsxs)(`code`,{dir:`ltr`,className:`rounded bg-gray-100 dark:bg-dark-200 px-1.5 py-0.5 text-xs text-gray-600 dark:text-gray-300`,children:[t.tokenPrefix,`…`]}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.revokedBadge`,`Revoked`)})]}),(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:t.scopes.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e},e))}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.apiKeys.createdAt`,`Created`),`:`,` `,ar(t.createdAt),` · `,e(`settings.apiKeys.lastUsedAt`,`Last used`),`:`,` `,ar(t.lastUsedAt),` · `,e(`settings.apiKeys.expiresAt`,`Expires`),`:`,` `,t.expiresAt?ar(t.expiresAt):e(`settings.apiKeys.neverExpires`,`Never`)]})]}),!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void E(t),disabled:l===t.id,children:l===t.id?e(`settings.apiKeys.revoking`,`Revoking…`):e(`settings.apiKeys.revoke`,`Revoke`)})})]},t.id))})]})};function sr({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,voices:a,voiceProfiles:s,selectableVoiceProfiles:c,loadingVoiceProfiles:l,testing:u,onSettingChange:d,onModelChange:f,onVoiceChange:p,onDeleteVoiceProfile:m,onRevokeVoiceProfile:h,onReset:g,onTest:_,onSave:v}){let{t:y}=o(),b=r.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:y(`settings.tts.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(z,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:y(`settings.tts.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Ke,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:y(`settings.tts.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:y(`settings.tts.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t.enabled,onChange:e=>d(`enabled`,e)})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.autoPlay`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.autoPlayDescription`)})]}),(0,Q.jsx)(X,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>{e&&Jt(),d(`autoPlay`,e)}})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.streamSentences`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.streamSentencesDescription`)})]}),(0,Q.jsx)(X,{checked:t.streamSentences!==!1,disabled:!t.enabled,onChange:e=>d(`streamSentences`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.voiceConfiguration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.model`)}),(0,Q.jsx)(zt,{"aria-label":y(`settings.tts.model`),value:b?Tt(b):``,onChange:e=>{let t=r.find(t=>Tt(t)===e.target.value);t&&f(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:y(`settings.model.selectModel`)},...r.map(e=>({value:Tt(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.modelDescription`)})]}),a.length>0||c.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.voice`)}),(0,Q.jsx)(zt,{"aria-label":y(`settings.tts.voice`),value:n.voiceProfileId?lr(n.voiceProfileId):n.voice,onChange:e=>{let t=ur(e.target.value);p(t?``:e.target.value,t||``)},disabled:!t.enabled,options:[{value:``,label:y(`settings.tts.selectVoice`)},...a.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...c.map(e=>({value:lr(e.id),label:y(`settings.tts.savedVoiceOption`,{name:e.name,defaultValue:`{{name}} (saved voice)`}),key:`saved-voice-${e.id}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.voiceDescription`)})]}):l?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`p`,{className:`rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:y(`settings.tts.providerDefaultVoice`)})]})]}),b?.config?.supports_voice_cloning&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/20 bg-primary-500/[0.06] p-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.voiceCloningAvailable`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-600 dark:text-gray-400`,children:y(`settings.tts.voiceCloningAvailableDescription`)})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:y(`settings.tts.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,y(`settings.tts.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:g,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),y(`common.reset`)]}),(0,Q.jsx)(q,{onClick:_,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{size:16}),y(`settings.tts.stop`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:16}),y(`settings.tts.test`)]})})]}),(0,Q.jsxs)(q,{onClick:v,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),y(`settings.saveSettings`)]})]})]})]}),(l||s.length>0)&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.savedVoices`,{defaultValue:`Saved voices`})}),l?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:s.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`truncate text-sm text-gray-800 dark:text-gray-200`,children:[e.name,e.consentStatus===`revoked`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-red-100 px-1.5 py-0.5 text-[10px] font-medium text-red-700 dark:bg-red-950/40 dark:text-red-400`,children:y(`settings.tts.consentRevoked`,{defaultValue:`Consent withdrawn`})}),e.consentStatus===`expired`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-950/40 dark:text-amber-400`,children:y(`settings.tts.consentExpired`,{defaultValue:`Consent expired`})})]}),(0,Q.jsxs)(`p`,{className:`truncate text-xs text-gray-500 dark:text-gray-400`,children:[e.pluginId,` · `,e.model,` · `,y(`settings.tts.transferCount`,{total:e.transferCount??0,defaultValue:`sent to provider {{total}}×`}),e.consentExpiresAt&&e.consentStatus===`active`&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,y(`settings.tts.consentExpires`,{date:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.consentExpiresAt),defaultValue:`consent until {{date}}`})]})]})]}),(e.consentStatus??`active`)===`active`&&(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(e),"aria-label":y(`settings.tts.revokeSavedVoice`,{name:e.name,defaultValue:`Withdraw consent for {{name}}`}),className:`shrink-0 px-2 text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:hover:bg-amber-950/30`,children:(0,Q.jsx)(te,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>m(e),"aria-label":y(`settings.tts.deleteSavedVoice`,{name:e.name,defaultValue:`Delete saved voice {{name}}`}),className:`shrink-0 px-2 text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950/30`,children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]},e.id))})]})]})}var cr=`__saved_voice__:`;function lr(e){return`${cr}${e}`}function ur(e){return e.startsWith(cr)?e.slice(16):void 0}var dr=({title:e,description:t,actions:n,className:r})=>(0,Q.jsxs)(`header`,{className:u(`mb-5 flex flex-col gap-3 border-b border-gray-200/70 pb-4 dark:border-white/[0.08] sm:flex-row sm:items-end sm:justify-between`,r),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-dark-800`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:n})]}),fr=[`text`,`number`,`select`,`boolean`],pr=({variables:e,onChange:t})=>{let{t:n}=o(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:Bt,children:n(`promptsPage.form.variables`)}),(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-400 dark:text-dark-500`,children:n(`promptsPage.form.variablesHint`)}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.map((i,a)=>(0,Q.jsxs)(`div`,{"data-testid":`prompt-variable-row`,className:`rounded-xl border border-black/[0.06] bg-black/[0.02] p-2.5 dark:border-white/[0.07] dark:bg-white/[0.03]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.name,onChange:e=>r(a,{name:e.target.value}),placeholder:n(`promptsPage.form.variableName`),"aria-label":n(`promptsPage.form.variableName`),className:J,maxLength:64}),(0,Q.jsx)(`select`,{value:i.type,onChange:e=>r(a,{type:e.target.value,options:e.target.value===`select`?i.options??[]:void 0}),"aria-label":n(`promptsPage.form.variableType`),className:J,children:fr.map(e=>(0,Q.jsx)(`option`,{value:e,children:n(`promptsPage.variableTypes.${e}`)},e))}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter((e,t)=>t!==a)),"aria-label":n(`promptsPage.form.removeVariable`),"data-testid":`prompt-variable-remove`,className:`shrink-0 rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-500/10 hover:text-red-500`,children:(0,Q.jsx)(B,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.label??``,onChange:e=>r(a,{label:e.target.value}),placeholder:n(`promptsPage.form.variableLabel`),"aria-label":n(`promptsPage.form.variableLabel`),className:J,maxLength:120}),(0,Q.jsx)(`input`,{type:`text`,value:i.default??``,onChange:e=>r(a,{default:e.target.value}),placeholder:n(`promptsPage.form.variableDefault`),"aria-label":n(`promptsPage.form.variableDefault`),className:J,maxLength:500}),(0,Q.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[12px] text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.required===!0,onChange:e=>r(a,{required:e.target.checked}),className:`h-3.5 w-3.5 rounded border-gray-300 dark:border-dark-400`}),n(`promptsPage.form.variableRequired`)]})]}),i.type===`select`&&(0,Q.jsx)(`input`,{type:`text`,value:(i.options??[]).join(`, `),onChange:e=>r(a,{options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),placeholder:n(`promptsPage.form.variableOptionsPlaceholder`),"aria-label":n(`promptsPage.form.variableOptions`),className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 mt-2`})]},a)),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,{name:``,type:`text`}]),"data-testid":`prompt-add-variable`,className:`flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5`}),n(`promptsPage.form.addVariable`)]})]})]})},mr=/^[a-z0-9][a-z0-9-]{0,63}$/;function hr({open:e,prompt:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(gr,{prompt:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function gr({prompt:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=o(),s=e??t,[c,l]=(0,Z.useState)(s?.slug??``),[u,d]=(0,Z.useState)(s?.title??``),[f,p]=(0,Z.useState)(s?.description??``),[m,h]=(0,Z.useState)(s?.content??``),[g,_]=(0,Z.useState)(s?.variables??[]),[v,y]=(0,Z.useState)((s?.tags??[]).join(`, `)),b=mr.test(c.trim()),x=b&&u.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Vt,{titleId:`prompt-modal-title`,title:a(e?`promptsPage.editPrompt`:`promptsPage.newPrompt`),onClose:r,widthClassName:`max-w-2xl`,testId:`prompt-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{x&&i({slug:c.trim(),title:u.trim(),description:f.trim()||void 0,content:m,variables:g.filter(e=>e.name.trim().length>0),tags:v.split(`,`).map(e=>e.trim()).filter(Boolean)})},disabled:n||!x,"data-testid":`prompt-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-slug`,className:Bt,children:a(`promptsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`prompt-slug`,"data-testid":`prompt-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`promptsPage.form.slugPlaceholder`),className:J,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!b?a(`promptsPage.form.slugInvalid`):a(`promptsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-title`,className:Bt,children:a(`promptsPage.form.title`)}),(0,Q.jsx)(`input`,{id:`prompt-title`,"data-testid":`prompt-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`promptsPage.form.titlePlaceholder`),className:J,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-description`,className:Bt,children:a(`promptsPage.form.description`)}),(0,Q.jsx)(`input`,{id:`prompt-description`,type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:a(`promptsPage.form.descriptionPlaceholder`),className:J,maxLength:500})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-content`,className:Bt,children:a(`promptsPage.form.content`)}),(0,Q.jsx)(`textarea`,{id:`prompt-content`,"data-testid":`prompt-content`,value:m,onChange:e=>h(e.target.value),placeholder:a(`promptsPage.form.contentPlaceholder`),rows:8,className:J,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`promptsPage.form.contentHint`)})]}),(0,Q.jsx)(pr,{variables:g,onChange:_}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-tags`,className:Bt,children:a(`promptsPage.form.tags`)}),(0,Q.jsx)(`input`,{id:`prompt-tags`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:a(`promptsPage.form.tagsPlaceholder`),className:J})]})]})}var _r=({title:e,cards:t,testId:n,onPick:r})=>t.length===0?null:(0,Q.jsxs)(`div`,{className:`mt-8`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:e}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:t.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),"data-testid":n,className:`rounded-2xl border border-black/[0.06] bg-white/40 px-4 py-3 text-start transition-colors hover:bg-white/80 dark:border-white/[0.07] dark:bg-dark-100/40 dark:hover:bg-dark-100/80`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e.description}),e.meta&&(0,Q.jsx)(`p`,{className:`mt-1.5 font-mono text-[11px] text-gray-400 dark:text-dark-500`,dir:`ltr`,children:e.meta})]},e.id))})]}),vr=[{id:`reviewPr`,input:{slug:`review-pr`,title:`Pull request review`,description:`Structured code review with adjustable strictness.`,content:`Review the following {{language}} changes with {{strictness}} strictness. Point out bugs first, style second, and end with a one-line verdict.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0},{name:`strictness`,type:`select`,label:`Strictness`,default:`normal`,options:[`low`,`normal`,`pedantic`]}],tags:[`code`,`review`]}},{id:`summarize`,input:{slug:`summarize`,title:`Summarize for an audience`,description:`Bullet-point summary tuned to a reader.`,content:`Summarize the following in at most {{points}} bullet points for {{audience}}. Keep every bullet self-contained, lead with the most important point, and end with a one-sentence takeaway.`,variables:[{name:`points`,type:`number`,label:`Bullets`,default:`5`},{name:`audience`,type:`text`,label:`Audience`,default:`a technical reader`}],tags:[`writing`]}},{id:`translate`,input:{slug:`translate`,title:`Translate`,description:`Translation that preserves tone and formatting.`,content:`Translate the following into {{target_language}}. Preserve tone, formatting, and markup exactly; keep code, identifiers, and proper names untranslated. If a phrase is ambiguous, pick the most natural reading and note the alternative in brackets.`,variables:[{name:`target_language`,type:`text`,label:`Target language`,required:!0}],tags:[`writing`,`translation`]}},{id:`explainCode`,input:{slug:`explain-code`,title:`Explain code`,description:`Walkthrough plus edge cases and risks.`,content:`Explain what the following {{language}} code does, step by step but briefly. Then list edge cases it mishandles, hidden assumptions, and the one change you would make first.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0}],tags:[`code`]}}],yr=({title:e,entries:t,loading:n,currentVersion:r,rollingBackTo:i,onRollback:a,onClose:s,testId:c})=>{let{t:u,i18n:d}=o();return(0,Q.jsx)(Vt,{titleId:`version-history-title`,title:e,subtitle:u(`promptsPage.history.subtitle`),onClose:s,widthClassName:`max-w-2xl`,testId:c,footer:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:u(`common.close`)}),children:n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(z,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,Q.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,Q.jsx)(Ze,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:u(`promptsPage.history.empty`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,Q.jsxs)(`div`,{"data-testid":`version-history-entry`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:[u(`promptsPage.versionLabel`,{version:e.version}),e.version===r&&(0,Q.jsx)(`span`,{className:`ms-2 rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary-600 dark:text-primary-400`,children:u(`promptsPage.history.current`)})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-gray-400 dark:text-dark-500`,children:l(e.createdAt,d.language)})]}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:e.version===r||i!==null,onClick:()=>a(e.version),"data-testid":`version-rollback`,children:i===e.version?u(`promptsPage.history.rollingBack`):u(`promptsPage.history.rollback`)})]}),(0,Q.jsx)(`pre`,{className:`mt-2 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-black/[0.03] p-2.5 text-[11px] leading-5 text-gray-600 scrollbar-thin dark:bg-white/[0.04] dark:text-dark-600`,children:e.body})]},e.version))})})},br=(e,t)=>{let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},xr=async e=>JSON.parse(await e.text()),Sr=(e,t)=>{let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)},Cr=e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error),r.onload=()=>t(String(r.result??``)),r.readAsText(e)}),wr=V(`pages:prompts`),Tr=()=>{let{t:e,i18n:t}=o(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(0,Z.useRef)(null),[D,O]=(0,Z.useState)(0),k=(0,Z.useCallback)(()=>O(e=>e+1),[]);(0,Z.useEffect)(()=>{let t=!1;return wt.list().then(n=>{t||(n.success&&n.data?r(n.data):L.error(n.error||e(`promptsPage.loadFailed`)))}).catch(n=>{t||(wr.error(`Failed to load prompts:`,n),L.error(e(`promptsPage.loadFailed`)))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[D,e]);let A=async t=>{h(!0);try{let n=u?await wt.update(u.id,t):await wt.create(t);n.success?(c(!1),p(null),L.success(e(`promptsPage.saved`)),k()):L.error(n.error||e(`promptsPage.saveFailed`))}catch(t){wr.error(`Failed to save prompt:`,t),L.error(e(`promptsPage.saveFailed`))}finally{h(!1)}},j=async()=>{if(!g)return;let t=g;_(null);try{let n=await wt.remove(t.id);if(!n.success)throw Error(n.error);L.success(e(`promptsPage.deleted`)),k()}catch(t){wr.error(`Failed to delete prompt:`,t),L.error(e(`promptsPage.deleteFailed`))}},M=async t=>{try{let e=await wt.export(t.id);if(!e.success||!e.data)throw Error(e.error);br(`${t.slug}.prompt.json`,e.data)}catch(t){wr.error(`Failed to export prompt:`,t),L.error(e(`promptsPage.exportFailed`))}},ee=async t=>{try{let n=await wt.import(await xr(t));if(!n.success)throw Error(n.error);L.success(e(`promptsPage.imported`)),k()}catch(t){wr.error(`Failed to import prompt:`,t),L.error(e(`promptsPage.importFailed`))}},N=async t=>{y(t),C(!0),x([]);try{let n=await wt.versions(t.id);n.success&&n.data?x(n.data):L.error(n.error||e(`promptsPage.historyFailed`))}catch(t){wr.error(`Failed to load prompt history:`,t),L.error(e(`promptsPage.historyFailed`))}finally{C(!1)}},P=async t=>{if(v){T(t);try{let n=await wt.rollback(v.id,t);if(!n.success||!n.data)throw Error(n.error);L.success(e(`promptsPage.rolledBack`)),y(null),k()}catch(t){wr.error(`Failed to roll the prompt back:`,t),L.error(e(`promptsPage.rollbackFailed`))}finally{T(null)}}};return(0,Q.jsxs)(`div`,{"data-testid":`prompts-page`,className:`pb-2`,children:[(0,Q.jsx)(dr,{title:e(`promptsPage.title`),description:e(`promptsPage.description`),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{ref:E,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`prompt-import-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&ee(t)}}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>E.current?.click(),"data-testid":`prompt-import`,children:[(0,Q.jsx)(Je,{className:`me-1.5 h-3.5 w-3.5`}),e(`common.import`)]}),(0,Q.jsxs)(q,{size:`sm`,onClick:()=>{d(null),p(null),c(!0)},"data-testid":`prompt-new`,children:[(0,Q.jsx)(Oe,{className:`me-1.5 h-3.5 w-3.5`}),e(`promptsPage.newPrompt`)]})]})}),i?null:n.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,Q.jsx)(et,{className:`mx-auto mb-3 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e(`promptsPage.empty`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-[13px] leading-6 text-gray-400 dark:text-dark-500`,children:e(`promptsPage.emptyHint`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(n=>(0,Q.jsx)(`div`,{"data-testid":`prompt-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsxs)(`code`,{className:`rounded-md bg-black/[0.04] px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:[`/`,n.slug]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.versionLabel`,{version:n.version})})]}),n.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-[12px] text-gray-500 dark:text-dark-500`,children:n.description}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[n.tags.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-black/[0.04] px-2 py-0.5 text-[10px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:e},e)),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.updated`,{when:l(n.updatedAt,t.language)})})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(Ut,{icon:Ze,label:e(`promptsPage.history.open`),testId:`prompt-history`,onClick:()=>void N(n)}),(0,Q.jsx)(Ut,{icon:ct,label:e(`common.export`),testId:`prompt-export`,onClick:()=>void M(n)}),(0,Q.jsx)(Ut,{icon:Ge,label:e(`common.edit`),testId:`prompt-edit`,onClick:()=>{d(n),c(!0)}}),(0,Q.jsx)(Ut,{icon:B,label:e(`common.delete`),testId:`prompt-delete`,destructive:!0,onClick:()=>_(n)})]})]})},n.id))}),!i&&(0,Q.jsx)(_r,{title:e(`promptsPage.templatesTitle`),testId:`prompt-template`,cards:vr.map(t=>({id:t.id,name:e(`promptsPage.templates.${t.id}.name`),description:e(`promptsPage.templates.${t.id}.description`),meta:`/${t.input.slug}`})),onPick:e=>{let t=vr.find(t=>t.id===e);t&&(d(null),p(t.input),c(!0))}}),(0,Q.jsx)(hr,{open:s,prompt:u,prefill:f,saving:m,onClose:()=>{c(!1),p(null)},onSave:e=>void A(e)}),v&&(0,Q.jsx)(yr,{title:e(`promptsPage.history.title`,{title:v.title}),entries:b.map(e=>({version:e.version,body:e.content,createdAt:e.createdAt})),loading:S,currentVersion:v.version,rollingBackTo:w,onRollback:e=>void P(e),onClose:()=>y(null),testId:`prompt-history-modal`}),g&&(0,Q.jsx)(Vt,{titleId:`prompt-delete-title`,title:e(`promptsPage.deleteTitle`),subtitle:e(`promptsPage.deleteConfirm`,{title:g.title}),onClose:()=>_(null),widthClassName:`max-w-sm`,testId:`prompt-delete-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>_(null),children:e(`common.cancel`)}),(0,Q.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>void j(),"data-testid":`prompt-delete-confirm`,children:e(`common.delete`)})]})})]})},Er=/^[a-z0-9][a-z0-9-]{0,63}$/;function Dr({open:e,skill:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(Or,{skill:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function Or({skill:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=o(),s=e??t,[c,l]=(0,Z.useState)(s?.slug??``),[u,d]=(0,Z.useState)(s?.name??``),[f,p]=(0,Z.useState)(s?.description??``),[m,h]=(0,Z.useState)(s?.instructions??``),[g,_]=(0,Z.useState)(s?.enabled??!0),v=Er.test(c.trim()),y=v&&u.trim().length>0&&f.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Vt,{titleId:`skill-modal-title`,title:a(e?`skillsPage.editSkill`:`skillsPage.newSkill`),onClose:r,widthClassName:`max-w-2xl`,testId:`skill-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{y&&i({slug:c.trim(),name:u.trim(),description:f.trim(),instructions:m,enabled:g})},disabled:n||!y,"data-testid":`skill-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-slug`,className:Bt,children:a(`skillsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`skill-slug`,"data-testid":`skill-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`skillsPage.form.slugPlaceholder`),className:J,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!v?a(`skillsPage.form.slugInvalid`):a(`skillsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-name`,className:Bt,children:a(`skillsPage.form.name`)}),(0,Q.jsx)(`input`,{id:`skill-name`,"data-testid":`skill-name`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`skillsPage.form.namePlaceholder`),className:J,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-description`,className:Bt,children:a(`skillsPage.form.description`)}),(0,Q.jsx)(`textarea`,{id:`skill-description`,"data-testid":`skill-description`,value:f,onChange:e=>p(e.target.value),placeholder:a(`skillsPage.form.descriptionPlaceholder`),rows:2,className:J,maxLength:1e3}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.descriptionHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-instructions`,className:Bt,children:a(`skillsPage.form.instructions`)}),(0,Q.jsx)(`textarea`,{id:`skill-instructions`,"data-testid":`skill-instructions`,value:m,onChange:e=>h(e.target.value),placeholder:a(`skillsPage.form.instructionsPlaceholder`),rows:10,className:`${J} font-mono`,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.instructionsHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`skillsPage.form.enabled`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.enabledHint`)})]}),(0,Q.jsx)(Ht,{checked:g,onChange:_})]}),e&&(0,Q.jsx)(kr,{skillId:e.id})]})}function kr({skillId:e}){let{t}=o(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(()=>{U.listFiles(e).then(e=>r(e.success&&e.data?e.data:[])).catch(()=>r([]))},[e]);(0,Z.useEffect)(()=>{p()},[p]);let m=async n=>{if(n===null){a(``),c(``),u(``);return}try{let t=await U.getFile(e,n);if(!t.success||!t.data)throw Error(t.error);a(n),c(n),u(t.data.content)}catch{L.error(t(`skillsPage.files.loadFailed`))}},h=async()=>{let n=s.trim();if(n){f(!0);try{let t=await U.putFile(e,n,l);if(!t.success)throw Error(t.error);i&&i!==n&&await U.deleteFile(e,i),a(null),p()}catch(e){L.error(e instanceof Error&&e.message?e.message:t(`skillsPage.files.saveFailed`))}finally{f(!1)}}},g=async n=>{try{let t=await U.deleteFile(e,n);if(!t.success)throw Error(t.error);i===n&&a(null),p()}catch{L.error(t(`skillsPage.files.deleteFailed`))}};return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,"data-testid":`skill-files`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:t(`skillsPage.files.title`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.hint`)})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>void m(null),"data-testid":`skill-file-add`,children:[(0,Q.jsx)(Me,{className:`me-1.5 h-3.5 w-3.5`}),t(`skillsPage.files.add`)]})]}),n&&n.length>0&&(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:n.map(e=>(0,Q.jsxs)(`li`,{"data-testid":`skill-file-row`,className:`flex items-center gap-2 rounded-lg bg-black/[0.03] px-2 py-1.5 dark:bg-white/[0.04]`,children:[(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate text-[12px] text-gray-700 dark:text-dark-800`,dir:`ltr`,children:e.path}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:[e.size,` B`]}),(0,Q.jsx)(Ut,{icon:Ge,label:t(`common.edit`),testId:`skill-file-edit`,onClick:()=>void m(e.path)}),(0,Q.jsx)(Ut,{icon:B,label:t(`common.delete`),testId:`skill-file-delete`,destructive:!0,onClick:()=>void g(e.path)})]},e.path))}),n&&n.length===0&&i===null&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.empty`)}),i!==null&&(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,"data-testid":`skill-file-editor`,children:[(0,Q.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:t(`skillsPage.files.pathPlaceholder`),dir:`ltr`,"data-testid":`skill-file-path`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`,maxLength:200}),(0,Q.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:t(`skillsPage.files.contentPlaceholder`),rows:6,dir:`ltr`,"data-testid":`skill-file-content`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>a(null),children:t(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,disabled:d||!s.trim(),onClick:()=>void h(),"data-testid":`skill-file-save`,children:t(d?`common.saving`:`common.save`)})]})]})]})}var Ar=[{id:`citeSources`,input:{slug:`cite-sources`,name:`Cite sources`,description:`How to cite evidence: numbered references with URLs, no unreferenced claims.`,instructions:`# Citing sources
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{i as r,t as i}from"./useQuery-CoWV2PmJ.js";import{a}from"./router-vendor-BGP0k6Y2.js";import{t as o}from"./useTranslation-DrnYb6Cx.js";import{a as s,n as c,r as l,t as u}from"./utils-D9UstwTG.js";import{C as d,D as f,E as p,_ as m,b as h,c as g,l as _,m as v,p as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./chatStore-BXWiKI6E.js";import{$ as E,$t as D,An as O,At as k,Cn as A,E as j,Ft as M,G as ee,Gn as N,Ht as P,I as te,In as ne,It as re,Jt as ie,K as ae,Kt as oe,L as F,Ln as se,Lt as ce,Nt as le,Pt as I,Qt as ue,R as de,Rt as fe,Sn as pe,St as me,T as he,Tt as ge,U as _e,Un as ve,Ut as ye,V as be,Vn as xe,W as Se,Wn as Ce,Wt as we,X as Te,Y as Ee,Yt as De,Z as Oe,_n as ke,_r as L,_t as Ae,ct as je,dn as Me,g as Ne,gn as Pe,gr as R,in as Fe,ir as Ie,j as Le,jn as Re,jt as z,mn as ze,mr as Be,mt as Ve,n as He,nn as Ue,nr as We,nt as Ge,o as Ke,or as qe,p as Je,pr as Ye,pt as Xe,q as Ze,qt as Qe,r as $e,rr as et,t as tt,tn as nt,un as rt,v as B,vn as it,w as at,wn as ot,x as st,xn as ct,z as lt,zt as ut}from"./ui-vendor-C0KwbTD4.js";import{t as V}from"./logger-CpCQz3Vi.js";import{n as dt}from"./workApi-BUxESSmH.js";import{C as ft,F as pt,I as mt,M as ht,N as gt,S as _t,a as vt,c as yt,d as H,f as U,i as bt,j as xt,l as St,n as Ct,p as wt,r as Tt,s as W,u as Et,w as Dt,y as G}from"./api-IiXPQ8se.js";import{a as K,o as Ot,s as kt,t as At}from"./imageGenModels-Dx_QMLJQ.js";import{t as jt,u as Mt}from"./authStore-jbmnSGyL.js";import{a as Nt,n as Pt,o as Ft,t as It}from"./appStore-D_3JwBEY.js";import{l as Lt}from"./messageCodeStyles-D1-WsF_0.js";import{t as q}from"./Button--pDOakZx.js";import{_ as Rt,g as zt,i as Bt,n as Vt,r as J,s as Ht,t as Ut,v as Wt}from"./ui-BxB90kIo.js";import{t as Gt}from"./Logo-BE9SvCC5.js";import{t as Kt}from"./LogoMark-C8x1yyP3.js";import{t as qt}from"./ShareDialog-buTN0EBc.js";import{s as Jt}from"./ttsBatching-C9kQXFB1.js";import{r as Y,t as Yt}from"./webauthnClient-CPSq528Q.js";import{t as Xt}from"./appVersion-Chg_Ru57.js";import{t as X}from"./SettingsToggle-C16gtVyi.js";import{i as Zt,r as Qt,t as $t}from"./thinking-DwlkTfPX.js";var Z=e(t(),1),Q=n();function en(e){let t=e.match(/^v?(\d+)\.(\d+)\.(\d+)/);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function tn(e,t){for(let n=0;n<3;n++)if(e[n]!==t[n])return e[n]-t[n];return 0}function nn(e){let[t,n]=(0,Z.useState)(`checking`),[r,i]=(0,Z.useState)(null);return(0,Z.useEffect)(()=>{let t=!1,r=en(e),a=e.includes(`-dev`);return(async()=>{try{let e=await fetch(`https://api.github.com/repos/libre-webui/libre-webui/releases/latest`,{headers:{Accept:`application/vnd.github+json`}});if(!e.ok)throw Error(`HTTP ${e.status}`);let o=en((await e.json()).tag_name??``);if(t)return;if(!r||!o){n(`error`);return}i(o.join(`.`));let s=tn(r,o);n(s<0?`behind`:s>0||a?`ahead`:`latest`)}catch{t||n(`error`)}})(),()=>{t=!0}},[e]),{status:t,latestVersion:r}}var $=[{href:`https://github.com/libre-webui/libre-webui`,icon:D,labelKey:`settings.about.links.github`,descriptionKey:`settings.about.links.githubDescription`},{href:`https://github.com/libre-webui/libre-webui`,icon:he,labelKey:`settings.about.links.star`,descriptionKey:`settings.about.links.starDescription`},{href:`https://git.kroonen.ai/libre-webui/libre-webui`,icon:De,labelKey:`settings.about.links.forgejo`,descriptionKey:`settings.about.links.forgejoDescription`},{href:`https://librewebui.org`,icon:it,labelKey:`settings.about.links.website`,descriptionKey:`settings.about.links.websiteDescription`},{href:`https://docs.librewebui.org`,icon:Ie,labelKey:`settings.about.links.documentation`,descriptionKey:`settings.about.links.documentationDescription`},{href:`https://github.com/sponsors/libre-webui`,icon:P,labelKey:`settings.about.links.sponsor`,descriptionKey:`settings.about.links.sponsorDescription`},{href:`https://github.com/libre-webui/libre-webui/issues`,icon:me,labelKey:`settings.about.links.reportIssue`,descriptionKey:`settings.about.links.reportIssueDescription`}],rn=[`settings.about.features.privacy`,`settings.about.features.openSource`,`settings.about.features.localInference`];function an({status:e,latestVersion:t}){let{t:n}=o();return e===`checking`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-500 dark:text-dark-500`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),n(`settings.about.updates.checking`)]}):e===`latest`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-success-600 dark:text-success-400`,children:[(0,Q.jsx)(ne,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.upToDate`)]}):e===`ahead`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(ue,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.ahead`,{version:t??``})]}):e===`behind`?(0,Q.jsxs)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/latest`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 font-medium text-primary-600 transition-colors hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:[(0,Q.jsx)(se,{className:`h-3.5 w-3.5`}),n(`settings.about.updates.updateAvailable`,{version:t??``}),(0,Q.jsx)(it,{className:`h-3 w-3`})]}):(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-dark-500`,children:n(`settings.about.updates.checkFailed`)})}function on({appVersion:e}){let{t}=o(),{status:n,latestVersion:r}=nn(e);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center gap-2.5 text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Kt,{size:`md`,label:null}),(0,Q.jsx)(Gt,{})]}),(0,Q.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 mb-6`,children:(0,Q.jsx)(`span`,{children:t(`settings.about.title`)})}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-100 rounded-lg p-6 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsx)(`div`,{className:`space-y-4 text-sm text-gray-700 dark:text-gray-300`,children:rn.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 bg-primary-500 rounded-full mt-2 flex-shrink-0`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-semibold text-gray-900 dark:text-gray-100 mb-1`,children:t(`${e}.title`)}),(0,Q.jsx)(`p`,{children:t(`${e}.description`)})]})]},e))})}),(0,Q.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`settings.about.links.title`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:$.map(e=>{let n=e.icon;return(0,Q.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-3 p-3 bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg hover:bg-gray-50 dark:hover:bg-dark-200 hover:border-gray-300 dark:hover:border-dark-400 transition-all duration-200 group`,children:[(0,Q.jsx)(n,{className:`h-5 w-5 text-gray-600 dark:text-gray-400 group-hover:text-gray-900 dark:group-hover:text-gray-200`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t(e.labelKey)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(e.descriptionKey)})]}),(0,Q.jsx)(it,{className:`h-4 w-4 text-gray-400 ms-auto opacity-0 group-hover:opacity-100 transition-opacity`})]},e.labelKey)})})]}),(0,Q.jsx)(`div`,{className:`mt-6 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1.5`,children:[e.includes(`-dev`)?(0,Q.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:t(`settings.about.version`,{version:e})}):(0,Q.jsx)(`a`,{href:`https://github.com/libre-webui/libre-webui/releases/tag/v${e}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-400 transition-colors`,children:t(`settings.about.version`,{version:e})}),(0,Q.jsx)(an,{status:n,latestVersion:r}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`libre:open-whats-new`)),className:`inline-flex items-center gap-1.5 text-gray-500 transition-colors hover:text-gray-900 dark:text-gray-400 dark:hover:text-dark-900`,"data-testid":`about-view-changelog`,children:[(0,Q.jsx)(Se,{className:`h-3.5 w-3.5`}),t(`settings.about.updates.viewChangelog`)]})]}),(0,Q.jsxs)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:[t(`settings.about.openSourceBy`,{company:``}),(0,Q.jsx)(`a`,{href:`https://kroonen.ai`,target:`_blank`,rel:`noopener noreferrer`,className:`text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:`Kroonen AI`})]})]})})]})})}var sn=V(`components:background-upload`),cn=({className:e=``})=>{let{t}=o(),{preferences:n,setPreferences:r,backgroundImage:i,uploadBackgroundImage:a,removeBackgroundImage:s}=It(),c=(0,Z.useRef)(null),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),p=n.backgroundSettings||{enabled:!1,imageUrl:``,blurAmount:10,opacity:.6},m=async e=>{if(!e.type.startsWith(`image/`)){L.error(t(`personaBackground.invalidFile`));return}if(e.size>5242880){L.error(t(`personaBackground.fileTooLarge`));return}u(!0);try{await a(e),L.success(t(`personaBackground.uploaded`))}catch(e){sn.error(`Failed to upload background:`,e),L.error(t(`personaBackground.uploadFailed`))}finally{u(!1)}},h=e=>{let t=e.target.files?.[0];t&&m(t)},g=e=>{e.preventDefault(),f(!0)},_=e=>{e.preventDefault(),f(!1)},v=e=>{e.preventDefault(),f(!1);let t=e.dataTransfer.files?.[0];t&&m(t)},y=()=>{s(),L.success(t(`personaBackground.removed`))},b=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,enabled:e};if(r({backgroundSettings:n}),t||!e)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}},x=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,blurAmount:e};if(r({backgroundSettings:n}),t)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}},S=async e=>{let t=i||p.imageUrl||``,n={...p,imageUrl:t,opacity:e};if(r({backgroundSettings:n}),t)try{await W.updatePreferences({backgroundSettings:n})}catch(e){sn.error(`Failed to update preferences:`,e)}};return(0,Q.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-3`,children:t(`settings.appearance.background.title`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:t(`settings.appearance.background.enable`)}),(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`settings.appearance.background.enableDescription`)})]}),(0,Q.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:p.enabled,onChange:e=>b(e.target.checked)}),(0,Q.jsx)(`div`,{className:`w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary-300 dark:peer-focus:ring-primary-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-primary-600`})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,Q.jsx)(`div`,{className:`relative`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-gray-50 dark:bg-dark-200 rounded-lg`,children:[(0,Q.jsx)(`div`,{className:`flex-shrink-0`,children:(0,Q.jsx)(`img`,{src:i,alt:`Background preview`,className:`w-12 h-12 object-cover rounded-md`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 truncate`,children:`Custom background image`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:`Click to change or remove`})]}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:y,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,Q.jsx)(He,{className:`h-4 w-4`})})]})}):(0,Q.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${d?`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:g,onDragLeave:_,onDrop:v,onClick:()=>c.current?.click(),children:[(0,Q.jsx)(ut,{className:`h-12 w-12 mx-auto text-gray-400 dark:text-gray-500 mb-4`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:t(`settings.appearance.background.upload`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:t(`settings.appearance.background.dragDrop`)}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,disabled:l,className:`mx-auto`,children:[(0,Q.jsx)(Je,{className:`h-4 w-4 me-2`}),t(l?`common.loading`:`settings.appearance.background.chooseImage`)]})]}),(0,Q.jsx)(`input`,{ref:c,type:`file`,accept:`image/*`,onChange:h,className:`hidden`})]}),i&&(0,Q.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.blur`),`:`,` `,p.blurAmount,`px`]}),(0,Q.jsx)(`input`,{type:`range`,min:`0`,max:`30`,step:`1`,value:p.blurAmount,onChange:e=>x(parseInt(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[t(`settings.appearance.background.opacity`),`:`,` `,Math.round(p.opacity*100),`%`]}),(0,Q.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.1`,value:p.opacity,onChange:e=>S(parseFloat(e.target.value)),className:`w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer dark:bg-gray-700`})]})]})]})})},ln=()=>{let{t:e,i18n:t}=o();return(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:e(`settings.appearance.language.title`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:e(`settings.appearance.language.description`)})]}),(0,Q.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,Q.jsx)(`select`,{"data-testid":`language-switcher-select`,value:p(t.language),onChange:e=>{let t=e.target.value;d(t)},className:`h-9 max-w-[220px] cursor-pointer appearance-none rounded-full bg-surface-subtle pe-9 ps-3.5 text-sm text-ink transition-colors hover:bg-hover-solid focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,children:f.map(e=>(0,Q.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,Q.jsx)(Ce,{className:`pointer-events-none absolute end-3 top-1/2 h-4 w-4 -translate-y-1/2 text-ink-muted`})]})]})};function un({title:e,description:t,children:n}){return(0,Q.jsxs)(`div`,{className:`flex items-center gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:n})]})}function dn({checked:e,onChange:t,label:n,testId:r}){return(0,Q.jsxs)(`label`,{className:`relative inline-flex shrink-0 cursor-pointer items-center`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"data-testid":r,"aria-label":n,className:`peer sr-only`,checked:e,onChange:e=>t(e.target.checked)}),(0,Q.jsx)(`div`,{className:`peer h-6 w-11 rounded-full bg-line-strong transition-colors peer-focus:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-primary-500/40 peer-checked:bg-primary-500 after:absolute after:start-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:bg-white after:shadow-sm after:transition-all after:content-[''] peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full`})]})}function fn({theme:e,preferences:t,onThemeChange:n,onAccentChange:r,onCustomAccentChange:i,onAdaptToAccentChange:a,onShowUsernameChange:s,onShowFollowUpsChange:c,onAutoOpenArtifactsChange:l,onHapticFeedbackChange:d}){let{t:f}=o(),p=e.accent||`blue`,m=e.customAccent||`#4176e6`,h=Nt(e),g=(t,r,i)=>{let a=e.mode===t;return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>n(t),"aria-pressed":a,className:u(`flex flex-1 basis-[180px] flex-col items-center justify-center gap-1 rounded-2xl border px-8 py-5 text-sm leading-[22px] text-ink transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,a?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(r,{className:`h-4 w-4`}),i]})};return(0,Q.jsxs)(`div`,{className:`divide-y divide-line`,children:[(0,Q.jsx)(ln,{}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 py-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.title`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-stretch gap-2`,children:[g(`light`,at,f(`settings.appearance.theme.light`)),g(`dark`,Xe,f(`settings.appearance.theme.dark`)),g(`amoled`,Ve,f(`settings.appearance.theme.amoled`))]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 py-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.title`,{defaultValue:`Accent color`})}),(0,Q.jsx)(`div`,{className:`h-6 w-6 flex-shrink-0 rounded-full border border-line`,style:{backgroundColor:h},"aria-hidden":`true`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[Pt.map(e=>{let t=p===e.id;return(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),className:u(`relative h-9 w-9 rounded-full transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,t?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),style:{backgroundColor:e.color},"aria-label":f(`settings.appearance.accent.useColor`,{defaultValue:`Use ${e.label} accent`,color:e.label}),title:e.label,children:t&&(0,Q.jsx)(N,{className:`absolute inset-0 m-auto h-4 w-4 drop-shadow`,style:{color:e.foreground}})},e.id)}),(0,Q.jsxs)(`label`,{className:u(`relative h-9 w-9 cursor-pointer overflow-hidden rounded-full transition-all duration-200 focus-within:outline-none focus-within:ring-2 focus-within:ring-primary-500/40`,p===`custom`?`scale-105 ring-2 ring-ink ring-offset-2 ring-offset-surface`:`hover:scale-110`),title:f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),"aria-label":f(`settings.appearance.accent.custom`,{defaultValue:`Custom color`}),children:[(0,Q.jsx)(`input`,{type:`color`,value:m,onInput:e=>i(e.currentTarget.value),onChange:e=>i(e.target.value),className:`absolute inset-0 h-full w-full cursor-pointer opacity-0`}),(0,Q.jsx)(`span`,{className:`absolute inset-0`,style:{backgroundColor:m},"aria-hidden":`true`}),(0,Q.jsx)(je,{className:`absolute inset-0 m-auto h-4 w-4 text-white drop-shadow`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.behaviorTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-ink-subtle`,children:f(`settings.appearance.accent.behaviorDescription`)}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-stretch gap-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":!e.adaptToAccent,onClick:()=>a(!1),className:u(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line hover:bg-interactive-hover`:`border-line-strong bg-surface-subtle`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.defaultStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.defaultStyleDescription`)})]}),(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":e.adaptToAccent===!0,onClick:()=>a(!0),className:u(`flex-1 basis-[180px] rounded-2xl border p-4 text-start transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`,e.adaptToAccent?`border-line-strong bg-surface-subtle`:`border-line hover:bg-interactive-hover`),children:[(0,Q.jsx)(`span`,{className:`block text-sm leading-[22px] text-ink`,children:f(`settings.appearance.accent.adaptedStyle`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-snug text-ink-subtle`,children:f(`settings.appearance.accent.adaptedStyleDescription`)})]})]})]})]}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.showUsername`),description:f(`settings.appearance.chatInterface.showUsernameDescription`),children:(0,Q.jsx)(dn,{checked:t.showUsername,onChange:s,label:f(`settings.appearance.chatInterface.showUsername`)})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.followUpSuggestions`),description:f(`settings.appearance.chatInterface.followUpSuggestionsDescription`),children:(0,Q.jsx)(dn,{checked:t.showFollowUpSuggestions!==!1,onChange:c,label:f(`settings.appearance.chatInterface.followUpSuggestions`)})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.autoOpenArtifacts`),description:f(`settings.appearance.chatInterface.autoOpenArtifactsDescription`),children:(0,Q.jsx)(dn,{checked:t.autoOpenArtifactPanel!==!1,onChange:l,label:f(`settings.appearance.chatInterface.autoOpenArtifacts`),testId:`auto-open-artifacts-toggle`})}),(0,Q.jsx)(un,{title:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),description:f(`settings.appearance.chatInterface.hapticFeedbackDescription`,{defaultValue:`Use subtle vibration for important mobile actions`}),children:(0,Q.jsx)(dn,{checked:t.hapticFeedbackEnabled===!0,onChange:d,label:f(`settings.appearance.chatInterface.hapticFeedback`,{defaultValue:`Haptic feedback (Android)`}),testId:`haptic-feedback-toggle`})}),(0,Q.jsx)(`div`,{className:`py-4`,children:(0,Q.jsx)(cn,{})})]})}function pn(){let{t:e,i18n:t}=o(),{sessions:n,setSessionArchived:r,deleteSession:i}=x(),a=n.filter(e=>e.archived);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:e(`settings.data.archivedChats.title`)}),a.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.data.archivedChats.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:a.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsx)(`p`,{className:`text-[11px] tabular-nums text-gray-400 dark:text-dark-500`,children:l(n.updatedAt,t.language)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:()=>r(n.id,!1),className:`h-8 gap-1.5 px-2 text-xs`,title:e(`settings.data.archivedChats.unarchive`),children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`}),e(`settings.data.archivedChats.unarchive`)]}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{window.confirm(e(`chat.session.deleteConfirm`))&&i(n.id)},className:`h-8 w-8 p-0 text-red-500 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-900/20`,title:e(`chat.session.deleteChat`),children:(0,Q.jsx)(B,{className:`h-3.5 w-3.5`})})]})]},n.id))})]})}function mn({sessionCount:e,loading:t,importing:n,preflighting:r,preflight:i,showImportOptions:a,mergeStrategy:s,importResult:c,importFileInputRef:l,onExportData:u,onImportFileSelect:d,onClearAllHistory:f,onMergeStrategyChange:p,onConfirmImport:m,onCancelImport:h,onDismissImportResult:g}){let{t:_}=o();return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:_(`settings.data.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.export`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.exportDescription`)}),(0,Q.jsx)(`p`,{className:`mb-3 text-[11px] text-amber-700 dark:text-amber-300`,children:_(`settings.data.archiveScopeV3`,{defaultValue:`Includes preferences, chats, folders, Notes, knowledge collections, and extracted document text. Excludes accounts and secrets, biometric cloned voices, generated media, personas and memory, and Work data or volumes.`})}),(0,Q.jsx)(q,{onClick:u,variant:`outline`,size:`sm`,className:`w-full`,children:_(`settings.data.exportAll`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.import`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.importDescription`)}),(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json`,onChange:d,className:`hidden`}),(0,Q.jsx)(q,{onClick:()=>l.current?.click(),variant:`outline`,size:`sm`,className:`w-full`,disabled:n,children:_(n?`settings.data.importing`:`settings.data.importData`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:_(`settings.data.clearSessions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3 flex-1`,children:_(`settings.data.clearSessionsDescription`)}),(0,Q.jsx)(q,{onClick:f,variant:`outline`,size:`sm`,className:`w-full text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300 border-red-200 hover:border-red-300 dark:border-red-800 dark:hover:border-red-700`,disabled:e===0||t,children:t?_(`settings.data.clearing`):_(`settings.data.clearAll`,{count:e})})]})]}),a&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-3`,children:_(`settings.data.importOptions`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:_(`settings.data.importOptionsDescription`)}),(0,Q.jsxs)(`div`,{className:`space-y-2 mb-4`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`skip`,checked:s===`skip`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.skipDuplicates`)})]}),(0,Q.jsxs)(`label`,{className:`flex items-center`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`mergeStrategy`,value:`overwrite`,checked:s===`overwrite`,onChange:e=>p(e.target.value),className:`me-2`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:_(`settings.data.overwrite`)})]})]}),r&&(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-gray-600 dark:text-gray-300`,children:_(`settings.data.validatingArchive`,{defaultValue:`Validating archive and calculating changes…`})}),i&&!r&&(0,Q.jsxs)(`div`,{className:`mb-4 space-y-2 rounded-md border border-gray-200 bg-white p-3 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-gray-300`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:_(`settings.data.preflightReport`,{defaultValue:`Import preview`})}),(0,Q.jsx)(`p`,{children:_(`settings.data.preflightIncoming`,{defaultValue:`{{folders}} folders · {{sessions}} chats · {{messages}} messages · {{notes}} Notes · {{collections}} collections · {{documents}} documents · {{chunks}} chunks`,folders:i.incoming.sessionFolders,sessions:i.incoming.sessions,messages:i.incoming.messages,notes:i.incoming.notes,collections:i.incoming.knowledgeCollections,documents:i.incoming.documents,chunks:i.incoming.documentChunks})}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:[[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),i.result.sessionFolders],[_(`settings.data.sessions`),i.result.sessions],[_(`settings.data.notes`,{defaultValue:`Notes`}),i.result.notes],[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),i.result.knowledgeCollections],[_(`settings.data.documents`),i.result.documents]].map(([e,t])=>(0,Q.jsxs)(`p`,{children:[e,`: `,t.imported,` `,_(`settings.data.toCreate`,{defaultValue:`to create`}),`, `,t.overwritten,` `,_(`settings.data.toOverwrite`,{defaultValue:`to overwrite`}),`, `,t.skipped,` `,_(`settings.data.toSkip`,{defaultValue:`to skip`})]},e))}),i.result.remappedIds>0&&(0,Q.jsx)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:_(`settings.data.preflightRemappedIds`,{defaultValue:`{{count}} IDs will be remapped to protect another account's data.`,count:i.result.remappedIds})}),i.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`preflight-warning-${t}`))]}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{onClick:m,size:`sm`,disabled:n||r||!i||i.strategy!==s,children:_(n?`settings.data.importing`:`settings.data.import`)}),(0,Q.jsx)(q,{onClick:h,variant:`outline`,size:`sm`,children:_(`common.cancel`)})]})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-100 border border-gray-200 dark:border-dark-300 rounded-lg`,children:[(0,Q.jsx)(`h5`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:_(`settings.data.importResults`)}),(0,Q.jsxs)(`div`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[_(`settings.data.preferences`),`:`,` `,c.preferences.imported?_(`settings.data.imported`):_(`settings.data.failed`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessions`),`:`,` `,c.sessions.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessions.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessions.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.documents`),`:`,` `,c.documents.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.documents.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.documents.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.notes`,{defaultValue:`Notes`}),`:`,` `,c.notes.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.notes.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.notes.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.sessionFolders`,{defaultValue:`Session folders`}),`: `,c.sessionFolders.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.sessionFolders.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.sessionFolders.skipped,` `,_(`settings.data.skipped`)]}),(0,Q.jsxs)(`div`,{children:[_(`settings.data.knowledgeCollections`,{defaultValue:`Knowledge collections`}),`: `,c.knowledgeCollections.imported,` `,_(`settings.data.importedLabel`),`,`,` `,c.knowledgeCollections.overwritten,` `,_(`settings.data.overwrittenLabel`,{defaultValue:`overwritten`}),`, `,c.knowledgeCollections.skipped,` `,_(`settings.data.skipped`)]}),c.warnings.length>0&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[_(`settings.data.warnings`,{defaultValue:`Warnings`}),`:`]}),c.warnings.map((e,t)=>(0,Q.jsxs)(`p`,{className:`text-amber-700 dark:text-amber-300`,children:[`• `,e]},`warning-${t}`))]})]}),(0,Q.jsx)(q,{onClick:g,variant:`outline`,size:`sm`,className:`mt-2`,children:_(`common.close`)})]})]})]}),(0,Q.jsx)(pn,{})]})}function hn({settings:e,effectiveSettings:t,modelOptions:n,status:r,regenerating:i,onSettingChange:a,onReset:s,onRegenerate:c,onSave:l}){let{t:u}=o();return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:u(`settings.documents.title`)}),(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 p-4 rounded-lg border border-gray-200 dark:border-dark-300 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:u(`settings.documents.embeddings.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:u(`settings.documents.embeddings.enable`)})]}),(0,Q.jsx)(X,{checked:e.enabled,onChange:e=>a(`enabled`,e)})]}),e.enabled&&(0,Q.jsxs)(`div`,{className:`space-y-4 pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:u(`settings.documents.embeddings.model`)}),(0,Q.jsx)(zt,{value:t.model,onChange:e=>a(`model`,e.target.value),options:n}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:u(`settings.documents.embeddings.modelDescription`)})]}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.chunkSize`),value:e.chunkSize,min:500,max:2e3,step:100,description:u(`settings.documents.embeddings.chunkSizeDescription`),onChange:e=>a(`chunkSize`,e)}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.chunkOverlap`),value:e.chunkOverlap,min:50,max:500,step:50,description:u(`settings.documents.embeddings.chunkOverlapDescription`),onChange:e=>a(`chunkOverlap`,e)}),(0,Q.jsx)(_n,{label:u(`settings.documents.embeddings.similarityThreshold`),value:e.similarityThreshold,min:.3,max:.9,step:.05,description:u(`settings.documents.embeddings.similarityDescription`),format:e=>e.toFixed(2),onChange:e=>a(`similarityThreshold`,e)})]})]}),r&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-100 p-4 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-2`,children:u(`settings.documents.embeddings.status`)}),(0,Q.jsxs)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300 space-y-1`,children:[(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.statusLabel`),`:`,` `,(0,Q.jsx)(`span`,{className:r.available?`font-medium text-green-600 dark:text-green-400`:`font-medium text-red-600 dark:text-red-400`,children:r.available?u(`settings.documents.embeddings.available`):u(`settings.documents.embeddings.unavailable`)})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.model`),`:`,` `,(0,Q.jsx)(`span`,{className:`font-medium`,children:r.model})]}),(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.chunksWithEmbeddings`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[r.chunksWithEmbeddings,` / `,r.totalChunks]})]}),r.totalChunks>0&&(0,Q.jsxs)(`div`,{children:[u(`settings.documents.embeddings.coverage`),`:`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[Math.round(r.chunksWithEmbeddings/r.totalChunks*100),`%`]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:s,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),u(`settings.generation.resetDefaults`)]}),e.enabled&&r&&r.totalChunks>0&&(0,Q.jsxs)(q,{onClick:c,disabled:i,variant:`outline`,className:`flex items-center gap-2 text-orange-600 dark:text-orange-400 border-orange-200 dark:border-orange-600 hover:bg-orange-50 dark:hover:bg-orange-900/20`,children:[(0,Q.jsx)(pe,{size:16}),u(i?`settings.documents.embeddings.regenerating`:`settings.documents.embeddings.regenerate`)]})]}),(0,Q.jsxs)(q,{onClick:l,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),u(`settings.saveSettings`)]})]}),(0,Q.jsx)(gn,{})]})})}function gn(){let{t:e}=o(),t=r(),[n,a]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),{data:m}=i({queryKey:[`knowledge-collections`],queryFn:async()=>{let[e,t]=await Promise.all([xt.getCollections(),xt.getDocuments()]);return{collections:e.success&&e.data?e.data:[],documents:t.success&&t.data?t.data:[]}}}),{collections:h=[],documents:g=[]}=m??{},_=()=>t.invalidateQueries({queryKey:[`knowledge-collections`]}),v=async()=>{let t=n.trim();if(t){a(``);try{let e=await xt.createCollection(t);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.createFailed`))}}},y=async t=>{l(null);try{let e=await xt.deleteCollection(t);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.deleteFailed`))}},b=async t=>{p(null);try{let e=await xt.deleteDocument(t);if(!e.success)throw Error(e.error);window.dispatchEvent(new Event(`libre:documents-updated`)),await _()}catch{R.error(e(`settings.documents.library.deleteFailed`))}},x=async(t,n)=>{try{let e=await xt.setDocumentCollection(t,n);if(!e.success)throw Error(e.error);await _()}catch{R.error(e(`settings.documents.collections.assignFailed`))}};return(0,Q.jsxs)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.collections.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.collections.description`)}),(0,Q.jsxs)(`div`,{className:`mb-3 flex gap-2`,children:[(0,Q.jsx)(`input`,{value:n,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v()},placeholder:e(`settings.documents.collections.namePlaceholder`),className:`flex-1 rounded-lg border border-gray-200 bg-white px-3 py-1.5 text-sm text-gray-900 placeholder:text-gray-400 focus:border-primary-500/40 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-900`}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void v(),disabled:!n.trim(),children:e(`settings.documents.collections.create`)})]}),h.length>0&&(0,Q.jsx)(`div`,{className:`mb-4 flex flex-wrap gap-1.5`,children:h.map(t=>s===t.id?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-red-200 bg-red-50 px-2.5 py-1 text-xs text-red-700 dark:border-red-800 dark:bg-red-900/20 dark:text-red-300`,children:[e(`settings.documents.collections.deleteConfirm`),(0,Q.jsx)(`button`,{onClick:()=>void y(t.id),className:`font-medium underline decoration-red-400 underline-offset-2 hover:text-red-800 dark:hover:text-red-200`,children:e(`common.delete`)}),(0,Q.jsx)(`button`,{onClick:()=>l(null),className:`text-red-400 hover:text-red-600 dark:hover:text-red-300`,title:e(`common.cancel`),children:(0,Q.jsx)(He,{className:`h-3 w-3`})})]},t.id):(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full border border-gray-200 bg-gray-50 px-2.5 py-1 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-200 dark:text-dark-800`,children:[(0,Q.jsx)(Ie,{className:`h-3 w-3`}),t.name,(0,Q.jsx)(`span`,{className:`tabular-nums text-gray-400 dark:text-dark-500`,children:t.documentCount??0}),t.shared?(0,Q.jsx)(`span`,{className:`text-[10px] uppercase text-gray-400 dark:text-dark-500`,children:e(`settings.documents.collections.shared`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{onClick:()=>d({id:t.id,name:t.name}),className:`text-gray-400 transition-colors hover:text-primary-500 dark:text-dark-500`,title:e(`settings.documents.collections.share`),"data-testid":`collection-share`,children:(0,Q.jsx)(de,{className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:()=>l(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(He,{className:`h-3 w-3`})})]})]},t.id))}),(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-1`,children:e(`settings.documents.library.title`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:e(`settings.documents.library.description`)}),g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.documents.library.empty`)}):(0,Q.jsx)(`div`,{className:`divide-y divide-gray-100 rounded-xl border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:g.map(t=>(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-3 px-3 py-2`,children:f===t.id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm text-red-700 dark:text-red-300`,children:e(`settings.documents.library.deleteConfirm`,{name:t.filename})}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,className:`text-red-600 border-red-200 hover:bg-red-50 dark:text-red-400 dark:border-red-800 dark:hover:bg-red-900/20`,onClick:()=>void b(t.id),children:e(`common.delete`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>p(null),children:e(`common.cancel`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(rt,{className:`h-4 w-4 shrink-0 text-gray-400 dark:text-dark-500`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-dark-900`,children:t.filename}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-400 dark:text-dark-500`,children:[c(t.size),` · `,t.sessionId?e(`settings.documents.library.chatScope`):e(`settings.documents.library.everyChatScope`)]})]}),t.processingStatus===`failed`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-red-100 px-2 py-0.5 text-xs font-medium text-red-700 dark:bg-red-900/30 dark:text-red-300`,title:t.processingError||e(`settings.documents.library.extractionFailed`),children:e(`settings.documents.library.extractionFailed`)}),t.processingStatus===`queued`&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium text-gray-600 dark:bg-dark-200 dark:text-dark-700`,children:e(`settings.documents.library.extractionQueued`)}),h.length>0&&(0,Q.jsxs)(`select`,{value:t.collectionId??``,onChange:e=>void x(t.id,e.target.value||null),className:`rounded-lg border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700 focus:outline-none dark:border-dark-300 dark:bg-dark-50 dark:text-dark-800`,children:[(0,Q.jsx)(`option`,{value:``,children:e(`settings.documents.collections.none`)}),h.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Q.jsx)(`button`,{onClick:()=>p(t.id),className:`text-gray-400 transition-colors hover:text-red-500 dark:text-dark-500`,title:e(`common.delete`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]})},t.id))}),u&&(0,Q.jsx)(qt,{resourceType:`knowledge-collection`,resourceId:u.id,resourceLabel:u.name,onClose:()=>d(null)})]})}function _n({label:e,value:t,min:n,max:r,step:i,description:a,format:o=e=>String(e),onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,`: `,o(t)]}),(0,Q.jsx)(`input`,{type:`range`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full range-slider`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:a})]})}function vn({generationOptions:e,generationScope:t,scopedModel:n,onGenerationScopeChange:r,embeddingSettings:i,effectiveEmbeddingSettings:a,embeddingModelOptions:s,embeddingStatus:c,onGenerationOptionChange:l,onEmbeddingSettingsChange:d,onResetGenerationOptions:f,onSaveGenerationOptions:p,onResetEmbeddingSettings:m,onSaveEmbeddingSettings:h}){let{t:g}=o(),[_,v]=(0,Z.useState)(!1),y=(0,Z.useId)(),b=(0,Z.useId)(),x=(0,Z.useId)(),S=[{value:`global`,label:g(`settings.generation.scopeAll`)},...n?[{value:`model`,label:g(`settings.generation.scopeModel`,{model:n})}]:[]];return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:g(`settings.generation.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:g(`settings.generation.description`)}),(0,Q.jsxs)(`div`,{className:`mb-6 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`label`,{htmlFor:b,className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.scopeLabel`)}),(0,Q.jsx)(zt,{id:b,value:t,onChange:e=>r(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:g(t===`model`?`settings.generation.scopeModelHint`:`settings.generation.scopeAllHint`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":_,"aria-controls":y,onClick:()=>v(e=>!e),className:`flex w-full items-center justify-between gap-4 p-4 text-left`,children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-gray-900 dark:text-gray-100`,children:g(`settings.generation.advancedSettings`)}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs text-gray-500 dark:text-gray-400`,children:g(`settings.generation.advancedSettingsDescription`)})]}),(0,Q.jsx)(Ce,{className:u(`h-4 w-4 flex-shrink-0 text-gray-500 transition-transform`,_&&`rotate-180`)})]}),_&&(0,Q.jsxs)(`div`,{id:y,className:`space-y-6 border-t border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(bn,{title:g(`settings.generation.coreParameters`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.temperature`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.temperature,placeholder:`0.8`,description:g(`settings.generation.temperatureDescription`),onChange:e=>l(`temperature`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.topP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.top_p,placeholder:`0.9`,description:g(`settings.generation.topPDescription`),onChange:e=>l(`top_p`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.topK`),hint:`(1-100)`,min:1,max:100,value:e.top_k,placeholder:`40`,integer:!0,description:g(`settings.generation.topKDescription`),onChange:e=>l(`top_k`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.minP`),hint:`(0.0-1.0)`,min:0,max:1,step:.05,value:e.min_p,placeholder:`0.0`,description:g(`settings.generation.minPDescription`),onChange:e=>l(`min_p`,e)})]}),(0,Q.jsxs)(bn,{title:g(`settings.generation.generationControl`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.maxTokens`),min:-1,max:4096,value:e.num_predict,placeholder:`128`,integer:!0,description:g(`settings.generation.maxTokensDescription`),onChange:e=>l(`num_predict`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.repeatPenalty`),hint:`(0.0-2.0)`,min:0,max:2,step:.1,value:e.repeat_penalty,placeholder:`1.1`,description:g(`settings.generation.repeatPenaltyDescription`),onChange:e=>l(`repeat_penalty`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.contextLength`),min:512,max:32768,step:512,value:e.num_ctx,placeholder:`2048`,integer:!0,description:g(`settings.generation.contextLengthDescription`),onChange:e=>l(`num_ctx`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.seed`),hint:`(${g(`settings.generation.optional`)})`,value:e.seed,placeholder:g(`settings.generation.random`),integer:!0,description:g(`settings.generation.seedDescription`),onChange:e=>l(`seed`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsx)(`label`,{htmlFor:x,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.generation.thinking`)}),(0,Q.jsx)(zt,{id:x,value:Qt(e.think),onChange:e=>l(`think`,Zt(e.target.value)),options:$t.map(e=>({value:e,label:g(`settings.generation.thinkingLevels.${e}`)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.thinkingDescription`)})]})]}),(0,Q.jsxs)(bn,{title:g(`settings.generation.advancedOptions`),children:[(0,Q.jsx)(xn,{label:g(`settings.generation.presencePenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.presence_penalty,placeholder:`0.0`,description:g(`settings.generation.presencePenaltyDescription`),onChange:e=>l(`presence_penalty`,e)}),(0,Q.jsx)(xn,{label:g(`settings.generation.frequencyPenalty`),hint:`(-2.0-2.0)`,min:-2,max:2,step:.1,value:e.frequency_penalty,placeholder:`0.0`,description:g(`settings.generation.frequencyPenaltyDescription`),onChange:e=>l(`frequency_penalty`,e)}),(0,Q.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[g(`settings.generation.stopSequences`),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 ms-1`,children:[`(`,g(`settings.generation.commaSeparated`),`)`]})]}),(0,Q.jsx)(`input`,{type:`text`,value:e.stop?.join(`, `)??``,onChange:e=>l(`stop`,e.target.value?e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,placeholder:`\\\\n, ###, STOP`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:g(`settings.generation.stopSequencesDescription`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:f,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:p,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),g(`settings.generation.saveOptions`)]})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:g(`settings.generation.embeddingSettings`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:g(`settings.generation.enableEmbeddings`)}),(0,Q.jsx)(X,{checked:i.enabled,onChange:e=>d(`enabled`,e)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:g(`settings.documents.embeddings.model`)}),(0,Q.jsx)(zt,{value:a.model,onChange:e=>d(`model`,e.target.value),options:s,disabled:!i.enabled})]}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.chunkSize`),hint:g(`settings.documents.embeddings.chunkSizeInTokens`),value:i.chunkSize,min:1,disabled:!i.enabled,onChange:e=>d(`chunkSize`,e)}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.chunkOverlap`),hint:g(`settings.documents.embeddings.chunkOverlapInTokens`),value:i.chunkOverlap,min:0,disabled:!i.enabled,onChange:e=>d(`chunkOverlap`,e)}),(0,Q.jsx)(Sn,{label:g(`settings.documents.embeddings.similarityThreshold`),value:i.similarityThreshold,min:0,max:1,step:.01,disabled:!i.enabled,onChange:e=>d(`similarityThreshold`,e)})]}),c&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.status`),`:`]}),(0,Q.jsx)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:c.available?g(`settings.documents.embeddings.available`):g(`settings.documents.embeddings.unavailable`)})]}),c.available&&(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-sm mt-1`,children:[(0,Q.jsxs)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:[g(`settings.documents.embeddings.chunksWithEmbeddings`),`:`]}),(0,Q.jsxs)(`span`,{className:`font-medium text-gray-900 dark:text-gray-100`,children:[c.chunksWithEmbeddings,` /`,` `,c.totalChunks]})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center mt-4`,children:[(0,Q.jsxs)(q,{onClick:m,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),g(`settings.generation.resetDefaults`)]}),(0,Q.jsxs)(q,{onClick:h,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),g(`settings.saveSettings`)]})]})]})}),(0,Q.jsx)(yn,{})]})})}function yn(){let{t:e}=o(),t=jt(e=>e.user),n=jt(e=>e.systemInfo),r=t?.role===`admin`||n?.requiresAuth===!1,i=x(e=>e.models),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(`8000`),[u,d]=(0,Z.useState)(`8`),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{if(!r)return;let t=!1;return gt.getCompactionConfig().then(e=>{t||!e.success||!e.data||(s(e.data.enabled),l(String(e.data.thresholdTokens)),d(String(e.data.keepRecentMessages)),p(e.data.model),h(e.data.prompt),_(!0))}).catch(()=>{t||R.error(e(`settings.compaction.loadFailed`))}),()=>{t=!0}},[r,e]),!r)return null;let b=i.filter(e=>!e.isPersona&&!e.isAgent),S=[{value:``,label:e(`settings.compaction.sessionModelOption`)},...b.map(e=>({value:e.name,label:e.isPlugin?`${e.name} · ${e.pluginName||e.pluginId}`:`${e.name} · Ollama`})),...f&&!b.some(e=>e.name===f)?[{value:f,label:`${f} (current)`}]:[]],C=async(t=a)=>{let n=Number(c);if(!Number.isInteger(n)||n<500||n>1e6){R.error(e(`settings.compaction.thresholdInvalid`));return}let r=Number(u);if(!Number.isInteger(r)||r<2||r>200){R.error(e(`settings.compaction.keepRecentInvalid`));return}y(!0);try{let i=await gt.setCompactionConfig({enabled:t,thresholdTokens:n,keepRecentMessages:r,model:f,prompt:m});if(!i.success||!i.data)throw Error(i.error||e(`settings.compaction.saveFailed`));s(i.data.enabled),l(String(i.data.thresholdTokens)),d(String(i.data.keepRecentMessages)),p(i.data.model),h(i.data.prompt),R.success(e(`settings.compaction.saved`))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.compaction.saveFailed`))}finally{y(!1)}};return(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 mb-1`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(`settings.compaction.title`)}),(0,Q.jsx)(X,{checked:a,onChange:e=>{C(e)},disabled:v||!g})]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-4`,children:e(`settings.compaction.description`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.thresholdLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:500,max:1e6,step:500,value:c,onChange:e=>l(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.thresholdDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.keepRecentLabel`)}),(0,Q.jsx)(`input`,{type:`number`,min:2,max:200,value:u,onChange:e=>d(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.keepRecentDescription`)})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.modelLabel`)}),(0,Q.jsx)(zt,{value:f,onChange:e=>p(e.target.value),options:S}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.compaction.promptLabel`)}),(0,Q.jsx)(Rt,{value:m,onChange:e=>h(e.target.value),rows:5,placeholder:e(`settings.compaction.promptPlaceholder`),spellCheck:!1}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:e(`settings.compaction.promptDescription`,{previousSummaryVariable:`{{PREVIOUS_SUMMARY}}`,messagesVariable:`{{MESSAGES}}`})})]})]}),(0,Q.jsx)(`div`,{className:`flex justify-end items-center mt-4`,children:(0,Q.jsxs)(q,{onClick:()=>void C(),disabled:v||!g,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),e(`settings.saveSettings`)]})})]})})}function bn({title:e,children:t}){return(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-md font-medium text-gray-900 dark:text-gray-100 mb-4`,children:e}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:t})]})}function xn({label:e,value:t,placeholder:n,description:r,hint:i,min:a,max:o,step:s,integer:c=!1,onChange:l}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,i&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:i})]}),(0,Q.jsx)(`input`,{type:`number`,min:a,max:o,step:s,value:t??``,placeholder:n,onChange:e=>l(e.target.value?c?parseInt(e.target.value):parseFloat(e.target.value):void 0),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:r})]})}function Sn({label:e,value:t,min:n,max:r,step:i,hint:a,disabled:o,onChange:s}){return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[e,a&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 ms-1`,children:a})]}),(0,Q.jsx)(`input`,{type:`number`,min:n,max:r,step:i,value:t,onChange:e=>s(Number(e.target.value)),className:`w-full px-3 py-2 border border-gray-300 dark:border-dark-300 rounded-md focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-dark-200 text-gray-900 dark:text-gray-100`,disabled:o})]})}function Cn({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,sizes:a,qualities:s,styles:c,onSettingChange:l,onModelChange:u,onReset:d,onSave:f}){let{t:p}=o(),m=At(r,n.model,n.pluginId);return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:p(`settings.imageGen.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(z,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:p(`settings.imageGen.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(ut,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:p(`settings.imageGen.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:p(`settings.imageGen.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:p(`settings.imageGen.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:p(`settings.imageGen.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t.enabled,onChange:e=>l(`enabled`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:p(`settings.imageGen.configuration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.model`)}),(0,Q.jsx)(zt,{value:m?K(m):``,onChange:e=>{let t=r.find(t=>K(t)===e.target.value);t&&u(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:p(`settings.model.selectModel`)},...r.map(e=>({value:K(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.modelDescription`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:m?.config?.size_label||p(`settings.imageGen.size`)}),(0,Q.jsx)(zt,{value:n.size,onChange:e=>l(`size`,e.target.value),disabled:!t.enabled||a.length===0,options:[...a.length>0?a.map(e=>({value:e,label:e})):[{value:`1024x1024`,label:`1024x1024`},{value:`1792x1024`,label:`1792x1024`},{value:`1024x1792`,label:`1024x1792`}]]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.sizeDescription`)})]}),s.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.quality`)}),(0,Q.jsx)(zt,{value:n.quality,onChange:e=>l(`quality`,e.target.value),disabled:!t.enabled,options:s.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.qualityDescription`)})]}),c.length>0&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:p(`settings.imageGen.style`)}),(0,Q.jsx)(zt,{value:n.style,onChange:e=>l(`style`,e.target.value),disabled:!t.enabled,options:c.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)}))}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:p(`settings.imageGen.styleDescription`)})]})]})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:p(`settings.imageGen.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,p(`settings.imageGen.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(q,{onClick:d,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),p(`common.reset`)]}),(0,Q.jsxs)(q,{onClick:f,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),p(`settings.saveSettings`)]})]})]})]})})}var wn=192e3,Tn=(e,t)=>e.isPlugin&&e.pluginId?e.pluginId:t,En=()=>{let{t:e}=o(),t=x(e=>e.models),n=x(e=>e.loadModels),[r,i]=(0,Z.useState)([]),[a,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)({}),[p,m]=(0,Z.useState)(``),[h,_]=(0,Z.useState)(`all`),[v,y]=(0,Z.useState)(null),[S,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(null),k=(0,Z.useRef)(null),A=(0,Z.useRef)(null),j=(0,Z.useMemo)(()=>t.filter(e=>!e.isPersona&&!e.isAgent),[t]);(0,Z.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await G.getModelVisibility();if(e||!t.success||!t.data)return;let{hidden:n,order:r,starred:a,metadata:o}=t.data;i(n??[]),s(r??[]),l(a??[]),f(o??{})}catch{}})(),()=>{e=!0}},[]);let M=(0,Z.useMemo)(()=>new Set(r),[r]),ee=(0,Z.useMemo)(()=>new Set(c),[c]),N=(0,Z.useMemo)(()=>g(j,a,c),[j,a,c]),P=(0,Z.useMemo)(()=>{let e=p.trim().toLowerCase();return N.filter(t=>{let n=b(t);if(h===`local`&&t.isPlugin||h===`provider`&&!t.isPlugin||h===`hidden`&&!M.has(n))return!1;if(!e)return!0;let r=d[n]?.label??``;return t.name.toLowerCase().includes(e)||r.toLowerCase().includes(e)||Tn(t,`ollama`).toLowerCase().includes(e)})},[N,p,h,M,d]),te=async(e,t)=>{let n=r,a=t?n.filter(t=>t!==e):[...n,e];i(a),await le({hidden:a},()=>i(n))},ne=e=>{let t=new Set(P.map(b)),n=r,a=e?n.filter(e=>!t.has(e)):[...new Set([...n,...t])];i(a),le({hidden:a},()=>i(n))},re=(e,t)=>{let n=c,r=t?[e,...n.filter(t=>t!==e)]:n.filter(t=>t!==e);l(r),le({starred:r},()=>l(n))},ie=(e,t,n)=>{if(e===t)return;let r=N.map(b),i=r.indexOf(e);if(i===-1)return;r.splice(i,1);let o=r.indexOf(t);if(o===-1)return;r.splice(n===`after`?o+1:o,0,e);let c=a;s(r),le({order:r},()=>s(c))},ae=(e,t,n)=>{let r={...e,[t]:{...e[t],...n}};return!r[t].label&&!r[t].avatar&&delete r[t],r},F=(e,t,n=!1)=>{let r=d,i=ae(r,e,t);f(i),n&&le({metadata:i},()=>f(r))},se=e=>{A.current=e,k.current?.click()},ce=t=>{let n=t.target.files?.[0],r=A.current;if(t.target.value=``,!n||!r)return;if(!n.type.startsWith(`image/`)){R.error(e(`modelManager.catalog.pictureInvalid`));return}if(n.size>wn){R.error(e(`modelManager.catalog.pictureTooLarge`));return}let i=new FileReader;i.onload=()=>{typeof i.result==`string`&&F(r,{avatar:i.result},!0)},i.readAsDataURL(n)},le=async(t,r)=>{w(!0);try{let i=await G.setModelVisibility(t);if(!i.success){r(),R.error(i.error??e(`modelManager.catalog.visibilityFailed`));return}await n()}catch(t){r(),R.error(C(t,e(`modelManager.catalog.visibilityFailed`)))}finally{w(!1)}},I=[{id:`all`,label:e(`modelManager.catalog.filterAll`)},{id:`local`,label:e(`modelManager.catalog.filterLocal`)},{id:`provider`,label:e(`modelManager.catalog.filterProviders`)},{id:`hidden`,label:e(`modelManager.catalog.filterHidden`)}];return(0,Q.jsxs)(`div`,{className:`space-y-3`,"data-testid":`model-catalog`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,Q.jsxs)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:[e(`modelManager.sections.catalog`),(0,Q.jsx)(`span`,{className:`ms-2 text-xs font-normal text-gray-500 dark:text-gray-400`,children:j.length})]}),S&&(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`modelManager.catalog.saving`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-[180px] flex-1`,children:[(0,Q.jsx)(_e,{className:`pointer-events-none absolute start-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(Wt,{value:p,onChange:e=>m(e.target.value),placeholder:e(`modelManager.catalog.searchPlaceholder`),className:`ps-9`})]}),(0,Q.jsx)(`select`,{value:h,onChange:e=>_(e.target.value),className:`h-9 rounded-lg border border-gray-200 bg-white px-2 text-xs text-gray-700 dark:border-dark-300 dark:bg-dark-100 dark:text-gray-200`,"aria-label":e(`modelManager.catalog.filterAll`),children:I.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.label},e.id))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>ne(!0),children:e(`modelManager.catalog.enableAll`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>ne(!1),children:e(`modelManager.catalog.disableAll`)})]}),(0,Q.jsx)(`input`,{ref:k,type:`file`,accept:`image/*`,onChange:ce,className:`hidden`}),(0,Q.jsxs)(`div`,{className:`divide-y divide-gray-100 rounded-lg border border-gray-200 dark:divide-dark-200/60 dark:border-dark-300`,children:[P.length===0&&(0,Q.jsx)(`p`,{className:`px-3 py-6 text-center text-xs text-gray-500 dark:text-gray-400`,children:j.length===0?e(`modelManager.catalog.noModels`):e(`modelManager.catalog.empty`)}),P.map(t=>{let n=b(t),r=d[n]??{},i=!M.has(n),a=ee.has(n),o=v===n,s=e(a?`modelManager.catalog.unstar`:`modelManager.catalog.star`,{name:r.label||t.name});return(0,Q.jsxs)(`div`,{"data-testid":`model-catalog-row`,draggable:!0,onDragStart:()=>E(n),onDragEnd:()=>{E(null),O(null)},onDragOver:e=>{if(e.preventDefault(),!T||T===n)return;let t=e.currentTarget.getBoundingClientRect(),r=e.clientY-t.top<t.height/2?`before`:`after`;O(e=>e?.key===n&&e.edge===r?e:{key:n,edge:r})},onDrop:e=>{e.preventDefault(),T&&ie(T,n,D?.key===n?D.edge:`before`),E(null),O(null)},className:u(`relative flex flex-col gap-2 px-3 py-2`,T===n&&`opacity-50`),children:[D?.key===n&&T&&T!==n&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:u(`pointer-events-none absolute inset-x-0 h-0.5 bg-primary-500`,D.edge===`before`?`top-0`:`bottom-0`)}),(0,Q.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 pe-1`,children:[(0,Q.jsx)(oe,{className:`h-4 w-4 shrink-0 cursor-grab text-gray-300 dark:text-dark-500`,"aria-hidden":`true`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>se(n),title:e(`modelManager.catalog.setPicture`),className:`flex h-7 w-7 shrink-0 items-center justify-center overflow-hidden rounded-full border border-gray-200 bg-gray-50 text-gray-400 dark:border-dark-300 dark:bg-dark-200`,children:r.avatar?(0,Q.jsx)(`img`,{src:r.avatar,alt:``,className:`h-full w-full object-cover`}):(0,Q.jsx)(ut,{className:`h-3.5 w-3.5`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block truncate text-sm text-gray-900 dark:text-gray-100`,children:r.label||t.name}),(0,Q.jsxs)(`span`,{className:`block truncate text-[11px] text-gray-500 dark:text-gray-400`,children:[r.label?`${t.name} · `:``,Tn(t,e(`modelManager.catalog.providerOllama`))]})]}),!i&&(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-500 dark:bg-dark-200 dark:text-gray-400`,children:e(`modelManager.catalog.hidden`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>re(n,!a),"aria-pressed":a,title:s,"aria-label":s,className:u(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-1 dark:hover:bg-dark-200 dark:focus-visible:ring-offset-dark-100`,a?`text-primary-600 dark:text-primary-400`:`text-gray-400 hover:text-gray-700 dark:hover:text-gray-200`),children:(0,Q.jsx)(he,{className:u(`h-4 w-4`,a&&`fill-current`),"aria-hidden":`true`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>y(o?null:n),title:e(`modelManager.catalog.rename`),className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`,children:o?(0,Q.jsx)(He,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(Ge,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void te(n,!i),"aria-pressed":!i,title:e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),"aria-label":e(i?`modelManager.catalog.hide`:`modelManager.catalog.show`),className:u(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors`,i?`text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-dark-200`:`text-warning-600 hover:bg-gray-100 dark:text-warning-500 dark:hover:bg-dark-200`),children:i?(0,Q.jsx)(Pe,{className:`h-4 w-4`}):(0,Q.jsx)(ke,{className:`h-4 w-4`})})]}),o&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ps-8`,children:[(0,Q.jsx)(Wt,{value:r.label??``,onChange:e=>F(n,{label:e.target.value}),onBlur:e=>F(n,{label:e.target.value},!0),placeholder:t.name,className:`h-8 max-w-xs text-xs`}),r.avatar&&(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>F(n,{avatar:``},!0),children:e(`modelManager.catalog.clearPicture`)})]})]},n)})]})]})};function Dn({models:e,selectedModel:t,selectedProviderType:n,selectedProviderId:r,systemMessage:i,tempSystemMessage:a,loading:s,preferences:c,currentVisionModel:l,visionModelOptions:u,currentTaskModel:d,autoTitleTaskModelOptions:f,onModelChange:p,onSystemMessageChange:h,onSystemMessageSave:g,onAutoTitleChange:b,onAutoTitleTaskModelChange:x,onVisionModelChange:S}){let{user:C,systemInfo:w}=jt(),T=C?.role===`admin`||w?.requiresAuth===!1,{t:E}=o(),D={model:t,providerType:n,providerId:r},O=m(e,D),k=t?y(O,D):``,A=v(O,D);return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:E(`settings.model.title`)}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.defaultModel`)}),(0,Q.jsx)(zt,{value:k,onChange:p,options:[{value:``,label:E(`settings.model.selectModel`)},...O.map(e=>({value:_(e),label:e.isLegacySelection?`${e.name} (provider not recorded${e.isUnavailable?`, unavailable`:``})`:e.isPersona?`${e.personaName} (${E(`settings.model.persona`)})`:e.isPlugin?`${e.name} (${e.pluginName||e.pluginId}${e.isUnavailable?`, unavailable`:``})`:`${e.name} (Ollama${e.isUnavailable?`, unavailable`:``})`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.defaultModelDescription`)})]}),t&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.currentModelInfo`)}),(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,Q.jsx)(On,{label:`${E(`settings.model.name`)}:`,value:t,truncate:!0}),A?.details&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(On,{label:`${E(`settings.model.size`)}:`,value:A.details.parameter_size}),(0,Q.jsx)(On,{label:`${E(`settings.model.family`)}:`,value:A.details.family}),(0,Q.jsx)(On,{label:`${E(`settings.model.format`)}:`,value:A.details.format})]})]})})]}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.systemMessage.title`)}),(0,Q.jsx)(Rt,{value:a,onChange:h,placeholder:E(`settings.systemMessage.placeholder`),className:`w-full min-h-[100px] bg-gray-50 dark:bg-dark-50 border-gray-200 dark:border-dark-300 text-gray-900 dark:text-gray-100`,rows:4}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mt-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.systemMessage.description`)}),(0,Q.jsx)(q,{onClick:g,size:`sm`,disabled:s||a===i,children:E(`common.save`)})]})]})]}),(0,Q.jsx)(`div`,{className:`mt-6`,children:(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:E(`settings.model.specializedModels`,{defaultValue:`Specialized Models`})}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-1 gap-5 lg:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.visionModel`,{defaultValue:`Vision Model`})}),(0,Q.jsx)(zt,{"data-testid":`vision-model-select`,value:l,onChange:e=>S(e.target.value),options:u}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.visionModelDescription`,{defaultValue:`Used automatically whenever the outgoing chat context contains images. Choose a model that supports image input.`})})]}),(0,Q.jsxs)(`div`,{className:`lg:border-s lg:border-gray-200 lg:ps-5 dark:lg:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col pe-4`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:E(`settings.model.autoTitle.enable`)}),(0,Q.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:E(`settings.model.autoTitle.enableDescription`)})]}),(0,Q.jsx)(X,{checked:c.titleSettings?.autoTitle||!1,onChange:b})]}),c.titleSettings?.autoTitle&&(0,Q.jsxs)(`div`,{className:`mt-4`,children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:E(`settings.model.autoTitle.taskModel`)}),(0,Q.jsx)(zt,{value:d,onChange:e=>x(e.target.value),options:f}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:E(`settings.model.autoTitle.taskModelDescription`)})]})]})]})]})})]}),T&&(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsx)(En,{})})]})}function On({label:e,value:t,truncate:n=!1}){return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-white dark:bg-dark-100 rounded-md border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e}),(0,Q.jsx)(`span`,{className:n?`text-sm font-semibold text-gray-900 dark:text-gray-100 truncate ms-2`:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t})]})}var kn=[{titleKey:`keyboard.groups.general`,rows:[{labelKey:`keyboard.openPalette`,keys:[`mod`,`K`]},{labelKey:`keyboard.openSettings`,keys:[`mod`,`,`]},{labelKey:`keyboard.toggleDarkMode`,keys:[`mod`,`D`]},{labelKey:`keyboard.showShortcuts`,keys:[`?`]},{labelKey:`keyboard.closeModals`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.navigation`,rows:[{labelKey:`keyboard.toggleSidebar`,keys:[`mod`,`B`]},{labelKey:`keyboard.newChat`,keys:[`mod`,`⇧`,`O`]},{labelKey:`keyboard.newWork`,keys:[`mod`,`⇧`,`U`]}]},{titleKey:`keyboard.groups.chat`,rows:[{labelKey:`keyboard.actions.sendMessage`,keys:[`↩`]},{labelKey:`keyboard.actions.newLine`,keys:[`⇧`,`↩`]},{labelKey:`keyboard.actions.saveEdit`,keys:[`↩`]},{labelKey:`keyboard.actions.cancelEdit`,keys:[`Esc`]}]},{titleKey:`keyboard.groups.workspace`,rows:[{labelKey:`keyboard.actions.saveFile`,keys:[`mod`,`S`]},{labelKey:`keyboard.actions.formatCode`,keys:[`⌥`,`⇧`,`F`]}]}];function An(){let{t:e}=o(),t=s()?`⌘`:`Ctrl`,n=s()?`⌥`:`Alt`,r=e=>e===`mod`?t:e===`⌥`?n:e;return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:e(`keyboard.title`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-gray-400`,children:e(`keyboard.description`)})]}),kn.map(t=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:e(t.titleKey)}),(0,Q.jsx)(`div`,{className:`divide-y divide-gray-200 overflow-hidden rounded-lg border border-gray-200 dark:divide-dark-300 dark:border-dark-300`,children:t.rows.map(n=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 bg-white px-4 py-2.5 dark:bg-dark-100`,children:[(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e(n.labelKey)}),(0,Q.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:n.keys.map((e,t)=>(0,Q.jsx)(`kbd`,{className:`rounded border border-gray-300 bg-gray-100 px-2 py-1 font-mono text-xs text-gray-700 dark:border-dark-400 dark:bg-dark-200 dark:text-gray-300`,children:r(e)},`${n.labelKey}-${e}-${t}`))})]},`${t.titleKey}-${n.labelKey}`))})]},t.titleKey))]})}var jn=8;function Mn(e,t){let n=e.trim();if(!n)return null;let r;try{r=new URL(n)}catch{return`invalid-url`}return r.protocol!==`http:`&&r.protocol!==`https:`?`insecure-url`:t?.toLowerCase().endsWith(`base_url`)&&(r.search||r.hash)?`query-or-fragment`:null}function Nn(e){try{return new URL(e.trim()).protocol===`http:`}catch{return!1}}function Pn(e){let t=e.toLowerCase();return t===`endpoint`||t===`base_url`||t===`api_url`||t===`models_endpoint`||t.endsWith(`_endpoint`)||t.endsWith(`_base_url`)}function Fn(e){let t=e.trim();if(!t.startsWith(`/`)||t.startsWith(`//`)||t.includes(`://`)||t.includes(`\\`)||t.includes(`?`)||t.includes(`#`))return!1;let n=t;for(let e=0;e<=jn;e+=1){let t;try{t=decodeURIComponent(n)}catch{return!1}if(t===n)return!n.includes(`\\`)&&!n.includes(`?`)&&!n.includes(`#`)&&!n.split(`/`).some(e=>e===`.`||e===`..`);if(e===jn)return!1;n=t}return!1}var In=new Set([`api_mode`,`api_path`,`endpoint`,`base_url`,`api_url`,`image_endpoint`,`embedding_endpoint`,`tts_endpoint`,`model`,`model_id`,`models_endpoint`]);function Ln(e){let t=new Set(In),n=e?.capabilities;for(let e of Object.values(n||{})){let n=e?.config?.endpoint_variable??e?.endpoint_variable;typeof n==`string`&&n.trim()&&t.add(n)}return t}function Rn(e,t){return Ln(t).has(e)}function zn(e,t){if(e.default!==void 0)return e.default;if(!t)return;if(e.name===`endpoint`||e.name===`api_url`)return t.endpoint||void 0;if(e.name===`base_url`)return t.base_url;if(e.name===`api_path`)return t.api_path;if(e.name===`api_mode`){if(t.api_mode)return t.api_mode;try{return new URL(t.endpoint).pathname.replace(/\/+$/,``).endsWith(`/responses`)?`responses`:`chat_completions`}catch{return`chat_completions`}}let n=t.capabilities;for(let t of Object.values(n||{}))if((t?.config?.endpoint_variable??t?.endpoint_variable)===e.name&&typeof t.endpoint==`string`)return t.endpoint}function Bn(e,t){let n=[],r=[];for(let i of e)(Rn(i.name,t)?n:r).push(i);return{connection:n,advanced:r}}function Vn(e,t){let n={};for(let r of e){let e=t[r.name];n[r.name]=e?.has_value&&!e.is_sensitive?e.value:``}return n}function Hn(e,t,n,r,i){let a=new Set(e.map(e=>e.name)),o={},s=[];for(let c of n){if(!a.has(c))continue;let n=e.find(e=>e.name===c);if(!n)continue;let l=t[c],u=r[c],d=typeof l==`string`&&l.trim().length===0,f=zn(n,i),p=f!==void 0&&(typeof l==`string`&&typeof f==`string`?l.trim()===f.trim():Object.is(l,f));if(d||p){if(n.sensitive&&u?.has_value)continue;u?.has_value&&s.push(c);continue}o[c]=l}return{variables:o,unset:s}}V(`components:hugging-face-model-browser`);var Un=({plugin:e})=>{let{t}=o(),n=r(),i=jt(e=>e.user),a=jt(e=>e.systemInfo)?.requiresAuth===!1||i?.role===`admin`,{pluginVariables:s,fetchPluginVariables:c,updatePluginVariables:l,resetPluginVariables:d,loadPlugins:f}=Mt(),[p,m]=(0,Z.useState)({}),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(new Set),[x,S]=(0,Z.useState)({}),[C,w]=(0,Z.useState)(new Set),[T,E]=(0,Z.useState)(!1),D=Z.useId(),O=Z.useId(),k=(0,Z.useMemo)(()=>e.variables||[],[e.variables]),A=(0,Z.useMemo)(()=>Ln(e),[e]),j=(0,Z.useMemo)(()=>a?k:k.filter(e=>!A.has(e.name)),[a,A,k]),M=(0,Z.useMemo)(()=>s[e.id]||{},[s,e.id]),N=(0,Z.useMemo)(()=>Bn(j,e),[e,j]);(0,Z.useEffect)(()=>{c(e.id)},[c,e.id]);let P=JSON.stringify(M),te=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let t=j.map(e=>`${e.name}:${e.type}`).join(`|`),n=`${e.id}:${t}:${P}`;if(te.current===n)return;te.current=n;let r=JSON.parse(P);m(e=>{let t=Vn(j,r);for(let n of C)n in e&&(t[n]=e[n]);return t})},[C,e.id,j,P]);let ne=async()=>{let r={};for(let n of j){if(!C.has(n.name))continue;let i=p[n.name],a=typeof i==`string`&&i.trim().length===0,o=M[n.name],s=zn(n,e);if(a&&n.required&&s===void 0&&!(n.sensitive&&o?.has_value)){r[n.name]=t(`pluginManager.variables.required`,`A value is required`);continue}if(Pn(n.name)&&typeof i==`string`&&!a){let e=Mn(i,n.name);e===`invalid-url`?r[n.name]=t(`pluginManager.variables.invalidUrl`,`Enter a valid full API endpoint URL, for example https://provider.example/v1/chat/completions`):e===`insecure-url`?r[n.name]=t(`pluginManager.variables.insecureUrl`,`API endpoints must use HTTP or HTTPS.`):e===`query-or-fragment`&&(r[n.name]=t(`pluginManager.variables.invalidBaseUrl`,`Base URLs cannot contain a query string or fragment.`))}if(n.name===`api_path`&&typeof i==`string`&&i.length>0&&!Fn(i)&&(r[n.name]=t(`pluginManager.variables.invalidApiPath`,`Must start with / and contain no URL, query, fragment, or .. segment`)),n.type===`number`&&!a){let e=Number(i);n.min!==void 0&&e<n.min&&(r[n.name]=`Min: ${n.min}`),n.max!==void 0&&e>n.max&&(r[n.name]=`Max: ${n.max}`)}n.type===`string`&&typeof i==`string`&&i.length>2048&&(r[n.name]=t(`pluginManager.variables.tooLong`,`Value is too long`))}if(S(r),Object.keys(r).length>0)return;let i=Hn(j,p,C,M,e),a=new Set(C),o=Object.fromEntries([...Object.keys(i.variables).map(e=>[e,!0]),...i.unset.map(e=>[e,!0])]);if(Object.keys(i.variables).length===0&&i.unset.length===0){w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),L.success(t(`pluginManager.variables.saved`,`Variables saved`));return}g(!0);try{await l(e.id,i.variables,i.unset)?(Object.keys(o).some(e=>A.has(e))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(e=>{let t={...e};for(let e of j)e.sensitive&&a.has(e.name)&&(t[e.name]=``);return t}),b(e=>{let t=new Set(e);for(let e of j)e.sensitive&&a.has(e.name)&&t.delete(e.name);return t}),w(e=>{let t=new Set(e);for(let e of a)t.delete(e);return t}),S(e=>{let t={...e};for(let e of a)delete t[e];return t}),L.success(t(`pluginManager.variables.saved`,`Variables saved`))):L.error(t(`pluginManager.variables.saveFailed`,`Failed to save variables`))}finally{g(!1)}},re=async()=>{v(!0);try{if(!await d(e.id)){L.error(t(`pluginManager.variables.resetFailed`,`Failed to reset variables`));return}j.some(e=>A.has(e.name))&&(await f(),await Promise.all([n.invalidateQueries({queryKey:[`image-gen-data`]}),n.invalidateQueries({queryKey:[`tts-data`]})])),m(Vn(j,{})),w(new Set),S({}),b(new Set),L.success(t(`pluginManager.variables.reset`,`Variables reset to defaults`))}finally{v(!1)}},ie=(e,t)=>{m(n=>({...n,[e]:t})),w(t=>new Set(t).add(e)),S(t=>{if(!t[e])return t;let n={...t};return delete n[e],n})},oe=e=>{b(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},F=e=>{let t=j.indexOf(e),n=`${O}-${t}`;return{controlId:n,descriptionId:`${n}-description`,errorId:`${n}-error`,warningId:`${n}-http-warning`}},se=t=>{if(!Pn(t.name))return!1;let n=p[t.name],r=zn(t,e),i=typeof n==`string`&&n.trim()?n:r;return typeof i==`string`&&Nn(i)},ce=n=>{let r=p[n.name],i=n.sensitive??!1,a=y.has(n.name),o=M[n.name],{controlId:s,descriptionId:c,errorId:l,warningId:d}=F(n),f=!!x[n.name],m=se(n),g=n.name===`endpoint`||n.name===`api_url`,v=[n.description||g?c:void 0,m?d:void 0,f?l:void 0].filter(Boolean).join(` `)||void 0,b=zn(n,e),S=b===void 0?t(`pluginManager.variables.inherited`,`Use provider default`):t(`pluginManager.variables.inheritedValue`,{defaultValue:`Use provider default ({{value}})`,value:String(b)}),C=u(`w-full px-3 py-2 rounded-lg border text-sm`,`bg-white dark:bg-dark-100`,`border-gray-300 dark:border-dark-300`,`text-gray-900 dark:text-dark-700`,`focus:outline-none focus:ring-2 focus:ring-blue-500/20`);switch(n.type){case`boolean`:return(0,Q.jsxs)(`select`,{id:s,value:r===``?``:String(!!r),onChange:e=>ie(n.name,e.target.value===``?``:e.target.value===`true`),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(0,Q.jsx)(`option`,{value:`true`,children:t(`pluginManager.variables.enabled`,`Enabled`)}),(0,Q.jsx)(`option`,{value:`false`,children:t(`pluginManager.variables.disabled`,`Disabled`)})]});case`select`:return(0,Q.jsxs)(`select`,{id:s,value:String(r??``),onChange:e=>ie(n.name,e.target.value),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_,children:[(0,Q.jsx)(`option`,{value:``,children:S}),(n.options||[]).map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]});case`number`:return(0,Q.jsx)(`input`,{id:s,type:`number`,value:r===``?``:Number(r),min:n.min,max:n.max,placeholder:S,onChange:e=>ie(n.name,e.target.value===``?``:Number(e.target.value)),className:C,"aria-invalid":f,"aria-describedby":v,disabled:h||_});default:return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`input`,{id:s,type:i&&!a?`password`:`text`,value:i&&o?.has_value&&r===``?``:String(r??``),placeholder:i&&o?.has_value?t(`pluginManager.variables.sensitiveSet`,`Value is set (enter new value to change)`):S,onChange:e=>ie(n.name,e.target.value),className:u(C,i&&`pr-10`),"aria-invalid":f,"aria-describedby":v,disabled:h||_}),i&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>oe(n.name),"aria-controls":s,"aria-label":a?t(`pluginManager.variables.hideValue`,{defaultValue:`Hide {{label}} value`,label:n.label}):t(`pluginManager.variables.showValue`,{defaultValue:`Show {{label}} value`,label:n.label}),disabled:h||_,className:`absolute end-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50 dark:hover:text-gray-300`,children:a?(0,Q.jsx)(ke,{className:`w-4 h-4`}):(0,Q.jsx)(Pe,{className:`w-4 h-4`})})]})}},le=e=>{let{controlId:n,descriptionId:r,errorId:i,warningId:a}=F(e),o=e.name===`endpoint`||e.name===`api_url`,s=se(e);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`label`,{htmlFor:n,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[o?t(`pluginManager.variables.fullApiEndpoint`,`Full API endpoint URL`):e.label,e.required&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`text-red-500 ml-1`,children:`*`})]}),(e.description||o)&&(0,Q.jsxs)(`p`,{id:r,className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:[e.description,e.description&&o&&` `,o&&t(`pluginManager.variables.endpointHelp`,`Enter the complete request URL, including its operation path (for example, /v1/chat/completions), not only the provider base URL.`)]}),ce(e),s&&(0,Q.jsxs)(`p`,{id:a,role:`status`,className:`mt-1 flex items-start gap-1 text-xs text-amber-700 dark:text-amber-400`,children:[(0,Q.jsx)(Ne,{"aria-hidden":`true`,className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{children:t(`pluginManager.variables.httpWarning`,`HTTP does not encrypt credentials or traffic. Use it only on a trusted network.`)})]}),x[e.name]&&(0,Q.jsx)(`p`,{id:i,role:`alert`,className:`text-xs text-red-500 mt-1`,children:x[e.name]})]},e.name)};return(0,Q.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-700`,children:[N.connection.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:t(`pluginManager.variables.connection`,`Connection`)}),N.connection.map(le)]}),N.advanced.length>0&&(0,Q.jsxs)(`div`,{className:u(N.connection.length>0&&`mt-4 border-t pt-4`,`border-gray-200 dark:border-gray-700`),children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-expanded":T,"aria-controls":D,onClick:()=>E(e=>!e),className:`flex w-full items-center justify-between rounded-md py-1 text-left text-sm font-medium text-gray-700 hover:text-gray-950 dark:text-gray-300 dark:hover:text-white`,children:[(0,Q.jsxs)(`span`,{children:[t(`pluginManager.variables.advanced`,`Advanced parameters`),` (`,N.advanced.length,`)`]}),(0,Q.jsx)(Ce,{className:u(`h-4 w-4 transition-transform`,T&&`rotate-180`)})]}),T&&(0,Q.jsx)(`div`,{id:D,className:`mt-3 space-y-3`,children:N.advanced.map(le)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-4`,children:[(0,Q.jsxs)(q,{size:`sm`,onClick:ne,disabled:h||_||C.size===0,className:`gap-1.5`,children:[(0,Q.jsx)(ee,{className:`w-3.5 h-3.5`}),h?t(`pluginManager.variables.saving`,`Saving...`):t(`pluginManager.variables.save`,`Save`)]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:re,disabled:h||_,className:`gap-1.5`,children:[(0,Q.jsx)(ae,{className:`w-3.5 h-3.5`}),t(`pluginManager.variables.resetDefaults`,`Reset to Defaults`)]})]})]})};function Wn({plugins:e,loading:t,uploading:n,error:r,hasKeys:i,showUploadForm:a,showJsonForm:s,jsonInput:c,fileInputRef:l,expandedPluginId:u,pluginApiKeys:d,showApiKey:f,savingApiKey:p,refreshingPluginIds:m,onClearError:g,onShowUploadFormChange:_,onShowJsonFormChange:v,onJsonInputChange:y,onFileUpload:b,onJsonSubmit:x,onExpandedPluginChange:S,onPluginApiKeyChange:C,onShowApiKeyChange:w,onActivatePlugin:E,onDeletePlugin:D,onExportPlugin:O,onSaveApiKey:k,onDeleteApiKey:A,onRefreshModels:j}){let{t:M}=o(),ee=jt(e=>e.user),N=jt(e=>e.systemInfo)?.requiresAuth===!1||ee?.role===`admin`,[P,te]=(0,Z.useState)(``),[ne,re]=(0,Z.useState)(null),ie=(0,Z.useId)(),ae=(0,Z.useMemo)(()=>e.filter(e=>h(e,P)),[e,P]),oe=ne&&e.some(e=>e.id===ne)?ne:e[0]?.id??null,F=e.find(e=>e.id===oe)??null,se=e=>{e!==oe&&(S(null),re(e))};return(0,Q.jsx)(`div`,{className:`space-y-6`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`mb-4`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providerConnections`,{defaultValue:`Provider connections`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.providerConnectionsDescription`,{defaultValue:`Connect, configure, and inspect model providers through plugins.`})})]}),r&&(0,Q.jsx)(`div`,{className:`p-4 bg-primary-50/80 dark:bg-primary-950/25 border border-primary-200 dark:border-primary-800/50 rounded-lg mb-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`p`,{className:`text-primary-800 dark:text-primary-200`,children:r}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:g,className:`text-primary-700 hover:text-primary-900 dark:text-primary-300 dark:hover:text-primary-100`,children:(0,Q.jsx)(He,{className:`h-4 w-4`})})]})}),N&&(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.addNew`)}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!a),disabled:t||n,children:[(0,Q.jsx)(Je,{className:`h-4 w-4 me-2`}),M(`settings.plugins.upload`)]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>v(!s),disabled:t,children:M(`settings.plugins.addJson`)})]})]}),a&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300 mb-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,Q.jsx)(`input`,{ref:l,type:`file`,accept:`.json,.zip`,onChange:b,className:`flex-1 p-2 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 file:me-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 dark:file:bg-dark-200 dark:file:text-dark-700 hover:file:bg-gray-200 dark:hover:file:bg-dark-300`,disabled:n}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>_(!1),disabled:n,children:M(`common.cancel`)})]}),n&&(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-2`,children:M(`settings.plugins.uploading`)})]}),s&&(0,Q.jsx)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`textarea`,{value:c,onChange:e=>y(e.target.value),placeholder:M(`settings.plugins.jsonPlaceholder`),className:`w-full h-32 p-3 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500 font-mono text-sm`,disabled:t}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end space-x-2`,children:[(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:()=>{v(!1),y(``)},children:M(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:x,disabled:!c.trim()||t,children:M(`settings.plugins.install`)})]})]})})]}),(0,Q.jsx)(`div`,{"data-testid":`provider-workspace`,className:`overflow-hidden rounded-xl border border-gray-200 bg-white dark:border-dark-300 dark:bg-dark-100`,children:(0,Q.jsxs)(`div`,{className:`grid min-h-[30rem] grid-cols-1 lg:grid-cols-[minmax(15rem,0.8fr)_minmax(0,1.6fr)]`,children:[(0,Q.jsxs)(`section`,{"data-testid":`provider-list`,"aria-label":M(`settings.plugins.providers`,{defaultValue:`Providers`}),className:`border-b border-gray-200 dark:border-dark-300 lg:flex lg:min-h-0 lg:flex-col lg:border-b-0 lg:border-e`,children:[(0,Q.jsxs)(`div`,{className:`border-b border-gray-200 p-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:M(`settings.plugins.providers`,{defaultValue:`Providers`})}),(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600 dark:bg-dark-200 dark:text-gray-300`,children:e.length})]}),(0,Q.jsx)(`label`,{htmlFor:ie,className:`sr-only`,children:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`})}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(_e,{"aria-hidden":`true`,className:`absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400`}),(0,Q.jsx)(`input`,{id:ie,type:`search`,value:P,onChange:e=>te(e.target.value),placeholder:M(`settings.plugins.searchProviders`,{defaultValue:`Search providers`}),className:`w-full rounded-lg border border-gray-300 bg-white py-2 pe-3 ps-9 text-sm text-gray-900 placeholder:text-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 dark:border-dark-300 dark:bg-dark-50 dark:text-gray-100`})]})]}),(0,Q.jsx)(`div`,{className:`max-h-[32rem] space-y-2 overflow-y-auto p-3 lg:min-h-0 lg:max-h-none lg:flex-1`,children:t&&e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`mx-auto mb-2 h-5 w-5 animate-spin`}),M(`settings.plugins.loading`)]}):e.length===0?(0,Q.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,Q.jsx)(Te,{className:`mx-auto mb-3 h-9 w-9 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noPlugins`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-400 dark:text-gray-500`,children:M(`settings.plugins.noPluginsDescription`)})]}):ae.length===0?(0,Q.jsx)(`p`,{className:`p-6 text-center text-sm text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.noProvidersFound`,{defaultValue:`No providers match your search.`})}):ae.map(e=>{let t=oe===e.id,n=T(e).length;return(0,Q.jsx)(`button`,{type:`button`,"aria-current":t?`true`:void 0,onClick:()=>se(e.id),className:`w-full rounded-xl border p-3 text-start transition-colors ${t?`border-blue-500 bg-blue-50/70 dark:border-blue-500 dark:bg-blue-950/20`:`border-gray-200 hover:border-gray-300 hover:bg-gray-50 dark:border-dark-300 dark:hover:border-dark-400 dark:hover:bg-dark-50`}`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`sr-only`,children:[e.active?M(`settings.plugins.activeLabel`):M(`settings.plugins.inactive`),`.`,` `]}),(0,Q.jsx)(`span`,{className:`block truncate text-sm font-medium text-gray-900 dark:text-gray-100`,children:e.name}),(0,Q.jsxs)(`span`,{className:`mt-0.5 block text-xs capitalize text-gray-500 dark:text-gray-400`,children:[e.type,` · `,n,` `,M(`settings.plugins.models`)]})]})]})},e.id)})})]}),(0,Q.jsx)(`section`,{"data-testid":`provider-detail`,className:`min-w-0 p-4 sm:p-5`,children:F?(0,Q.jsx)(Gn,{plugin:F,loading:t,hasApiKey:i[F.id]||!1,expanded:u===F.id,apiKey:d[F.id]||``,showApiKey:f[F.id]||!1,savingApiKey:p===F.id,refreshingModels:!!m[F.id],canManagePlugin:N,onExpand:()=>S(u===F.id?null:F.id),onActivate:()=>E(F.id),onExport:()=>O(F.id),onDelete:()=>D(F.id),onRefreshModels:()=>j(F.id),onApiKeyChange:e=>C(F.id,e),onShowApiKeyChange:e=>w(F.id,e),onSaveApiKey:()=>k(F.id),onDeleteApiKey:()=>A(F.id)}):(0,Q.jsx)(`div`,{className:`flex min-h-[24rem] items-center justify-center text-center`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(Te,{className:`mx-auto mb-3 h-10 w-10 text-gray-400`}),(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:M(`settings.plugins.selectProvider`,{defaultValue:`Select a provider`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:M(`settings.plugins.selectProviderDescription`,{defaultValue:`Choose a provider to inspect its connection and model catalog.`})})]})})})]})})]})})}function Gn({plugin:e,loading:t,hasApiKey:n,expanded:r,apiKey:i,showApiKey:a,savingApiKey:s,refreshingModels:c,canManagePlugin:l,onExpand:u,onActivate:d,onExport:f,onDelete:p,onRefreshModels:m,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}){let{t:y}=o(),b=!!(e.auth?.header||e.auth?.key_env),x=Ln(e),S=l?e.variables||[]:(e.variables||[]).filter(e=>!x.has(e.name)),C=S.length>0,E=b||C,D=(0,Z.useId)(),O=T(e),k=e.base_url||e.endpoint;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-gray-200 pb-4 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full ${e.active?`bg-green-500`:`bg-gray-400 dark:bg-gray-500`}`}),(0,Q.jsx)(`h4`,{className:`truncate text-lg font-semibold text-gray-900 dark:text-gray-100`,children:e.name})]}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e.id,` · `,(0,Q.jsx)(`span`,{className:`capitalize`,children:e.type}),b&&n&&(0,Q.jsxs)(`span`,{className:`text-green-600`,children:[` `,`· `,y(`settings.plugins.apiKeySet`)]})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[E&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:u,"aria-expanded":r,"aria-controls":D,title:y(`settings.plugins.configure`),className:n?`text-green-600`:``,children:[b?(0,Q.jsx)(re,{className:`h-4 w-4`}):(0,Q.jsx)(Le,{className:`h-4 w-4`}),y(`settings.plugins.configure`),r?(0,Q.jsx)(xe,{className:`h-3 w-3`}):(0,Q.jsx)(Ce,{className:`h-3 w-3`})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:d,disabled:t,className:e.active?`border-green-300 text-green-600`:``,children:e.active?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(N,{className:`h-4 w-4`}),y(`settings.plugins.deactivate`)]}):y(`settings.plugins.activate`)}),l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:f,disabled:t,title:y(`settings.plugins.exportPlugin`,`Export plugin`),className:`px-2`,children:(0,Q.jsx)(ct,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:p,disabled:t,className:`px-2 text-red-600 hover:bg-red-50 hover:text-red-700`,title:y(`settings.plugins.deletePlugin`,`Delete plugin`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.status`,{defaultValue:`Status`})}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:e.active?y(`settings.plugins.activeLabel`):y(`settings.plugins.inactive`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.models`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-900 dark:text-gray-100`,children:O.length})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400`,children:y(`settings.plugins.defaultEndpoint`,{defaultValue:`Default endpoint`})}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-sm text-gray-900 dark:text-gray-100`,title:k,children:k})]})]})]}),r&&E&&(0,Q.jsxs)(`div`,{id:D,children:[b&&(0,Q.jsx)(qn,{plugin:e,hasApiKey:n,apiKey:i,showApiKey:a,savingApiKey:s,onApiKeyChange:h,onShowApiKeyChange:g,onSaveApiKey:_,onDeleteApiKey:v}),C&&(0,Q.jsxs)(`div`,{className:`mt-4 rounded-lg border border-gray-200 bg-gray-50 p-4 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Q.jsx)(Le,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsxs)(`h5`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:[y(`settings.plugins.providerSettings`),` (`,S.length,`)`]})]}),(0,Q.jsx)(Un,{plugin:e},e.id)]})]}),(0,Q.jsx)(Kn,{catalog:O,canRefresh:w(e),refreshing:c,onRefresh:m})]})}function Kn({catalog:e,canRefresh:t,refreshing:n,onRefresh:r}){let{t:i}=o();return(0,Q.jsxs)(`section`,{"data-testid":`provider-model-catalog`,className:`mt-5`,children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h5`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:i(`settings.plugins.modelCatalog`,{defaultValue:`Model catalog`})}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:i(`settings.plugins.modelCatalogDescription`,{defaultValue:`Discovered and configured models for this provider and its capabilities.`})})]}),t&&(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:r,disabled:n,"aria-busy":n,children:[n?(0,Q.jsx)(z,{className:`h-4 w-4 animate-spin`}):(0,Q.jsx)(Ee,{className:`h-4 w-4`}),i(`settings.plugins.refreshModels`,{defaultValue:`Refresh models`})]})]}),e.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-dark-300 dark:text-gray-400`,children:i(`settings.plugins.noModelsConfigured`,{defaultValue:`No models are configured for this provider.`})}):(0,Q.jsx)(`div`,{className:`max-h-[26rem] overflow-auto rounded-lg border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`table`,{className:`w-full min-w-[24rem] text-start text-sm`,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 z-10 bg-gray-50 text-xs uppercase tracking-wide text-gray-500 dark:bg-dark-50 dark:text-gray-400`,children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.modelId`,{defaultValue:`Model ID`})}),(0,Q.jsx)(`th`,{scope:`col`,className:`px-3 py-2 text-start font-medium`,children:i(`settings.plugins.capabilities`,{defaultValue:`Capabilities`})})]})}),(0,Q.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-dark-300`,children:e.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{className:`px-3 py-2.5 font-mono text-xs text-gray-900 dark:text-gray-100`,children:e.id}),(0,Q.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-blue-50 px-2 py-0.5 text-xs text-blue-700 dark:bg-blue-950/30 dark:text-blue-300`,children:i(`settings.plugins.capability.${e.toLowerCase()}`,{defaultValue:e})},e))})})]},e.id))})]})})]})}function qn({plugin:e,hasApiKey:t,apiKey:n,showApiKey:r,savingApiKey:i,onApiKeyChange:a,onShowApiKeyChange:s,onSaveApiKey:c,onDeleteApiKey:l}){let{t:u}=o(),d=(0,Z.useId)();return(0,Q.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50 dark:bg-dark-50 rounded-lg border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,Q.jsx)(re,{className:`h-4 w-4 text-gray-500`}),(0,Q.jsx)(`h6`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:u(`settings.plugins.apiKeyConfiguration`)})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-3`,children:[u(`settings.plugins.apiKeyDescription`,{name:e.name,defaultValue:`Store a personal API key for {{name}}.`}),e.auth?.key_env&&(0,Q.jsxs)(`span`,{className:`block mt-1`,children:[u(`settings.plugins.apiKeyEnvAlternative`),` `,(0,Q.jsx)(`code`,{className:`bg-gray-200 dark:bg-dark-200 px-1 rounded`,children:e.auth.key_env}),` `,u(`settings.plugins.environmentVariable`),`.`]})]}),t?(0,Q.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{className:`h-4 w-4 text-green-600`}),(0,Q.jsx)(`span`,{className:`text-sm text-green-700 dark:text-green-300`,children:u(`settings.plugins.apiKeyConfigured`)})]}),(0,Q.jsx)(q,{variant:`outline`,size:`sm`,onClick:l,disabled:i,className:`text-red-600 border-red-300 hover:bg-red-50`,children:i?(0,Q.jsx)(z,{className:`h-4 w-4 animate-spin`}):u(`common.remove`)})]}):(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`label`,{htmlFor:d,className:`sr-only`,children:u(`settings.plugins.apiKey.title`)}),(0,Q.jsx)(`input`,{id:d,type:r?`text`:`password`,value:n,onChange:e=>a(e.target.value),placeholder:u(`settings.plugins.apiKeyPlaceholder`),disabled:i,className:`w-full p-2 pe-10 border border-gray-300 dark:border-dark-300 rounded-md bg-white dark:bg-dark-100 text-gray-900 dark:text-dark-800 placeholder:text-gray-400 dark:placeholder:text-dark-500`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(!r),"aria-controls":d,"aria-label":u(r?`settings.plugins.hideApiKey`:`settings.plugins.showApiKey`),disabled:i,className:`absolute end-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 disabled:cursor-not-allowed disabled:opacity-50`,children:r?(0,Q.jsx)(ke,{className:`h-4 w-4`}):(0,Q.jsx)(Pe,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,onClick:c,disabled:i||!n.trim(),children:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(z,{className:`h-4 w-4 me-2 animate-spin`}),u(`common.saving`)]}):u(`settings.plugins.saveApiKey`)})})]})]})}var Jn=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)(!1),[r,i]=(0,Z.useState)(``),[a,s]=(0,Z.useState)(`6`),[c,l]=(0,Z.useState)(!0),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{let e=!1;return Dt.getConfig().then(t=>{e||!t.success||!t.data||(n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),d(!0))}).catch(()=>{}),()=>{e=!0}},[]);let g=async(o=t)=>{let u=Number(a);if(!Number.isInteger(u)||u<1||u>100){R.error(e(`settings.search.maxResultsInvalid`));return}p(!0);try{let t=await Dt.setConfig(o,r.trim(),{maxResults:u,safeSearch:c});if(!t.success||!t.data)throw Error(t.error||e(`settings.search.saveFailed`));n(t.data.enabled),i(t.data.url??``),typeof t.data.maxResults==`number`&&s(String(t.data.maxResults)),typeof t.data.safeSearch==`boolean`&&l(t.data.safeSearch),R.success(e(`settings.search.saved`))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.search.saveFailed`))}finally{p(!1)}},_=async()=>{h(!0);try{let t=await Dt.test();if(!t.success||!t.data?.ok)throw Error(t.error||e(`settings.search.testFailed`));R.success(e(`settings.search.testOk`,{results:t.data.results}))}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.search.testFailed`))}finally{h(!1)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ie,{className:`h-5 w-5 text-primary-500`}),e(`settings.search.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.search.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.enableLabel`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.search.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t,onChange:e=>{n(e),g(e)},disabled:f||!u||!t&&!r.trim()})]})}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.urlLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.urlDescription`)}),(0,Q.jsx)(Wt,{value:r,onChange:e=>i(e.target.value),placeholder:`http://searxng:8080`,spellCheck:!1,dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.maxResultsLabel`)}),(0,Q.jsx)(`span`,{className:`mb-2 block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.maxResultsDescription`)}),(0,Q.jsx)(Wt,{type:`number`,min:1,max:100,value:a,onChange:e=>s(e.target.value),dir:`ltr`})]}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-4 sm:pt-1`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.search.safeSearchLabel`)}),(0,Q.jsx)(`span`,{className:`block text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.search.safeSearchDescription`)})]}),(0,Q.jsx)(X,{checked:c,onChange:l,disabled:f||!u})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void _(),disabled:m||f||!t,children:e(m?`settings.search.testing`:`settings.search.test`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>void g(),disabled:f||!u,children:e(`settings.search.save`)})]})]})]})},Yn=e=>e.response?.data?.message,Xn=e=>e?new Date(e).toLocaleString():`—`,Zn=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=(0,Z.useCallback)(async()=>{i(!0);try{let e=await mt.getMfaStatus();e.success&&e.data&&n(e.data)}catch{}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void g(),0);return()=>clearTimeout(e)},[g]);let _=async()=>{s(!0);try{let t=await mt.mfaEnroll();t.success&&t.data?(l(t.data),d(``)):R.error(t.message||e(`auth.mfa.enrollFailed`))}catch(t){R.error(Yn(t)||e(`auth.mfa.enrollFailed`))}finally{s(!1)}},v=async t=>{if(t.preventDefault(),u.trim()){s(!0);try{let t=await mt.mfaActivate({code:u.trim()});t.success&&t.data?(l(null),p(t.data.recoveryCodes),R.success(e(`auth.mfa.enabled`)),await g()):R.error(t.message||e(`auth.mfa.invalidCode`))}catch(t){R.error(Yn(t)||e(`auth.mfa.invalidCode`))}finally{d(``),s(!1)}}},y=async t=>{if(t.preventDefault(),!(!u.trim()||!m)){s(!0);try{if(m===`disable`){let t=await mt.mfaDisable({code:u.trim()});t.success?(R.success(e(`auth.mfa.disabled`)),p(null)):R.error(t.message||e(`auth.mfa.invalidCode`))}else{let t=await mt.mfaRegenerateRecoveryCodes({code:u.trim()});t.success&&t.data?(p(t.data.recoveryCodes),R.success(e(`auth.mfa.recoveryCodesRegenerated`))):R.error(t.message||e(`auth.mfa.invalidCode`))}h(null),await g()}catch(t){R.error(Yn(t)||e(`auth.mfa.invalidCode`))}finally{d(``),s(!1)}}},b=async()=>{s(!0);try{let t=await mt.passkeyRegisterOptions();if(!t.success||!t.data){R.error(t.message||e(`auth.passkeys.registerFailed`));return}let n=await Yt(t.data.publicKey),r=await mt.passkeyRegister({challengeToken:t.data.challengeToken,credential:n});r.success?(R.success(e(`auth.passkeys.registered`)),await g()):R.error(r.message||e(`auth.passkeys.registerFailed`))}catch(t){let n=t;if(n.name===`NotAllowedError`||n.name===`AbortError`)return;R.error(Yn(t)||e(`auth.passkeys.registerFailed`))}finally{s(!1)}},x=async t=>{s(!0);try{let n=await mt.deletePasskey(t);n.success?(R.success(e(`auth.passkeys.removed`)),await g()):R.error(n.message||e(`auth.passkeys.removeFailed`))}catch(t){R.error(Yn(t)||e(`auth.passkeys.removeFailed`))}finally{s(!1)}};if(r||!t)return null;let S=`h-9 w-40 rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 px-3 text-sm text-gray-900 dark:text-gray-100 outline-none focus:ring-2 focus:ring-primary-500/35`;return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-mfa-section`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(F,{className:`h-5 w-5 text-primary-500`}),e(`auth.mfa.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.sectionDescription`)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.totpTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:t.totpEnabled?e(`auth.mfa.totpEnabledHint`,{count:t.recoveryCodesRemaining}):e(`auth.mfa.totpDisabledHint`)})]}),t.totpEnabled?(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`regenerate`),d(``)},children:e(`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:a,onClick:()=>{h(`disable`),d(``)},children:e(`auth.mfa.disableButton`)})]}):!c&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:_,children:e(`auth.mfa.enableButton`)})]}),c&&(0,Q.jsxs)(`form`,{onSubmit:v,className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.secretHint`)}),(0,Q.jsx)(`code`,{dir:`ltr`,className:`block break-all rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:c.secret}),(0,Q.jsx)(`a`,{href:c.otpauthUrl,dir:`ltr`,className:`inline-block text-xs font-medium text-primary-600 hover:text-primary-700 dark:text-primary-400`,children:e(`auth.mfa.openAuthenticator`)}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(`auth.mfa.activateButton`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>l(null),children:e(`common.cancel`)})]})]}),m&&(0,Q.jsxs)(`form`,{onSubmit:y,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.confirmWithCode`)}),(0,Q.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,dir:`ltr`,value:u,onChange:e=>d(e.target.value),placeholder:e(`auth.mfa.codePlaceholder`),className:S}),(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:a||!u.trim(),children:e(m===`disable`?`auth.mfa.disableButton`:`auth.mfa.regenerateCodes`)}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>h(null),children:e(`common.cancel`)})]}),f&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-gray-900 dark:text-gray-100`,children:e(`auth.mfa.recoveryCodesTitle`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.mfa.recoveryCodesHint`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-2 rounded-lg bg-gray-50 dark:bg-dark-200 p-3 font-mono text-sm text-gray-900 dark:text-gray-100`,children:f.map(e=>(0,Q.jsx)(`span`,{dir:`ltr`,children:e},e))}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>p(null),children:e(`auth.mfa.recoveryCodesSaved`)})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ce,{className:`h-4 w-4 text-primary-500`}),e(`auth.passkeys.sectionTitle`)]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.sectionDescription`)})]}),Y()&&(0,Q.jsx)(q,{size:`sm`,disabled:a,onClick:b,children:e(`auth.passkeys.addButton`)})]}),t.passkeys.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`auth.passkeys.empty`)}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.passkeys.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-gray-50 dark:bg-dark-200 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm text-gray-900 dark:text-gray-100`,children:t.name||e(`auth.passkeys.unnamed`)}),(0,Q.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[e(`auth.passkeys.createdAt`),`:`,` `,Xn(t.createdAt),` · `,e(`auth.passkeys.lastUsedAt`),`:`,` `,Xn(t.lastUsedAt)]})]}),(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,disabled:a,onClick:()=>void x(t.id),"aria-label":e(`auth.passkeys.removeButton`),children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]},t.id))})]})]})},Qn=e=>e?new Date(e).toLocaleString():`—`,$n=()=>{let{t:e}=o(),[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!0),[a,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(!1),f=(0,Z.useCallback)(async()=>{i(!0),s(!1);try{let e=await mt.getSessions();if(!e.success||!e.data)throw Error(e.error||`Failed to load sessions.`);n(e.data)}catch{s(!0)}finally{i(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void f(),0);return()=>clearTimeout(e)},[f]);let p=async t=>{l(t.id);try{let n=await mt.revokeSession(t.id);if(!n.success)throw Error(n.error||e(`settings.sessions.revokeFailed`));R.success(e(`settings.sessions.revoked`,`Session signed out.`)),await f()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{l(null)}},m=async()=>{d(!0);try{let t=await mt.revokeOtherSessions();if(!t.success||!t.data)throw Error(t.error||e(`settings.sessions.revokeFailed`));R.success(e(`settings.sessions.othersRevoked`,{count:t.data.revokedCount,defaultValue:`Other sessions signed out: {{count}}`})),await f()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.sessions.revokeFailed`,`The session could not be signed out.`))}finally{d(!1)}},h=t.filter(e=>!e.current&&!e.revokedAt);return(0,Q.jsxs)(`div`,{className:`space-y-8`,children:[(0,Q.jsx)(Zn,{}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(Ae,{className:`h-5 w-5 text-primary-500`}),e(`settings.sessions.title`,`Sessions`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.description`,`Everywhere this account is signed in. Signing a session out takes effect immediately; signing in again restores access.`)})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void m(),disabled:u||r||h.length===0,children:u?e(`settings.sessions.signingOutOthers`,`Signing out…`):e(`settings.sessions.signOutOthers`,`Sign out other sessions`)})}),r?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):a?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.loadFailed`,`The sessions could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void f(),children:e(`common.retry`)})]}):t.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.empty`,`No sessions found.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:t.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.kind}),t.current&&(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs font-medium text-primary-700 dark:text-primary-300`,children:e(`settings.sessions.current`,`This session`)}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.sessions.revokedBadge`,`Signed out`)})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-gray-500 dark:text-gray-400`,children:t.userAgent||e(`settings.sessions.unknownDevice`,`Unknown device`)}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.sessions.createdAt`,`Signed in`),`:`,` `,Qn(t.createdAt),` · `,e(`settings.sessions.lastSeenAt`,`Last active`),`:`,` `,Qn(t.lastSeenAt),t.expiresAt&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,e(`settings.sessions.expiresAt`,`Expires`),`:`,` `,Qn(t.expiresAt)]})]})]}),!t.current&&!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void p(t),disabled:c===t.id||u,children:c===t.id?e(`settings.sessions.signingOut`,`Signing out…`):e(`settings.sessions.signOut`,`Sign out`)})})]},t.id))})]})},er={getPublicKey:()=>dt.get(`/push/public-key`).then(e=>e.data),listSubscriptions:()=>dt.get(`/push/subscriptions`).then(e=>e.data),subscribe:e=>dt.post(`/push/subscriptions`,e).then(e=>e.data),unsubscribe:e=>dt.delete(`/push/subscriptions`,{data:{endpoint:e}}).then(e=>e.data)},tr=V(`components:settings-notifications`),nr=()=>typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window,rr=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i},ir=()=>{let{t:e}=o(),[t]=(0,Z.useState)(nr),[n,r]=(0,Z.useState)(typeof Notification<`u`?Notification.permission:`denied`),[i,a]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=(0,Z.useCallback)(async()=>{if(t)try{let e=await navigator.serviceWorker.getRegistration();if(!e){u(!1),a(!1);return}u(!0);let t=await e.pushManager.getSubscription();a(!!t)}catch(e){tr.debug(`Push state read failed`,e)}},[t]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void d(),0);return()=>clearTimeout(e)},[d]);let f=async()=>{let t=await navigator.serviceWorker.getRegistration();if(!t){R.error(e(`settings.notifications.workerMissing`));return}let n=await Notification.requestPermission();if(r(n),n!==`granted`){R.error(e(`settings.notifications.permissionDenied`));return}let i=await er.getPublicKey();if(!i.success||!i.data){R.error(i.message||e(`settings.notifications.enableFailed`));return}let o=await t.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:rr(i.data.publicKey)}),s=await er.subscribe(o.toJSON());if(!s.success){await o.unsubscribe().catch(()=>void 0),R.error(s.message||e(`settings.notifications.enableFailed`));return}a(!0),R.success(e(`settings.notifications.enabled`))},p=async()=>{let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();t&&(await er.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>void 0)),a(!1),R.success(e(`settings.notifications.disabled`))},m=async t=>{c(!0);try{t?await f():await p()}catch(t){tr.error(`Push toggle failed`,t),R.error(e(`settings.notifications.enableFailed`))}finally{c(!1)}},h=t?l?n===`denied`?e(`settings.notifications.permissionDenied`):null:e(`settings.notifications.workerMissing`):e(`settings.notifications.unsupported`);return(0,Q.jsxs)(`div`,{className:`space-y-6`,"data-testid":`settings-notifications-tab`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(qe,{className:`h-5 w-5 text-primary-500`}),e(`settings.notifications.title`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.description`)})]}),(0,Q.jsx)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.notifications.pushTitle`)}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-gray-500 dark:text-gray-400`,children:h??e(`settings.notifications.pushHint`)})]}),(0,Q.jsx)(X,{checked:i,disabled:s||!!(h&&!i),onChange:m})]})}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`settings.notifications.deviceNote`)})]})},ar=e=>e?new Date(e).toLocaleString():`—`,or=()=>{let{t:e}=o(),t=jt(e=>e.isAdmin)(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),x=pt.filter(e=>e!==`admin`||t),S=(0,Z.useCallback)(async()=>{a(!0),c(!1);try{let e=await mt.listApiTokens();if(!e.success||!e.data)throw Error(e.error||`Failed to load API keys.`);r(e.data)}catch{c(!0)}finally{a(!1)}},[]);(0,Z.useEffect)(()=>{let e=setTimeout(()=>void S(),0);return()=>clearTimeout(e)},[S]);let C=e=>{m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async t=>{if(t.preventDefault(),!d.trim()){R.error(e(`settings.apiKeys.nameRequired`,`Give the key a name.`));return}if(p.length===0){R.error(e(`settings.apiKeys.scopesRequired`,`Select at least one scope.`));return}let n;if(h.trim()){let t=Number(h);if(!Number.isInteger(t)||t<1){R.error(e(`settings.apiKeys.expiryInvalid`,`Expiry must be a whole number of days.`));return}n=t}v(!0);try{let t=await mt.createApiToken({name:d.trim(),scopes:p,expiresInDays:n});if(!t.success||!t.data)throw Error(t.error||e(`settings.apiKeys.createFailed`));b(t.data.token),f(``),m([]),g(``),R.success(e(`settings.apiKeys.created`,`API key created.`)),await S()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.createFailed`,`The API key could not be created.`))}finally{v(!1)}},T=async()=>{if(y)try{await navigator.clipboard.writeText(y),R.success(e(`settings.apiKeys.copied`,`Copied to clipboard.`))}catch{R.error(e(`settings.apiKeys.copyFailed`,`Copy failed.`))}},E=async t=>{u(t.id);try{let n=await mt.revokeApiToken(t.id);if(!n.success)throw Error(n.error||e(`settings.apiKeys.revokeFailed`));R.success(e(`settings.apiKeys.revoked`,`API key revoked.`)),await S()}catch(t){R.error(t instanceof Error&&t.message?t.message:e(`settings.apiKeys.revokeFailed`,`The API key could not be revoked.`))}finally{u(null)}};return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-lg font-semibold text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(ce,{className:`h-5 w-5 text-primary-500`}),e(`settings.apiKeys.title`,`API keys`)]}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.description`,`Scoped tokens for scripts and integrations. Each key only has access to the scopes you pick.`)})]}),y&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/40 bg-primary-50 dark:bg-primary-900/20 p-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.newKeyTitle`,`Your new API key`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`code`,{dir:`ltr`,className:`min-w-0 flex-1 overflow-x-auto rounded-md bg-white dark:bg-dark-100 border border-gray-200 dark:border-dark-300 px-3 py-2 text-xs text-gray-900 dark:text-gray-100`,"data-testid":`new-api-key`,children:y}),(0,Q.jsxs)(q,{size:`sm`,variant:`outline`,onClick:()=>void T(),className:`shrink-0 gap-1.5`,children:[(0,Q.jsx)(ot,{size:14}),e(`settings.apiKeys.copy`,`Copy`)]})]}),(0,Q.jsx)(`p`,{className:`text-xs text-warning-700 dark:text-warning-400`,children:e(`settings.apiKeys.showOnceWarning`,`Copy it now — it will not be shown again.`)}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,variant:`ghost`,onClick:()=>b(null),children:e(`settings.apiKeys.dismiss`,`Done`)})})]}),(0,Q.jsxs)(`form`,{onSubmit:w,className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 space-y-3`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.createTitle`,`Create a key`)}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.nameLabel`,`Name`)}),(0,Q.jsx)(Wt,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.apiKeys.namePlaceholder`,`e.g. CI pipeline`)})]}),(0,Q.jsxs)(`label`,{className:`block`,children:[(0,Q.jsx)(`span`,{className:`mb-1 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.expiryLabel`,`Expires in days (optional)`)}),(0,Q.jsx)(Wt,{type:`number`,min:1,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.apiKeys.expiryPlaceholder`,`Never`),dir:`ltr`})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`mb-2 block text-sm font-medium text-gray-900 dark:text-gray-100`,children:e(`settings.apiKeys.scopesLabel`,`Scopes`)}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,children:x.map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-900 dark:text-gray-100`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:p.includes(e),onChange:()=>C(e),className:`h-4 w-4 rounded border-gray-300 dark:border-dark-300 text-primary-600 focus:ring-primary-500`}),e]},e))})]}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(q,{size:`sm`,type:`submit`,disabled:_,children:_?e(`settings.apiKeys.creating`,`Creating…`):e(`settings.apiKeys.create`,`Create key`)})})]}),i?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):s?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex items-center justify-between gap-4`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.loadFailed`,`The API keys could not be loaded.`)}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void S(),children:e(`common.retry`)})]}):n.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.empty`,`No API keys yet.`)}):(0,Q.jsx)(`div`,{className:`space-y-3`,children:n.map(t=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 dark:border-dark-300 bg-white dark:bg-dark-100 p-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:t.name}),(0,Q.jsxs)(`code`,{dir:`ltr`,className:`rounded bg-gray-100 dark:bg-dark-200 px-1.5 py-0.5 text-xs text-gray-600 dark:text-gray-300`,children:[t.tokenPrefix,`…`]}),t.revokedAt&&(0,Q.jsx)(`span`,{className:`rounded-full bg-gray-100 dark:bg-dark-200 px-2 py-0.5 text-xs font-medium text-gray-500 dark:text-gray-400`,children:e(`settings.apiKeys.revokedBadge`,`Revoked`)})]}),(0,Q.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:t.scopes.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-primary-100 dark:bg-primary-900/30 px-2 py-0.5 text-xs text-primary-700 dark:text-primary-300`,children:e},e))}),(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:[e(`settings.apiKeys.createdAt`,`Created`),`:`,` `,ar(t.createdAt),` · `,e(`settings.apiKeys.lastUsedAt`,`Last used`),`:`,` `,ar(t.lastUsedAt),` · `,e(`settings.apiKeys.expiresAt`,`Expires`),`:`,` `,t.expiresAt?ar(t.expiresAt):e(`settings.apiKeys.neverExpires`,`Never`)]})]}),!t.revokedAt&&(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(q,{size:`sm`,variant:`outline`,onClick:()=>void E(t),disabled:l===t.id,children:l===t.id?e(`settings.apiKeys.revoking`,`Revoking…`):e(`settings.apiKeys.revoke`,`Revoke`)})})]},t.id))})]})};function sr({loading:e,settings:t,effectiveSettings:n,models:r,plugins:i,voices:a,voiceProfiles:s,selectableVoiceProfiles:c,loadingVoiceProfiles:l,testing:u,onSettingChange:d,onModelChange:f,onVoiceChange:p,onDeleteVoiceProfile:m,onRevokeVoiceProfile:h,onReset:g,onTest:_,onSave:v}){let{t:y}=o(),b=r.find(e=>e.model===n.model&&(!n.pluginId||e.plugin===n.pluginId));return(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.title`)}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-6`,children:y(`settings.tts.description`)}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,Q.jsx)(z,{className:`h-8 w-8 animate-spin text-primary-500`}),(0,Q.jsx)(`span`,{className:`ms-3 text-gray-600 dark:text-gray-400`,children:y(`settings.tts.loadingProviders`)})]}):r.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-yellow-200 bg-yellow-500/10 p-4 dark:border-yellow-800 dark:bg-yellow-900/20`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(Ke,{className:`h-5 w-5 text-yellow-600 dark:text-yellow-400 mt-0.5`}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-ink`,children:y(`settings.tts.noProviders`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-ink-muted`,children:y(`settings.tts.noProvidersDescription`)})]})]})}):(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.enable`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.enableDescription`)})]}),(0,Q.jsx)(X,{checked:t.enabled,onChange:e=>d(`enabled`,e)})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.autoPlay`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.autoPlayDescription`)})]}),(0,Q.jsx)(X,{checked:t.autoPlay,disabled:!t.enabled,onChange:e=>{e&&Jt(),d(`autoPlay`,e)}})]})}),(0,Q.jsx)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.streamSentences`)}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:y(`settings.tts.streamSentencesDescription`)})]}),(0,Q.jsx)(X,{checked:t.streamSentences!==!1,disabled:!t.enabled,onChange:e=>d(`streamSentences`,e)})]})}),(0,Q.jsxs)(`div`,{className:`bg-white dark:bg-dark-100 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100 mb-4`,children:y(`settings.tts.voiceConfiguration`)}),(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.model`)}),(0,Q.jsx)(zt,{"aria-label":y(`settings.tts.model`),value:b?Tt(b):``,onChange:e=>{let t=r.find(t=>Tt(t)===e.target.value);t&&f(t.model,t.plugin)},disabled:!t.enabled,options:[{value:``,label:y(`settings.model.selectModel`)},...r.map(e=>({value:Tt(e),label:`${e.model} (${e.plugin})`,key:`${e.plugin}:${e.model}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.modelDescription`)})]}),a.length>0||c.length>0?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:y(`settings.tts.voice`)}),(0,Q.jsx)(zt,{"aria-label":y(`settings.tts.voice`),value:n.voiceProfileId?lr(n.voiceProfileId):n.voice,onChange:e=>{let t=ur(e.target.value);p(t?``:e.target.value,t||``)},disabled:!t.enabled,options:[{value:``,label:y(`settings.tts.selectVoice`)},...a.map(e=>({value:e,label:e.charAt(0).toUpperCase()+e.slice(1)})),...c.map(e=>({value:lr(e.id),label:y(`settings.tts.savedVoiceOption`,{name:e.name,defaultValue:`{{name}} (saved voice)`}),key:`saved-voice-${e.id}`}))]}),(0,Q.jsx)(`p`,{className:`text-xs text-gray-500 mt-1`,children:y(`settings.tts.voiceDescription`)})]}):l?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`p`,{className:`rounded-lg bg-gray-50 p-3 text-xs text-gray-600 dark:bg-dark-50 dark:text-gray-400`,children:y(`settings.tts.providerDefaultVoice`)})]})]}),b?.config?.supports_voice_cloning&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-primary-500/20 bg-primary-500/[0.06] p-4`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.voiceCloningAvailable`)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-gray-600 dark:text-gray-400`,children:y(`settings.tts.voiceCloningAvailableDescription`)})]}),i.length>0&&(0,Q.jsxs)(`div`,{className:`bg-gray-50 dark:bg-dark-50 rounded-lg p-4 border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:y(`settings.tts.availableProviders`)}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:i.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 bg-white dark:bg-dark-100 rounded border border-gray-200 dark:border-dark-300`,children:[(0,Q.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-green-500`}),(0,Q.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[`(`,e.models?.length||0,` `,y(`settings.tts.models`),`)`]})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center pt-4 border-t border-gray-200 dark:border-dark-300`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(q,{onClick:g,variant:`outline`,className:`flex items-center gap-2`,children:[(0,Q.jsx)(ae,{size:16}),y(`common.reset`)]}),(0,Q.jsx)(q,{onClick:_,variant:`outline`,disabled:!t.enabled||!n.model,className:`flex items-center gap-2`,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{size:16}),y(`settings.tts.stop`)]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(E,{size:16}),y(`settings.tts.test`)]})})]}),(0,Q.jsxs)(q,{onClick:v,className:`flex items-center gap-2`,children:[(0,Q.jsx)(N,{size:16}),y(`settings.saveSettings`)]})]})]})]}),(l||s.length>0)&&(0,Q.jsxs)(`div`,{className:`rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,children:[(0,Q.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-gray-100`,children:y(`settings.tts.savedVoices`,{defaultValue:`Saved voices`})}),l?(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-xs text-gray-600 dark:text-gray-400`,children:[(0,Q.jsx)(z,{className:`h-3.5 w-3.5 animate-spin`}),y(`settings.tts.loadingSavedVoices`,{defaultValue:`Loading saved voices…`})]}):(0,Q.jsx)(`div`,{className:`mt-3 space-y-2`,children:s.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 dark:border-dark-300 dark:bg-dark-50`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`truncate text-sm text-gray-800 dark:text-gray-200`,children:[e.name,e.consentStatus===`revoked`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-red-100 px-1.5 py-0.5 text-[10px] font-medium text-red-700 dark:bg-red-950/40 dark:text-red-400`,children:y(`settings.tts.consentRevoked`,{defaultValue:`Consent withdrawn`})}),e.consentStatus===`expired`&&(0,Q.jsx)(`span`,{className:`ml-2 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:bg-amber-950/40 dark:text-amber-400`,children:y(`settings.tts.consentExpired`,{defaultValue:`Consent expired`})})]}),(0,Q.jsxs)(`p`,{className:`truncate text-xs text-gray-500 dark:text-gray-400`,children:[e.pluginId,` · `,e.model,` · `,y(`settings.tts.transferCount`,{total:e.transferCount??0,defaultValue:`sent to provider {{total}}×`}),e.consentExpiresAt&&e.consentStatus===`active`&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,y(`settings.tts.consentExpires`,{date:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.consentExpiresAt),defaultValue:`consent until {{date}}`})]})]})]}),(e.consentStatus??`active`)===`active`&&(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(e),"aria-label":y(`settings.tts.revokeSavedVoice`,{name:e.name,defaultValue:`Withdraw consent for {{name}}`}),className:`shrink-0 px-2 text-amber-600 hover:bg-amber-50 hover:text-amber-700 dark:hover:bg-amber-950/30`,children:(0,Q.jsx)(te,{className:`h-4 w-4`})}),(0,Q.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>m(e),"aria-label":y(`settings.tts.deleteSavedVoice`,{name:e.name,defaultValue:`Delete saved voice {{name}}`}),className:`shrink-0 px-2 text-red-600 hover:bg-red-50 hover:text-red-700 dark:hover:bg-red-950/30`,children:(0,Q.jsx)(B,{className:`h-4 w-4`})})]},e.id))})]})]})}var cr=`__saved_voice__:`;function lr(e){return`${cr}${e}`}function ur(e){return e.startsWith(cr)?e.slice(16):void 0}var dr=({title:e,description:t,actions:n,className:r})=>(0,Q.jsxs)(`header`,{className:u(`mb-5 flex flex-col gap-3 border-b border-gray-200/70 pb-4 dark:border-white/[0.08] sm:flex-row sm:items-end sm:justify-between`,r),children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-dark-800`,children:e}),t&&(0,Q.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-gray-600 dark:text-dark-600`,children:t})]}),n&&(0,Q.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:n})]}),fr=[`text`,`number`,`select`,`boolean`],pr=({variables:e,onChange:t})=>{let{t:n}=o(),r=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:Bt,children:n(`promptsPage.form.variables`)}),(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] text-gray-400 dark:text-dark-500`,children:n(`promptsPage.form.variablesHint`)}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.map((i,a)=>(0,Q.jsxs)(`div`,{"data-testid":`prompt-variable-row`,className:`rounded-xl border border-black/[0.06] bg-black/[0.02] p-2.5 dark:border-white/[0.07] dark:bg-white/[0.03]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.name,onChange:e=>r(a,{name:e.target.value}),placeholder:n(`promptsPage.form.variableName`),"aria-label":n(`promptsPage.form.variableName`),className:J,maxLength:64}),(0,Q.jsx)(`select`,{value:i.type,onChange:e=>r(a,{type:e.target.value,options:e.target.value===`select`?i.options??[]:void 0}),"aria-label":n(`promptsPage.form.variableType`),className:J,children:fr.map(e=>(0,Q.jsx)(`option`,{value:e,children:n(`promptsPage.variableTypes.${e}`)},e))}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.filter((e,t)=>t!==a)),"aria-label":n(`promptsPage.form.removeVariable`),"data-testid":`prompt-variable-remove`,className:`shrink-0 rounded-lg p-1.5 text-gray-400 transition-colors hover:bg-red-500/10 hover:text-red-500`,children:(0,Q.jsx)(B,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`text`,value:i.label??``,onChange:e=>r(a,{label:e.target.value}),placeholder:n(`promptsPage.form.variableLabel`),"aria-label":n(`promptsPage.form.variableLabel`),className:J,maxLength:120}),(0,Q.jsx)(`input`,{type:`text`,value:i.default??``,onChange:e=>r(a,{default:e.target.value}),placeholder:n(`promptsPage.form.variableDefault`),"aria-label":n(`promptsPage.form.variableDefault`),className:J,maxLength:500}),(0,Q.jsxs)(`label`,{className:`flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[12px] text-gray-600 dark:text-dark-600`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:i.required===!0,onChange:e=>r(a,{required:e.target.checked}),className:`h-3.5 w-3.5 rounded border-gray-300 dark:border-dark-400`}),n(`promptsPage.form.variableRequired`)]})]}),i.type===`select`&&(0,Q.jsx)(`input`,{type:`text`,value:(i.options??[]).join(`, `),onChange:e=>r(a,{options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),placeholder:n(`promptsPage.form.variableOptionsPlaceholder`),"aria-label":n(`promptsPage.form.variableOptions`),className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 mt-2`})]},a)),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>t([...e,{name:``,type:`text`}]),"data-testid":`prompt-add-variable`,className:`flex items-center gap-1.5 rounded-lg px-2 py-1 text-[12px] font-medium text-primary-600 transition-colors hover:bg-primary-500/10 dark:text-primary-400`,children:[(0,Q.jsx)(Oe,{className:`h-3.5 w-3.5`}),n(`promptsPage.form.addVariable`)]})]})]})},mr=/^[a-z0-9][a-z0-9-]{0,63}$/;function hr({open:e,prompt:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(gr,{prompt:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function gr({prompt:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=o(),s=e??t,[c,l]=(0,Z.useState)(s?.slug??``),[u,d]=(0,Z.useState)(s?.title??``),[f,p]=(0,Z.useState)(s?.description??``),[m,h]=(0,Z.useState)(s?.content??``),[g,_]=(0,Z.useState)(s?.variables??[]),[v,y]=(0,Z.useState)((s?.tags??[]).join(`, `)),b=mr.test(c.trim()),x=b&&u.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Vt,{titleId:`prompt-modal-title`,title:a(e?`promptsPage.editPrompt`:`promptsPage.newPrompt`),onClose:r,widthClassName:`max-w-2xl`,testId:`prompt-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{x&&i({slug:c.trim(),title:u.trim(),description:f.trim()||void 0,content:m,variables:g.filter(e=>e.name.trim().length>0),tags:v.split(`,`).map(e=>e.trim()).filter(Boolean)})},disabled:n||!x,"data-testid":`prompt-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-slug`,className:Bt,children:a(`promptsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`prompt-slug`,"data-testid":`prompt-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`promptsPage.form.slugPlaceholder`),className:J,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!b?a(`promptsPage.form.slugInvalid`):a(`promptsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-title`,className:Bt,children:a(`promptsPage.form.title`)}),(0,Q.jsx)(`input`,{id:`prompt-title`,"data-testid":`prompt-title`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`promptsPage.form.titlePlaceholder`),className:J,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-description`,className:Bt,children:a(`promptsPage.form.description`)}),(0,Q.jsx)(`input`,{id:`prompt-description`,type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:a(`promptsPage.form.descriptionPlaceholder`),className:J,maxLength:500})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-content`,className:Bt,children:a(`promptsPage.form.content`)}),(0,Q.jsx)(`textarea`,{id:`prompt-content`,"data-testid":`prompt-content`,value:m,onChange:e=>h(e.target.value),placeholder:a(`promptsPage.form.contentPlaceholder`),rows:8,className:J,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`promptsPage.form.contentHint`)})]}),(0,Q.jsx)(pr,{variables:g,onChange:_}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`prompt-tags`,className:Bt,children:a(`promptsPage.form.tags`)}),(0,Q.jsx)(`input`,{id:`prompt-tags`,type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:a(`promptsPage.form.tagsPlaceholder`),className:J})]})]})}var _r=({title:e,cards:t,testId:n,onPick:r})=>t.length===0?null:(0,Q.jsxs)(`div`,{className:`mt-8`,children:[(0,Q.jsx)(`p`,{className:`mb-2 text-[11px] font-medium uppercase tracking-wide text-gray-400 dark:text-dark-500 rtl:tracking-normal`,children:e}),(0,Q.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:t.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),"data-testid":n,className:`rounded-2xl border border-black/[0.06] bg-white/40 px-4 py-3 text-start transition-colors hover:bg-white/80 dark:border-white/[0.07] dark:bg-dark-100/40 dark:hover:bg-dark-100/80`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:e.name}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[12px] text-gray-500 dark:text-dark-500`,children:e.description}),e.meta&&(0,Q.jsx)(`p`,{className:`mt-1.5 font-mono text-[11px] text-gray-400 dark:text-dark-500`,dir:`ltr`,children:e.meta})]},e.id))})]}),vr=[{id:`reviewPr`,input:{slug:`review-pr`,title:`Pull request review`,description:`Structured code review with adjustable strictness.`,content:`Review the following {{language}} changes with {{strictness}} strictness. Point out bugs first, style second, and end with a one-line verdict.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0},{name:`strictness`,type:`select`,label:`Strictness`,default:`normal`,options:[`low`,`normal`,`pedantic`]}],tags:[`code`,`review`]}},{id:`summarize`,input:{slug:`summarize`,title:`Summarize for an audience`,description:`Bullet-point summary tuned to a reader.`,content:`Summarize the following in at most {{points}} bullet points for {{audience}}. Keep every bullet self-contained, lead with the most important point, and end with a one-sentence takeaway.`,variables:[{name:`points`,type:`number`,label:`Bullets`,default:`5`},{name:`audience`,type:`text`,label:`Audience`,default:`a technical reader`}],tags:[`writing`]}},{id:`translate`,input:{slug:`translate`,title:`Translate`,description:`Translation that preserves tone and formatting.`,content:`Translate the following into {{target_language}}. Preserve tone, formatting, and markup exactly; keep code, identifiers, and proper names untranslated. If a phrase is ambiguous, pick the most natural reading and note the alternative in brackets.`,variables:[{name:`target_language`,type:`text`,label:`Target language`,required:!0}],tags:[`writing`,`translation`]}},{id:`explainCode`,input:{slug:`explain-code`,title:`Explain code`,description:`Walkthrough plus edge cases and risks.`,content:`Explain what the following {{language}} code does, step by step but briefly. Then list edge cases it mishandles, hidden assumptions, and the one change you would make first.`,variables:[{name:`language`,type:`text`,label:`Language`,required:!0}],tags:[`code`]}}],yr=({title:e,entries:t,loading:n,currentVersion:r,rollingBackTo:i,onRollback:a,onClose:s,testId:c})=>{let{t:u,i18n:d}=o();return(0,Q.jsx)(Vt,{titleId:`version-history-title`,title:e,subtitle:u(`promptsPage.history.subtitle`),onClose:s,widthClassName:`max-w-2xl`,testId:c,footer:(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:s,children:u(`common.close`)}),children:n?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-10`,children:(0,Q.jsx)(z,{className:`h-5 w-5 animate-spin text-gray-400`})}):t.length===0?(0,Q.jsxs)(`div`,{className:`py-10 text-center`,children:[(0,Q.jsx)(Ze,{className:`mx-auto mb-2 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-400 dark:text-dark-500`,children:u(`promptsPage.history.empty`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,Q.jsxs)(`div`,{"data-testid":`version-history-entry`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:[u(`promptsPage.versionLabel`,{version:e.version}),e.version===r&&(0,Q.jsx)(`span`,{className:`ms-2 rounded-full bg-primary-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-wide text-primary-600 dark:text-primary-400`,children:u(`promptsPage.history.current`)})]}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-gray-400 dark:text-dark-500`,children:l(e.createdAt,d.language)})]}),(0,Q.jsx)(q,{size:`sm`,variant:`outline`,disabled:e.version===r||i!==null,onClick:()=>a(e.version),"data-testid":`version-rollback`,children:i===e.version?u(`promptsPage.history.rollingBack`):u(`promptsPage.history.rollback`)})]}),(0,Q.jsx)(`pre`,{className:`mt-2 max-h-32 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-black/[0.03] p-2.5 text-[11px] leading-5 text-gray-600 scrollbar-thin dark:bg-white/[0.04] dark:text-dark-600`,children:e.body})]},e.version))})})},br=(e,t)=>{let n=new Blob([JSON.stringify(t,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)},xr=async e=>JSON.parse(await e.text()),Sr=(e,t)=>{let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),URL.revokeObjectURL(r)},Cr=e=>new Promise((t,n)=>{let r=new FileReader;r.onerror=()=>n(r.error),r.onload=()=>t(String(r.result??``)),r.readAsText(e)}),wr=V(`pages:prompts`),Tr=()=>{let{t:e,i18n:t}=o(),[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)(!0),[s,c]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(null),E=(0,Z.useRef)(null),[D,O]=(0,Z.useState)(0),k=(0,Z.useCallback)(()=>O(e=>e+1),[]);(0,Z.useEffect)(()=>{let t=!1;return wt.list().then(n=>{t||(n.success&&n.data?r(n.data):L.error(n.error||e(`promptsPage.loadFailed`)))}).catch(n=>{t||(wr.error(`Failed to load prompts:`,n),L.error(e(`promptsPage.loadFailed`)))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[D,e]);let A=async t=>{h(!0);try{let n=u?await wt.update(u.id,t):await wt.create(t);n.success?(c(!1),p(null),L.success(e(`promptsPage.saved`)),k()):L.error(n.error||e(`promptsPage.saveFailed`))}catch(t){wr.error(`Failed to save prompt:`,t),L.error(e(`promptsPage.saveFailed`))}finally{h(!1)}},j=async()=>{if(!g)return;let t=g;_(null);try{let n=await wt.remove(t.id);if(!n.success)throw Error(n.error);L.success(e(`promptsPage.deleted`)),k()}catch(t){wr.error(`Failed to delete prompt:`,t),L.error(e(`promptsPage.deleteFailed`))}},M=async t=>{try{let e=await wt.export(t.id);if(!e.success||!e.data)throw Error(e.error);br(`${t.slug}.prompt.json`,e.data)}catch(t){wr.error(`Failed to export prompt:`,t),L.error(e(`promptsPage.exportFailed`))}},ee=async t=>{try{let n=await wt.import(await xr(t));if(!n.success)throw Error(n.error);L.success(e(`promptsPage.imported`)),k()}catch(t){wr.error(`Failed to import prompt:`,t),L.error(e(`promptsPage.importFailed`))}},N=async t=>{y(t),C(!0),x([]);try{let n=await wt.versions(t.id);n.success&&n.data?x(n.data):L.error(n.error||e(`promptsPage.historyFailed`))}catch(t){wr.error(`Failed to load prompt history:`,t),L.error(e(`promptsPage.historyFailed`))}finally{C(!1)}},P=async t=>{if(v){T(t);try{let n=await wt.rollback(v.id,t);if(!n.success||!n.data)throw Error(n.error);L.success(e(`promptsPage.rolledBack`)),y(null),k()}catch(t){wr.error(`Failed to roll the prompt back:`,t),L.error(e(`promptsPage.rollbackFailed`))}finally{T(null)}}};return(0,Q.jsxs)(`div`,{"data-testid":`prompts-page`,className:`pb-2`,children:[(0,Q.jsx)(dr,{title:e(`promptsPage.title`),description:e(`promptsPage.description`),actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{ref:E,type:`file`,accept:`application/json,.json`,className:`hidden`,"data-testid":`prompt-import-input`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&ee(t)}}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>E.current?.click(),"data-testid":`prompt-import`,children:[(0,Q.jsx)(Je,{className:`me-1.5 h-3.5 w-3.5`}),e(`common.import`)]}),(0,Q.jsxs)(q,{size:`sm`,onClick:()=>{d(null),p(null),c(!0)},"data-testid":`prompt-new`,children:[(0,Q.jsx)(Oe,{className:`me-1.5 h-3.5 w-3.5`}),e(`promptsPage.newPrompt`)]})]})}),i?null:n.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-16 text-center`,children:[(0,Q.jsx)(et,{className:`mx-auto mb-3 h-6 w-6 text-gray-300 dark:text-dark-400`}),(0,Q.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-dark-500`,children:e(`promptsPage.empty`)}),(0,Q.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-[13px] leading-6 text-gray-400 dark:text-dark-500`,children:e(`promptsPage.emptyHint`)})]}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:n.map(n=>(0,Q.jsx)(`div`,{"data-testid":`prompt-row`,className:`rounded-2xl border border-black/[0.06] bg-white/60 px-4 py-3 dark:border-white/[0.07] dark:bg-dark-100/60`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-[14px] font-medium text-gray-900 dark:text-dark-900`,children:n.title}),(0,Q.jsxs)(`code`,{className:`rounded-md bg-black/[0.04] px-1.5 py-0.5 text-[11px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:[`/`,n.slug]}),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.versionLabel`,{version:n.version})})]}),n.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-[12px] text-gray-500 dark:text-dark-500`,children:n.description}),(0,Q.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-1.5`,children:[n.tags.map(e=>(0,Q.jsx)(`span`,{className:`rounded-full bg-black/[0.04] px-2 py-0.5 text-[10px] text-gray-500 dark:bg-white/[0.06] dark:text-dark-500`,children:e},e)),(0,Q.jsx)(`span`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:e(`promptsPage.updated`,{when:l(n.updatedAt,t.language)})})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(Ut,{icon:Ze,label:e(`promptsPage.history.open`),testId:`prompt-history`,onClick:()=>void N(n)}),(0,Q.jsx)(Ut,{icon:ct,label:e(`common.export`),testId:`prompt-export`,onClick:()=>void M(n)}),(0,Q.jsx)(Ut,{icon:Ge,label:e(`common.edit`),testId:`prompt-edit`,onClick:()=>{d(n),c(!0)}}),(0,Q.jsx)(Ut,{icon:B,label:e(`common.delete`),testId:`prompt-delete`,destructive:!0,onClick:()=>_(n)})]})]})},n.id))}),!i&&(0,Q.jsx)(_r,{title:e(`promptsPage.templatesTitle`),testId:`prompt-template`,cards:vr.map(t=>({id:t.id,name:e(`promptsPage.templates.${t.id}.name`),description:e(`promptsPage.templates.${t.id}.description`),meta:`/${t.input.slug}`})),onPick:e=>{let t=vr.find(t=>t.id===e);t&&(d(null),p(t.input),c(!0))}}),(0,Q.jsx)(hr,{open:s,prompt:u,prefill:f,saving:m,onClose:()=>{c(!1),p(null)},onSave:e=>void A(e)}),v&&(0,Q.jsx)(yr,{title:e(`promptsPage.history.title`,{title:v.title}),entries:b.map(e=>({version:e.version,body:e.content,createdAt:e.createdAt})),loading:S,currentVersion:v.version,rollingBackTo:w,onRollback:e=>void P(e),onClose:()=>y(null),testId:`prompt-history-modal`}),g&&(0,Q.jsx)(Vt,{titleId:`prompt-delete-title`,title:e(`promptsPage.deleteTitle`),subtitle:e(`promptsPage.deleteConfirm`,{title:g.title}),onClose:()=>_(null),widthClassName:`max-w-sm`,testId:`prompt-delete-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>_(null),children:e(`common.cancel`)}),(0,Q.jsx)(q,{variant:`danger`,size:`sm`,onClick:()=>void j(),"data-testid":`prompt-delete-confirm`,children:e(`common.delete`)})]})})]})},Er=/^[a-z0-9][a-z0-9-]{0,63}$/;function Dr({open:e,skill:t,prefill:n=null,saving:r,onClose:i,onSave:a}){return e?(0,Q.jsx)(Or,{skill:t,prefill:n,saving:r,onClose:i,onSave:a},t?.id??(n?`template-${n.slug}`:`new`)):null}function Or({skill:e,prefill:t,saving:n,onClose:r,onSave:i}){let{t:a}=o(),s=e??t,[c,l]=(0,Z.useState)(s?.slug??``),[u,d]=(0,Z.useState)(s?.name??``),[f,p]=(0,Z.useState)(s?.description??``),[m,h]=(0,Z.useState)(s?.instructions??``),[g,_]=(0,Z.useState)(s?.enabled??!0),v=Er.test(c.trim()),y=v&&u.trim().length>0&&f.trim().length>0&&m.trim().length>0;return(0,Q.jsxs)(Vt,{titleId:`skill-modal-title`,title:a(e?`skillsPage.editSkill`:`skillsPage.newSkill`),onClose:r,widthClassName:`max-w-2xl`,testId:`skill-modal`,footer:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:r,children:a(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,onClick:()=>{y&&i({slug:c.trim(),name:u.trim(),description:f.trim(),instructions:m,enabled:g})},disabled:n||!y,"data-testid":`skill-save`,children:a(n?`common.saving`:`common.save`)})]}),children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-slug`,className:Bt,children:a(`skillsPage.form.slug`)}),(0,Q.jsx)(`input`,{id:`skill-slug`,"data-testid":`skill-slug`,type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`skillsPage.form.slugPlaceholder`),className:J,maxLength:64,autoFocus:!0}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:c.trim().length>0&&!v?a(`skillsPage.form.slugInvalid`):a(`skillsPage.form.slugHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-name`,className:Bt,children:a(`skillsPage.form.name`)}),(0,Q.jsx)(`input`,{id:`skill-name`,"data-testid":`skill-name`,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:a(`skillsPage.form.namePlaceholder`),className:J,maxLength:200})]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-description`,className:Bt,children:a(`skillsPage.form.description`)}),(0,Q.jsx)(`textarea`,{id:`skill-description`,"data-testid":`skill-description`,value:f,onChange:e=>p(e.target.value),placeholder:a(`skillsPage.form.descriptionPlaceholder`),rows:2,className:J,maxLength:1e3}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.descriptionHint`)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{htmlFor:`skill-instructions`,className:Bt,children:a(`skillsPage.form.instructions`)}),(0,Q.jsx)(`textarea`,{id:`skill-instructions`,"data-testid":`skill-instructions`,value:m,onChange:e=>h(e.target.value),placeholder:a(`skillsPage.form.instructionsPlaceholder`),rows:10,className:`${J} font-mono`,maxLength:5e4}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.instructionsHint`)})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:a(`skillsPage.form.enabled`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:a(`skillsPage.form.enabledHint`)})]}),(0,Q.jsx)(Ht,{checked:g,onChange:_})]}),e&&(0,Q.jsx)(kr,{skillId:e.id})]})}function kr({skillId:e}){let{t}=o(),[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(!1),p=(0,Z.useCallback)(()=>{U.listFiles(e).then(e=>r(e.success&&e.data?e.data:[])).catch(()=>r([]))},[e]);(0,Z.useEffect)(()=>{p()},[p]);let m=async n=>{if(n===null){a(``),c(``),u(``);return}try{let t=await U.getFile(e,n);if(!t.success||!t.data)throw Error(t.error);a(n),c(n),u(t.data.content)}catch{L.error(t(`skillsPage.files.loadFailed`))}},h=async()=>{let n=s.trim();if(n){f(!0);try{let t=await U.putFile(e,n,l);if(!t.success)throw Error(t.error);i&&i!==n&&await U.deleteFile(e,i),a(null),p()}catch(e){L.error(e instanceof Error&&e.message?e.message:t(`skillsPage.files.saveFailed`))}finally{f(!1)}}},g=async n=>{try{let t=await U.deleteFile(e,n);if(!t.success)throw Error(t.error);i===n&&a(null),p()}catch{L.error(t(`skillsPage.files.deleteFailed`))}};return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-black/[0.06] px-3 py-2.5 dark:border-white/[0.07]`,"data-testid":`skill-files`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-[13px] font-medium text-gray-900 dark:text-dark-900`,children:t(`skillsPage.files.title`)}),(0,Q.jsx)(`p`,{className:`text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.hint`)})]}),(0,Q.jsxs)(q,{variant:`outline`,size:`sm`,onClick:()=>void m(null),"data-testid":`skill-file-add`,children:[(0,Q.jsx)(Me,{className:`me-1.5 h-3.5 w-3.5`}),t(`skillsPage.files.add`)]})]}),n&&n.length>0&&(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1`,children:n.map(e=>(0,Q.jsxs)(`li`,{"data-testid":`skill-file-row`,className:`flex items-center gap-2 rounded-lg bg-black/[0.03] px-2 py-1.5 dark:bg-white/[0.04]`,children:[(0,Q.jsx)(`code`,{className:`min-w-0 flex-1 truncate text-[12px] text-gray-700 dark:text-dark-800`,dir:`ltr`,children:e.path}),(0,Q.jsxs)(`span`,{className:`shrink-0 text-[11px] text-gray-400 dark:text-dark-500`,children:[e.size,` B`]}),(0,Q.jsx)(Ut,{icon:Ge,label:t(`common.edit`),testId:`skill-file-edit`,onClick:()=>void m(e.path)}),(0,Q.jsx)(Ut,{icon:B,label:t(`common.delete`),testId:`skill-file-delete`,destructive:!0,onClick:()=>void g(e.path)})]},e.path))}),n&&n.length===0&&i===null&&(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-gray-400 dark:text-dark-500`,children:t(`skillsPage.files.empty`)}),i!==null&&(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,"data-testid":`skill-file-editor`,children:[(0,Q.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:t(`skillsPage.files.pathPlaceholder`),dir:`ltr`,"data-testid":`skill-file-path`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`,maxLength:200}),(0,Q.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),placeholder:t(`skillsPage.files.contentPlaceholder`),rows:6,dir:`ltr`,"data-testid":`skill-file-content`,className:`w-full rounded-lg border border-black/[0.08] bg-white px-2.5 py-1.5 text-[13px] text-gray-900 focus:border-primary-500/40 focus:outline-none dark:border-white/[0.08] dark:bg-dark-100 dark:text-dark-900 font-mono`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,Q.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>a(null),children:t(`common.cancel`)}),(0,Q.jsx)(q,{size:`sm`,disabled:d||!s.trim(),onClick:()=>void h(),"data-testid":`skill-file-save`,children:t(d?`common.saving`:`common.save`)})]})]})]})}var Ar=[{id:`citeSources`,input:{slug:`cite-sources`,name:`Cite sources`,description:`How to cite evidence: numbered references with URLs, no unreferenced claims.`,instructions:`# Citing sources
|
|
3
3
|
|
|
4
4
|
- Every factual claim gets a numbered reference like [1].
|
|
5
5
|
- End with a References section: number, title, URL.
|