@chenpu17/cc-gw 0.8.4 → 0.8.5
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/package.json +5 -5
- package/src/web/dist/assets/{About-C_aKibBC.js → About-DUvmHkXW.js} +1 -1
- package/src/web/dist/assets/{ApiKeys-DsAyIbwB.js → ApiKeys--jCty6ZH.js} +1 -1
- package/src/web/dist/assets/{ConfirmDialog-z8FIBVOS.js → ConfirmDialog-Dwx6RgvT.js} +1 -1
- package/src/web/dist/assets/Dashboard-JKAR2hcD.js +1 -0
- package/src/web/dist/assets/{DialogShell-Cdf4kRdb.js → DialogShell-DpB7I936.js} +1 -1
- package/src/web/dist/assets/EChart-B2VLuu4H.js +1 -0
- package/src/web/dist/assets/{Events-D8BFNMmT.js → Events-COTOWRsF.js} +1 -1
- package/src/web/dist/assets/{Help-CLnzpKCo.js → Help-mc9elk2p.js} +1 -1
- package/src/web/dist/assets/{Login-DaukwolD.js → Login-CHt4FZ25.js} +1 -1
- package/src/web/dist/assets/{Logs-CxWTzBAj.js → Logs-ZWbE_Oab.js} +1 -1
- package/src/web/dist/assets/ModelManagement-DLeiN23D.js +1 -0
- package/src/web/dist/assets/{PageHeader-bBBkQNPI.js → PageHeader-DipLZp28.js} +1 -1
- package/src/web/dist/assets/{PageSection-Bkk2okl7.js → PageSection-q7kP54e8.js} +1 -1
- package/src/web/dist/assets/{PageState-QEhNwS9Q.js → PageState-CiCo8uzV.js} +1 -1
- package/src/web/dist/assets/{Profiler-LHVe6wwO.js → Profiler-tMLEINUS.js} +1 -1
- package/src/web/dist/assets/RoutingManagement-BGVGRnZ_.js +1 -0
- package/src/web/dist/assets/{Settings-D7qUYpBC.js → Settings-CLz6BWYx.js} +1 -1
- package/src/web/dist/assets/{Skeleton-CCQlvfTP.js → Skeleton-9uhP36eN.js} +1 -1
- package/src/web/dist/assets/{badge-dFhP0Qyo.js → badge-CUJnXP--.js} +1 -1
- package/src/web/dist/assets/{card-BeBgk27f.js → card-Vz-Wm3NU.js} +1 -1
- package/src/web/dist/assets/{charts-core-B4zLPEwd.js → charts-core-D_rRW-0W.js} +1 -1
- package/src/web/dist/assets/{charts-engine-CmnAuZWT.js → charts-engine-BXnGh0aE.js} +1 -1
- package/src/web/dist/assets/{charts-react-C9hy6r5j.js → charts-react-t97X9Vfc.js} +1 -1
- package/src/web/dist/assets/{gateway-DWOrDCuI.js → gateway-D8Ly9AH3.js} +1 -1
- package/src/web/dist/assets/{i18n-DJXLExhE.js → i18n-dgCQR_PB.js} +1 -1
- package/src/web/dist/assets/index-BYn7J5K_.js +61 -0
- package/src/web/dist/assets/index-UZDzrtNM.css +1 -0
- package/src/web/dist/assets/{input-BTCXiXUM.js → input-BpqO0M53.js} +1 -1
- package/src/web/dist/assets/{label-DjpX-mjh.js → label-G00TC871.js} +1 -1
- package/src/web/dist/assets/{popover-Brp8rADW.js → popover-Dhl3J4mH.js} +1 -1
- package/src/web/dist/assets/{query-CR1zzqi0.js → query-Db16w3tH.js} +1 -1
- package/src/web/dist/assets/{radix-BMe0_WA0.js → radix-D08JKSgz.js} +1 -1
- package/src/web/dist/assets/{router-cKa0BaP7.js → router-BURlSZbt.js} +2 -2
- package/src/web/dist/assets/{select-C3RskPYc.js → select-D49a8SjJ.js} +1 -1
- package/src/web/dist/assets/{switch-n7tI2AqZ.js → switch-tXufYzT3.js} +1 -1
- package/src/web/dist/assets/{useApiQuery-olO5q8vr.js → useApiQuery-Dqxujlur.js} +1 -1
- package/src/web/dist/assets/{useAppMutation-BJbRpdNF.js → useAppMutation-D-iOmckM.js} +1 -1
- package/src/web/dist/assets/useModelManagementState-B58fytAY.js +1 -0
- package/src/web/dist/assets/{vendor-CseyjbPR.js → vendor-DfnQOGOQ.js} +46 -41
- package/src/web/dist/index.html +7 -7
- package/src/web/dist/assets/Dashboard-DVP7GTtz.js +0 -1
- package/src/web/dist/assets/EChart-BlZFJiWb.js +0 -1
- package/src/web/dist/assets/ModelManagement-D5SFzd2o.js +0 -1
- package/src/web/dist/assets/index-CXBZSNMv.css +0 -1
- package/src/web/dist/assets/index-wrD5MdRi.js +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,aB as J,ax as gt,aw as xt,r as m,Y as bt}from"./vendor-CseyjbPR.js";import{C as Le}from"./ConfirmDialog-z8FIBVOS.js";import{c as M,L as Fe,B as k,r as Te,h as ft,b as vt,u as jt}from"./index-wrD5MdRi.js";import{P as yt}from"./PageHeader-bBBkQNPI.js";import{C as A,a as L}from"./card-BeBgk27f.js";import{B as E}from"./badge-dFhP0Qyo.js";import{I as w}from"./input-BTCXiXUM.js";import{L as v}from"./label-DjpX-mjh.js";import{S as B}from"./switch-n7tI2AqZ.js";import{S as Nt,a as wt,b as Ct,c as Pt,d as kt}from"./select-C3RskPYc.js";import{u as R}from"./i18n-DJXLExhE.js";import{u as Me}from"./useApiQuery-olO5q8vr.js";import{u as Q}from"./useAppMutation-BJbRpdNF.js";import{g as Oe}from"./gateway-DWOrDCuI.js";import{c as St}from"./clipboard-CALi6bTW.js";import{q as _}from"./queryKeys-BMvyDTQS.js";import"./DialogShell-Cdf4kRdb.js";import"./radix-BMe0_WA0.js";import"./query-CR1zzqi0.js";import"./router-cKa0BaP7.js";const Rt=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}],te=[{id:"section-basics",labelKey:"settings.sections.basics"},{id:"section-protocol",labelKey:"settings.sections.protocol"},{id:"section-security",labelKey:"settings.sections.security"},{id:"section-config-file",labelKey:"settings.sections.configFile"},{id:"section-cleanup",labelKey:"settings.sections.cleanup"}];function z(s){var o,l,c,a,i,h,p,T,x,d,N;const t=s.storePayloads,n=C=>typeof C=="boolean"?C:typeof t=="boolean"?t:!0;return{port:String(s.port??((o=s.http)==null?void 0:o.port)??""),host:s.host??((l=s.http)==null?void 0:l.host)??"127.0.0.1",logRetentionDays:String(s.logRetentionDays??30),logExportTimeoutSeconds:String(s.logExportTimeoutSeconds??60),storeRequestPayloads:n(s.storeRequestPayloads),storeResponsePayloads:n(s.storeResponsePayloads),logLevel:s.logLevel??"info",bodyLimitMb:(()=>{const C=s.bodyLimit;return typeof C=="number"&&Number.isFinite(C)&&C>0?String(Math.max(1,Math.round(C/(1024*1024)))):"10"})(),enableRoutingFallback:s.enableRoutingFallback===!0,httpEnabled:((c=s.http)==null?void 0:c.enabled)!==!1,httpPort:String(((a=s.http)==null?void 0:a.port)??s.port??4100),httpHost:((i=s.http)==null?void 0:i.host)??s.host??"127.0.0.1",httpsEnabled:((h=s.https)==null?void 0:h.enabled)===!0,httpsPort:String(((p=s.https)==null?void 0:p.port)??4443),httpsHost:((T=s.https)==null?void 0:T.host)??s.host??"127.0.0.1",httpsKeyPath:((x=s.https)==null?void 0:x.keyPath)??"",httpsCertPath:((d=s.https)==null?void 0:d.certPath)??"",httpsCaPath:((N=s.https)==null?void 0:N.caPath)??""}}function Y(s){return{enabled:s.enabled,username:s.username??"",password:"",confirmPassword:""}}function Et({activeSection:s,onSelectSection:t}){const{t:n}=R();return e.jsxs(e.Fragment,{children:[e.jsx("nav",{className:"hidden xl:block",children:e.jsxs("div",{className:"sticky top-20 rounded-lg border border-border bg-card p-4",children:[e.jsx("p",{className:"mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:n("settings.sections.jump")}),e.jsx("div",{className:"space-y-1",children:te.map((o,l)=>e.jsxs("button",{type:"button",onClick:()=>t(o.id),className:M("flex w-full items-center gap-3 rounded-full px-3.5 py-2.5 text-left text-sm transition-all",s===o.id?"bg-accent font-medium text-primary":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[e.jsx("span",{className:M("flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",s===o.id?"border-primary/20 bg-primary text-primary-foreground":"border-border bg-secondary text-muted-foreground"),children:l+1}),e.jsx("span",{children:n(o.labelKey)})]},o.id))})]})}),e.jsx("div",{className:"xl:hidden",children:e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1",children:e.jsx("div",{className:"flex w-max gap-2 px-1",children:te.map(o=>e.jsx("button",{type:"button",onClick:()=>t(o.id),className:M("rounded-full border px-3.5 py-2 text-xs font-medium transition-all",s===o.id?"border-primary bg-accent text-primary":"border-border bg-card text-muted-foreground hover:border-primary/20 hover:bg-accent hover:text-primary"),children:n(o.labelKey)},o.id))})})})]})}function At({configPath:s,defaultsSummary:t,form:n,protocolSummaryLabel:o,protocolChangesPending:l,isAuthDirty:c,isConfigDirty:a,authEnabled:i,authUsername:h}){const{t:p}=R();return e.jsx(A,{children:e.jsxs(L,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:p("settings.overview.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p("settings.overview.description")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(E,{variant:a||c?"warning":"success",children:p(a||c?"modelManagement.actions.unsaved":"common.status.success")}),l?e.jsx(E,{variant:"outline",className:"border-amber-300 text-amber-700 dark:border-amber-700 dark:text-amber-300",children:p("settings.protocol.restartWarning")}):null]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(U,{label:p("settings.overview.cards.protocols"),value:o,helper:`${n.httpHost||"127.0.0.1"}:${n.httpPort}${n.httpsEnabled?` / ${n.httpsHost||"127.0.0.1"}:${n.httpsPort}`:""}`}),e.jsx(U,{label:p("settings.overview.cards.security"),value:p(i?"settings.overview.values.authEnabled":"settings.overview.values.authDisabled"),helper:h?`${p("settings.auth.username")}: ${h}`:p("settings.auth.enableHint")}),e.jsx(U,{label:p("settings.overview.cards.configFile"),value:s||p("settings.file.unknown"),helper:t??p("settings.defaults.none"),mono:!0})]})]})})}function Lt({defaultsSummary:s,errors:t,form:n,onInputChange:o,onSetForm:l,sectionRef:c}){const{t:a}=R();return e.jsx(A,{id:"section-basics",ref:c,children:e.jsxs(L,{className:"pt-6",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("settings.sections.basics")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a("settings.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(X,{label:a("settings.fields.retention"),value:n.logRetentionDays}),e.jsx(X,{label:a("settings.fields.logExportTimeout"),value:`${n.logExportTimeoutSeconds}s`}),e.jsx(X,{label:a("settings.fields.bodyLimit"),value:`${n.bodyLimitMb} MB`})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:n.port,onChange:i=>o("port")(i.target.value),"aria-invalid":!!t.port}),t.port?e.jsx("p",{className:"text-xs text-destructive",children:t.port}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.host")}),e.jsx(w,{value:n.host,onChange:i=>o("host")(i.target.value),placeholder:a("settings.fields.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.retention")}),e.jsx(w,{type:"number",min:1,max:365,value:n.logRetentionDays,onChange:i=>o("logRetentionDays")(i.target.value),"aria-invalid":!!t.logRetentionDays}),t.logRetentionDays?e.jsx("p",{className:"text-xs text-destructive",children:t.logRetentionDays}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.logExportTimeout")}),e.jsx(w,{type:"number",min:5,max:600,value:n.logExportTimeoutSeconds,onChange:i=>o("logExportTimeoutSeconds")(i.target.value),"aria-invalid":!!t.logExportTimeoutSeconds}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.fields.logExportTimeoutHint")}),t.logExportTimeoutSeconds?e.jsx("p",{className:"text-xs text-destructive",children:t.logExportTimeoutSeconds}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.bodyLimit")}),e.jsx(w,{type:"number",min:1,max:2048,value:n.bodyLimitMb,onChange:i=>o("bodyLimitMb")(i.target.value),"aria-invalid":!!t.bodyLimitMb}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.fields.bodyLimitHint")}),t.bodyLimitMb?e.jsx("p",{className:"text-xs text-destructive",children:t.bodyLimitMb}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.logLevel")}),e.jsxs(Nt,{value:n.logLevel,onValueChange:i=>l(h=>({...h,logLevel:i})),children:[e.jsx(wt,{children:e.jsx(Ct,{})}),e.jsx(Pt,{children:Rt.map(i=>e.jsx(kt,{value:i.value,children:a(`settings.fields.logLevelOption.${i.labelKey}`)},i.value))})]})]}),e.jsxs("div",{className:"grid gap-4 md:col-span-2 sm:grid-cols-2",children:[e.jsx(Z,{label:a("settings.fields.storeRequestPayloads"),hint:a("settings.fields.storeRequestPayloadsHint"),checked:n.storeRequestPayloads,onCheckedChange:i=>l(h=>({...h,storeRequestPayloads:i}))}),e.jsx(Z,{label:a("settings.fields.storeResponsePayloads"),hint:a("settings.fields.storeResponsePayloadsHint"),checked:n.storeResponsePayloads,onCheckedChange:i=>l(h=>({...h,storeResponsePayloads:i}))}),e.jsx(Z,{label:a("settings.fields.enableRoutingFallback"),hint:a("settings.fields.enableRoutingFallbackHint"),checked:n.enableRoutingFallback,onCheckedChange:i=>l(h=>({...h,enableRoutingFallback:i}))})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-4 md:col-span-2",children:[e.jsx(v,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:a("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:s??a("settings.defaults.none")})]})]})]})})}function Tt({errors:s,form:t,onSetForm:n,sectionRef:o}){const{t:l}=R();return e.jsx(A,{id:"section-protocol",ref:o,children:e.jsxs(L,{className:"space-y-6 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:l("settings.sections.protocol")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("settings.protocol.description")})]}),e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-[hsl(var(--warning)/1)]"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:l("settings.protocol.restartWarning")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.restartHint")}),e.jsx("code",{className:"block rounded-lg border border-border bg-secondary px-3 py-2 text-xs font-mono text-foreground",children:"cc-gw restart --daemon"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.restartTip")})]})]})}),s.protocol?e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive",children:[e.jsx(J,{className:"mr-2 inline h-4 w-4"}),s.protocol]}):null,e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:l("settings.protocol.http.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.http.hint")})]}),e.jsx(B,{checked:t.httpEnabled,onCheckedChange:c=>n(a=>({...a,httpEnabled:c}))})]}),t.httpEnabled?e.jsxs("div",{className:"mt-4 grid gap-4 border-t border-border pt-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.http.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:t.httpPort,onChange:c=>n(a=>({...a,httpPort:c.target.value})),"aria-invalid":!!s.httpPort}),s.httpPort?e.jsx("p",{className:"text-xs text-destructive",children:s.httpPort}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.http.host")}),e.jsx(w,{value:t.httpHost,onChange:c=>n(a=>({...a,httpHost:c.target.value})),placeholder:"127.0.0.1"})]})]}):null]}),e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:l("settings.protocol.https.enable")}),e.jsx(gt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.https.hint")})]}),e.jsx(B,{checked:t.httpsEnabled,onCheckedChange:c=>n(a=>({...a,httpsEnabled:c}))})]}),t.httpsEnabled?e.jsxs("div",{className:"mt-4 space-y-4 border-t border-border pt-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.https.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:t.httpsPort,onChange:c=>n(a=>({...a,httpsPort:c.target.value})),"aria-invalid":!!s.httpsPort}),s.httpsPort?e.jsx("p",{className:"text-xs text-destructive",children:s.httpsPort}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.https.host")}),e.jsx(w,{value:t.httpsHost,onChange:c=>n(a=>({...a,httpsHost:c.target.value})),placeholder:"127.0.0.1"})]})]}),e.jsx(ee,{label:l("settings.protocol.https.keyPath"),value:t.httpsKeyPath,onChange:c=>n(a=>({...a,httpsKeyPath:c})),placeholder:"~/.cc-gw/certs/key.pem"}),e.jsx(ee,{label:l("settings.protocol.https.certPath"),value:t.httpsCertPath,onChange:c=>n(a=>({...a,httpsCertPath:c})),placeholder:"~/.cc-gw/certs/cert.pem"}),e.jsx(ee,{label:l("settings.protocol.https.caPath"),value:t.httpsCaPath,onChange:c=>n(a=>({...a,httpsCaPath:c})),placeholder:"留空则不使用"}),e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-[hsl(var(--warning)/1)]"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:l("settings.protocol.https.warning")}),e.jsxs("p",{className:"text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:[e.jsx("strong",{children:l("settings.protocol.https.invalidCert")}),l("settings.protocol.https.invalidCertDetail")]}),e.jsxs("p",{className:"text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:[e.jsx("strong",{children:l("settings.protocol.https.recommended")}),l("settings.protocol.https.recommendedDetail")]}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-600 dark:text-amber-400",children:l("settings.protocol.https.tip")})]})]})})]}):null]})]})})}function Mt({authErrors:s,authForm:t,authLoading:n,authSettings:o,needsPassword:l,onAuthReset:c,onAuthSave:a,onSetAuthForm:i,savingAuth:h,isAuthDirty:p,sectionRef:T}){const{t:x}=R();return e.jsx(A,{id:"section-security",ref:T,children:e.jsxs(L,{className:"space-y-5 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:x("settings.sections.security")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x("settings.auth.description")})]}),n&&!o?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(Fe,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 rounded-lg border border-border bg-secondary p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium",children:x("settings.auth.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"/ui"}),e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"/api/*"}),e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"Cookie Session"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 self-start sm:self-auto",children:[e.jsx(E,{variant:t.enabled?"success":"secondary",children:t.enabled?x("settings.auth.statusEnabled"):x("settings.auth.statusDisabled")}),e.jsx(B,{checked:t.enabled,onCheckedChange:d=>i(N=>({...N,enabled:d}))})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(v,{children:x("settings.auth.username")}),e.jsx(w,{value:t.username,onChange:d=>i(N=>({...N,username:d.target.value})),placeholder:x("settings.auth.usernamePlaceholder")}),s.username?e.jsx("p",{className:"text-xs text-destructive",children:s.username}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:x("settings.auth.password")}),e.jsx(w,{type:"password",value:t.password,disabled:!t.enabled,onChange:d=>i(N=>({...N,password:d.target.value})),placeholder:x("settings.auth.passwordPlaceholder")}),s.password?e.jsx("p",{className:"text-xs text-destructive",children:s.password}):e.jsx("p",{className:"text-xs text-muted-foreground",children:x(l?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:x("settings.auth.confirmPassword")}),e.jsx(w,{type:"password",value:t.confirmPassword,disabled:!t.enabled,onChange:d=>i(N=>({...N,confirmPassword:d.target.value})),placeholder:x("settings.auth.confirmPasswordPlaceholder")}),s.confirmPassword?e.jsx("p",{className:"text-xs text-destructive",children:s.confirmPassword}):null]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:x("settings.auth.status")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:o!=null&&o.enabled?x("settings.auth.statusEnabled"):x("settings.auth.statusDisabled")}),o!=null&&o.username?e.jsxs("div",{className:"mt-3 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-primary",children:[x("settings.auth.username"),": ",o.username]}):null]}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary p-4 text-xs text-muted-foreground",children:x(l?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsx(k,{onClick:a,disabled:h||!p,className:"w-full lg:w-auto",children:x(h?"common.actions.saving":"settings.auth.actions.save")}),e.jsx(k,{variant:"outline",onClick:c,disabled:h||!p,className:"w-full lg:w-auto",children:x("common.actions.reset")})]})]})]})})}function Ot({configPath:s,onCopyPath:t,sectionRef:n}){const{t:o}=R();return e.jsx(A,{id:"section-config-file",ref:n,children:e.jsxs(L,{className:"space-y-3 pt-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:o("settings.sections.configFile")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o("settings.file.description")})]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:t,className:"w-full sm:w-auto",children:[e.jsx(xt,{className:"mr-2 h-4 w-4"}),o("common.actions.copy")]})]}),e.jsx("code",{className:"block break-all rounded-lg border border-border bg-secondary px-4 py-3 text-xs",children:s||o("settings.file.unknown")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:o("help.note")})]})})}function Ft({cleaning:s,clearingAll:t,onOpenCleanup:n,onOpenClearAll:o,sectionRef:l}){const{t:c}=R();return e.jsx(A,{id:"section-cleanup",ref:l,children:e.jsxs(L,{className:"space-y-4 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:c("settings.sections.cleanup")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:c("settings.cleanup.description")})]}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:c("settings.cleanup.confirmCleanup")}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{variant:"warning",children:c("settings.cleanup.softLabel")}),e.jsx("p",{className:"text-sm font-medium",children:c("settings.cleanup.softTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("settings.cleanup.softDescription")}),e.jsx(k,{variant:"outline",onClick:n,disabled:s,className:"w-full sm:w-auto",children:c(s?"common.actions.cleaning":"common.actions.cleanup")})]})}),e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{variant:"outline",className:"border-destructive/40 bg-destructive/10 text-destructive",children:c("settings.cleanup.hardLabel")}),e.jsx("p",{className:"text-sm font-medium",children:c("settings.cleanup.hardTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("settings.cleanup.clearAllWarning")}),e.jsx(k,{variant:"destructive",onClick:o,disabled:t,className:"w-full sm:w-auto",children:c(t?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]})})]})]})})}function Ht({isAuthDirty:s,isConfigDirty:t,protocolChangesPending:n,onAuthReset:o,onAuthSave:l,onReset:c,onSave:a,saving:i,savingAuth:h}){const{t:p}=R();return!s&&!t?null:e.jsxs("div",{className:"sticky bottom-4 z-20 flex flex-col gap-3 rounded-lg border border-primary/20 bg-card p-4 shadow-lg backdrop-blur-sm md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"secondary",children:p("modelManagement.actions.unsaved")}),t?e.jsx(E,{variant:"outline",children:p("settings.sections.basics")}):null,s?e.jsx(E,{variant:"outline",children:p("settings.sections.security")}):null,n?e.jsx(E,{variant:"outline",className:"border-amber-300 text-amber-700 dark:border-amber-700 dark:text-amber-300",children:p("settings.sections.protocol")}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p(n?"settings.toast.protocolRestartRequired":"modelManagement.actions.footerDirtyHint")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:items-center",children:[s?e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:o,disabled:h,className:"w-full lg:w-auto",children:p("common.actions.reset")}),e.jsx(k,{onClick:l,disabled:h,className:"w-full lg:w-auto",children:p(h?"common.actions.saving":"settings.auth.actions.save")})]}):null,t?e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:c,disabled:i,className:"w-full lg:w-auto",children:p("common.actions.reset")}),e.jsx(k,{onClick:a,disabled:i,className:"w-full lg:w-auto",children:p(i?"common.actions.saving":"common.actions.save")})]}):null]})]})}function U({label:s,value:t,helper:n,mono:o=!1}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:M("mt-2 text-sm font-semibold text-foreground",o&&"break-all font-mono text-xs"),children:t}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:n})]})}function X({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:t})]})}function Z({checked:s,className:t,hint:n,hintClassName:o,label:l,labelClassName:c,onCheckedChange:a}){return e.jsxs("div",{className:M("flex flex-col gap-4 rounded-lg border border-border bg-secondary p-4 sm:flex-row sm:items-center sm:justify-between",t),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:M("text-sm font-medium",c),children:l}),e.jsx("p",{className:M("text-xs text-muted-foreground",o),children:n})]}),e.jsx(B,{checked:s,onCheckedChange:a,className:"self-start sm:self-auto"})]})}function ee({label:s,onChange:t,placeholder:n,value:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:s}),e.jsx(w,{value:o,onChange:l=>t(l.target.value),placeholder:n,className:"font-mono text-xs"})]})}const V={authStatusRequest(){return{url:"/api/auth/web",method:"GET"}},saveWebAuth:async s=>ft(vt.post("/api/auth/web",s)),cleanupLogs:async()=>Te({url:"/api/logs/cleanup",method:"POST"}),clearLogs:async()=>Te({url:"/api/logs/clear",method:"POST"})};function Dt(){const{t:s}=R(),{pushToast:t}=jt(),[n,o]=m.useState(te[0].id),l=m.useRef(new Map),c=m.useCallback(r=>{const g=l.current.get(r);g&&g.scrollIntoView({behavior:"smooth",block:"start"})},[]),a=m.useCallback(r=>g=>{g?l.current.set(r,g):l.current.delete(r)},[]),i=Me(_.config.info(),Oe.configInfoRequest()),h=Me(_.auth.web(),V.authStatusRequest()),p=Q({mutationFn:V.saveWebAuth,successToast:()=>({title:s("settings.auth.toast.success")}),errorToast:r=>({title:s("settings.auth.toast.failure",{message:r.message})}),invalidateKeys:[_.auth.web()]}),T=Q({mutationFn:V.cleanupLogs,successToast:r=>({title:r.deleted>0?s("settings.toast.cleanupSuccess",{count:r.deleted}):s("settings.toast.cleanupNone")}),errorToast:r=>({title:s("settings.toast.cleanupFailure",{message:r.message})})}),x=Q({mutationFn:V.clearLogs,successToast:r=>({title:s("settings.toast.clearAllSuccess",{logs:r.deleted,metrics:r.metricsCleared})}),errorToast:r=>({title:s("settings.toast.clearAllFailure",{message:r.message})})}),[d,N]=m.useState(null),[C,He]=m.useState(""),[u,H]=m.useState({port:"",host:"",logRetentionDays:"",logExportTimeoutSeconds:"60",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",bodyLimitMb:"10",enableRoutingFallback:!1,httpEnabled:!0,httpPort:"4100",httpHost:"127.0.0.1",httpsEnabled:!1,httpsPort:"4443",httpsHost:"127.0.0.1",httpsKeyPath:"",httpsCertPath:"",httpsCaPath:""}),[De,I]=m.useState({}),[Ke,se]=m.useState(!1),[qe,ae]=m.useState(!1),[Ve,ne]=m.useState(!1),[Be,Ie]=m.useState(!1),[$e,We]=m.useState(!1),[j,re]=m.useState(null),[b,D]=m.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[Ge,K]=m.useState({}),[Je,le]=m.useState(!1),Qe=m.useMemo(()=>{if(!(d!=null&&d.defaults))return null;const r=[];return d.defaults.completion&&r.push(s("settings.defaults.completion",{model:d.defaults.completion})),d.defaults.reasoning&&r.push(s("settings.defaults.reasoning",{model:d.defaults.reasoning})),d.defaults.background&&r.push(s("settings.defaults.background",{model:d.defaults.background})),r.length>0?r.join(" | "):s("settings.defaults.none")},[d,s]),_e=m.useMemo(()=>u.httpEnabled&&u.httpsEnabled?s("settings.overview.values.httpAndHttps"):u.httpsEnabled?s("settings.overview.values.httpsOnly"):s("settings.overview.values.httpOnly"),[u.httpEnabled,u.httpsEnabled,s]),ze=m.useMemo(()=>b.enabled?j!=null&&j.hasPassword?b.username.trim()!==(j.username??""):!0:!1,[b.enabled,b.username,j]),O=m.useMemo(()=>d?z(d):null,[d]),Ye=m.useMemo(()=>O?JSON.stringify(u)!==JSON.stringify(O):!1,[u,O]),$=m.useMemo(()=>j?Y(j):null,[j]),Ue=m.useMemo(()=>$?JSON.stringify(b)!==JSON.stringify($):!1,[b,$]),Xe=m.useMemo(()=>O?["httpEnabled","httpPort","httpHost","httpsEnabled","httpsPort","httpsHost","httpsKeyPath","httpsCertPath","httpsCaPath","port","host"].some(g=>u[g]!==O[g]):!1,[u,O]);m.useEffect(()=>{i.data&&(N(i.data.config),He(i.data.path),H(z(i.data.config)))},[i.data]),m.useEffect(()=>{h.data&&(re(h.data),D(Y(h.data)),K({}))},[h.data]),m.useEffect(()=>{!i.isError||!i.error||t({title:s("settings.toast.loadFailure",{message:i.error.message}),variant:"error"})},[i.error,i.isError,t,s]),m.useEffect(()=>{!h.isError||!h.error||t({title:s("settings.toast.authLoadFailure",{message:h.error.message}),variant:"error"})},[h.error,h.isError,t,s]);const Ze=m.useCallback(r=>g=>{H(y=>({...y,[r]:g}))},[]),oe=m.useCallback(()=>{const r={};if(!u.httpEnabled&&!u.httpsEnabled&&(r.protocol=s("settings.validation.protocolRequired")),u.httpEnabled){const S=Number(u.httpPort);(!Number.isFinite(S)||S<1||S>65535)&&(r.httpPort=s("settings.validation.httpPort"))}if(u.httpsEnabled){const S=Number(u.httpsPort);(!Number.isFinite(S)||S<1||S>65535)&&(r.httpsPort=s("settings.validation.httpsPort")),(!u.httpsKeyPath||!u.httpsCertPath)&&(r.protocol=s("settings.validation.httpsCertificate"))}const g=Number(u.port);(!Number.isFinite(g)||g<1||g>65535)&&(r.port=s("settings.validation.port"));const y=Number(u.logRetentionDays);(!Number.isFinite(y)||y<1||y>365)&&(r.logRetentionDays=s("settings.validation.retention"));const P=Number(u.logExportTimeoutSeconds);(!Number.isFinite(P)||P<5||P>600)&&(r.logExportTimeoutSeconds=s("settings.validation.logExportTimeout"));const F=Number(u.bodyLimitMb);return(!Number.isFinite(F)||F<1||F>2048)&&(r.bodyLimitMb=s("settings.validation.bodyLimit")),I(r),Object.keys(r).length===0},[u,s]),ie=m.useCallback(()=>{const r={},g=b.username.trim(),y=j?g!==(j.username??""):!0,P=b.enabled&&(!(j!=null&&j.hasPassword)||y);return b.enabled&&!g&&(r.username=s("settings.auth.validation.username")),b.password&&b.password.length<6&&(r.password=s("settings.auth.validation.minLength")),P&&!b.password&&(r.password=s("settings.auth.validation.passwordRequired")),(b.password||b.confirmPassword)&&b.password!==b.confirmPassword&&(r.confirmPassword=s("settings.auth.validation.confirmMismatch")),K(r),Object.keys(r).length===0},[b,j,s]),et=m.useCallback(async()=>{var r,g,y,P,F,S,ce,de,ue,me,pe,he,ge,xe,be,fe,ve,je,ye,Ne,we,Ce,Pe,ke,Se,Re;if(!d){t({title:s("settings.toast.loadFailure",{message:s("settings.toast.missingConfig")}),variant:"error"});return}if(oe()){se(!0);try{const q=Number(u.port),ot=Number(u.logRetentionDays),it=Number(u.logExportTimeoutSeconds),ct=Number(u.bodyLimitMb),f={...d,http:{enabled:u.httpEnabled,port:Number(u.httpPort),host:u.httpHost.trim()||"127.0.0.1"},https:{enabled:u.httpsEnabled,port:Number(u.httpsPort),host:u.httpsHost.trim()||"127.0.0.1",keyPath:u.httpsKeyPath.trim(),certPath:u.httpsCertPath.trim(),caPath:u.httpsCaPath.trim()||void 0},port:q,host:u.host.trim()||void 0,logRetentionDays:ot,logExportTimeoutSeconds:Math.min(Math.max(Math.round(it),5),600),storeRequestPayloads:u.storeRequestPayloads,storeResponsePayloads:u.storeResponsePayloads,logLevel:u.logLevel,bodyLimit:Math.max(1,Math.floor(ct*1024*1024)),enableRoutingFallback:u.enableRoutingFallback};delete f.requestLogging,delete f.responseLogging;const Ee={...f};delete Ee.webAuth,await Oe.saveConfig(Ee),N({...f,webAuth:d.webAuth});const Ae=G=>(G==null?void 0:G.trim())||void 0,dt=d.port??((r=d.http)==null?void 0:r.port)??4100,ut=f.port??((g=f.http)==null?void 0:g.port)??4100,mt=((y=d.host)==null?void 0:y.trim())||((F=(P=d.http)==null?void 0:P.host)==null?void 0:F.trim())||"127.0.0.1",pt=((S=f.host)==null?void 0:S.trim())||((de=(ce=f.http)==null?void 0:ce.host)==null?void 0:de.trim())||"127.0.0.1",ht=dt!==ut||mt!==pt||((ue=d.http)==null?void 0:ue.enabled)!==((me=f.http)==null?void 0:me.enabled)||((pe=d.http)==null?void 0:pe.port)!==((he=f.http)==null?void 0:he.port)||(((ge=d.http)==null?void 0:ge.host)??d.host??"127.0.0.1")!==(((xe=f.http)==null?void 0:xe.host)??f.host??"127.0.0.1")||((be=d.https)==null?void 0:be.enabled)!==((fe=f.https)==null?void 0:fe.enabled)||((ve=d.https)==null?void 0:ve.port)!==((je=f.https)==null?void 0:je.port)||(((ye=d.https)==null?void 0:ye.host)??d.host??"127.0.0.1")!==(((Ne=f.https)==null?void 0:Ne.host)??f.host??"127.0.0.1")||((we=d.https)==null?void 0:we.keyPath)!==((Ce=f.https)==null?void 0:Ce.keyPath)||((Pe=d.https)==null?void 0:Pe.certPath)!==((ke=f.https)==null?void 0:ke.certPath)||Ae((Se=d.https)==null?void 0:Se.caPath)!==Ae((Re=f.https)==null?void 0:Re.caPath);t({title:s(ht?"settings.toast.protocolRestartRequired":"settings.toast.saveSuccess"),variant:"success"}),i.refetch()}catch(q){t({title:s("settings.toast.saveFailure",{message:q instanceof Error?q.message:"unknown"}),variant:"error"})}finally{se(!1)}}},[d,i,u,t,s,oe]),tt=m.useCallback(()=>{d&&(H(z(d)),I({}))},[d]),st=m.useCallback(async()=>{if(ie()){le(!0);try{const r={enabled:b.enabled,username:b.username.trim()||void 0};b.password&&(r.password=b.password);const g=await p.mutateAsync(r);g.auth&&(re(g.auth),D({enabled:g.auth.enabled,username:g.auth.username??"",password:"",confirmPassword:""}),K({})),h.refetch()}catch{}finally{le(!1)}}},[b,h,p,ie]),at=m.useCallback(()=>{j&&(D(Y(j)),K({}))},[j]),nt=m.useCallback(async()=>{if(!C){t({title:s("settings.toast.copyFailure",{message:s("settings.file.unknown")}),variant:"error"});return}try{await St(C),t({title:s("settings.toast.copySuccess"),variant:"success"})}catch(r){t({title:s("settings.toast.copyFailure",{message:r instanceof Error?r.message:"unknown"}),variant:"error"})}},[C,t,s]),rt=m.useCallback(async()=>{ae(!0);try{await T.mutateAsync()}catch{}finally{ae(!1)}},[T]),lt=m.useCallback(async()=>{ne(!0);try{await x.mutateAsync()}catch{}finally{ne(!1)}},[x]),W=i.isPending||!d&&i.isFetching;return m.useEffect(()=>{if(W)return;const r=Array.from(l.current.values());if(r.length===0)return;const g=new IntersectionObserver(y=>{for(const P of y)if(P.isIntersecting){o(P.target.id);break}},{rootMargin:"-80px 0px -60% 0px",threshold:0});for(const y of r)g.observe(y);return()=>g.disconnect()},[W]),{activeSection:n,authErrors:Ge,authForm:b,authQuery:h,authSettings:j,clearingAll:Ve,cleaning:qe,config:d,configPath:C,configQuery:i,confirmCleanupOpen:Be,confirmClearAllOpen:$e,defaultsSummary:Qe,errors:De,form:u,handleAuthReset:at,handleAuthSave:st,handleCleanupLogs:rt,handleClearAllLogs:lt,handleCopyPath:nt,handleInputChange:Ze,handleReset:tt,handleSave:et,handleSectionClick:c,isAuthDirty:Ue,isConfigDirty:Ye,isLoading:W,needsPassword:ze,protocolSummaryLabel:_e,protocolChangesPending:Xe,saving:Ke,savingAuth:Je,sectionRefs:l,setAuthForm:D,setConfirmCleanupOpen:Ie,setConfirmClearAllOpen:We,setErrors:I,setForm:H,setSectionRef:a,t:s}}function ns(){var l,c;const{t:s}=R(),t=Dt(),n=Number(t.isConfigDirty)+Number(t.isAuthDirty),o=t.protocolChangesPending?s("settings.protocol.restartHint"):s("settings.overview.description");return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(yt,{icon:e.jsx(bt,{className:"h-5 w-5","aria-hidden":"true"}),title:s("settings.title"),description:s("settings.description"),eyebrow:"Gateway Controls",breadcrumb:"Gateway / Settings",helper:o,badge:n>0?s("settings.overview.unsavedCount",{count:n}):void 0,actions:t.config?e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:t.protocolChangesPending?s("settings.protocol.restartWarning"):s("common.status.success")}),e.jsx(k,{variant:"outline",onClick:t.handleReset,disabled:t.saving||!t.isConfigDirty,className:"w-full sm:w-auto",children:s("common.actions.reset")}),e.jsx(k,{onClick:()=>void t.handleSave(),disabled:t.saving||!t.isConfigDirty,className:"w-full sm:w-auto",children:t.saving?s("common.actions.saving"):s("common.actions.save")})]}):null}),t.isLoading?e.jsx(A,{children:e.jsx(L,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(Fe,{})})}):t.config?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[200px_1fr]",children:[e.jsx(Et,{activeSection:t.activeSection,onSelectSection:t.handleSectionClick}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(At,{configPath:t.configPath,defaultsSummary:t.defaultsSummary,form:t.form,protocolSummaryLabel:t.protocolSummaryLabel,protocolChangesPending:t.protocolChangesPending,isAuthDirty:t.isAuthDirty,isConfigDirty:t.isConfigDirty,authEnabled:((l=t.authSettings)==null?void 0:l.enabled)??!1,authUsername:(c=t.authSettings)==null?void 0:c.username}),e.jsx(Lt,{defaultsSummary:t.defaultsSummary,errors:t.errors,form:t.form,onInputChange:t.handleInputChange,onSetForm:t.setForm,sectionRef:t.setSectionRef("section-basics")}),e.jsx(Tt,{errors:t.errors,form:t.form,onSetForm:t.setForm,sectionRef:t.setSectionRef("section-protocol")}),e.jsx(Mt,{authErrors:t.authErrors,authForm:t.authForm,authLoading:t.authQuery.isPending||!t.authSettings&&t.authQuery.isFetching,authSettings:t.authSettings,needsPassword:t.needsPassword,onAuthReset:t.handleAuthReset,onAuthSave:()=>void t.handleAuthSave(),onSetAuthForm:t.setAuthForm,savingAuth:t.savingAuth,isAuthDirty:t.isAuthDirty,sectionRef:t.setSectionRef("section-security")}),e.jsx(Ot,{configPath:t.configPath,onCopyPath:()=>void t.handleCopyPath(),sectionRef:t.setSectionRef("section-config-file")}),e.jsx(Ft,{cleaning:t.cleaning,clearingAll:t.clearingAll,onOpenCleanup:()=>t.setConfirmCleanupOpen(!0),onOpenClearAll:()=>t.setConfirmClearAllOpen(!0),sectionRef:t.setSectionRef("section-cleanup")})]})]}),e.jsx(Ht,{isAuthDirty:t.isAuthDirty,isConfigDirty:t.isConfigDirty,protocolChangesPending:t.protocolChangesPending,onAuthReset:t.handleAuthReset,onAuthSave:()=>void t.handleAuthSave(),onReset:t.handleReset,onSave:()=>void t.handleSave(),saving:t.saving,savingAuth:t.savingAuth})]}):e.jsx(A,{children:e.jsx(L,{className:"pt-6",children:e.jsx("p",{className:"text-sm font-medium text-destructive",children:s("settings.toast.missingConfig")})})}),e.jsx(Le,{open:t.confirmCleanupOpen,onOpenChange:a=>{!a&&!t.cleaning&&t.setConfirmCleanupOpen(!1)},title:s("settings.cleanup.confirmTitle"),description:s("settings.cleanup.confirmDescription"),confirmLabel:t.cleaning?s("common.actions.cleaning"):s("common.actions.cleanup"),cancelLabel:s("common.actions.cancel"),loading:t.cleaning,onConfirm:async()=>{await t.handleCleanupLogs(),t.setConfirmCleanupOpen(!1)}}),e.jsx(Le,{open:t.confirmClearAllOpen,onOpenChange:a=>{!a&&!t.clearingAll&&t.setConfirmClearAllOpen(!1)},title:s("settings.cleanup.clearAllTitle"),description:s("settings.cleanup.clearAllWarning"),confirmLabel:t.clearingAll?s("settings.cleanup.clearingAll"):s("settings.cleanup.clearAll"),cancelLabel:s("common.actions.cancel"),loading:t.clearingAll,onConfirm:async()=>{await t.handleClearAllLogs(),t.setConfirmClearAllOpen(!1)}})]})}export{ns as default};
|
|
1
|
+
import{j as e,aC as J,ay as gt,ax as xt,r as m,Z as bt}from"./vendor-DfnQOGOQ.js";import{C as Le}from"./ConfirmDialog-Dwx6RgvT.js";import{c as M,L as Fe,B as k,r as Te,h as ft,b as vt,u as jt}from"./index-BYn7J5K_.js";import{P as yt}from"./PageHeader-DipLZp28.js";import{C as A,a as L}from"./card-Vz-Wm3NU.js";import{B as E}from"./badge-CUJnXP--.js";import{I as w}from"./input-BpqO0M53.js";import{L as v}from"./label-G00TC871.js";import{S as B}from"./switch-tXufYzT3.js";import{S as Nt,a as wt,b as Ct,c as Pt,d as kt}from"./select-D49a8SjJ.js";import{u as R}from"./i18n-dgCQR_PB.js";import{u as Me}from"./useApiQuery-Dqxujlur.js";import{u as Q}from"./useAppMutation-D-iOmckM.js";import{g as Oe}from"./gateway-D8Ly9AH3.js";import{c as St}from"./clipboard-CALi6bTW.js";import{q as _}from"./queryKeys-BMvyDTQS.js";import"./DialogShell-DpB7I936.js";import"./radix-D08JKSgz.js";import"./query-Db16w3tH.js";import"./router-BURlSZbt.js";const Rt=[{value:"fatal",labelKey:"fatal"},{value:"error",labelKey:"error"},{value:"warn",labelKey:"warn"},{value:"info",labelKey:"info"},{value:"debug",labelKey:"debug"},{value:"trace",labelKey:"trace"}],te=[{id:"section-basics",labelKey:"settings.sections.basics"},{id:"section-protocol",labelKey:"settings.sections.protocol"},{id:"section-security",labelKey:"settings.sections.security"},{id:"section-config-file",labelKey:"settings.sections.configFile"},{id:"section-cleanup",labelKey:"settings.sections.cleanup"}];function z(s){var o,l,c,a,i,h,p,T,x,d,N;const t=s.storePayloads,n=C=>typeof C=="boolean"?C:typeof t=="boolean"?t:!0;return{port:String(s.port??((o=s.http)==null?void 0:o.port)??""),host:s.host??((l=s.http)==null?void 0:l.host)??"127.0.0.1",logRetentionDays:String(s.logRetentionDays??30),logExportTimeoutSeconds:String(s.logExportTimeoutSeconds??60),storeRequestPayloads:n(s.storeRequestPayloads),storeResponsePayloads:n(s.storeResponsePayloads),logLevel:s.logLevel??"info",bodyLimitMb:(()=>{const C=s.bodyLimit;return typeof C=="number"&&Number.isFinite(C)&&C>0?String(Math.max(1,Math.round(C/(1024*1024)))):"10"})(),enableRoutingFallback:s.enableRoutingFallback===!0,httpEnabled:((c=s.http)==null?void 0:c.enabled)!==!1,httpPort:String(((a=s.http)==null?void 0:a.port)??s.port??4100),httpHost:((i=s.http)==null?void 0:i.host)??s.host??"127.0.0.1",httpsEnabled:((h=s.https)==null?void 0:h.enabled)===!0,httpsPort:String(((p=s.https)==null?void 0:p.port)??4443),httpsHost:((T=s.https)==null?void 0:T.host)??s.host??"127.0.0.1",httpsKeyPath:((x=s.https)==null?void 0:x.keyPath)??"",httpsCertPath:((d=s.https)==null?void 0:d.certPath)??"",httpsCaPath:((N=s.https)==null?void 0:N.caPath)??""}}function Z(s){return{enabled:s.enabled,username:s.username??"",password:"",confirmPassword:""}}function Et({activeSection:s,onSelectSection:t}){const{t:n}=R();return e.jsxs(e.Fragment,{children:[e.jsx("nav",{className:"hidden xl:block",children:e.jsxs("div",{className:"sticky top-20 rounded-lg border border-border bg-card p-4",children:[e.jsx("p",{className:"mb-3 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:n("settings.sections.jump")}),e.jsx("div",{className:"space-y-1",children:te.map((o,l)=>e.jsxs("button",{type:"button",onClick:()=>t(o.id),className:M("flex w-full items-center gap-3 rounded-full px-3.5 py-2.5 text-left text-sm transition-all",s===o.id?"bg-accent font-medium text-primary":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[e.jsx("span",{className:M("flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",s===o.id?"border-primary/20 bg-primary text-primary-foreground":"border-border bg-secondary text-muted-foreground"),children:l+1}),e.jsx("span",{children:n(o.labelKey)})]},o.id))})]})}),e.jsx("div",{className:"xl:hidden",children:e.jsx("div",{className:"-mx-1 overflow-x-auto pb-1",children:e.jsx("div",{className:"flex w-max gap-2 px-1",children:te.map(o=>e.jsx("button",{type:"button",onClick:()=>t(o.id),className:M("rounded-full border px-3.5 py-2 text-xs font-medium transition-all",s===o.id?"border-primary bg-accent text-primary":"border-border bg-card text-muted-foreground hover:border-primary/20 hover:bg-accent hover:text-primary"),children:n(o.labelKey)},o.id))})})})]})}function At({configPath:s,defaultsSummary:t,form:n,protocolSummaryLabel:o,protocolChangesPending:l,isAuthDirty:c,isConfigDirty:a,authEnabled:i,authUsername:h}){const{t:p}=R();return e.jsx(A,{children:e.jsxs(L,{className:"space-y-4 pt-5",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.18em] text-muted-foreground",children:p("settings.overview.title")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p("settings.overview.description")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(E,{variant:a||c?"warning":"success",children:p(a||c?"modelManagement.actions.unsaved":"common.status.success")}),l?e.jsx(E,{variant:"outline",className:"border-amber-300 text-amber-700 dark:border-amber-700 dark:text-amber-300",children:p("settings.protocol.restartWarning")}):null]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(U,{label:p("settings.overview.cards.protocols"),value:o,helper:`${n.httpHost||"127.0.0.1"}:${n.httpPort}${n.httpsEnabled?` / ${n.httpsHost||"127.0.0.1"}:${n.httpsPort}`:""}`}),e.jsx(U,{label:p("settings.overview.cards.security"),value:p(i?"settings.overview.values.authEnabled":"settings.overview.values.authDisabled"),helper:h?`${p("settings.auth.username")}: ${h}`:p("settings.auth.enableHint")}),e.jsx(U,{label:p("settings.overview.cards.configFile"),value:s||p("settings.file.unknown"),helper:t??p("settings.defaults.none"),mono:!0})]})]})})}function Lt({defaultsSummary:s,errors:t,form:n,onInputChange:o,onSetForm:l,sectionRef:c}){const{t:a}=R();return e.jsx(A,{id:"section-basics",ref:c,children:e.jsxs(L,{className:"pt-6",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:a("settings.sections.basics")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a("settings.description")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx(X,{label:a("settings.fields.retention"),value:n.logRetentionDays}),e.jsx(X,{label:a("settings.fields.logExportTimeout"),value:`${n.logExportTimeoutSeconds}s`}),e.jsx(X,{label:a("settings.fields.bodyLimit"),value:`${n.bodyLimitMb} MB`})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:n.port,onChange:i=>o("port")(i.target.value),"aria-invalid":!!t.port}),t.port?e.jsx("p",{className:"text-xs text-destructive",children:t.port}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.host")}),e.jsx(w,{value:n.host,onChange:i=>o("host")(i.target.value),placeholder:a("settings.fields.hostPlaceholder")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.retention")}),e.jsx(w,{type:"number",min:1,max:365,value:n.logRetentionDays,onChange:i=>o("logRetentionDays")(i.target.value),"aria-invalid":!!t.logRetentionDays}),t.logRetentionDays?e.jsx("p",{className:"text-xs text-destructive",children:t.logRetentionDays}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.logExportTimeout")}),e.jsx(w,{type:"number",min:5,max:600,value:n.logExportTimeoutSeconds,onChange:i=>o("logExportTimeoutSeconds")(i.target.value),"aria-invalid":!!t.logExportTimeoutSeconds}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.fields.logExportTimeoutHint")}),t.logExportTimeoutSeconds?e.jsx("p",{className:"text-xs text-destructive",children:t.logExportTimeoutSeconds}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.bodyLimit")}),e.jsx(w,{type:"number",min:1,max:2048,value:n.bodyLimitMb,onChange:i=>o("bodyLimitMb")(i.target.value),"aria-invalid":!!t.bodyLimitMb}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.fields.bodyLimitHint")}),t.bodyLimitMb?e.jsx("p",{className:"text-xs text-destructive",children:t.bodyLimitMb}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:a("settings.fields.logLevel")}),e.jsxs(Nt,{value:n.logLevel,onValueChange:i=>l(h=>({...h,logLevel:i})),children:[e.jsx(wt,{children:e.jsx(Ct,{})}),e.jsx(Pt,{children:Rt.map(i=>e.jsx(kt,{value:i.value,children:a(`settings.fields.logLevelOption.${i.labelKey}`)},i.value))})]})]}),e.jsxs("div",{className:"grid gap-4 md:col-span-2 sm:grid-cols-2",children:[e.jsx(Y,{label:a("settings.fields.storeRequestPayloads"),hint:a("settings.fields.storeRequestPayloadsHint"),checked:n.storeRequestPayloads,onCheckedChange:i=>l(h=>({...h,storeRequestPayloads:i}))}),e.jsx(Y,{label:a("settings.fields.storeResponsePayloads"),hint:a("settings.fields.storeResponsePayloadsHint"),checked:n.storeResponsePayloads,onCheckedChange:i=>l(h=>({...h,storeResponsePayloads:i}))}),e.jsx(Y,{label:a("settings.fields.enableRoutingFallback"),hint:a("settings.fields.enableRoutingFallbackHint"),checked:n.enableRoutingFallback,onCheckedChange:i=>l(h=>({...h,enableRoutingFallback:i}))})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-4 md:col-span-2",children:[e.jsx(v,{className:"text-xs uppercase tracking-wide text-muted-foreground",children:a("settings.fields.defaults")}),e.jsx("p",{className:"mt-2 text-sm",children:s??a("settings.defaults.none")})]})]})]})})}function Tt({errors:s,form:t,onSetForm:n,sectionRef:o}){const{t:l}=R();return e.jsx(A,{id:"section-protocol",ref:o,children:e.jsxs(L,{className:"space-y-6 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:l("settings.sections.protocol")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:l("settings.protocol.description")})]}),e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-[hsl(var(--warning)/1)]"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:l("settings.protocol.restartWarning")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.restartHint")}),e.jsx("code",{className:"block rounded-lg border border-border bg-secondary px-3 py-2 text-xs font-mono text-foreground",children:"cc-gw restart --daemon"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.restartTip")})]})]})}),s.protocol?e.jsxs("div",{className:"rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive",children:[e.jsx(J,{className:"mr-2 inline h-4 w-4"}),s.protocol]}):null,e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:l("settings.protocol.http.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.http.hint")})]}),e.jsx(B,{checked:t.httpEnabled,onCheckedChange:c=>n(a=>({...a,httpEnabled:c}))})]}),t.httpEnabled?e.jsxs("div",{className:"mt-4 grid gap-4 border-t border-border pt-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.http.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:t.httpPort,onChange:c=>n(a=>({...a,httpPort:c.target.value})),"aria-invalid":!!s.httpPort}),s.httpPort?e.jsx("p",{className:"text-xs text-destructive",children:s.httpPort}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.http.host")}),e.jsx(w,{value:t.httpHost,onChange:c=>n(a=>({...a,httpHost:c.target.value})),placeholder:"127.0.0.1"})]})]}):null]}),e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"text-sm font-medium text-foreground",children:l("settings.protocol.https.enable")}),e.jsx(gt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:l("settings.protocol.https.hint")})]}),e.jsx(B,{checked:t.httpsEnabled,onCheckedChange:c=>n(a=>({...a,httpsEnabled:c}))})]}),t.httpsEnabled?e.jsxs("div",{className:"mt-4 space-y-4 border-t border-border pt-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.https.port")}),e.jsx(w,{type:"number",min:1,max:65535,value:t.httpsPort,onChange:c=>n(a=>({...a,httpsPort:c.target.value})),"aria-invalid":!!s.httpsPort}),s.httpsPort?e.jsx("p",{className:"text-xs text-destructive",children:s.httpsPort}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:l("settings.protocol.https.host")}),e.jsx(w,{value:t.httpsHost,onChange:c=>n(a=>({...a,httpsHost:c.target.value})),placeholder:"127.0.0.1"})]})]}),e.jsx(ee,{label:l("settings.protocol.https.keyPath"),value:t.httpsKeyPath,onChange:c=>n(a=>({...a,httpsKeyPath:c})),placeholder:"~/.cc-gw/certs/key.pem"}),e.jsx(ee,{label:l("settings.protocol.https.certPath"),value:t.httpsCertPath,onChange:c=>n(a=>({...a,httpsCertPath:c})),placeholder:"~/.cc-gw/certs/cert.pem"}),e.jsx(ee,{label:l("settings.protocol.https.caPath"),value:t.httpsCaPath,onChange:c=>n(a=>({...a,httpsCaPath:c})),placeholder:"留空则不使用"}),e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{className:"mt-0.5 h-5 w-5 flex-shrink-0 text-[hsl(var(--warning)/1)]"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("p",{className:"text-sm font-medium text-amber-800 dark:text-amber-200",children:l("settings.protocol.https.warning")}),e.jsxs("p",{className:"text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:[e.jsx("strong",{children:l("settings.protocol.https.invalidCert")}),l("settings.protocol.https.invalidCertDetail")]}),e.jsxs("p",{className:"text-xs leading-relaxed text-amber-700 dark:text-amber-300",children:[e.jsx("strong",{children:l("settings.protocol.https.recommended")}),l("settings.protocol.https.recommendedDetail")]}),e.jsx("p",{className:"text-xs leading-relaxed text-amber-600 dark:text-amber-400",children:l("settings.protocol.https.tip")})]})]})})]}):null]})]})})}function Mt({authErrors:s,authForm:t,authLoading:n,authSettings:o,needsPassword:l,onAuthReset:c,onAuthSave:a,onSetAuthForm:i,savingAuth:h,isAuthDirty:p,sectionRef:T}){const{t:x}=R();return e.jsx(A,{id:"section-security",ref:T,children:e.jsxs(L,{className:"space-y-5 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:x("settings.sections.security")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:x("settings.auth.description")})]}),n&&!o?e.jsx("div",{className:"flex min-h-[120px] items-center justify-center",children:e.jsx(Fe,{})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-4 rounded-lg border border-border bg-secondary p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-sm font-medium",children:x("settings.auth.enable")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:x("settings.auth.enableHint")}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs font-medium text-muted-foreground",children:[e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"/ui"}),e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"/api/*"}),e.jsx("span",{className:"rounded-full border border-border bg-card px-3 py-1",children:"Cookie Session"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 self-start sm:self-auto",children:[e.jsx(E,{variant:t.enabled?"success":"secondary",children:t.enabled?x("settings.auth.statusEnabled"):x("settings.auth.statusDisabled")}),e.jsx(B,{checked:t.enabled,onCheckedChange:d=>i(N=>({...N,enabled:d}))})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,0.85fr)]",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(v,{children:x("settings.auth.username")}),e.jsx(w,{value:t.username,onChange:d=>i(N=>({...N,username:d.target.value})),placeholder:x("settings.auth.usernamePlaceholder")}),s.username?e.jsx("p",{className:"text-xs text-destructive",children:s.username}):null]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:x("settings.auth.password")}),e.jsx(w,{type:"password",value:t.password,disabled:!t.enabled,onChange:d=>i(N=>({...N,password:d.target.value})),placeholder:x("settings.auth.passwordPlaceholder")}),s.password?e.jsx("p",{className:"text-xs text-destructive",children:s.password}):e.jsx("p",{className:"text-xs text-muted-foreground",children:x(l?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:x("settings.auth.confirmPassword")}),e.jsx(w,{type:"password",value:t.confirmPassword,disabled:!t.enabled,onChange:d=>i(N=>({...N,confirmPassword:d.target.value})),placeholder:x("settings.auth.confirmPasswordPlaceholder")}),s.confirmPassword?e.jsx("p",{className:"text-xs text-destructive",children:s.confirmPassword}):null]})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"rounded-lg border border-border bg-secondary p-4",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:x("settings.auth.status")}),e.jsx("p",{className:"mt-2 text-base font-semibold",children:o!=null&&o.enabled?x("settings.auth.statusEnabled"):x("settings.auth.statusDisabled")}),o!=null&&o.username?e.jsxs("div",{className:"mt-3 rounded-lg bg-accent px-3 py-2 text-xs font-medium text-primary",children:[x("settings.auth.username"),": ",o.username]}):null]}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary p-4 text-xs text-muted-foreground",children:x(l?"settings.auth.passwordHintRequired":"settings.auth.passwordHintOptional")})]})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 lg:flex lg:flex-wrap lg:justify-end",children:[e.jsx(k,{onClick:a,disabled:h||!p,className:"w-full lg:w-auto",children:x(h?"common.actions.saving":"settings.auth.actions.save")}),e.jsx(k,{variant:"outline",onClick:c,disabled:h||!p,className:"w-full lg:w-auto",children:x("common.actions.reset")})]})]})]})})}function Ot({configPath:s,onCopyPath:t,sectionRef:n}){const{t:o}=R();return e.jsx(A,{id:"section-config-file",ref:n,children:e.jsxs(L,{className:"space-y-3 pt-6",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:o("settings.sections.configFile")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:o("settings.file.description")})]}),e.jsxs(k,{variant:"outline",size:"sm",onClick:t,className:"w-full sm:w-auto",children:[e.jsx(xt,{className:"mr-2 h-4 w-4"}),o("common.actions.copy")]})]}),e.jsx("code",{className:"block break-all rounded-lg border border-border bg-secondary px-4 py-3 text-xs",children:s||o("settings.file.unknown")}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:o("help.note")})]})})}function Ft({cleaning:s,clearingAll:t,onOpenCleanup:n,onOpenClearAll:o,sectionRef:l}){const{t:c}=R();return e.jsx(A,{id:"section-cleanup",ref:l,children:e.jsxs(L,{className:"space-y-4 pt-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold",children:c("settings.sections.cleanup")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:c("settings.cleanup.description")})]}),e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-4 py-3 text-xs text-muted-foreground",children:c("settings.cleanup.confirmCleanup")}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx("div",{className:"rounded-lg border border-[hsl(var(--warning)/0.3)] bg-[hsl(var(--warning-bg))] p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{variant:"warning",children:c("settings.cleanup.softLabel")}),e.jsx("p",{className:"text-sm font-medium",children:c("settings.cleanup.softTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("settings.cleanup.softDescription")}),e.jsx(k,{variant:"outline",onClick:n,disabled:s,className:"w-full sm:w-auto",children:c(s?"common.actions.cleaning":"common.actions.cleanup")})]})}),e.jsx("div",{className:"rounded-lg border border-destructive/30 bg-destructive/5 p-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{variant:"outline",className:"border-destructive/40 bg-destructive/10 text-destructive",children:c("settings.cleanup.hardLabel")}),e.jsx("p",{className:"text-sm font-medium",children:c("settings.cleanup.hardTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:c("settings.cleanup.clearAllWarning")}),e.jsx(k,{variant:"destructive",onClick:o,disabled:t,className:"w-full sm:w-auto",children:c(t?"settings.cleanup.clearingAll":"settings.cleanup.clearAll")})]})})]})]})})}function Ht({isAuthDirty:s,isConfigDirty:t,protocolChangesPending:n,onAuthReset:o,onAuthSave:l,onReset:c,onSave:a,saving:i,savingAuth:h}){const{t:p}=R();return!s&&!t?null:e.jsxs("div",{className:"sticky bottom-4 z-20 flex flex-col gap-3 rounded-lg border border-primary/20 bg-card p-4 shadow-lg backdrop-blur-sm md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(E,{variant:"secondary",children:p("modelManagement.actions.unsaved")}),t?e.jsx(E,{variant:"outline",children:p("settings.sections.basics")}):null,s?e.jsx(E,{variant:"outline",children:p("settings.sections.security")}):null,n?e.jsx(E,{variant:"outline",className:"border-amber-300 text-amber-700 dark:border-amber-700 dark:text-amber-300",children:p("settings.sections.protocol")}):null]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:p(n?"settings.toast.protocolRestartRequired":"modelManagement.actions.footerDirtyHint")})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:flex lg:flex-wrap lg:items-center",children:[s?e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:o,disabled:h,className:"w-full lg:w-auto",children:p("common.actions.reset")}),e.jsx(k,{onClick:l,disabled:h,className:"w-full lg:w-auto",children:p(h?"common.actions.saving":"settings.auth.actions.save")})]}):null,t?e.jsxs(e.Fragment,{children:[e.jsx(k,{variant:"outline",onClick:c,disabled:i,className:"w-full lg:w-auto",children:p("common.actions.reset")}),e.jsx(k,{onClick:a,disabled:i,className:"w-full lg:w-auto",children:p(i?"common.actions.saving":"common.actions.save")})]}):null]})]})}function U({label:s,value:t,helper:n,mono:o=!1}){return e.jsxs("div",{className:"rounded-lg border border-border bg-card px-4 py-3",children:[e.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-muted-foreground",children:s}),e.jsx("p",{className:M("mt-2 text-sm font-semibold text-foreground",o&&"break-all font-mono text-xs"),children:t}),e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:n})]})}function X({label:s,value:t}){return e.jsxs("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-muted-foreground",children:s}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-foreground",children:t})]})}function Y({checked:s,className:t,hint:n,hintClassName:o,label:l,labelClassName:c,onCheckedChange:a}){return e.jsxs("div",{className:M("flex flex-col gap-4 rounded-lg border border-border bg-secondary p-4 sm:flex-row sm:items-center sm:justify-between",t),children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:M("text-sm font-medium",c),children:l}),e.jsx("p",{className:M("text-xs text-muted-foreground",o),children:n})]}),e.jsx(B,{checked:s,onCheckedChange:a,className:"self-start sm:self-auto"})]})}function ee({label:s,onChange:t,placeholder:n,value:o}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{children:s}),e.jsx(w,{value:o,onChange:l=>t(l.target.value),placeholder:n,className:"font-mono text-xs"})]})}const V={authStatusRequest(){return{url:"/api/auth/web",method:"GET"}},saveWebAuth:async s=>ft(vt.post("/api/auth/web",s)),cleanupLogs:async()=>Te({url:"/api/logs/cleanup",method:"POST"}),clearLogs:async()=>Te({url:"/api/logs/clear",method:"POST"})};function Dt(){const{t:s}=R(),{pushToast:t}=jt(),[n,o]=m.useState(te[0].id),l=m.useRef(new Map),c=m.useCallback(r=>{const g=l.current.get(r);g&&g.scrollIntoView({behavior:"smooth",block:"start"})},[]),a=m.useCallback(r=>g=>{g?l.current.set(r,g):l.current.delete(r)},[]),i=Me(_.config.info(),Oe.configInfoRequest()),h=Me(_.auth.web(),V.authStatusRequest()),p=Q({mutationFn:V.saveWebAuth,successToast:()=>({title:s("settings.auth.toast.success")}),errorToast:r=>({title:s("settings.auth.toast.failure",{message:r.message})}),invalidateKeys:[_.auth.web()]}),T=Q({mutationFn:V.cleanupLogs,successToast:r=>({title:r.deleted>0?s("settings.toast.cleanupSuccess",{count:r.deleted}):s("settings.toast.cleanupNone")}),errorToast:r=>({title:s("settings.toast.cleanupFailure",{message:r.message})})}),x=Q({mutationFn:V.clearLogs,successToast:r=>({title:s("settings.toast.clearAllSuccess",{logs:r.deleted,metrics:r.metricsCleared})}),errorToast:r=>({title:s("settings.toast.clearAllFailure",{message:r.message})})}),[d,N]=m.useState(null),[C,He]=m.useState(""),[u,H]=m.useState({port:"",host:"",logRetentionDays:"",logExportTimeoutSeconds:"60",storeRequestPayloads:!0,storeResponsePayloads:!0,logLevel:"info",bodyLimitMb:"10",enableRoutingFallback:!1,httpEnabled:!0,httpPort:"4100",httpHost:"127.0.0.1",httpsEnabled:!1,httpsPort:"4443",httpsHost:"127.0.0.1",httpsKeyPath:"",httpsCertPath:"",httpsCaPath:""}),[De,I]=m.useState({}),[Ke,se]=m.useState(!1),[qe,ae]=m.useState(!1),[Ve,ne]=m.useState(!1),[Be,Ie]=m.useState(!1),[$e,We]=m.useState(!1),[j,re]=m.useState(null),[b,D]=m.useState({enabled:!1,username:"",password:"",confirmPassword:""}),[Ge,K]=m.useState({}),[Je,le]=m.useState(!1),Qe=m.useMemo(()=>{if(!(d!=null&&d.defaults))return null;const r=[];return d.defaults.completion&&r.push(s("settings.defaults.completion",{model:d.defaults.completion})),d.defaults.reasoning&&r.push(s("settings.defaults.reasoning",{model:d.defaults.reasoning})),d.defaults.background&&r.push(s("settings.defaults.background",{model:d.defaults.background})),r.length>0?r.join(" | "):s("settings.defaults.none")},[d,s]),_e=m.useMemo(()=>u.httpEnabled&&u.httpsEnabled?s("settings.overview.values.httpAndHttps"):u.httpsEnabled?s("settings.overview.values.httpsOnly"):s("settings.overview.values.httpOnly"),[u.httpEnabled,u.httpsEnabled,s]),ze=m.useMemo(()=>b.enabled?j!=null&&j.hasPassword?b.username.trim()!==(j.username??""):!0:!1,[b.enabled,b.username,j]),O=m.useMemo(()=>d?z(d):null,[d]),Ze=m.useMemo(()=>O?JSON.stringify(u)!==JSON.stringify(O):!1,[u,O]),$=m.useMemo(()=>j?Z(j):null,[j]),Ue=m.useMemo(()=>$?JSON.stringify(b)!==JSON.stringify($):!1,[b,$]),Xe=m.useMemo(()=>O?["httpEnabled","httpPort","httpHost","httpsEnabled","httpsPort","httpsHost","httpsKeyPath","httpsCertPath","httpsCaPath","port","host"].some(g=>u[g]!==O[g]):!1,[u,O]);m.useEffect(()=>{i.data&&(N(i.data.config),He(i.data.path),H(z(i.data.config)))},[i.data]),m.useEffect(()=>{h.data&&(re(h.data),D(Z(h.data)),K({}))},[h.data]),m.useEffect(()=>{!i.isError||!i.error||t({title:s("settings.toast.loadFailure",{message:i.error.message}),variant:"error"})},[i.error,i.isError,t,s]),m.useEffect(()=>{!h.isError||!h.error||t({title:s("settings.toast.authLoadFailure",{message:h.error.message}),variant:"error"})},[h.error,h.isError,t,s]);const Ye=m.useCallback(r=>g=>{H(y=>({...y,[r]:g}))},[]),oe=m.useCallback(()=>{const r={};if(!u.httpEnabled&&!u.httpsEnabled&&(r.protocol=s("settings.validation.protocolRequired")),u.httpEnabled){const S=Number(u.httpPort);(!Number.isFinite(S)||S<1||S>65535)&&(r.httpPort=s("settings.validation.httpPort"))}if(u.httpsEnabled){const S=Number(u.httpsPort);(!Number.isFinite(S)||S<1||S>65535)&&(r.httpsPort=s("settings.validation.httpsPort")),(!u.httpsKeyPath||!u.httpsCertPath)&&(r.protocol=s("settings.validation.httpsCertificate"))}const g=Number(u.port);(!Number.isFinite(g)||g<1||g>65535)&&(r.port=s("settings.validation.port"));const y=Number(u.logRetentionDays);(!Number.isFinite(y)||y<1||y>365)&&(r.logRetentionDays=s("settings.validation.retention"));const P=Number(u.logExportTimeoutSeconds);(!Number.isFinite(P)||P<5||P>600)&&(r.logExportTimeoutSeconds=s("settings.validation.logExportTimeout"));const F=Number(u.bodyLimitMb);return(!Number.isFinite(F)||F<1||F>2048)&&(r.bodyLimitMb=s("settings.validation.bodyLimit")),I(r),Object.keys(r).length===0},[u,s]),ie=m.useCallback(()=>{const r={},g=b.username.trim(),y=j?g!==(j.username??""):!0,P=b.enabled&&(!(j!=null&&j.hasPassword)||y);return b.enabled&&!g&&(r.username=s("settings.auth.validation.username")),b.password&&b.password.length<6&&(r.password=s("settings.auth.validation.minLength")),P&&!b.password&&(r.password=s("settings.auth.validation.passwordRequired")),(b.password||b.confirmPassword)&&b.password!==b.confirmPassword&&(r.confirmPassword=s("settings.auth.validation.confirmMismatch")),K(r),Object.keys(r).length===0},[b,j,s]),et=m.useCallback(async()=>{var r,g,y,P,F,S,ce,de,ue,me,pe,he,ge,xe,be,fe,ve,je,ye,Ne,we,Ce,Pe,ke,Se,Re;if(!d){t({title:s("settings.toast.loadFailure",{message:s("settings.toast.missingConfig")}),variant:"error"});return}if(oe()){se(!0);try{const q=Number(u.port),ot=Number(u.logRetentionDays),it=Number(u.logExportTimeoutSeconds),ct=Number(u.bodyLimitMb),f={...d,http:{enabled:u.httpEnabled,port:Number(u.httpPort),host:u.httpHost.trim()||"127.0.0.1"},https:{enabled:u.httpsEnabled,port:Number(u.httpsPort),host:u.httpsHost.trim()||"127.0.0.1",keyPath:u.httpsKeyPath.trim(),certPath:u.httpsCertPath.trim(),caPath:u.httpsCaPath.trim()||void 0},port:q,host:u.host.trim()||void 0,logRetentionDays:ot,logExportTimeoutSeconds:Math.min(Math.max(Math.round(it),5),600),storeRequestPayloads:u.storeRequestPayloads,storeResponsePayloads:u.storeResponsePayloads,logLevel:u.logLevel,bodyLimit:Math.max(1,Math.floor(ct*1024*1024)),enableRoutingFallback:u.enableRoutingFallback};delete f.requestLogging,delete f.responseLogging;const Ee={...f};delete Ee.webAuth,await Oe.saveConfig(Ee),N({...f,webAuth:d.webAuth});const Ae=G=>(G==null?void 0:G.trim())||void 0,dt=d.port??((r=d.http)==null?void 0:r.port)??4100,ut=f.port??((g=f.http)==null?void 0:g.port)??4100,mt=((y=d.host)==null?void 0:y.trim())||((F=(P=d.http)==null?void 0:P.host)==null?void 0:F.trim())||"127.0.0.1",pt=((S=f.host)==null?void 0:S.trim())||((de=(ce=f.http)==null?void 0:ce.host)==null?void 0:de.trim())||"127.0.0.1",ht=dt!==ut||mt!==pt||((ue=d.http)==null?void 0:ue.enabled)!==((me=f.http)==null?void 0:me.enabled)||((pe=d.http)==null?void 0:pe.port)!==((he=f.http)==null?void 0:he.port)||(((ge=d.http)==null?void 0:ge.host)??d.host??"127.0.0.1")!==(((xe=f.http)==null?void 0:xe.host)??f.host??"127.0.0.1")||((be=d.https)==null?void 0:be.enabled)!==((fe=f.https)==null?void 0:fe.enabled)||((ve=d.https)==null?void 0:ve.port)!==((je=f.https)==null?void 0:je.port)||(((ye=d.https)==null?void 0:ye.host)??d.host??"127.0.0.1")!==(((Ne=f.https)==null?void 0:Ne.host)??f.host??"127.0.0.1")||((we=d.https)==null?void 0:we.keyPath)!==((Ce=f.https)==null?void 0:Ce.keyPath)||((Pe=d.https)==null?void 0:Pe.certPath)!==((ke=f.https)==null?void 0:ke.certPath)||Ae((Se=d.https)==null?void 0:Se.caPath)!==Ae((Re=f.https)==null?void 0:Re.caPath);t({title:s(ht?"settings.toast.protocolRestartRequired":"settings.toast.saveSuccess"),variant:"success"}),i.refetch()}catch(q){t({title:s("settings.toast.saveFailure",{message:q instanceof Error?q.message:"unknown"}),variant:"error"})}finally{se(!1)}}},[d,i,u,t,s,oe]),tt=m.useCallback(()=>{d&&(H(z(d)),I({}))},[d]),st=m.useCallback(async()=>{if(ie()){le(!0);try{const r={enabled:b.enabled,username:b.username.trim()||void 0};b.password&&(r.password=b.password);const g=await p.mutateAsync(r);g.auth&&(re(g.auth),D({enabled:g.auth.enabled,username:g.auth.username??"",password:"",confirmPassword:""}),K({})),h.refetch()}catch{}finally{le(!1)}}},[b,h,p,ie]),at=m.useCallback(()=>{j&&(D(Z(j)),K({}))},[j]),nt=m.useCallback(async()=>{if(!C){t({title:s("settings.toast.copyFailure",{message:s("settings.file.unknown")}),variant:"error"});return}try{await St(C),t({title:s("settings.toast.copySuccess"),variant:"success"})}catch(r){t({title:s("settings.toast.copyFailure",{message:r instanceof Error?r.message:"unknown"}),variant:"error"})}},[C,t,s]),rt=m.useCallback(async()=>{ae(!0);try{await T.mutateAsync()}catch{}finally{ae(!1)}},[T]),lt=m.useCallback(async()=>{ne(!0);try{await x.mutateAsync()}catch{}finally{ne(!1)}},[x]),W=i.isPending||!d&&i.isFetching;return m.useEffect(()=>{if(W)return;const r=Array.from(l.current.values());if(r.length===0)return;const g=new IntersectionObserver(y=>{for(const P of y)if(P.isIntersecting){o(P.target.id);break}},{rootMargin:"-80px 0px -60% 0px",threshold:0});for(const y of r)g.observe(y);return()=>g.disconnect()},[W]),{activeSection:n,authErrors:Ge,authForm:b,authQuery:h,authSettings:j,clearingAll:Ve,cleaning:qe,config:d,configPath:C,configQuery:i,confirmCleanupOpen:Be,confirmClearAllOpen:$e,defaultsSummary:Qe,errors:De,form:u,handleAuthReset:at,handleAuthSave:st,handleCleanupLogs:rt,handleClearAllLogs:lt,handleCopyPath:nt,handleInputChange:Ye,handleReset:tt,handleSave:et,handleSectionClick:c,isAuthDirty:Ue,isConfigDirty:Ze,isLoading:W,needsPassword:ze,protocolSummaryLabel:_e,protocolChangesPending:Xe,saving:Ke,savingAuth:Je,sectionRefs:l,setAuthForm:D,setConfirmCleanupOpen:Ie,setConfirmClearAllOpen:We,setErrors:I,setForm:H,setSectionRef:a,t:s}}function ns(){var l,c;const{t:s}=R(),t=Dt(),n=Number(t.isConfigDirty)+Number(t.isAuthDirty),o=t.protocolChangesPending?s("settings.protocol.restartHint"):s("settings.overview.description");return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(yt,{icon:e.jsx(bt,{className:"h-5 w-5","aria-hidden":"true"}),title:s("settings.title"),description:s("settings.description"),eyebrow:"Gateway Controls",breadcrumb:"Gateway / Settings",helper:o,badge:n>0?s("settings.overview.unsavedCount",{count:n}):void 0,actions:t.config?e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center",children:[e.jsx("div",{className:"rounded-lg border border-border bg-secondary px-3 py-2 text-xs text-muted-foreground",children:t.protocolChangesPending?s("settings.protocol.restartWarning"):s("common.status.success")}),e.jsx(k,{variant:"outline",onClick:t.handleReset,disabled:t.saving||!t.isConfigDirty,className:"w-full sm:w-auto",children:s("common.actions.reset")}),e.jsx(k,{onClick:()=>void t.handleSave(),disabled:t.saving||!t.isConfigDirty,className:"w-full sm:w-auto",children:t.saving?s("common.actions.saving"):s("common.actions.save")})]}):null}),t.isLoading?e.jsx(A,{children:e.jsx(L,{className:"flex min-h-[220px] items-center justify-center",children:e.jsx(Fe,{})})}):t.config?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[200px_1fr]",children:[e.jsx(Et,{activeSection:t.activeSection,onSelectSection:t.handleSectionClick}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsx(At,{configPath:t.configPath,defaultsSummary:t.defaultsSummary,form:t.form,protocolSummaryLabel:t.protocolSummaryLabel,protocolChangesPending:t.protocolChangesPending,isAuthDirty:t.isAuthDirty,isConfigDirty:t.isConfigDirty,authEnabled:((l=t.authSettings)==null?void 0:l.enabled)??!1,authUsername:(c=t.authSettings)==null?void 0:c.username}),e.jsx(Lt,{defaultsSummary:t.defaultsSummary,errors:t.errors,form:t.form,onInputChange:t.handleInputChange,onSetForm:t.setForm,sectionRef:t.setSectionRef("section-basics")}),e.jsx(Tt,{errors:t.errors,form:t.form,onSetForm:t.setForm,sectionRef:t.setSectionRef("section-protocol")}),e.jsx(Mt,{authErrors:t.authErrors,authForm:t.authForm,authLoading:t.authQuery.isPending||!t.authSettings&&t.authQuery.isFetching,authSettings:t.authSettings,needsPassword:t.needsPassword,onAuthReset:t.handleAuthReset,onAuthSave:()=>void t.handleAuthSave(),onSetAuthForm:t.setAuthForm,savingAuth:t.savingAuth,isAuthDirty:t.isAuthDirty,sectionRef:t.setSectionRef("section-security")}),e.jsx(Ot,{configPath:t.configPath,onCopyPath:()=>void t.handleCopyPath(),sectionRef:t.setSectionRef("section-config-file")}),e.jsx(Ft,{cleaning:t.cleaning,clearingAll:t.clearingAll,onOpenCleanup:()=>t.setConfirmCleanupOpen(!0),onOpenClearAll:()=>t.setConfirmClearAllOpen(!0),sectionRef:t.setSectionRef("section-cleanup")})]})]}),e.jsx(Ht,{isAuthDirty:t.isAuthDirty,isConfigDirty:t.isConfigDirty,protocolChangesPending:t.protocolChangesPending,onAuthReset:t.handleAuthReset,onAuthSave:()=>void t.handleAuthSave(),onReset:t.handleReset,onSave:()=>void t.handleSave(),saving:t.saving,savingAuth:t.savingAuth})]}):e.jsx(A,{children:e.jsx(L,{className:"pt-6",children:e.jsx("p",{className:"text-sm font-medium text-destructive",children:s("settings.toast.missingConfig")})})}),e.jsx(Le,{open:t.confirmCleanupOpen,onOpenChange:a=>{!a&&!t.cleaning&&t.setConfirmCleanupOpen(!1)},title:s("settings.cleanup.confirmTitle"),description:s("settings.cleanup.confirmDescription"),confirmLabel:t.cleaning?s("common.actions.cleaning"):s("common.actions.cleanup"),cancelLabel:s("common.actions.cancel"),loading:t.cleaning,onConfirm:async()=>{await t.handleCleanupLogs(),t.setConfirmCleanupOpen(!1)}}),e.jsx(Le,{open:t.confirmClearAllOpen,onOpenChange:a=>{!a&&!t.clearingAll&&t.setConfirmClearAllOpen(!1)},title:s("settings.cleanup.clearAllTitle"),description:s("settings.cleanup.clearAllWarning"),confirmLabel:t.clearingAll?s("settings.cleanup.clearingAll"):s("settings.cleanup.clearAll"),cancelLabel:s("common.actions.cancel"),loading:t.clearingAll,onConfirm:async()=>{await t.handleClearAllLogs(),t.setConfirmClearAllOpen(!1)}})]})}export{ns as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./vendor-
|
|
1
|
+
import{j as e}from"./vendor-DfnQOGOQ.js";import{c as n}from"./index-BYn7J5K_.js";function s({className:a}){return e.jsx("div",{role:"status","aria-label":"Loading",className:n("animate-pulse rounded-xl bg-muted/70",a)})}function o(){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s,{className:"h-3 w-24"}),e.jsx(s,{className:"h-10 w-10 rounded-xl"})]}),e.jsx(s,{className:"h-8 w-32"})]})}function m(){return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s,{className:"h-4 w-32"}),e.jsx(s,{className:"h-3 w-48"})]}),e.jsx(s,{className:"h-[320px] w-full rounded-lg"})]})}function i({columns:a=6}){const r=["w-24","w-16","w-20","w-28","w-14","w-12","w-20","w-16","w-14","w-12"];return e.jsx("tr",{className:"border-b",children:Array.from({length:a}).map((d,l)=>e.jsx("td",{className:"px-3 py-3",children:e.jsx(s,{className:n("h-4",r[l%r.length])})},l))})}export{m as C,o as S,i as T};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as d,
|
|
1
|
+
import{j as d,a1 as t}from"./vendor-DfnQOGOQ.js";import{c as o}from"./index-BYn7J5K_.js";const n=t("inline-flex items-center rounded-full border px-2.5 py-1 text-[11px] font-semibold tracking-[0.02em] transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-primary/15 bg-primary/10 text-primary hover:bg-primary/15 dark:border-primary/25 dark:bg-primary/15 dark:text-primary-foreground",secondary:"border-border/70 bg-secondary/90 text-secondary-foreground hover:bg-secondary dark:border-border dark:bg-secondary/70 dark:text-secondary-foreground",destructive:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 dark:border-red-900 dark:bg-red-950/60 dark:text-red-300",outline:"border-border bg-transparent text-muted-foreground hover:bg-accent dark:border-border dark:text-muted-foreground dark:hover:bg-accent",success:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 dark:border-emerald-900 dark:bg-emerald-950/60 dark:text-emerald-300",warning:"border-amber-200 bg-amber-50 text-amber-700 hover:bg-amber-100 dark:border-amber-900 dark:bg-amber-950/60 dark:text-amber-300",info:"border-cyan-200 bg-cyan-50 text-cyan-700 hover:bg-cyan-100 dark:border-cyan-900 dark:bg-cyan-950/60 dark:text-cyan-300",purple:"border-violet-200 bg-violet-50 text-violet-700 hover:bg-violet-100 dark:border-violet-900 dark:bg-violet-950/60 dark:text-violet-300",pink:"border-pink-200 bg-pink-50 text-pink-700 hover:bg-pink-100 dark:border-pink-900 dark:bg-pink-950/60 dark:text-pink-300"}},defaultVariants:{variant:"default"}});function g({className:r,variant:e,...a}){return d.jsx("div",{className:o(n({variant:e}),r),...a})}export{g as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as d,
|
|
1
|
+
import{r as s,j as d,a1 as n}from"./vendor-DfnQOGOQ.js";import{c as o}from"./index-BYn7J5K_.js";const i=n("rounded-lg border border-border bg-card text-card-foreground transition-all duration-200",{variants:{variant:{default:"shadow-sm",elevated:"shadow-md",outline:"border-border bg-background shadow-none",ghost:"border-transparent bg-transparent shadow-none",interactive:"cursor-pointer shadow-sm hover:-translate-y-0.5 hover:border-primary/20 hover:shadow-md"}},defaultVariants:{variant:"default"}}),l=s.forwardRef(({className:a,variant:r,...e},t)=>d.jsx("div",{ref:t,className:o(i({variant:r}),a),...e}));l.displayName="Card";const c=s.forwardRef(({className:a,...r},e)=>d.jsx("div",{ref:e,className:o("flex flex-col space-y-1.5 p-6",a),...r}));c.displayName="CardHeader";const m=s.forwardRef(({className:a,...r},e)=>d.jsx("div",{ref:e,className:o("text-lg font-semibold leading-none tracking-[-0.01em]",a),...r}));m.displayName="CardTitle";const f=s.forwardRef(({className:a,...r},e)=>d.jsx("div",{ref:e,className:o("text-sm leading-6 text-muted-foreground",a),...r}));f.displayName="CardDescription";const p=s.forwardRef(({className:a,...r},e)=>d.jsx("div",{ref:e,className:o("p-6 pt-0",a),...r}));p.displayName="CardContent";const x=s.forwardRef(({className:a,...r},e)=>d.jsx("div",{ref:e,className:o("flex items-center p-6 pt-0",a),...r}));x.displayName="CardFooter";export{l as C,p as a,c as b,m as c,f as d,x as e};
|