diff --git a/.management-html-version b/.management-html-version
index 2b827b4..40963a9 100644
--- a/.management-html-version
+++ b/.management-html-version
@@ -1 +1 @@
-v1.7.17
+v1.7.19
diff --git a/management.html b/management.html
index 56abd80..58b3e54 100644
--- a/management.html
+++ b/management.html
@@ -5,180 +5,180 @@
CLI Proxy API Management Center
-
-
+`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const n=q_(e),i=Uu(n);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const n=q_(e),i=Uu(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function I2e(t){const e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new D2e||null,prettyErrors:e}}function Dm(t,e={}){const{lineCounter:n,prettyErrors:i}=I2e(e),s=new F2e(n?.addNewLine),a=new O2e(e);let o=null;for(const r of a.compose(s.parse(t),!0,t.length))if(!o)o=r;else if(o.options.logLevel!=="silent"){o.errors.push(new Pf(r.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&n&&(o.errors.forEach(SR(t,n)),o.warnings.forEach(SR(t,n))),o}function lI(t,e,n){let i;const s=Dm(t,n);if(!s)return null;if(s.warnings.forEach(a=>jF(s.options.logLevel,a)),s.errors.length>0){if(s.options.logLevel!=="silent")throw s.errors[0];s.errors=[]}return s.toJS(Object.assign({reviver:i},n))}const U2e="ConfigSection-module__section___36A5y",B2e="ConfigSection-module__header___9y9kI",q2e="ConfigSection-module__titleRow___MDqPS",z2e="ConfigSection-module__indexBadge___BNk-6",K2e="ConfigSection-module__iconBadge___608--",V2e="ConfigSection-module__headingGroup___iqK3P",H2e="ConfigSection-module__title___fNwM-",W2e="ConfigSection-module__description___uM2Zw",G2e="ConfigSection-module__content___RBAGw",or={section:U2e,header:B2e,titleRow:q2e,indexBadge:z2e,iconBadge:K2e,headingGroup:V2e,title:H2e,description:W2e,content:G2e},rr=S.forwardRef(function({title:e,description:n,indexLabel:i,icon:s,className:a,children:o,...r},c){const d=[or.section,a].filter(Boolean).join(" ");return h.jsxs("section",{ref:c,className:d,...r,children:[h.jsxs("header",{className:or.header,children:[h.jsxs("div",{className:or.titleRow,children:[i?h.jsx("span",{className:or.indexBadge,children:i}):null,s?h.jsx("span",{className:or.iconBadge,children:s}):null]}),h.jsxs("div",{className:or.headingGroup,children:[h.jsx("h2",{className:or.title,children:e}),n?h.jsx("p",{className:or.description,children:n}):null]})]}),h.jsx("div",{className:or.content,children:o})]})}),$2e="VisualConfigEditor-module__visualEditor___qt8bb",X2e="VisualConfigEditor-module__overview___OzHQc",Q2e="VisualConfigEditor-module__overviewHeader___A8kWa",Y2e="VisualConfigEditor-module__overviewMeta___SM8ZF",J2e="VisualConfigEditor-module__overviewPill___eXq54",Z2e="VisualConfigEditor-module__overviewPillWarning___ruscj",eSe="VisualConfigEditor-module__overviewFocusList___UfkDy",tSe="VisualConfigEditor-module__overviewFocusLink___CSqNR",nSe="VisualConfigEditor-module__overviewFocusLinkActive___LCEnC",iSe="VisualConfigEditor-module__focusIcon___9SvWW",sSe="VisualConfigEditor-module__focusCopy___FTgbh",aSe="VisualConfigEditor-module__focusTitle___mIxOM",oSe="VisualConfigEditor-module__focusDescription___NUwa3",rSe="VisualConfigEditor-module__workspace___gqLDP",lSe="VisualConfigEditor-module__sidebar___SiTqL",cSe="VisualConfigEditor-module__sidebarPlaceholder___LpX2Y",uSe="VisualConfigEditor-module__sidebarRail___aktyQ",dSe="VisualConfigEditor-module__floatingSidebarContainer___FWwFS",hSe="VisualConfigEditor-module__floatingSidebarRail___ym20u",fSe="VisualConfigEditor-module__navList___Z7CyL",mSe="VisualConfigEditor-module__navButton___EtGL7",pSe="VisualConfigEditor-module__navButtonActive___oMl0Y",gSe="VisualConfigEditor-module__navIndex___NEFe2",_Se="VisualConfigEditor-module__navMain___JoJFq",ySe="VisualConfigEditor-module__navHeadingRow___ulXXL",bSe="VisualConfigEditor-module__navLabelWrap___3-6B4",vSe="VisualConfigEditor-module__navIcon___ZGr7m",xSe="VisualConfigEditor-module__navLabel___-reRP",SSe="VisualConfigEditor-module__navDescription___PvAH-",wSe="VisualConfigEditor-module__navBadge___UKNbs",kSe="VisualConfigEditor-module__sections___UAac4",CSe="VisualConfigEditor-module__sectionGrid___KHy6p",ASe="VisualConfigEditor-module__sectionStack___nY-l7",NSe="VisualConfigEditor-module__divider___RHNc6",TSe="VisualConfigEditor-module__toggleRow___Lb65M",MSe="VisualConfigEditor-module__toggleCopy___IC6RU",LSe="VisualConfigEditor-module__toggleTitle___ep81q",OSe="VisualConfigEditor-module__toggleDescription___DrJw5",PSe="VisualConfigEditor-module__fieldShell___Q-UC-",ESe="VisualConfigEditor-module__fieldLabel___B0C9J",jSe="VisualConfigEditor-module__fieldControl___bzi3y",RSe="VisualConfigEditor-module__fieldHint___lA9jH",DSe="VisualConfigEditor-module__inlinePill___qI2DE",FSe="VisualConfigEditor-module__subsection___wLWRY",ISe="VisualConfigEditor-module__subsectionHeader___OAu1N",USe="VisualConfigEditor-module__subsectionTitle___9spj4",BSe="VisualConfigEditor-module__subsectionDescription___Cy1zr",qSe="VisualConfigEditor-module__blockHeaderRow___bw0Ek",zSe="VisualConfigEditor-module__blockStack___skL7x",KSe="VisualConfigEditor-module__ruleCard___PtDhf",VSe="VisualConfigEditor-module__ruleCardHeader___MYRwJ",HSe="VisualConfigEditor-module__ruleCardTitle___tshgp",WSe="VisualConfigEditor-module__blockLabel___NjEEm",GSe="VisualConfigEditor-module__actionRow___XLzbJ",$Se="VisualConfigEditor-module__emptyState___A7-n3",XSe="VisualConfigEditor-module__stringList___lQQGc",QSe="VisualConfigEditor-module__stringListRow___4k2cz",YSe="VisualConfigEditor-module__payloadRuleModelRow___VKBv1",JSe="VisualConfigEditor-module__payloadRuleModelRowProtocolFirst___OaJ2F",ZSe="VisualConfigEditor-module__payloadRuleParamRow___KZJW-",ewe="VisualConfigEditor-module__payloadRuleParamGroup___1QLNQ",twe="VisualConfigEditor-module__payloadJsonInput___ewOqz",nwe="VisualConfigEditor-module__payloadParamError___wGWdg",iwe="VisualConfigEditor-module__payloadFilterModelRow___MeP9-",swe="VisualConfigEditor-module__apiKeyModalInputRow___08QmU",awe="VisualConfigEditor-module__payloadRowActionButton___8Fdka",Ie={visualEditor:$2e,overview:X2e,overviewHeader:Q2e,overviewMeta:Y2e,overviewPill:J2e,overviewPillWarning:Z2e,overviewFocusList:eSe,overviewFocusLink:tSe,overviewFocusLinkActive:nSe,focusIcon:iSe,focusCopy:sSe,focusTitle:aSe,focusDescription:oSe,workspace:rSe,sidebar:lSe,sidebarPlaceholder:cSe,sidebarRail:uSe,floatingSidebarContainer:dSe,floatingSidebarRail:hSe,navList:fSe,navButton:mSe,navButtonActive:pSe,navIndex:gSe,navMain:_Se,navHeadingRow:ySe,navLabelWrap:bSe,navIcon:vSe,navLabel:xSe,navDescription:SSe,navBadge:wSe,sections:kSe,sectionGrid:CSe,sectionStack:ASe,divider:NSe,toggleRow:TSe,toggleCopy:MSe,toggleTitle:LSe,toggleDescription:OSe,fieldShell:PSe,fieldLabel:ESe,fieldControl:jSe,fieldHint:RSe,inlinePill:DSe,subsection:FSe,subsectionHeader:ISe,subsectionTitle:USe,subsectionDescription:BSe,blockHeaderRow:qSe,blockStack:zSe,ruleCard:KSe,ruleCardHeader:VSe,ruleCardTitle:HSe,blockLabel:WSe,actionRow:GSe,emptyState:$Se,stringList:XSe,stringListRow:QSe,payloadRuleModelRow:YSe,payloadRuleModelRowProtocolFirst:JSe,payloadRuleParamRow:ZSe,payloadRuleParamGroup:ewe,payloadJsonInput:twe,payloadParamError:nwe,payloadFilterModelRow:iwe,apiKeyModalInputRow:swe,payloadRowActionButton:awe},Ga=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,TR={host:"",port:"",tlsEnable:!1,tlsCert:"",tlsKey:"",rmAllowRemote:!1,rmSecretKey:"",rmDisableControlPanel:!1,rmPanelRepo:"",authDir:"",apiKeysText:"",debug:!1,commercialMode:!1,loggingToFile:!1,logsMaxTotalSizeMb:"",usageStatisticsEnabled:!1,proxyUrl:"",forceModelPrefix:!1,requestRetry:"",maxRetryCredentials:"",maxRetryInterval:"",quotaSwitchProject:!0,quotaSwitchPreviewModel:!0,routingStrategy:"round-robin",wsAuth:!1,payloadDefaultRules:[],payloadDefaultRawRules:[],payloadOverrideRules:[],payloadOverrideRawRules:[],payloadFilterRules:[],streaming:{keepaliveSeconds:"",bootstrapRetries:"",nonstreamKeepaliveInterval:""}};function Ai(t){return t===null||typeof t!="object"||Array.isArray(t)?null:t}function owe(t){if(typeof t=="string"){const i=t.trim();return i||null}const e=Ai(t);if(!e)return null;const n=[e["api-key"],e.apiKey,e.key,e.Key];for(const i of n)if(typeof i=="string"){const s=i.trim();if(s)return s}return null}function o2(t){if(!Array.isArray(t))return"";const e=[];for(const n of t){const i=owe(n);i&&e.push(i)}return e.join(`
+`)}function rwe(t){if(Object.prototype.hasOwnProperty.call(t,"api-keys"))return o2(t["api-keys"]);const e=Ai(t.auth),n=Ai(e?.providers),i=Ai(n?.["config-api-key"]);return i?Object.prototype.hasOwnProperty.call(i,"api-key-entries")?o2(i["api-key-entries"]):o2(i["api-keys"]):""}function Oi(t,e){return t.hasIn(e)}function Bu(t,e){const n=t.getIn(e,!0);Dl(n)||t.setIn(e,t.createNode({}))}function gr(t,e){const n=t.getIn(e,!0);Dl(n)&&n.items.length===0&&t.deleteIn(e)}function lr(t,e,n){if(n){t.setIn(e,!0);return}Oi(t,e)&&t.setIn(e,!1)}function ac(t,e,n){const i=typeof n=="string"?n:"";if(i.trim()!==""){t.setIn(e,i);return}Oi(t,e)&&t.setIn(e,"")}function al(t,e,n){const s=(typeof n=="string"?n:"").trim();if(s===""){Oi(t,e)&&t.deleteIn(e);return}if(!/^-?\d+$/.test(s))return;const a=Number(s);if(Number.isFinite(a)){t.setIn(e,a);return}}function oc(t){const e=t.trim();if(e)return/^-?\d+$/.test(e)&&Number(e)>=0?void 0:"non_negative_integer"}function lwe(t){const e=t.trim();if(!e)return;if(!/^\d+$/.test(e))return"port_range";const n=Number(e);return n>=1&&n<=65535?void 0:"port_range"}function cwe(t){return{port:lwe(t.port),logsMaxTotalSizeMb:oc(t.logsMaxTotalSizeMb),requestRetry:oc(t.requestRetry),maxRetryCredentials:oc(t.maxRetryCredentials),maxRetryInterval:oc(t.maxRetryInterval),"streaming.keepaliveSeconds":oc(t.streaming.keepaliveSeconds),"streaming.bootstrapRetries":oc(t.streaming.bootstrapRetries),"streaming.nonstreamKeepaliveInterval":oc(t.streaming.nonstreamKeepaliveInterval)}}function cI(t){const e=t.value.trim();switch(t.valueType){case"number":{if(!e)return"payload_invalid_number";const n=Number(e);return Number.isFinite(n)?void 0:"payload_invalid_number"}case"boolean":{const n=e.toLowerCase();return n==="true"||n==="false"?void 0:"payload_invalid_boolean"}case"json":{if(!e)return"payload_invalid_json";try{JSON.parse(t.value);return}catch{return"payload_invalid_json"}}default:return}}function z_(t){return t.some(e=>e.params.some(n=>!!cI(n)))}function uwe(t){return typeof structuredClone=="function"?structuredClone(t):JSON.parse(JSON.stringify(t))}function dwe(t){if(typeof t=="number")return{valueType:"number",value:String(t)};if(typeof t=="boolean")return{valueType:"boolean",value:String(t)};if(t===null||typeof t=="object")try{return{valueType:"json",value:JSON.stringify(t,null,2)??"null"}}catch{return{valueType:"json",value:String(t)}}return{valueType:"string",value:String(t??"")}}function hwe(t){if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)??""}catch{return String(t??"")}}function lC(t){if(typeof t=="string")return t.trim()?t:void 0}function fwe(t){Oi(t,["auth","providers","config-api-key","api-key-entries"])&&t.deleteIn(["auth","providers","config-api-key","api-key-entries"]),Oi(t,["auth","providers","config-api-key","api-keys"])&&t.deleteIn(["auth","providers","config-api-key","api-keys"]),gr(t,["auth","providers","config-api-key"]),gr(t,["auth","providers"]),gr(t,["auth"])}function MR(t){return Array.isArray(t)?t.map((e,n)=>{const i=Ai(e)??{},s=i.models,a=Array.isArray(s)?s.map((c,d)=>{const f=Ai(c),p=typeof c=="string"?c:f?.name??f?.id??"",g=typeof p=="string"?p:String(p??"");return{id:`model-${n}-${d}`,name:g,protocol:lC(f?.protocol)}}):[],o=Ai(i.params),r=o?Object.entries(o).map(([c,d],f)=>{const p=dwe(d);return{id:`param-${n}-${f}`,path:c,valueType:p.valueType,value:p.value}}):[];return{id:`payload-rule-${n}`,models:a,params:r}}):[]}function mwe(t){return Array.isArray(t)?t.map((e,n)=>{const i=Ai(e)??{},s=i.models,a=Array.isArray(s)?s.map((c,d)=>{const f=Ai(c),p=typeof c=="string"?c:f?.name??f?.id??"",g=typeof p=="string"?p:String(p??"");return{id:`filter-model-${n}-${d}`,name:g,protocol:lC(f?.protocol)}}):[],o=i.params,r=Array.isArray(o)?o.map(String):[];return{id:`payload-filter-rule-${n}`,models:a,params:r}}):[]}function LR(t){return Array.isArray(t)?t.map((e,n)=>{const i=Ai(e)??{},s=i.models,a=Array.isArray(s)?s.map((c,d)=>{const f=Ai(c),p=typeof c=="string"?c:f?.name??f?.id??"",g=typeof p=="string"?p:String(p??"");return{id:`raw-model-${n}-${d}`,name:g,protocol:lC(f?.protocol)}}):[],o=Ai(i.params),r=o?Object.entries(o).map(([c,d],f)=>({id:`raw-param-${n}-${f}`,path:c,valueType:"json",value:hwe(d)})):[];return{id:`payload-raw-rule-${n}`,models:a,params:r}}):[]}function OR(t){return t.map(e=>{const n=(e.models||[]).filter(s=>s.name?.trim()).map(s=>{const a={name:s.name.trim()};return s.protocol&&(a.protocol=s.protocol),a}),i={};for(const s of e.params||[]){if(!s.path?.trim())continue;let a=s.value;if(s.valueType==="number"){const o=Number(s.value);a=Number.isFinite(o)?o:s.value}else if(s.valueType==="boolean")a=s.value==="true";else if(s.valueType==="json")try{a=JSON.parse(s.value)}catch{a=s.value}i[s.path.trim()]=a}return{models:n,params:i}}).filter(e=>e.models.length>0)}function pwe(t){return t.map(e=>{const n=(e.models||[]).filter(s=>s.name?.trim()).map(s=>{const a={name:s.name.trim()};return s.protocol&&(a.protocol=s.protocol),a}),i=(Array.isArray(e.params)?e.params:[]).map(s=>String(s).trim()).filter(Boolean);return{models:n,params:i}}).filter(e=>e.models.length>0)}function PR(t){return t.map(e=>{const n=(e.models||[]).filter(s=>s.name?.trim()).map(s=>{const a={name:s.name.trim()};return s.protocol&&(a.protocol=s.protocol),a}),i={};for(const s of e.params||[])s.path?.trim()&&(i[s.path.trim()]=s.value);return{models:n,params:i}}).filter(e=>e.models.length>0)}function gwe(){const[t,e]=S.useState({...TR}),[n,i]=S.useState({...TR}),[s,a]=S.useState(null),o=S.useMemo(()=>cwe(t),[t]),r=S.useMemo(()=>z_(t.payloadDefaultRules)||z_(t.payloadDefaultRawRules)||z_(t.payloadOverrideRules)||z_(t.payloadOverrideRawRules),[t.payloadDefaultRules,t.payloadDefaultRawRules,t.payloadOverrideRules,t.payloadOverrideRawRules]),c=S.useMemo(()=>JSON.stringify(t)!==JSON.stringify(n),[n,t]),d=S.useCallback(g=>{try{const _=Dm(g);if(_.errors.length>0)throw new Error(_.errors[0]?.message??"Invalid YAML");const y=lI(g)||{},v=Ai(y)??{},x=Ai(v.tls),k=Ai(v["remote-management"]),A=Ai(v["quota-exceeded"]),N=Ai(v.routing),O=Ai(v.payload),M=Ai(v.streaming),L={host:typeof v.host=="string"?v.host:"",port:String(v.port??""),tlsEnable:!!x?.enable,tlsCert:typeof x?.cert=="string"?x.cert:"",tlsKey:typeof x?.key=="string"?x.key:"",rmAllowRemote:!!k?.["allow-remote"],rmSecretKey:typeof k?.["secret-key"]=="string"?k["secret-key"]:"",rmDisableControlPanel:!!k?.["disable-control-panel"],rmPanelRepo:typeof k?.["panel-github-repository"]=="string"?k["panel-github-repository"]:typeof k?.["panel-repo"]=="string"?k["panel-repo"]:"",authDir:typeof v["auth-dir"]=="string"?v["auth-dir"]:"",apiKeysText:rwe(v),debug:!!v.debug,commercialMode:!!v["commercial-mode"],loggingToFile:!!v["logging-to-file"],logsMaxTotalSizeMb:String(v["logs-max-total-size-mb"]??""),usageStatisticsEnabled:!!v["usage-statistics-enabled"],proxyUrl:typeof v["proxy-url"]=="string"?v["proxy-url"]:"",forceModelPrefix:!!v["force-model-prefix"],requestRetry:String(v["request-retry"]??""),maxRetryCredentials:String(v["max-retry-credentials"]??""),maxRetryInterval:String(v["max-retry-interval"]??""),wsAuth:!!v["ws-auth"],quotaSwitchProject:!!(A?.["switch-project"]??!0),quotaSwitchPreviewModel:!!(A?.["switch-preview-model"]??!0),routingStrategy:N?.strategy==="fill-first"?"fill-first":"round-robin",payloadDefaultRules:MR(O?.default),payloadDefaultRawRules:LR(O?.["default-raw"]),payloadOverrideRules:MR(O?.override),payloadOverrideRawRules:LR(O?.["override-raw"]),payloadFilterRules:mwe(O?.filter),streaming:{keepaliveSeconds:String(M?.["keepalive-seconds"]??""),bootstrapRetries:String(M?.["bootstrap-retries"]??""),nonstreamKeepaliveInterval:String(v["nonstream-keepalive-interval"]??"")}};return e(L),i(uwe(L)),a(null),{ok:!0}}catch(_){const y=_ instanceof Error?_.message:"Invalid YAML";return a(y),{ok:!1,error:y}}},[]),f=S.useCallback(g=>{try{const _=Dm(g);if(_.errors.length>0)return g;Dl(_.contents)||(_.contents=_.createNode({}));const y=t;ac(_,["host"],y.host),al(_,["port"],y.port),(Oi(_,["tls"])||y.tlsEnable||y.tlsCert.trim()||y.tlsKey.trim())&&(Bu(_,["tls"]),lr(_,["tls","enable"],y.tlsEnable),ac(_,["tls","cert"],y.tlsCert),ac(_,["tls","key"],y.tlsKey),gr(_,["tls"])),(Oi(_,["remote-management"])||y.rmAllowRemote||y.rmSecretKey.trim()||y.rmDisableControlPanel||y.rmPanelRepo.trim())&&(Bu(_,["remote-management"]),lr(_,["remote-management","allow-remote"],y.rmAllowRemote),ac(_,["remote-management","secret-key"],y.rmSecretKey),lr(_,["remote-management","disable-control-panel"],y.rmDisableControlPanel),ac(_,["remote-management","panel-github-repository"],y.rmPanelRepo),Oi(_,["remote-management","panel-repo"])&&_.deleteIn(["remote-management","panel-repo"]),gr(_,["remote-management"])),ac(_,["auth-dir"],y.authDir);const v=y.apiKeysText.split(`
+`).map(O=>O.trim()).filter(Boolean);v.length>0?_.setIn(["api-keys"],v):Oi(_,["api-keys"])&&_.deleteIn(["api-keys"]),fwe(_),lr(_,["debug"],y.debug),lr(_,["commercial-mode"],y.commercialMode),lr(_,["logging-to-file"],y.loggingToFile),al(_,["logs-max-total-size-mb"],y.logsMaxTotalSizeMb),lr(_,["usage-statistics-enabled"],y.usageStatisticsEnabled),ac(_,["proxy-url"],y.proxyUrl),lr(_,["force-model-prefix"],y.forceModelPrefix),al(_,["request-retry"],y.requestRetry),al(_,["max-retry-credentials"],y.maxRetryCredentials),al(_,["max-retry-interval"],y.maxRetryInterval),lr(_,["ws-auth"],y.wsAuth),(Oi(_,["quota-exceeded"])||!y.quotaSwitchProject||!y.quotaSwitchPreviewModel)&&(Bu(_,["quota-exceeded"]),_.setIn(["quota-exceeded","switch-project"],y.quotaSwitchProject),_.setIn(["quota-exceeded","switch-preview-model"],y.quotaSwitchPreviewModel),gr(_,["quota-exceeded"])),(Oi(_,["routing"])||y.routingStrategy!=="round-robin")&&(Bu(_,["routing"]),_.setIn(["routing","strategy"],y.routingStrategy),gr(_,["routing"]));const x=typeof y.streaming?.keepaliveSeconds=="string"?y.streaming.keepaliveSeconds:"",k=typeof y.streaming?.bootstrapRetries=="string"?y.streaming.bootstrapRetries:"",A=typeof y.streaming?.nonstreamKeepaliveInterval=="string"?y.streaming.nonstreamKeepaliveInterval:"";return(Oi(_,["streaming"])||x.trim()||k.trim())&&(Bu(_,["streaming"]),al(_,["streaming","keepalive-seconds"],x),al(_,["streaming","bootstrap-retries"],k),gr(_,["streaming"])),al(_,["nonstream-keepalive-interval"],A),(Oi(_,["payload"])||y.payloadDefaultRules.length>0||y.payloadDefaultRawRules.length>0||y.payloadOverrideRules.length>0||y.payloadOverrideRawRules.length>0||y.payloadFilterRules.length>0)&&(Bu(_,["payload"]),y.payloadDefaultRules.length>0?_.setIn(["payload","default"],OR(y.payloadDefaultRules)):Oi(_,["payload","default"])&&_.deleteIn(["payload","default"]),y.payloadDefaultRawRules.length>0?_.setIn(["payload","default-raw"],PR(y.payloadDefaultRawRules)):Oi(_,["payload","default-raw"])&&_.deleteIn(["payload","default-raw"]),y.payloadOverrideRules.length>0?_.setIn(["payload","override"],OR(y.payloadOverrideRules)):Oi(_,["payload","override"])&&_.deleteIn(["payload","override"]),y.payloadOverrideRawRules.length>0?_.setIn(["payload","override-raw"],PR(y.payloadOverrideRawRules)):Oi(_,["payload","override-raw"])&&_.deleteIn(["payload","override-raw"]),y.payloadFilterRules.length>0?_.setIn(["payload","filter"],pwe(y.payloadFilterRules)):Oi(_,["payload","filter"])&&_.deleteIn(["payload","filter"]),gr(_,["payload"])),_.toString({indent:2,lineWidth:120,minContentWidth:0})}catch{return g}},[t]),p=S.useCallback(g=>{e(_=>{const y={..._,...g};return g.streaming&&(y.streaming={..._.streaming,...g.streaming}),y})},[]);return{visualValues:t,visualDirty:c,visualParseError:s,visualValidationErrors:o,visualHasPayloadValidationErrors:r,loadVisualValuesFromYaml:d,applyVisualChangesToYaml:f,setVisualValues:p}}const _we=[{value:"",labelKey:"config_management.visual.payload_rules.provider_default",defaultLabel:"Default"},{value:"openai",labelKey:"config_management.visual.payload_rules.provider_openai",defaultLabel:"OpenAI"},{value:"openai-response",labelKey:"config_management.visual.payload_rules.provider_openai_response",defaultLabel:"OpenAI Response"},{value:"gemini",labelKey:"config_management.visual.payload_rules.provider_gemini",defaultLabel:"Gemini"},{value:"claude",labelKey:"config_management.visual.payload_rules.provider_claude",defaultLabel:"Claude"},{value:"codex",labelKey:"config_management.visual.payload_rules.provider_codex",defaultLabel:"Codex"},{value:"antigravity",labelKey:"config_management.visual.payload_rules.provider_antigravity",defaultLabel:"Antigravity"}],ywe=[{value:"string",labelKey:"config_management.visual.payload_rules.value_type_string",defaultLabel:"String"},{value:"number",labelKey:"config_management.visual.payload_rules.value_type_number",defaultLabel:"Number"},{value:"boolean",labelKey:"config_management.visual.payload_rules.value_type_boolean",defaultLabel:"Boolean"},{value:"json",labelKey:"config_management.visual.payload_rules.value_type_json",defaultLabel:"JSON"}];function bwe(t){return t?/^[\x21-\x7E]+$/.test(t):!1}function vwe(t,e){if(e)return t(`config_management.visual.validation.${e}`)}function uI(t,e){const n=_we.map(s=>({value:s.value,label:t(s.labelKey,{defaultValue:s.defaultLabel})})),i=new Set(n.map(s=>s.value));for(const s of e)for(const a of s.models){const o=a.protocol;!o||!o.trim()||i.has(o)||(i.add(o),n.push({value:o,label:o}))}return n}const xwe=S.memo(function({value:e,disabled:n,onChange:i}){const{t:s}=nt(),a=pn(G=>G.showNotification),o=S.useMemo(()=>e.split(`
+`).map(G=>G.trim()).filter(Boolean),[e]),[r,c]=S.useState(()=>o.map(()=>Ga())),d=S.useMemo(()=>r.length===o.length?r:r.length>o.length?r.slice(0,o.length):[...r,...Array.from({length:o.length-r.length},()=>Ga())],[r,o.length]),f=S.useId(),p=`${f}-hint`,g=`${f}-error`,[_,y]=S.useState(!1),[v,x]=S.useState(null),[k,A]=S.useState(""),[N,O]=S.useState("");function M(){const G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",q=new Uint8Array(17);return crypto.getRandomValues(q),"sk-"+Array.from(q,F=>G[F%G.length]).join("")}const L=()=>{x(null),A(""),O(""),y(!0)},T=G=>{const q=d.findIndex(F=>F===G);x(G),A(o[q]??""),O(""),y(!0)},P=()=>{y(!1),A(""),x(null),O("")},E=G=>{i(G.join(`
+`))},R=G=>{const q=d.findIndex(F=>F===G);q<0||(c(d.filter(F=>F!==G)),E(o.filter((F,V)=>V!==q)))},B=()=>{const G=k.trim();if(!G){O(s("config_management.visual.api_keys.error_empty"));return}if(!bwe(G)){O(s("config_management.visual.api_keys.error_invalid"));return}const q=v?d.findIndex(V=>V===v):-1,F=v===null?[...o,G]:o.map((V,H)=>H===q?G:V);v===null&&c([...d,Ga()]),E(F),P()},I=async G=>{const q=await Dy(G);a(s(q?"notification.link_copied":"notification.copy_failed"),q?"success":"error")},Q=()=>{A(M()),O("")};return h.jsxs("div",{className:"form-group",style:{marginBottom:0},children:[h.jsxs("div",{className:Ie.blockHeaderRow,children:[h.jsx("label",{style:{margin:0},children:s("config_management.visual.api_keys.label")}),h.jsx(fe,{size:"sm",onClick:L,disabled:n,children:s("config_management.visual.api_keys.add")})]}),o.length===0?h.jsx("div",{className:Ie.emptyState,children:s("config_management.visual.api_keys.empty")}):h.jsx("div",{className:"item-list",style:{marginTop:4},children:o.map((G,q)=>h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsxs("div",{className:"pill",children:["#",q+1]}),h.jsx("div",{className:"item-title",children:s("config_management.visual.api_keys.input_label")}),h.jsx("div",{className:"item-subtitle",children:Pa(String(G||""))})]}),h.jsxs("div",{className:"item-actions",children:[h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>I(G),disabled:n,children:s("common.copy")}),h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>T(d[q]??""),disabled:n,children:s("config_management.visual.common.edit")}),h.jsx(fe,{variant:"danger",size:"sm",onClick:()=>R(d[q]??""),disabled:n,children:s("config_management.visual.common.delete")})]})]},d[q]??`${G}-${q}`))}),h.jsx("div",{className:"hint",children:s("config_management.visual.api_keys.hint")}),h.jsx(vs,{open:_,onClose:P,title:s(v!==null?"config_management.visual.api_keys.edit_title":"config_management.visual.api_keys.add_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(fe,{variant:"secondary",onClick:P,disabled:n,children:s("config_management.visual.common.cancel")}),h.jsx(fe,{onClick:B,disabled:n,children:s(v!==null?"config_management.visual.common.update":"config_management.visual.common.add")})]}),children:h.jsxs("div",{className:"form-group",children:[h.jsx("label",{htmlFor:f,children:s("config_management.visual.api_keys.input_label")}),h.jsxs("div",{className:Ie.apiKeyModalInputRow,children:[h.jsx("input",{id:f,className:"input",placeholder:s("config_management.visual.api_keys.input_placeholder"),value:k,onChange:G=>A(G.target.value),disabled:n,"aria-describedby":N?`${g} ${p}`:p,"aria-invalid":!!N}),h.jsx(fe,{type:"button",variant:"secondary",size:"sm",onClick:Q,disabled:n,children:s("config_management.visual.api_keys.generate")})]}),h.jsx("div",{id:p,className:"hint",children:s("config_management.visual.api_keys.input_hint")}),N&&h.jsx("div",{id:g,className:"error-box",children:N})]})})]})}),Swe=S.memo(function({value:e,disabled:n,placeholder:i,inputAriaLabel:s,onChange:a}){const{t:o}=nt(),r=e.length?e:[],[c,d]=S.useState(()=>r.map(()=>Ga())),f=S.useMemo(()=>c.length===r.length?c:c.length>r.length?c.slice(0,r.length):[...c,...Array.from({length:r.length-c.length},()=>Ga())],[c,r.length]),p=(y,v)=>a(r.map((x,k)=>k===y?v:x)),g=()=>{d([...f,Ga()]),a([...r,""])},_=y=>{d(f.filter((v,x)=>x!==y)),a(r.filter((v,x)=>x!==y))};return h.jsxs("div",{className:Ie.stringList,children:[r.map((y,v)=>h.jsxs("div",{className:Ie.stringListRow,children:[h.jsx("input",{className:"input",placeholder:i,"aria-label":s??i,value:y,onChange:x=>p(v,x.target.value),disabled:n,style:{flex:1}}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>_(v),disabled:n,children:o("config_management.visual.common.delete")})]},f[v]??`item-${v}`)),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:g,disabled:n,children:o("config_management.visual.common.add")})})]})}),K_=S.memo(function({value:e,disabled:n,protocolFirst:i=!1,rawJsonValues:s=!1,onChange:a}){const{t:o}=nt(),r=e,c=S.useMemo(()=>uI(o,r),[r,o]),d=S.useMemo(()=>ywe.map(T=>({value:T.value,label:o(T.labelKey,{defaultValue:T.defaultLabel})})),[o]),f=S.useMemo(()=>[{value:"true",label:o("config_management.visual.payload_rules.boolean_true")},{value:"false",label:o("config_management.visual.payload_rules.boolean_false")}],[o]),p=()=>a([...r,{id:Ga(),models:[],params:[]}]),g=T=>a(r.filter((P,E)=>E!==T)),_=(T,P)=>a(r.map((E,R)=>R===T?{...E,...P}:E)),y=T=>{const P=r[T],E={id:Ga(),name:"",protocol:void 0};_(T,{models:[...P.models,E]})},v=(T,P)=>{const E=r[T];_(T,{models:E.models.filter((R,B)=>B!==P)})},x=(T,P,E)=>{const R=r[T];_(T,{models:R.models.map((B,I)=>I===P?{...B,...E}:B)})},k=T=>{const P=r[T],E={id:Ga(),path:"",valueType:s?"json":"string",value:""};_(T,{params:[...P.params,E]})},A=(T,P)=>{const E=r[T];_(T,{params:E.params.filter((R,B)=>B!==P)})},N=(T,P,E)=>{const R=r[T];_(T,{params:R.params.map((B,I)=>I===P?{...B,...E}:B)})},O=T=>{switch(T){case"string":return o("config_management.visual.payload_rules.value_string");case"number":return o("config_management.visual.payload_rules.value_number");case"boolean":return o("config_management.visual.payload_rules.value_boolean");case"json":return o("config_management.visual.payload_rules.value_json");default:return o("config_management.visual.payload_rules.value_default")}},M=T=>{const P=cI(s?{...T,valueType:"json"}:T);return vwe(o,P)},L=(T,P,E)=>s?h.jsx("textarea",{className:`input ${Ie.payloadJsonInput}`,placeholder:o("config_management.visual.payload_rules.value_raw_json"),"aria-label":o("config_management.visual.payload_rules.param_value"),value:E.value,onChange:R=>N(T,P,{value:R.target.value,valueType:"json"}),disabled:n}):E.valueType==="boolean"?h.jsx(Ki,{value:E.value.toLowerCase()==="true"||E.value.toLowerCase()==="false"?E.value.toLowerCase():"",options:f,placeholder:o("config_management.visual.payload_rules.value_boolean"),disabled:n,ariaLabel:o("config_management.visual.payload_rules.param_value"),onChange:R=>N(T,P,{value:R})}):E.valueType==="json"?h.jsx("textarea",{className:`input ${Ie.payloadJsonInput}`,placeholder:O(E.valueType),"aria-label":o("config_management.visual.payload_rules.param_value"),value:E.value,onChange:R=>N(T,P,{value:R.target.value}),disabled:n}):h.jsx("input",{className:"input",placeholder:O(E.valueType),"aria-label":o("config_management.visual.payload_rules.param_value"),value:E.value,onChange:R=>N(T,P,{value:R.target.value}),disabled:n});return h.jsxs("div",{className:Ie.blockStack,children:[r.map((T,P)=>h.jsxs("div",{className:Ie.ruleCard,children:[h.jsxs("div",{className:Ie.ruleCardHeader,children:[h.jsxs("div",{className:Ie.ruleCardTitle,children:[o("config_management.visual.payload_rules.rule")," ",P+1]}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>g(P),disabled:n,children:o("config_management.visual.common.delete")})]}),h.jsxs("div",{className:Ie.blockStack,children:[h.jsx("div",{className:Ie.blockLabel,children:o("config_management.visual.payload_rules.models")}),(T.models.length?T.models:[]).map((E,R)=>h.jsxs("div",{className:[Ie.payloadRuleModelRow,i?Ie.payloadRuleModelRowProtocolFirst:""].filter(Boolean).join(" "),children:[i?h.jsxs(h.Fragment,{children:[h.jsx(Ki,{value:E.protocol??"",options:c,disabled:n,ariaLabel:o("config_management.visual.payload_rules.provider_type"),onChange:B=>x(P,R,{protocol:B||void 0})}),h.jsx("input",{className:"input",placeholder:o("config_management.visual.payload_rules.model_name"),"aria-label":o("config_management.visual.payload_rules.model_name"),value:E.name,onChange:B=>x(P,R,{name:B.target.value}),disabled:n})]}):h.jsxs(h.Fragment,{children:[h.jsx("input",{className:"input",placeholder:o("config_management.visual.payload_rules.model_name"),"aria-label":o("config_management.visual.payload_rules.model_name"),value:E.name,onChange:B=>x(P,R,{name:B.target.value}),disabled:n}),h.jsx(Ki,{value:E.protocol??"",options:c,disabled:n,ariaLabel:o("config_management.visual.payload_rules.provider_type"),onChange:B=>x(P,R,{protocol:B||void 0})})]}),h.jsx(fe,{variant:"ghost",size:"sm",className:Ie.payloadRowActionButton,onClick:()=>v(P,R),disabled:n,children:o("config_management.visual.common.delete")})]},E.id)),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>y(P),disabled:n,children:o("config_management.visual.payload_rules.add_model")})})]}),h.jsxs("div",{className:Ie.blockStack,children:[h.jsx("div",{className:Ie.blockLabel,children:o("config_management.visual.payload_rules.params")}),(T.params.length?T.params:[]).map((E,R)=>{const B=M(E);return h.jsxs("div",{className:Ie.payloadRuleParamGroup,children:[h.jsxs("div",{className:Ie.payloadRuleParamRow,children:[h.jsx("input",{className:"input",placeholder:o("config_management.visual.payload_rules.json_path"),"aria-label":o("config_management.visual.payload_rules.json_path"),value:E.path,onChange:I=>N(P,R,{path:I.target.value}),disabled:n}),s?null:h.jsx(Ki,{value:E.valueType,options:d,disabled:n,ariaLabel:o("config_management.visual.payload_rules.param_type"),onChange:I=>N(P,R,{valueType:I,value:I==="boolean"?"true":I==="json"&&E.value.trim()===""?"{}":E.value})}),L(P,R,E),h.jsx(fe,{variant:"ghost",size:"sm",className:Ie.payloadRowActionButton,onClick:()=>A(P,R),disabled:n,children:o("config_management.visual.common.delete")})]}),B&&h.jsx("div",{className:`error-box ${Ie.payloadParamError}`,children:B})]},E.id)}),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>k(P),disabled:n,children:o("config_management.visual.payload_rules.add_param")})})]})]},T.id)),r.length===0&&h.jsx("div",{className:Ie.emptyState,children:o("config_management.visual.payload_rules.no_rules")}),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:p,disabled:n,children:o("config_management.visual.payload_rules.add_rule")})})]})}),wwe=S.memo(function({value:e,disabled:n,onChange:i}){const{t:s}=nt(),a=e,o=S.useMemo(()=>uI(s,a),[a,s]),r=()=>i([...a,{id:Ga(),models:[],params:[]}]),c=_=>i(a.filter((y,v)=>v!==_)),d=(_,y)=>i(a.map((v,x)=>x===_?{...v,...y}:v)),f=_=>{const y=a[_],v={id:Ga(),name:"",protocol:void 0};d(_,{models:[...y.models,v]})},p=(_,y)=>{const v=a[_];d(_,{models:v.models.filter((x,k)=>k!==y)})},g=(_,y,v)=>{const x=a[_];d(_,{models:x.models.map((k,A)=>A===y?{...k,...v}:k)})};return h.jsxs("div",{className:Ie.blockStack,children:[a.map((_,y)=>h.jsxs("div",{className:Ie.ruleCard,children:[h.jsxs("div",{className:Ie.ruleCardHeader,children:[h.jsxs("div",{className:Ie.ruleCardTitle,children:[s("config_management.visual.payload_rules.rule")," ",y+1]}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:()=>c(y),disabled:n,children:s("config_management.visual.common.delete")})]}),h.jsxs("div",{className:Ie.blockStack,children:[h.jsx("div",{className:Ie.blockLabel,children:s("config_management.visual.payload_rules.models")}),_.models.map((v,x)=>h.jsxs("div",{className:Ie.payloadFilterModelRow,children:[h.jsx("input",{className:"input",placeholder:s("config_management.visual.payload_rules.model_name"),"aria-label":s("config_management.visual.payload_rules.model_name"),value:v.name,onChange:k=>g(y,x,{name:k.target.value}),disabled:n}),h.jsx(Ki,{value:v.protocol??"",options:o,disabled:n,ariaLabel:s("config_management.visual.payload_rules.provider_type"),onChange:k=>g(y,x,{protocol:k||void 0})}),h.jsx(fe,{variant:"ghost",size:"sm",className:Ie.payloadRowActionButton,onClick:()=>p(y,x),disabled:n,children:s("config_management.visual.common.delete")})]},v.id)),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>f(y),disabled:n,children:s("config_management.visual.payload_rules.add_model")})})]}),h.jsxs("div",{className:Ie.blockStack,children:[h.jsx("div",{className:Ie.blockLabel,children:s("config_management.visual.payload_rules.remove_params")}),h.jsx(Swe,{value:_.params,disabled:n,placeholder:s("config_management.visual.payload_rules.json_path_filter"),inputAriaLabel:s("config_management.visual.payload_rules.json_path_filter"),onChange:v=>d(y,{params:v})})]})]},_.id)),a.length===0&&h.jsx("div",{className:Ie.emptyState,children:s("config_management.visual.payload_rules.no_rules")}),h.jsx("div",{className:Ie.actionRow,children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:r,disabled:n,children:s("config_management.visual.payload_rules.add_rule")})})]})});function ol(t,e){if(e)return t(`config_management.visual.validation.${e}`)}function Ba({title:t,description:e,checked:n,disabled:i,onChange:s}){return h.jsxs("div",{className:Ie.toggleRow,children:[h.jsxs("div",{className:Ie.toggleCopy,children:[h.jsx("div",{className:Ie.toggleTitle,children:t}),e?h.jsx("div",{className:Ie.toggleDescription,children:e}):null]}),h.jsx(bi,{checked:n,onChange:s,disabled:i,ariaLabel:t})]})}function ho({children:t}){return h.jsx("div",{className:Ie.sectionGrid,children:t})}function rc({children:t}){return h.jsx("div",{className:Ie.sectionStack,children:t})}function kwe(){return h.jsx("div",{className:Ie.divider})}function gf({title:t,description:e,children:n}){return h.jsxs("div",{className:Ie.subsection,children:[h.jsxs("div",{className:Ie.subsectionHeader,children:[h.jsx("h3",{className:Ie.subsectionTitle,children:t}),e?h.jsx("p",{className:Ie.subsectionDescription,children:e}):null]}),n]})}function r2({label:t,labelId:e,htmlFor:n,hint:i,hintId:s,error:a,errorId:o,children:r}){return h.jsxs("div",{className:Ie.fieldShell,children:[h.jsx("label",{id:e,htmlFor:n,className:Ie.fieldLabel,children:t}),r,a?h.jsx("div",{id:o,className:"error-box",children:a}):null,i?h.jsx("div",{id:s,className:Ie.fieldHint,children:i}):null]})}function Cwe({values:t,validationErrors:e,hasPayloadValidationErrors:n=!1,disabled:i=!1,onChange:s}){const{t:a}=nt(),o=Zm(),r=o?o.status==="current":!0,c=iS("(max-width: 768px)"),d=iS("(min-width: 1025px)"),f=!c&&d&&r,p=S.useId(),g=`${p}-hint`,_=S.useId(),y=`${_}-hint`,v=`${_}-error`,x=S.useId(),k=`${x}-hint`,A=`${x}-error`,[N,O]=S.useState("server"),M=S.useRef(null),L=S.useRef(null),T=S.useRef(null),P=S.useRef({}),E=t.streaming.keepaliveSeconds===""||t.streaming.keepaliveSeconds==="0",R=t.streaming.nonstreamKeepaliveInterval===""||t.streaming.nonstreamKeepaliveInterval==="0",B=ol(a,e?.port),I=ol(a,e?.logsMaxTotalSizeMb),Q=ol(a,e?.requestRetry),G=ol(a,e?.maxRetryCredentials),q=ol(a,e?.maxRetryInterval),F=ol(a,e?.["streaming.keepaliveSeconds"]),V=ol(a,e?.["streaming.bootstrapRetries"]),H=ol(a,e?.["streaming.nonstreamKeepaliveInterval"]),ee=S.useCallback(Y=>s({apiKeysText:Y}),[s]),X=S.useCallback(Y=>s({payloadDefaultRules:Y}),[s]),U=S.useCallback(Y=>s({payloadDefaultRawRules:Y}),[s]),K=S.useCallback(Y=>s({payloadOverrideRules:Y}),[s]),$=S.useCallback(Y=>s({payloadOverrideRawRules:Y}),[s]),J=S.useCallback(Y=>s({payloadFilterRules:Y}),[s]),ne=S.useCallback(Y=>Y.reduce((de,Ae)=>de+(e?.[Ae]?1:0),0),[e]),D=S.useMemo(()=>[{id:"server",title:a("config_management.visual.sections.server.title"),description:a("config_management.visual.sections.server.description"),icon:C2,errorCount:ne(["port"])},{id:"tls",title:a("config_management.visual.sections.tls.title"),description:a("config_management.visual.sections.tls.description"),icon:tL,errorCount:0},{id:"remote",title:a("config_management.visual.sections.remote.title"),description:a("config_management.visual.sections.remote.description"),icon:Gu,errorCount:0},{id:"auth",title:a("config_management.visual.sections.auth.title"),description:a("config_management.visual.sections.auth.description"),icon:k2,errorCount:0},{id:"system",title:a("config_management.visual.sections.system.title"),description:a("config_management.visual.sections.system.description"),icon:A2,errorCount:ne(["logsMaxTotalSizeMb"])},{id:"network",title:a("config_management.visual.sections.network.title"),description:a("config_management.visual.sections.network.description"),icon:N2,errorCount:ne(["requestRetry","maxRetryCredentials","maxRetryInterval"])},{id:"quota",title:a("config_management.visual.sections.quota.title"),description:a("config_management.visual.sections.quota.description"),icon:C0,errorCount:0},{id:"streaming",title:a("config_management.visual.sections.streaming.title"),description:a("config_management.visual.sections.streaming.description"),icon:Gu,errorCount:ne(["streaming.keepaliveSeconds","streaming.bootstrapRetries","streaming.nonstreamKeepaliveInterval"])},{id:"payload",title:a("config_management.visual.sections.payload.title"),description:a("config_management.visual.sections.payload.description"),icon:A0,errorCount:n?1:0}],[ne,n,a]),ie=D.some(Y=>Y.errorCount>0)||n,Z=S.useMemo(()=>D.filter(Y=>["server","network","payload"].includes(Y.id)),[D]);S.useEffect(()=>{if(typeof IntersectionObserver>"u")return;const Y=new IntersectionObserver(de=>{const Ae=de.filter(Ve=>Ve.isIntersecting).sort((Ve,Ge)=>Ge.intersectionRatio-Ve.intersectionRatio);Ae.length!==0&&O(Ae[0].target.id)},{rootMargin:"-18% 0px -58% 0px",threshold:[.12,.3,.55]});for(const de of D){const Ae=P.current[de.id];Ae&&Y.observe(Ae)}return()=>Y.disconnect()},[D]);const se=S.useCallback(Y=>{O(Y),P.current[Y]?.scrollIntoView({behavior:"smooth",block:"start"})},[]);S.useLayoutEffect(()=>{const Y=T.current,de=L.current,Ae=M.current;if(!Y)return;const Ve=()=>{Y.style.removeProperty("--visual-config-floating-left"),Y.style.removeProperty("--visual-config-floating-top"),Y.style.removeProperty("--visual-config-floating-width"),Y.style.removeProperty("--visual-config-floating-max-height"),Y.style.removeProperty("opacity"),Y.style.removeProperty("pointer-events")};if(!f||!de||!Ae){Ve();return}const Ge=()=>{const ft=document.querySelector(".main-header");if(ft)return ft.getBoundingClientRect().height;const It=getComputedStyle(document.documentElement).getPropertyValue("--header-height"),yt=Number.parseFloat(It);return Number.isFinite(yt)?yt:64},je=()=>document.querySelector(".content");let ze=0;const xt=()=>{ze=0;const ft=de.getBoundingClientRect(),It=Ae.getBoundingClientRect(),yt=Y.getBoundingClientRect().height,Mt=Ge()+20,dn=16,ue=It.bottom-yt,re=Math.min(Math.max(ft.top,Mt),ue),Le=Math.max(re,dn),$e=Math.max(ft.left,dn),ht=Math.max(Math.min(ft.width,window.innerWidth-$e-dn),220),bt=Math.max(window.innerHeight-Le-dn,160),At=It.bottom>Mt+24&&ft.top{ze&&cancelAnimationFrame(ze),ze=requestAnimationFrame(xt)};xe();const ot=je();window.addEventListener("resize",xe),window.addEventListener("scroll",xe,{passive:!0}),ot?.addEventListener("scroll",xe,{passive:!0});const ct=typeof ResizeObserver>"u"?null:new ResizeObserver(xe);return ct?.observe(de),ct?.observe(Ae),ct?.observe(Y),()=>{ze&&cancelAnimationFrame(ze),ct?.disconnect(),window.removeEventListener("resize",xe),window.removeEventListener("scroll",xe),ot?.removeEventListener("scroll",xe),Ve()}},[f]);const me=h.jsx("div",{className:Ie.navList,children:D.map((Y,de)=>{const Ae=Y.icon;return h.jsxs("button",{type:"button",className:`${Ie.navButton} ${N===Y.id?Ie.navButtonActive:""}`,onClick:()=>se(Y.id),children:[h.jsx("span",{className:Ie.navIndex,children:String(de+1).padStart(2,"0")}),h.jsxs("span",{className:Ie.navMain,children:[h.jsxs("span",{className:Ie.navHeadingRow,children:[h.jsxs("span",{className:Ie.navLabelWrap,children:[h.jsx("span",{className:Ie.navIcon,children:h.jsx(Ae,{size:14})}),h.jsx("span",{className:Ie.navLabel,children:Y.title})]}),Y.errorCount>0?h.jsx("span",{className:Ie.navBadge,"aria-hidden":"true",children:Y.errorCount}):null]}),h.jsx("span",{className:Ie.navDescription,children:Y.description})]})]},Y.id)})});return h.jsxs("div",{className:Ie.visualEditor,children:[h.jsxs("div",{className:Ie.overview,children:[h.jsx("div",{className:Ie.overviewHeader,children:h.jsxs("div",{className:Ie.overviewMeta,children:[h.jsx("span",{className:Ie.overviewPill,children:a("config_management.visual.quick_jump",{defaultValue:"快速跳转"})}),ie?h.jsx("span",{className:`${Ie.overviewPill} ${Ie.overviewPillWarning}`,children:a("config_management.visual.validation.validation_blocked")}):null]})}),h.jsx("div",{className:Ie.overviewFocusList,children:Z.map(Y=>{const de=Y.icon;return h.jsxs("button",{type:"button",className:`${Ie.overviewFocusLink} ${N===Y.id?Ie.overviewFocusLinkActive:""}`,onClick:()=>se(Y.id),children:[h.jsx("span",{className:Ie.focusIcon,children:h.jsx(de,{size:16})}),h.jsxs("span",{className:Ie.focusCopy,children:[h.jsx("span",{className:Ie.focusTitle,children:Y.title}),h.jsx("span",{className:Ie.focusDescription,children:Y.description})]}),Y.errorCount>0?h.jsx("span",{className:Ie.navBadge,"aria-hidden":"true",children:Y.errorCount}):null]},Y.id)})})]}),h.jsxs("div",{ref:M,className:Ie.workspace,children:[h.jsx("aside",{ref:L,className:Ie.sidebar,children:d?h.jsx("div",{className:Ie.sidebarPlaceholder,"aria-hidden":"true"}):h.jsx("div",{className:Ie.sidebarRail,children:me})}),h.jsxs("div",{className:Ie.sections,children:[h.jsx(rr,{id:"server",ref:Y=>{P.current.server=Y},indexLabel:"01",icon:h.jsx(C2,{size:16}),title:a("config_management.visual.sections.server.title"),description:a("config_management.visual.sections.server.description"),children:h.jsxs(ho,{children:[h.jsx(st,{label:a("config_management.visual.sections.server.host"),placeholder:"0.0.0.0",value:t.host,onChange:Y=>s({host:Y.target.value}),disabled:i}),h.jsx(st,{label:a("config_management.visual.sections.server.port"),type:"number",placeholder:"8317",value:t.port,onChange:Y=>s({port:Y.target.value}),disabled:i,error:B})]})}),h.jsx(rr,{id:"tls",ref:Y=>{P.current.tls=Y},indexLabel:"02",icon:h.jsx(tL,{size:16}),title:a("config_management.visual.sections.tls.title"),description:a("config_management.visual.sections.tls.description"),children:h.jsxs(rc,{children:[h.jsx(Ba,{title:a("config_management.visual.sections.tls.enable"),description:a("config_management.visual.sections.tls.enable_desc"),checked:t.tlsEnable,disabled:i,onChange:Y=>s({tlsEnable:Y})}),t.tlsEnable?h.jsxs(h.Fragment,{children:[h.jsx(kwe,{}),h.jsxs(ho,{children:[h.jsx(st,{label:a("config_management.visual.sections.tls.cert"),placeholder:"/path/to/cert.pem",value:t.tlsCert,onChange:Y=>s({tlsCert:Y.target.value}),disabled:i}),h.jsx(st,{label:a("config_management.visual.sections.tls.key"),placeholder:"/path/to/key.pem",value:t.tlsKey,onChange:Y=>s({tlsKey:Y.target.value}),disabled:i})]})]}):null]})}),h.jsx(rr,{id:"remote",ref:Y=>{P.current.remote=Y},indexLabel:"03",icon:h.jsx(Gu,{size:16}),title:a("config_management.visual.sections.remote.title"),description:a("config_management.visual.sections.remote.description"),children:h.jsxs(rc,{children:[h.jsx(Ba,{title:a("config_management.visual.sections.remote.allow_remote"),description:a("config_management.visual.sections.remote.allow_remote_desc"),checked:t.rmAllowRemote,disabled:i,onChange:Y=>s({rmAllowRemote:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.remote.disable_panel"),description:a("config_management.visual.sections.remote.disable_panel_desc"),checked:t.rmDisableControlPanel,disabled:i,onChange:Y=>s({rmDisableControlPanel:Y})}),h.jsxs(ho,{children:[h.jsx(st,{label:a("config_management.visual.sections.remote.secret_key"),type:"password",placeholder:a("config_management.visual.sections.remote.secret_key_placeholder"),value:t.rmSecretKey,onChange:Y=>s({rmSecretKey:Y.target.value}),disabled:i}),h.jsx(st,{label:a("config_management.visual.sections.remote.panel_repo"),placeholder:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",value:t.rmPanelRepo,onChange:Y=>s({rmPanelRepo:Y.target.value}),disabled:i})]})]})}),h.jsx(rr,{id:"auth",ref:Y=>{P.current.auth=Y},indexLabel:"04",icon:h.jsx(k2,{size:16}),title:a("config_management.visual.sections.auth.title"),description:a("config_management.visual.sections.auth.description"),children:h.jsxs(rc,{children:[h.jsx(st,{label:a("config_management.visual.sections.auth.auth_dir"),placeholder:"~/.cli-proxy-api",value:t.authDir,onChange:Y=>s({authDir:Y.target.value}),disabled:i,hint:a("config_management.visual.sections.auth.auth_dir_hint")}),h.jsx("div",{className:Ie.subsection,children:h.jsx(xwe,{value:t.apiKeysText,disabled:i,onChange:ee})})]})}),h.jsx(rr,{id:"system",ref:Y=>{P.current.system=Y},indexLabel:"05",icon:h.jsx(A2,{size:16}),title:a("config_management.visual.sections.system.title"),description:a("config_management.visual.sections.system.description"),children:h.jsxs(rc,{children:[h.jsxs(ho,{children:[h.jsx(Ba,{title:a("config_management.visual.sections.system.debug"),description:a("config_management.visual.sections.system.debug_desc"),checked:t.debug,disabled:i,onChange:Y=>s({debug:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.system.commercial_mode"),description:a("config_management.visual.sections.system.commercial_mode_desc"),checked:t.commercialMode,disabled:i,onChange:Y=>s({commercialMode:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.system.logging_to_file"),description:a("config_management.visual.sections.system.logging_to_file_desc"),checked:t.loggingToFile,disabled:i,onChange:Y=>s({loggingToFile:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.system.usage_statistics"),description:a("config_management.visual.sections.system.usage_statistics_desc"),checked:t.usageStatisticsEnabled,disabled:i,onChange:Y=>s({usageStatisticsEnabled:Y})})]}),h.jsx(ho,{children:h.jsx(st,{label:a("config_management.visual.sections.system.logs_max_size"),type:"number",placeholder:"0",value:t.logsMaxTotalSizeMb,onChange:Y=>s({logsMaxTotalSizeMb:Y.target.value}),disabled:i,error:I})})]})}),h.jsx(rr,{id:"network",ref:Y=>{P.current.network=Y},indexLabel:"06",icon:h.jsx(N2,{size:16}),title:a("config_management.visual.sections.network.title"),description:a("config_management.visual.sections.network.description"),children:h.jsxs(rc,{children:[h.jsxs(ho,{children:[h.jsx(st,{label:a("config_management.visual.sections.network.proxy_url"),placeholder:"socks5://user:pass@127.0.0.1:1080/",value:t.proxyUrl,onChange:Y=>s({proxyUrl:Y.target.value}),disabled:i}),h.jsx(st,{label:a("config_management.visual.sections.network.request_retry"),type:"number",placeholder:"3",value:t.requestRetry,onChange:Y=>s({requestRetry:Y.target.value}),disabled:i,error:Q}),h.jsx(st,{label:a("config_management.visual.sections.network.max_retry_credentials"),type:"number",placeholder:"0",value:t.maxRetryCredentials,onChange:Y=>s({maxRetryCredentials:Y.target.value}),disabled:i,hint:a("config_management.visual.sections.network.max_retry_credentials_hint"),error:G}),h.jsx(st,{label:a("config_management.visual.sections.network.max_retry_interval"),type:"number",placeholder:"30",value:t.maxRetryInterval,onChange:Y=>s({maxRetryInterval:Y.target.value}),disabled:i,error:q}),h.jsx(r2,{label:a("config_management.visual.sections.network.routing_strategy"),labelId:p,hint:a("config_management.visual.sections.network.routing_strategy_hint"),hintId:g,children:h.jsx(Ki,{value:t.routingStrategy,options:[{value:"round-robin",label:a("config_management.visual.sections.network.strategy_round_robin")},{value:"fill-first",label:a("config_management.visual.sections.network.strategy_fill_first")}],id:`${p}-select`,disabled:i,ariaLabelledBy:p,ariaDescribedBy:g,onChange:Y=>s({routingStrategy:Y})})})]}),h.jsxs(ho,{children:[h.jsx(Ba,{title:a("config_management.visual.sections.network.force_model_prefix"),description:a("config_management.visual.sections.network.force_model_prefix_desc"),checked:t.forceModelPrefix,disabled:i,onChange:Y=>s({forceModelPrefix:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.network.ws_auth"),description:a("config_management.visual.sections.network.ws_auth_desc"),checked:t.wsAuth,disabled:i,onChange:Y=>s({wsAuth:Y})})]})]})}),h.jsx(rr,{id:"quota",ref:Y=>{P.current.quota=Y},indexLabel:"07",icon:h.jsx(C0,{size:16}),title:a("config_management.visual.sections.quota.title"),description:a("config_management.visual.sections.quota.description"),children:h.jsxs(ho,{children:[h.jsx(Ba,{title:a("config_management.visual.sections.quota.switch_project"),description:a("config_management.visual.sections.quota.switch_project_desc"),checked:t.quotaSwitchProject,disabled:i,onChange:Y=>s({quotaSwitchProject:Y})}),h.jsx(Ba,{title:a("config_management.visual.sections.quota.switch_preview_model"),description:a("config_management.visual.sections.quota.switch_preview_model_desc"),checked:t.quotaSwitchPreviewModel,disabled:i,onChange:Y=>s({quotaSwitchPreviewModel:Y})})]})}),h.jsx(rr,{id:"streaming",ref:Y=>{P.current.streaming=Y},indexLabel:"08",icon:h.jsx(Gu,{size:16}),title:a("config_management.visual.sections.streaming.title"),description:a("config_management.visual.sections.streaming.description"),children:h.jsxs(rc,{children:[h.jsxs(ho,{children:[h.jsx(r2,{label:a("config_management.visual.sections.streaming.keepalive_seconds"),htmlFor:_,hint:a("config_management.visual.sections.streaming.keepalive_hint"),hintId:y,error:F,errorId:v,children:h.jsxs("div",{className:Ie.fieldControl,children:[h.jsx("input",{id:_,className:"input",type:"number",placeholder:"0",value:t.streaming.keepaliveSeconds,onChange:Y=>s({streaming:{...t.streaming,keepaliveSeconds:Y.target.value}}),disabled:i}),E?h.jsx("span",{className:Ie.inlinePill,children:a("config_management.visual.sections.streaming.disabled")}):null]})}),h.jsx(st,{label:a("config_management.visual.sections.streaming.bootstrap_retries"),type:"number",placeholder:"1",value:t.streaming.bootstrapRetries,onChange:Y=>s({streaming:{...t.streaming,bootstrapRetries:Y.target.value}}),disabled:i,hint:a("config_management.visual.sections.streaming.bootstrap_hint"),error:V})]}),h.jsx(ho,{children:h.jsx(r2,{label:a("config_management.visual.sections.streaming.nonstream_keepalive"),htmlFor:x,hint:a("config_management.visual.sections.streaming.nonstream_keepalive_hint"),hintId:k,error:H,errorId:A,children:h.jsxs("div",{className:Ie.fieldControl,children:[h.jsx("input",{id:x,className:"input",type:"number",placeholder:"0",value:t.streaming.nonstreamKeepaliveInterval,onChange:Y=>s({streaming:{...t.streaming,nonstreamKeepaliveInterval:Y.target.value}}),disabled:i}),R?h.jsx("span",{className:Ie.inlinePill,children:a("config_management.visual.sections.streaming.disabled")}):null]})})})]})}),h.jsx(rr,{id:"payload",ref:Y=>{P.current.payload=Y},indexLabel:"09",icon:h.jsx(A0,{size:16}),title:a("config_management.visual.sections.payload.title"),description:a("config_management.visual.sections.payload.description"),children:h.jsxs(rc,{children:[h.jsx(gf,{title:a("config_management.visual.sections.payload.default_rules"),description:a("config_management.visual.sections.payload.default_rules_desc"),children:h.jsx(K_,{value:t.payloadDefaultRules,disabled:i,onChange:X})}),h.jsx(gf,{title:a("config_management.visual.sections.payload.default_raw_rules"),description:a("config_management.visual.sections.payload.default_raw_rules_desc"),children:h.jsx(K_,{value:t.payloadDefaultRawRules,disabled:i,rawJsonValues:!0,onChange:U})}),h.jsx(gf,{title:a("config_management.visual.sections.payload.override_rules"),description:a("config_management.visual.sections.payload.override_rules_desc"),children:h.jsx(K_,{value:t.payloadOverrideRules,disabled:i,protocolFirst:!0,onChange:K})}),h.jsx(gf,{title:a("config_management.visual.sections.payload.override_raw_rules"),description:a("config_management.visual.sections.payload.override_raw_rules_desc"),children:h.jsx(K_,{value:t.payloadOverrideRawRules,disabled:i,protocolFirst:!0,rawJsonValues:!0,onChange:$})}),h.jsx(gf,{title:a("config_management.visual.sections.payload.filter_rules"),description:a("config_management.visual.sections.payload.filter_rules_desc"),children:h.jsx(wwe,{value:t.payloadFilterRules,disabled:i,onChange:J})})]})})]})]}),f&&typeof document<"u"?Or.createPortal(h.jsx("div",{ref:T,className:Ie.floatingSidebarContainer,children:h.jsx("div",{className:Ie.floatingSidebarRail,children:me})}),document.body):null]})}class _i{constructor(e,n,i,s){this.fromA=e,this.toA=n,this.fromB=i,this.toB=s}offset(e,n=e){return new _i(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function zc(t,e,n,i,s,a){if(t==i)return[];let o=uC(t,e,n,i,s,a),r=dC(t,e+o,n,i,s+o,a);e+=o,n-=r,s+=o,a-=r;let c=n-e,d=a-s;if(!c||!d)return[new _i(e,n,s,a)];if(c>d){let p=t.slice(e,n).indexOf(i.slice(s,a));if(p>-1)return[new _i(e,e+p,s,s),new _i(e+p+d,n,a,a)]}else if(d>c){let p=i.slice(s,a).indexOf(t.slice(e,n));if(p>-1)return[new _i(e,e,s,s+p),new _i(n,n,s+p+c,a)]}if(c==1||d==1)return[new _i(e,n,s,a)];let f=fI(t,e,n,i,s,a);if(f){let[p,g,_]=f;return zc(t,e,p,i,s,g).concat(zc(t,p+_,n,i,g+_,a))}return Awe(t,e,n,i,s,a)}let Ef=1e9,jf=0,cC=!1;function Awe(t,e,n,i,s,a){let o=n-e,r=a-s;if(Ef<1e9&&Math.min(o,r)>Ef*16||jf>0&&Date.now()>jf)return Math.min(o,r)>Ef*64?[new _i(e,n,s,a)]:ER(t,e,n,i,s,a);let c=Math.ceil((o+r)/2);l2.reset(c),c2.reset(c);let d=(_,y)=>t.charCodeAt(e+_)==i.charCodeAt(s+y),f=(_,y)=>t.charCodeAt(n-_-1)==i.charCodeAt(a-y-1),p=(o-r)%2!=0?c2:null,g=p?null:l2;for(let _=0;_Ef||jf>0&&!(_&63)&&Date.now()>jf)return ER(t,e,n,i,s,a);let y=l2.advance(_,o,r,c,p,!1,d)||c2.advance(_,o,r,c,g,!0,f);if(y)return Nwe(t,e,n,e+y[0],i,s,a,s+y[1])}return[new _i(e,n,s,a)]}class dI{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;nn)this.end+=2;else if(p>i)this.start+=2;else if(a){let g=s+(n-i)-c;if(g>=0&&g=n-f)return[_,s+_-g]}else{let _=n-a.vec[g];if(f>=_)return[f,p]}}}return null}}const l2=new dI,c2=new dI;function Nwe(t,e,n,i,s,a,o,r){let c=!1;return!Dd(t,i)&&++i==n&&(c=!0),!Dd(s,r)&&++r==o&&(c=!0),c?[new _i(e,n,a,o)]:zc(t,e,i,s,a,r).concat(zc(t,i,n,s,r,o))}function hI(t,e){let n=1,i=Math.min(t,e);for(;nn||f>a||t.slice(r,d)!=i.slice(c,f)){if(o==1)return r-e-(Dd(t,r)?0:1);o=o>>1}else{if(d==n||f==a)return d-e;r=d,c=f}}}function dC(t,e,n,i,s,a){if(e==n||s==a||t.charCodeAt(n-1)!=i.charCodeAt(a-1))return 0;let o=hI(n-e,a-s);for(let r=n,c=a;;){let d=r-o,f=c-o;if(d>1}else{if(d==e||f==s)return n-d;r=d,c=f}}}function fw(t,e,n,i,s,a,o,r){let c=i.slice(s,a),d=null;for(;;){if(d||o=n)break;let g=t.slice(f,p),_=-1;for(;(_=c.indexOf(g,_+1))!=-1;){let y=uC(t,p,n,i,s+_+g.length,a),v=dC(t,e,f,i,s,s+_),x=g.length+y+v;(!d||d[2]>1}}function fI(t,e,n,i,s,a){let o=n-e,r=a-s;if(os.fromA-e&&i.toB>s.fromB-e&&(t[n-1]=new _i(i.fromA,s.toA,i.fromB,s.toB),t.splice(n--,1))}}function Twe(t,e,n){for(;;){mI(n,1);let i=!1;for(let s=0;s3||r>3){let c=s==t.length-1?e.length:t[s+1].fromA,d=a.fromA-i,f=c-a.toA,p=RR(e,a.fromA,d),g=jR(e,a.toA,f),_=a.fromA-p,y=g-a.toA;if((!o||!r)&&_&&y){let v=Math.max(o,r),[x,k,A]=o?[e,a.fromA,a.toA]:[n,a.fromB,a.toB];v>_&&e.slice(p,a.fromA)==x.slice(A-_,A)?(a=t[s]=new _i(p,p+o,a.fromB-_,a.toB-_),p=a.fromA,g=jR(e,a.toA,c-a.toA)):v>y&&e.slice(a.toA,g)==x.slice(k,k+y)&&(a=t[s]=new _i(g-o,g,a.fromB+y,a.toB+y),g=a.toA,p=RR(e,a.fromA,a.fromA-i)),_=a.fromA-p,y=g-a.toA}if(_||y)a=t[s]=new _i(a.fromA-_,a.toA+y,a.fromB-_,a.toB+y);else if(o){if(!r){let v=FR(e,a.fromA,a.toA),x,k=v<0?-1:DR(e,a.toA,a.fromA);v>-1&&(x=v-a.fromA)<=f&&e.slice(a.fromA,v)==e.slice(a.toA,a.toA+x)?a=t[s]=a.offset(x):k>-1&&(x=a.toA-k)<=d&&e.slice(a.fromA-x,a.fromA)==e.slice(k,a.toA)&&(a=t[s]=a.offset(-x))}}else{let v=FR(n,a.fromB,a.toB),x,k=v<0?-1:DR(n,a.toB,a.fromB);v>-1&&(x=v-a.fromB)<=f&&n.slice(a.fromB,v)==n.slice(a.toB,a.toB+x)?a=t[s]=a.offset(x):k>-1&&(x=a.toB-k)<=d&&n.slice(a.fromB-x,a.fromB)==n.slice(k,a.toB)&&(a=t[s]=a.offset(-x))}}i=a.toA}return mI(t,3),t}let Pc;try{Pc=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function pI(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function gI(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?pI(n)?1:0:Pc?!bI(n)||e==t.length-1?Pc.test(String.fromCharCode(n))?1:0:Pc.test(t.slice(e,e+2))?2:0:0}function _I(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?pI(n)?1:0:Pc?!vI(n)||e==1?Pc.test(String.fromCharCode(n))?1:0:Pc.test(t.slice(e-2,e))?2:0:0}const yI=8;function jR(t,e,n){if(e==t.length||!_I(t,e))return e;for(let i=e,s=e+n,a=0;as)return i;i+=o}return e}function RR(t,e,n){if(!e||!gI(t,e))return e;for(let i=e,s=e-n,a=0;at>=55296&&t<=56319,vI=t=>t>=56320&&t<=57343;function Dd(t,e){return!e||e==t.length||!bI(t.charCodeAt(e-1))||!vI(t.charCodeAt(e))}function Lwe(t,e,n){var i;let s=n?.override;return s?s(t,e):(Ef=((i=n?.scanLimit)!==null&&i!==void 0?i:1e9)>>1,jf=n?.timeout?Date.now()+n.timeout:0,cC=!1,Twe(t,e,zc(t,0,t.length,e,0,e.length)))}function xI(){return!cC}function SI(t,e,n){return Mwe(Lwe(t,e,n),t,e)}class mb{constructor(e,n,i,s,a,o=!0){this.changes=e,this.fromA=n,this.toA=i,this.fromB=s,this.toB=a,this.precise=o}offset(e,n){return e||n?new mb(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,i){let s=SI(e.toString(),n.toString(),i);return wI(s,e,n,0,0,xI())}static updateA(e,n,i,s,a){return zR(qR(e,s,!0,i.length),e,n,i,a)}static updateB(e,n,i,s,a){return zR(qR(e,s,!1,n.length),e,n,i,a)}}function IR(t,e,n,i){let s=n.lineAt(t),a=i.lineAt(e);return s.to==t&&a.to==e&&tp+1&&x>g+1)break;_.push(y.offset(-d+i,-f+s)),[p,g]=UR(y.toA+i,y.toB+s,e,n),r++}o.push(new mb(_,d,Math.max(d,p),f,Math.max(f,g),a))}return o}const V_=1e3;function BR(t,e,n,i){let s=0,a=t.length;for(;;){if(s==a){let f=0,p=0;s&&({toA:f,toB:p}=t[s-1]);let g=e-(n?f:p);return[f+g,p+g]}let o=s+a>>1,r=t[o],[c,d]=n?[r.fromA,r.toA]:[r.fromB,r.toB];if(c>e)a=o;else if(d<=e)s=o+1;else return i?[r.fromA,r.fromB]:[r.toA,r.toB]}}function qR(t,e,n,i){let s=[];return e.iterChangedRanges((a,o,r,c)=>{let d=0,f=n?e.length:i,p=0,g=n?i:e.length;a>V_&&([d,p]=BR(t,a-V_,n,!0)),o=d?s[s.length-1]={fromA:y.fromA,fromB:y.fromB,toA:f,toB:g,diffA:y.diffA+v,diffB:y.diffB+x}:s.push({fromA:d,toA:f,fromB:p,toB:g,diffA:v,diffB:x})}),s}function zR(t,e,n,i,s){if(!t.length)return e;let a=[];for(let o=0,r=0,c=0,d=0;;o++){let f=o==t.length?null:t[o],p=f?f.fromA+r:n.length,g=f?f.fromB+c:i.length;for(;dp||x.endB+c>g)break;a.push(x.offset(r,c)),d++}if(!f)break;let _=f.toA+r+f.diffA,y=f.toB+c+f.diffB,v=SI(n.sliceString(p,_),i.sliceString(g,y),s);for(let x of wI(v,n,i,p,g,xI()))a.push(x);for(r+=f.diffA,c+=f.diffB;d_&&x.fromB+c>y)break;d++}}return a}const Owe="DiffModal-module__diffModal___v1LSh",Pwe="DiffModal-module__content___CqXvC",Ewe="DiffModal-module__emptyState___gS4Kg",jwe="DiffModal-module__diffContainer___AoJKb",Rwe="DiffModal-module__fileHeader___7jkN4",Dwe="DiffModal-module__fileIcon___OxYTx",Fwe="DiffModal-module__fileName___2ylCY",Iwe="DiffModal-module__fileStats___bN8WB",Uwe="DiffModal-module__statAdditions___EKdp8",Bwe="DiffModal-module__statDeletions___Py0Xg",qwe="DiffModal-module__statBar___tR7TQ",zwe="DiffModal-module__statBlock___4qKhG",Kwe="DiffModal-module__statBlockAdd___VI4yX",Vwe="DiffModal-module__statBlockDel___39sMa",Hwe="DiffModal-module__diffBody___9dIqe",Wwe="DiffModal-module__hunk___AcNIC",Gwe="DiffModal-module__hunkHeader___xUVgg",$we="DiffModal-module__hunkGutter___QVKqi",Xwe="DiffModal-module__hunkExpandIcon___zbAx-",Qwe="DiffModal-module__hunkText___iPVut",Ywe="DiffModal-module__diffLine___9KzZK",Jwe="DiffModal-module__lineNum___VXwKE",Zwe="DiffModal-module__lineNumEmpty___I-5AK",eke="DiffModal-module__linePrefix___ofp2Q",tke="DiffModal-module__lineText___Zdyo3",nke="DiffModal-module__context___RnJqZ",ike="DiffModal-module__deletion___rms8N",ske="DiffModal-module__addition___a6g2h",xn={diffModal:Owe,content:Pwe,emptyState:Ewe,diffContainer:jwe,fileHeader:Rwe,fileIcon:Dwe,fileName:Fwe,fileStats:Iwe,statAdditions:Uwe,statDeletions:Bwe,statBar:qwe,statBlock:zwe,statBlockAdd:Kwe,statBlockDel:Vwe,diffBody:Hwe,hunk:Wwe,hunkHeader:Gwe,hunkGutter:$we,hunkExpandIcon:Xwe,hunkText:Qwe,diffLine:Ywe,lineNum:Jwe,lineNumEmpty:Zwe,linePrefix:eke,lineText:tke,context:nke,deletion:ike,addition:ske},u2=3,KR=(t,e)=>Math.max(0,Math.min(e,t.length));function ake(t,e){const n=sn.of(t.split(`
+`)),i=sn.of(e.split(`
+`)),s=mb.build(n,i);let a=0,o=0;return{hunks:s.map(c=>{const d=[],f=c.fromA0;R--){const B=y-R+1,I=x-R+1;B>=1&&I>=1&&B<=n.lines&&d.push({type:"context",oldNum:B,newNum:I,text:n.line(B).text})}for(const R of g)d.push({type:"deletion",oldNum:R.num,newNum:null,text:R.text});for(const R of _)d.push({type:"addition",oldNum:null,newNum:R.num,text:R.text});const N=Math.max(0,Math.min(u2,n.lines-v+1)),O=Math.max(0,Math.min(u2,i.lines-k+1)),M=Math.min(N,O);for(let R=0;R=1&&B<=n.lines&&I>=1&&I<=i.lines&&d.push({type:"context",oldNum:B,newNum:I,text:n.line(B).text})}const L=d.find(R=>R.oldNum!==null)?.oldNum??1,T=d.find(R=>R.newNum!==null)?.newNum??1,P=d.filter(R=>R.type!=="addition").length,E=d.filter(R=>R.type!=="deletion").length;return{oldStart:L,oldCount:P,newStart:T,newCount:E,lines:d}}),additions:a,deletions:o}}const VR=5;function oke({additions:t,deletions:e}){const n=t+e;if(n===0)return null;const i=Math.round(t/n*VR);return h.jsx("span",{className:xn.statBar,children:Array.from({length:VR},(s,a)=>h.jsx("span",{className:`${xn.statBlock} ${aake(e,n),[e,n]);return h.jsx(vs,{open:t,title:o("config_management.diff.title"),onClose:s,width:"min(1200px, 90vw)",className:xn.diffModal,closeDisabled:a,footer:h.jsxs(h.Fragment,{children:[h.jsx(fe,{variant:"secondary",onClick:s,disabled:a,children:o("common.cancel")}),h.jsx(fe,{onClick:i,loading:a,disabled:a,children:o("config_management.diff.confirm")})]}),children:h.jsx("div",{className:xn.content,children:r.hunks.length===0?h.jsx("div",{className:xn.emptyState,children:o("config_management.diff.no_changes")}):h.jsxs("div",{className:xn.diffContainer,children:[h.jsxs("div",{className:xn.fileHeader,children:[h.jsx("svg",{className:xn.fileIcon,viewBox:"0 0 16 16",width:"16",height:"16",children:h.jsx("path",{fillRule:"evenodd",d:"M3.75 1.5a.25.25 0 00-.25.25v11.5c0 .138.112.25.25.25h8.5a.25.25 0 00.25-.25V6H9.75A1.75 1.75 0 018 4.25V1.5H3.75zm5.75.56v2.19c0 .138.112.25.25.25h2.19L9.5 2.06zM2 1.75C2 .784 2.784 0 3.75 0h5.086c.464 0 .909.184 1.237.513l3.414 3.414c.329.328.513.773.513 1.237v8.086A1.75 1.75 0 0112.25 15h-8.5A1.75 1.75 0 012 13.25V1.75z",fill:"currentColor"})}),h.jsx("span",{className:xn.fileName,children:"config.yaml"}),h.jsxs("span",{className:xn.fileStats,children:[h.jsxs("span",{className:xn.statAdditions,children:["+",r.additions]}),h.jsxs("span",{className:xn.statDeletions,children:["-",r.deletions]}),h.jsx(oke,{additions:r.additions,deletions:r.deletions})]})]}),h.jsx("div",{className:xn.diffBody,children:r.hunks.map((c,d)=>h.jsxs("div",{className:xn.hunk,children:[h.jsxs("div",{className:xn.hunkHeader,children:[h.jsx("span",{className:xn.hunkGutter,children:h.jsx("svg",{className:xn.hunkExpandIcon,viewBox:"0 0 16 16",width:"12",height:"12",children:h.jsx("path",{d:"M8.177 1.677l2.896 2.896a.25.25 0 01-.177.427H8.75v1.25a.75.75 0 01-1.5 0V5H5.104a.25.25 0 01-.177-.427l2.896-2.896a.25.25 0 01.354 0zM7.25 11.75a.75.75 0 011.5 0V13h2.146a.25.25 0 01.177.427l-2.896 2.896a.25.25 0 01-.354 0l-2.896-2.896A.25.25 0 015.104 13H7.25v-1.25z",fill:"currentColor"})})}),h.jsx("span",{className:xn.hunkGutter}),h.jsxs("span",{className:xn.hunkText,children:["@@ -",c.oldStart,",",c.oldCount," +",c.newStart,",",c.newCount," @@"]})]}),c.lines.map((f,p)=>h.jsxs("div",{className:`${xn.diffLine} ${xn[f.type]}`,children:[h.jsx("span",{className:`${xn.lineNum} ${f.oldNum===null?xn.lineNumEmpty:""}`,children:f.oldNum??""}),h.jsx("span",{className:`${xn.lineNum} ${f.newNum===null?xn.lineNumEmpty:""}`,children:f.newNum??""}),h.jsx("span",{className:xn.linePrefix,children:f.type==="deletion"?"-":f.type==="addition"?"+":" "}),h.jsx("code",{className:xn.lineText,children:f.text||" "})]},`${d}-${p}`))]},d))})]})})})}const lke="ConfigPage-module__container___5kN-Y",cke="ConfigPage-module__pageHeader___Zulyi",uke="ConfigPage-module__pageHeaderCopy___fiTfJ",dke="ConfigPage-module__pageEyebrow___Oib1p",hke="ConfigPage-module__pageTitle___BoVLE",fke="ConfigPage-module__description___qruwQ",mke="ConfigPage-module__pageMeta___NX40i",pke="ConfigPage-module__statusBadge___dQAmD",gke="ConfigPage-module__tabBar___PelpE",_ke="ConfigPage-module__tabItem___Uj1rU",yke="ConfigPage-module__tabActive___sZLh-",bke="ConfigPage-module__workspaceShell___Ztz3J",vke="ConfigPage-module__content___PgFbt",xke="ConfigPage-module__sourceWorkspace___bUuLs",Ske="ConfigPage-module__sourceToolbar___fhCdI",wke="ConfigPage-module__searchInputWrapper___-GeEQ",kke="ConfigPage-module__searchInput___ock8o",Cke="ConfigPage-module__searchRight___pwWBV",Ake="ConfigPage-module__searchCount___AIry7",Nke="ConfigPage-module__searchButton___GRbfi",Tke="ConfigPage-module__searchActions___ZGITa",Mke="ConfigPage-module__editorWrapper___yBudn",Lke="ConfigPage-module__modified___4mzgT",Oke="ConfigPage-module__saved___zmZx2",Pke="ConfigPage-module__error___qlpX1",Eke="ConfigPage-module__floatingActionContainer___3ZQ-z",jke="ConfigPage-module__floatingActionList___ky8bV",Rke="ConfigPage-module__floatingStatus___u8zOi",Dke="ConfigPage-module__floatingActionButton___Htxmz",Fke="ConfigPage-module__dirtyDot___zXEnD",rn={container:lke,pageHeader:cke,pageHeaderCopy:uke,pageEyebrow:dke,pageTitle:hke,description:fke,pageMeta:mke,statusBadge:pke,tabBar:gke,tabItem:_ke,tabActive:yke,workspaceShell:bke,content:vke,sourceWorkspace:xke,sourceToolbar:Ske,searchInputWrapper:wke,searchInput:kke,searchRight:Cke,searchCount:Ake,searchButton:Nke,searchActions:Tke,editorWrapper:Mke,modified:Lke,saved:Oke,error:Pke,floatingActionContainer:Eke,floatingActionList:jke,floatingStatus:Rke,floatingActionButton:Dke,dirtyDot:Fke};function HR(t){try{const e=lI(t);return!e||typeof e!="object"||Array.isArray(e)?!1:!!e["commercial-mode"]}catch{return!1}}function Ike(){const{t}=nt(),e=Zm(),n=e?e.status==="current":!0,i=pn(re=>re.showNotification),s=pn(re=>re.showConfirmation),a=Zt(re=>re.connectionStatus),o=Aa(re=>re.resolvedTheme),{visualValues:r,visualDirty:c,visualParseError:d,visualValidationErrors:f,visualHasPayloadValidationErrors:p,loadVisualValuesFromYaml:g,applyVisualChangesToYaml:_,setVisualValues:y}=gwe(),[v,x]=S.useState(()=>{const re=localStorage.getItem("config-management:tab");return re==="visual"||re==="source"?re:"visual"}),[k,A]=S.useState(""),[N,O]=S.useState(!0),[M,L]=S.useState(!1),[T,P]=S.useState(""),[E,R]=S.useState(!1),[B,I]=S.useState(!1),[Q,G]=S.useState(""),[q,F]=S.useState(""),[V,H]=S.useState(""),[ee,X]=S.useState({current:0,total:0}),[U,K]=S.useState(""),$=S.useRef(null),J=S.useRef(null),ne=a!=="connected",D=E||c,ie=n,Z=!!d,se=v==="visual"&&(Object.values(f).some(Boolean)||p),me=S.useCallback(async()=>{O(!0),P("");try{const re=await vf.fetchConfigYaml();A(re),R(!1),I(!1),G(re),F(re),g(re)}catch(re){const Le=re instanceof Error?re.message:t("notification.refresh_failed");P(Le)}finally{O(!1)}},[g,t]);S.useEffect(()=>{me()},[me]),S.useEffect(()=>{v!=="visual"||!d||(x("source"),localStorage.setItem("config-management:tab","source"),i(t("config_management.visual_mode_unavailable_detail",{message:d}),"error"))},[v,i,t,d]);const Y=async()=>{L(!0);try{const re=HR(Q),Le=HR(q),$e=re!==Le;await vf.saveConfigYaml(q);const ht=await vf.fetchConfigYaml();R(!1),I(!1),A(ht),G(ht),F(ht),g(ht),i(t("config_management.save_success"),"success"),$e&&i(t("notification.commercial_mode_restart_required"),"warning")}catch(re){const Le=re instanceof Error?re.message:"";i(`${t("notification.save_failed")}: ${Le}`,"error")}finally{L(!1)}},de=async()=>{if(v==="visual"&&d){i(t("config_management.visual_mode_save_blocked"),"error");return}L(!0);try{const re=await vf.fetchConfigYaml();if(v!=="source"){const ht=Dm(re);if(ht.errors.length>0){i(t("config_management.visual_mode_latest_yaml_invalid",{message:ht.errors[0]?.message??t("config_management.visual_mode_save_blocked")}),"error");return}}const Le=v==="source"?k:_(re);let $e=re;if(v!=="source")try{$e=Dm(re).toString({indent:2,lineWidth:120,minContentWidth:0})}catch{}if($e===Le){R(!1),A(re),G(re),F(Le),g(re),i(t("config_management.diff.no_changes"),"info");return}G($e),F(Le),I(!0)}catch(re){const Le=re instanceof Error?re.message:"";i(`${t("notification.save_failed")}: ${Le}`,"error")}finally{L(!1)}},Ae=S.useCallback(re=>{A(re),R(!0)},[]),Ve=S.useCallback(re=>{if(re!==v){if(re==="source"){if(c){const Le=_(k);Le!==k&&(A(Le),R(!0))}}else{const Le=g(k);if(!Le.ok){i(t("config_management.visual_mode_unavailable_detail",{message:Le.error}),"error");return}}x(re),localStorage.setItem("config-management:tab",re)}},[v,_,k,g,i,t,c]),Ge=S.useCallback((re,Le="next")=>{if(!re||!$.current?.view)return;const $e=$.current.view,ht=$e.state.doc.toString(),bt=[],At=re.toLowerCase(),St=ht.toLowerCase();let he=0;for(;heKt){Xn=an;break}an===bt.length-1&&(Xn=0)}else for(let an=bt.length-1;an>=0;an--){if(bt[an]{H(re),re?X({current:0,total:0}):(X({current:0,total:0}),K(""))},[]),ze=S.useCallback((re="next")=>{V&&(K(V),Ge(V,re))},[V,Ge]),xt=S.useCallback(re=>{re.key==="Enter"&&(re.preventDefault(),ze(re.shiftKey?"prev":"next"))},[ze]),xe=S.useCallback(()=>{U&&Ge(U,"prev")},[U,Ge]),ot=S.useCallback(()=>{U&&Ge(U,"next")},[U,Ge]);S.useLayoutEffect(()=>{if(typeof window>"u"||!ie)return;const re=J.current;if(!re)return;const Le=()=>{const ht=re.getBoundingClientRect().height;document.documentElement.style.setProperty("--config-action-bar-height",`${ht}px`)};Le(),window.addEventListener("resize",Le);const $e=typeof ResizeObserver>"u"?null:new ResizeObserver(Le);return $e?.observe(re),()=>{$e?.disconnect(),window.removeEventListener("resize",Le),document.documentElement.style.removeProperty("--config-action-bar-height")}},[ie]);const ct=S.useMemo(()=>[L1e(),hve(),X8(),hp.of(nF)],[]),ft=()=>t(ne?"config_management.status_disconnected":N?"config_management.status_loading":T?"config_management.status_load_failed":Z?"config_management.visual_mode_unavailable":se?"config_management.visual.validation.validation_blocked":M?"config_management.status_saving":D?"config_management.status_dirty":"config_management.status_loaded"),It=()=>T||Z||se?rn.error:D?rn.modified:!N&&!M?rn.saved:"",yt=S.useCallback(()=>{if(!D){me();return}s({title:t("common.unsaved_changes_title"),message:t("config_management.reload_confirm_message"),confirmText:t("config_management.reload"),cancelText:t("common.cancel"),variant:"danger",onConfirm:async()=>{await me()}})},[D,me,s,t]),Mt=h.jsx("div",{className:rn.floatingActionContainer,ref:J,children:h.jsxs("div",{className:rn.floatingActionList,children:[h.jsx("div",{className:`${rn.floatingStatus} ${It()}`,children:ft()}),h.jsx("button",{type:"button",className:rn.floatingActionButton,onClick:yt,disabled:N||M,title:t("config_management.reload"),"aria-label":t("config_management.reload"),children:h.jsx(Nw,{size:16})}),h.jsxs("button",{type:"button",className:rn.floatingActionButton,onClick:de,disabled:ne||N||M||!D||B||Z||se,title:t("config_management.save"),"aria-label":t("config_management.save"),children:[h.jsx(Mw,{size:16}),D&&h.jsx("span",{className:rn.dirtyDot,"aria-hidden":"true"})]})]})}),dn=v==="visual"?t("config_management.tabs.visual",{defaultValue:"可视化编辑"}):t("config_management.tabs.source",{defaultValue:"源文件编辑"}),ue=t(v==="visual"?"config_management.visual.notice":"config_management.description");return h.jsxs("div",{className:rn.container,children:[h.jsxs("div",{className:rn.pageHeader,children:[h.jsxs("div",{className:rn.pageHeaderCopy,children:[h.jsx("span",{className:rn.pageEyebrow,children:dn}),h.jsx("h1",{className:rn.pageTitle,children:t("config_management.title")}),h.jsx("p",{className:rn.description,children:ue})]}),h.jsxs("div",{className:rn.pageMeta,children:[h.jsx("div",{className:`${rn.statusBadge} ${It()}`,children:ft()}),h.jsxs("div",{className:rn.tabBar,children:[h.jsx("button",{type:"button",className:`${rn.tabItem} ${v==="visual"?rn.tabActive:""}`,onClick:()=>Ve("visual"),disabled:M||N,children:t("config_management.tabs.visual",{defaultValue:"可视化编辑"})}),h.jsx("button",{type:"button",className:`${rn.tabItem} ${v==="source"?rn.tabActive:""}`,onClick:()=>Ve("source"),disabled:M||N,children:t("config_management.tabs.source",{defaultValue:"源代码编辑"})})]})]})]}),h.jsx("div",{className:rn.workspaceShell,children:h.jsxs("div",{className:rn.content,children:[T&&h.jsx("div",{className:"error-box",children:T}),!T&&d&&h.jsx("div",{className:"error-box",children:t("config_management.visual_mode_unavailable_detail",{message:d})}),v==="visual"?h.jsx(Cwe,{values:r,validationErrors:f,hasPayloadValidationErrors:p,disabled:ne||N,onChange:y}):h.jsxs("div",{className:rn.sourceWorkspace,children:[h.jsxs("div",{className:rn.sourceToolbar,children:[h.jsx("div",{className:rn.searchInputWrapper,children:h.jsx(st,{value:V,onChange:re=>je(re.target.value),onKeyDown:xt,placeholder:t("config_management.search_placeholder",{defaultValue:"搜索配置内容..."}),disabled:ne||N,className:rn.searchInput,rightElement:h.jsxs("div",{className:rn.searchRight,children:[V&&U===V&&h.jsx("span",{className:rn.searchCount,children:ee.total>0?`${ee.current} / ${ee.total}`:t("config_management.search_no_results",{defaultValue:"无结果"})}),h.jsx("button",{type:"button",className:rn.searchButton,onClick:()=>ze("next"),disabled:!V||ne||N,title:t("config_management.search_button",{defaultValue:"搜索"}),children:h.jsx(W3,{size:16})})]})})}),h.jsxs("div",{className:rn.searchActions,children:[h.jsx(fe,{variant:"secondary",size:"sm",onClick:xe,disabled:!V||U!==V||ee.total===0,title:t("config_management.search_prev",{defaultValue:"上一个"}),children:h.jsx(Tw,{size:16})}),h.jsx(fe,{variant:"secondary",size:"sm",onClick:ot,disabled:!V||U!==V||ee.total===0,title:t("config_management.search_next",{defaultValue:"下一个"}),children:h.jsx(Cy,{size:16})})]})]}),h.jsx("div",{className:rn.editorWrapper,children:h.jsx(_F,{ref:$,value:k,onChange:Ae,extensions:ct,theme:o,editable:!ne&&!N,placeholder:t("config_management.editor_placeholder"),height:"100%",style:{height:"100%"},basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightActiveLine:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1,rectangularSelection:!0,crosshairCursor:!1,highlightSelectionMatches:!0,closeBracketsKeymap:!0,searchKeymap:!0,foldKeymap:!0,completionKeymap:!1,lintKeymap:!0}})})]})]})}),ie&&typeof document<"u"?Or.createPortal(Mt,document.body):null,h.jsx(rke,{open:B,original:Q,modified:q,onConfirm:Y,onCancel:()=>I(!1),loading:M})]})}function Uke(t,e){const[n,i]=S.useState(()=>{try{const a=window.localStorage.getItem(t);return a?JSON.parse(a):e}catch(a){return console.error(`Error reading localStorage key "${t}":`,a),e}});return[n,a=>{try{const o=a instanceof Function?a(n):a;i(o),window.localStorage.setItem(t,JSON.stringify(o))}catch(o){console.error(`Error setting localStorage key "${t}":`,o)}}]}const hC=["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"],Bke=["2xx","3xx","4xx","5xx"],kI=t=>{if(typeof t=="number"){if(t>=200&&t<300)return"2xx";if(t>=300&&t<400)return"3xx";if(t>=400&&t<500)return"4xx";if(t>=500&&t<600)return"5xx"}},qke=new RegExp(`\\b(${hC.join("|")})\\b`),zke=/^\[?(\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\]?/,Kke=/^\[?(trace|debug|info|warn|warning|error|fatal)\s*\]?(?=\s|\[|$)\s*/i,d2=/^\[([^\]]+)\]/,CI=/\b(?:\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))(?:\s*\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))*\b/i,Vke=/\b(?:\d{1,3}\.){3}\d{1,3}\b/,Hke=/\b(?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}\b/i,WR=/^([a-f0-9]{8}|--------)$/i,Wke=/^\d{1,2}:\d{2}:\d{2}(?:\.\d{1,3})?$/,h2=/^\[GIN\]\s+(\d{4})\/(\d{2})\/(\d{2})\s*-\s*(\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\s*$/,Gke=[/\|\s*([1-5]\d{2})\s*\|/,/\b([1-5]\d{2})\s*-/,new RegExp(`\\b(?:${hC.join("|")})\\s+\\S+\\s+([1-5]\\d{2})\\b`),/\b(?:status|code|http)[:\s]+([1-5]\d{2})\b/i,/\b([1-5]\d{2})\s+(?:OK|Created|Accepted|No Content|Moved|Found|Bad Request|Unauthorized|Forbidden|Not Found|Method Not Allowed|Internal Server Error|Bad Gateway|Service Unavailable|Gateway Timeout)\b/i],$ke=t=>{for(const e of Gke){const n=t.match(e);if(!n)continue;const i=Number.parseInt(n[1],10);if(Number.isFinite(i)&&i>=100&&i<=599)return i}},f2=t=>{const e=t.match(Vke);if(e)return e[0];const n=t.match(Hke);if(!n)return;const i=n[0];if(!Wke.test(i)&&!(!i.includes("::")&&i.split(":").length!==8))return i},H_=t=>{const e=t.trim(),n=e.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})/);return n?`${n[1]} ${n[2]}`:e},GR=t=>{const e=t.match(CI);if(e)return e[0].replace(/\s+/g,"")},Xke=t=>{const e=t.trim().toLowerCase();if(e==="warning"||e==="warn")return"warn";if(e==="info")return"info";if(e==="error")return"error";if(e==="fatal")return"fatal";if(e==="debug")return"debug";if(e==="trace")return"trace"},Qke=t=>{const e=t.toLowerCase();if(/\bfatal\b/.test(e))return"fatal";if(/\berror\b/.test(e))return"error";if(/\bwarn(?:ing)?\b/.test(e)||t.includes("警告"))return"warn";if(/\binfo\b/.test(e))return"info";if(/\bdebug\b/.test(e))return"debug";if(/\btrace\b/.test(e))return"trace"},m2=t=>{const e=t.match(qke);if(!e)return{};const n=e[1],i=e.index??0,s=t.slice(i+e[0].length).trim(),a=s?s.split(/\s+/)[0]:void 0;return{method:n,path:a}},Yke=t=>{let e=t.trim(),n;const i=e.match(zke);i&&(n=i[1],e=e.slice(i[0].length).trim());let s;const a=e.match(/^\[([a-f0-9]{8}|--------)\]\s*/i);if(a){const x=a[1];/^-+$/.test(x)||(s=x),e=e.slice(a[0].length).trim()}let o;const r=e.match(Kke);r&&(o=Xke(r[1]),e=e.slice(r[0].length).trim());let c;const d=e.match(d2);d&&(c=d[1],e=e.slice(d[0].length).trim());let f,p,g,_,y,v=e;if(e.includes("|")){const x=e.split("|").map(E=>E.trim()).filter(Boolean),k=new Set,A=x.findIndex(E=>h2.test(E));if(A>=0){const E=x[A].match(h2);if(E){const R=`${E[1]}-${E[2]}-${E[3]} ${E[4]}`,B=H_(R),I=n?H_(n):void 0;n?I===B&&k.add(A):(n=R,k.add(A))}}const N=x.findIndex(E=>WR.test(E));if(N>=0){const E=x[N].match(WR);if(E){const R=E[1];/^-+$/.test(R)||(s=R),k.add(N)}}const O=x.findIndex(E=>/^\d{3}$/.test(E));if(O>=0){const E=x[O].match(/^(\d{3})$/);if(E){const R=Number.parseInt(E[1],10);R>=100&&R<=599&&(f=R,k.add(O))}}const M=x.findIndex(E=>CI.test(E));if(M>=0){const E=GR(x[M]);E&&(p=E,k.add(M))}const L=x.findIndex(E=>!!f2(E));if(L>=0){const E=f2(x[L]);E&&(g=E,k.add(L))}const T=x.findIndex(E=>{const{method:R}=m2(E);return!!R});if(T>=0){const E=m2(x[T]);_=E.method,y=E.path,k.add(T)}const P=x.findIndex(E=>d2.test(E));if(P>=0){const E=x[P].match(d2);E&&(c=E[1],k.add(P))}v=x.filter((E,R)=>!k.has(R)).join(" | ")}else{f=$ke(e);const x=GR(e);x&&(p=x),g=f2(e);const k=m2(e);_=k.method,y=k.path}if(o||(o=Qke(t)),v){const x=v.match(h2);if(x){const k=`${x[1]}-${x[2]}-${x[3]} ${x[4]}`;n||(n=k),H_(n)===H_(k)&&(v="")}}return{raw:t,timestamp:n,level:o,source:c,requestId:s,statusCode:f,latency:p,ip:g,method:_,path:y,message:v}},Jke=12;function Zke(t){const{parsedLines:e}=t,[n,i]=S.useState([]),[s,a]=S.useState([]),[o,r]=S.useState([]),c=S.useMemo(()=>new Set(n),[n]),d=S.useMemo(()=>new Set(s),[s]),f=S.useMemo(()=>new Set(o),[o]),p=n.length>0||s.length>0||o.length>0,g=S.useMemo(()=>{const N={};return e.forEach(O=>{O.method&&(N[O.method]=(N[O.method]??0)+1)}),N},[e]),_=S.useMemo(()=>{const N={};return e.forEach(O=>{const M=kI(O.statusCode);M&&(N[M]=(N[M]??0)+1)}),N},[e]),y=S.useMemo(()=>{const N=new Map;return e.forEach(O=>{O.path&&N.set(O.path,(N.get(O.path)??0)+1)}),Array.from(N.entries()).sort((O,M)=>M[1]-O[1]||O[0].localeCompare(M[0])).slice(0,Jke).map(([O,M])=>({path:O,count:M}))},[e]);return S.useEffect(()=>{const N=new Set(y.map(O=>O.path));r(O=>{if(O.length===0)return O;const M=O.filter(L=>N.has(L));return M.length===O.length?O:M})},[y]),{methodFilters:n,statusFilters:s,pathFilters:o,methodFilterSet:c,statusFilterSet:d,pathFilterSet:f,hasStructuredFilters:p,methodCounts:g,statusCounts:_,pathOptions:y,toggleMethodFilter:N=>{i(O=>O.includes(N)?O.filter(M=>M!==N):[...O,N])},toggleStatusFilter:N=>{a(O=>O.includes(N)?O.filter(M=>M!==N):[...O,N])},togglePathFilter:N=>{r(O=>O.includes(N)?O.filter(M=>M!==N):[...O,N])},clearStructuredFilters:()=>{i([]),a([]),r([])}}}const eCe=200,tCe=72,nCe=t=>t?t.scrollHeight-t.scrollTop-t.clientHeight<=24:!0;function iCe(t){const{logState:e,setLogState:n,loading:i,isSearching:s,filteredLineCount:a,hasStructuredFilters:o,showRawLogs:r}=t,c=S.useRef(null),d=S.useRef(!1),f=S.useRef(null),p=!s&&e.visibleFrom>0,g=S.useCallback(()=>{const k=c.current;k&&(k.scrollTop=k.scrollHeight)},[]),_=S.useCallback(()=>{d.current=!0},[]),y=S.useCallback(()=>{const k=c.current;k&&(f.current||s||n(A=>A.visibleFrom<=0?A:(f.current={scrollHeight:k.scrollHeight,scrollTop:k.scrollTop},{...A,visibleFrom:Math.max(A.visibleFrom-eCe,0)})))},[s,n]),v=S.useCallback(k=>{const A=c.current;A&&(s||p&&(f.current||A.scrollTop>tCe||y()))},[p,s,y]);S.useLayoutEffect(()=>{const k=c.current,A=f.current;if(!k||!A)return;const N=k.scrollHeight-A.scrollHeight;k.scrollTop=A.scrollTop+N,f.current=null},[e.visibleFrom]);const x=S.useCallback(()=>{const k=c.current;!k||!p||s||f.current||k.scrollHeight>k.clientHeight+1||y()},[p,s,y]);return S.useEffect(()=>{if(i||!c.current)return;const A=window.requestAnimationFrame(()=>{x()});return()=>{window.cancelAnimationFrame(A)}},[a,o,i,e.visibleFrom,r,x]),S.useEffect(()=>{const k=()=>{window.requestAnimationFrame(()=>{x()})};return window.addEventListener("resize",k),()=>{window.removeEventListener("resize",k)}},[x]),S.useEffect(()=>{d.current&&(i||c.current&&(g(),d.current=!1))},[i,e.buffer,e.visibleFrom,g]),{logViewerRef:c,canLoadMore:p,handleLogScroll:v,scrollToBottom:g,requestScrollToBottom:_}}const sCe=60*1e3,aCe=5,oCe=new Set(["/v1/chat/completions","/v1/messages","/v1/responses"]),rCe=["/v1beta/models"],mw=t=>String(t??"").replace(/^"+|"+$/g,"").split("?")[0].trim(),lCe=t=>{const e=mw(t);return!e||e==="/"?e:e.replace(/\/+$/,"")},AI=t=>{const e=lCe(t);return e?oCe.has(e)?!0:rCe.some(n=>e.startsWith(n)):!1},cCe=/\bmodel[=:]\s*"?([a-zA-Z0-9._\-/]+)"?/i,uCe=t=>t&&t.match(cCe)?.[1]||void 0,dCe=(t,e)=>!t||!e?!1:t===e||t.startsWith(e)||e.startsWith(t),hCe=t=>{if(t instanceof Error)return t.message;if(typeof t=="string")return t;if(typeof t!="object"||t===null||!("message"in t))return"";const e=t.message;return typeof e=="string"?e:""};function fCe(t){const{traceScopeKey:e,connectionStatus:n,config:i,requestLogDownloading:s}=t,{t:a}=nt(),o=Zi(Q=>Q.usage),r=Zi(Q=>Q.scopeKey),c=Zi(Q=>Q.loadUsageStats),[d,f]=S.useState(null),[p,g]=S.useState(new Map),[_,y]=S.useState(!1),[v,x]=S.useState(""),k=S.useRef(0),A=S.useRef(""),N=r===e?o:null,O=S.useMemo(()=>_G(N),[N]),M=S.useMemo(()=>rD(i??{}),[i]),L=S.useCallback(async Q=>{if(A.current!==e&&(A.current=e,k.current=0,g(new Map),x("")),_)return;const G=Date.now(),q=k.current>0&&G-k.currentnull)]);if(F!==null){const V=Array.isArray(F)?F:F?.files;if(Array.isArray(V)){const H=new Map;V.forEach(ee=>{const X=ss(ee.auth_index??ee.authIndex);X&&H.set(X,{name:ee.name||X,type:(ee.type||ee.provider||"").toString()})}),g(H),k.current=Date.now()}}}catch(F){x(hCe(F)||a("logs.trace_usage_load_error"))}finally{y(!1)}},[c,a,_,e]),T=S.useCallback(async()=>{await L(!1)},[L]),P=S.useCallback(async()=>{await L(!0)},[L]);S.useEffect(()=>{n==="connected"&&(A.current=e,k.current=0,g(new Map),y(!1),x(""))},[n,e]);const E=S.useMemo(()=>{if(!d)return[];const Q=mw(d.path);if(!Q)return[];const G=d.timestamp?Date.parse(d.timestamp):Number.NaN,q=O.filter(X=>dCe(Q,mw(X.__endpointPath)));if(q.length===0)return[];const F=uCe(d.message),V=F?q.filter(X=>X.__modelName?.toLowerCase()===F.toLowerCase()):[],H=V.length>0;return(H?V:q).map(X=>{const U=!Number.isNaN(G)&&X.__timestampMs>0?Math.abs(G-X.__timestampMs):null;return{detail:X,modelMatched:H,timeDeltaMs:U}}).sort((X,U)=>(U.detail.__timestampMs||0)-(X.detail.__timestampMs||0)).slice(0,aCe)},[d,O]),R=S.useCallback((Q,G)=>lD(Q,G,M,p),[p,M]),B=S.useCallback(Q=>{AI(Q.path)&&(x(""),f(Q),T())},[T]),I=S.useCallback(()=>{s||f(null)},[s]);return{traceLogLine:d,traceLoading:_,traceError:v,traceCandidates:E,resolveTraceSourceInfo:R,loadTraceUsageDetails:T,refreshTraceUsageDetails:P,openTraceModal:B,closeTraceModal:I}}const mCe="LogsPage-module__container___aQ0JL",pCe="LogsPage-module__pageTitle___vZY55",gCe="LogsPage-module__tabBar___bI3hW",_Ce="LogsPage-module__tabItem___5tb4J",yCe="LogsPage-module__tabActive___JjbWX",bCe="LogsPage-module__content___hGaGn",vCe="LogsPage-module__logCard___KG4Jd",xCe="LogsPage-module__toolbar___9dY5F",SCe="LogsPage-module__filters___nUahU",wCe="LogsPage-module__searchWrapper___mrEmr",kCe="LogsPage-module__filterPanelHeader___Oi5tO",CCe="LogsPage-module__filterPanelToggle___ADZED",ACe="LogsPage-module__filterPanelButtonContent___sgOCp",NCe="LogsPage-module__filterPanelCount___kAJ5-",TCe="LogsPage-module__structuredFilters___fW4v7",MCe="LogsPage-module__filterChipGroup___bbPoy",LCe="LogsPage-module__filterChipLabel___jy0D3",OCe="LogsPage-module__filterChipList___hHeOY",PCe="LogsPage-module__filterChip___Efqh7",ECe="LogsPage-module__filterChipActive___8S8ki",jCe="LogsPage-module__filterChipHint___shcVo",RCe="LogsPage-module__searchInput___eoPij",DCe="LogsPage-module__searchIcon___73cvF",FCe="LogsPage-module__searchClear___yTM1y",ICe="LogsPage-module__actionButton___aYJPR",UCe="LogsPage-module__buttonContent___qjHrB",BCe="LogsPage-module__switchLabel___EfB3d",qCe="LogsPage-module__logPanel___2wjiP",zCe="LogsPage-module__errorPanel___0w-se",KCe="LogsPage-module__loadMoreBanner___BUD0t",VCe="LogsPage-module__loadMoreCount___UsdBd",HCe="LogsPage-module__loadMoreStats___e9bVk",WCe="LogsPage-module__logList___lFt6f",GCe="LogsPage-module__rawLog___F5YBd",$Ce="LogsPage-module__logRow___rxZS5",XCe="LogsPage-module__rowWarn___Lhg4M",QCe="LogsPage-module__rowError___XQ3Qi",YCe="LogsPage-module__timestamp___TZvLq",JCe="LogsPage-module__rowMain___f--We",ZCe="LogsPage-module__badge___tR566",eAe="LogsPage-module__pill___vGA2z",tAe="LogsPage-module__source___nv7Zu",nAe="LogsPage-module__requestIdBadge___yPO1b",iAe="LogsPage-module__statusBadge___hj08j",sAe="LogsPage-module__statusSuccess___3llcn",aAe="LogsPage-module__statusInfo___B6DaE",oAe="LogsPage-module__statusWarn___1Dwki",rAe="LogsPage-module__statusError___xxTDc",lAe="LogsPage-module__levelInfo___oZMOp",cAe="LogsPage-module__levelWarn___DsCD0",uAe="LogsPage-module__levelError___8VjWc",dAe="LogsPage-module__levelDebug___l-5yk",hAe="LogsPage-module__levelTrace___XvRLF",fAe="LogsPage-module__methodBadge___Cf9jC",mAe="LogsPage-module__path___frHAs",pAe="LogsPage-module__message___bNHRw",gAe="LogsPage-module__traceButton___TpMAt",_Ae="LogsPage-module__tracePanel___qLlvU",yAe="LogsPage-module__traceNotice___brNFz",bAe="LogsPage-module__traceSectionTitle___oZ-a0",vAe="LogsPage-module__traceCandidatesHeader___b8sav",xAe="LogsPage-module__traceInfoGrid___7bY40",SAe="LogsPage-module__traceInfoItem___ydd7g",wAe="LogsPage-module__traceInfoItemWide___pmNic",kAe="LogsPage-module__traceInfoLabel___zidDI",CAe="LogsPage-module__traceInfoValue___3AiSj",AAe="LogsPage-module__traceSourceType___4TLzV",NAe="LogsPage-module__traceCandidates___TbNAE",TAe="LogsPage-module__traceCandidate___jBw7W",MAe="LogsPage-module__traceCandidateHeader___daeEH",LAe="LogsPage-module__traceModelBadge___iJzwF",OAe="LogsPage-module__traceDelta___gfgPb",PAe="LogsPage-module__traceCandidateGrid___qPwow",Ce={container:mCe,pageTitle:pCe,tabBar:gCe,tabItem:_Ce,tabActive:yCe,content:bCe,logCard:vCe,toolbar:xCe,filters:SCe,searchWrapper:wCe,filterPanelHeader:kCe,filterPanelToggle:CCe,filterPanelButtonContent:ACe,filterPanelCount:NCe,structuredFilters:TCe,filterChipGroup:MCe,filterChipLabel:LCe,filterChipList:OCe,filterChip:PCe,filterChipActive:ECe,filterChipHint:jCe,searchInput:RCe,searchIcon:DCe,searchClear:FCe,actionButton:ICe,buttonContent:UCe,switchLabel:BCe,logPanel:qCe,errorPanel:zCe,loadMoreBanner:KCe,loadMoreCount:VCe,loadMoreStats:HCe,logList:WCe,rawLog:GCe,logRow:$Ce,rowWarn:XCe,rowError:QCe,timestamp:YCe,rowMain:JCe,badge:ZCe,pill:eAe,source:tAe,requestIdBadge:nAe,statusBadge:iAe,statusSuccess:sAe,statusInfo:aAe,statusWarn:oAe,statusError:rAe,levelInfo:lAe,levelWarn:cAe,levelError:uAe,levelDebug:dAe,levelTrace:hAe,methodBadge:fAe,path:mAe,message:pAe,traceButton:gAe,tracePanel:_Ae,traceNotice:yAe,traceSectionTitle:bAe,traceCandidatesHeader:vAe,traceInfoGrid:xAe,traceInfoItem:SAe,traceInfoItemWide:wAe,traceInfoLabel:kAe,traceInfoValue:CAe,traceSourceType:AAe,traceCandidates:NAe,traceCandidate:TAe,traceCandidateHeader:MAe,traceModelBadge:LAe,traceDelta:OAe,traceCandidateGrid:PAe},EAe=100,$R=1e4,jAe=650,XR=10,_f=t=>{if(t instanceof Error)return t.message;if(typeof t=="string")return t;if(typeof t!="object"||t===null||!("message"in t))return"";const e=t.message;return typeof e=="string"?e:""};function RAe(){const{t}=nt(),{showNotification:e,showConfirmation:n}=pn(),i=Zt(he=>he.connectionStatus),s=Zt(he=>he.apiBase),a=Zt(he=>he.managementKey),o=`${s}::${a}`,r=zt(he=>he.config),c=r?.requestLog??!1,[d,f]=S.useState("logs"),[p,g]=S.useState({buffer:[],visibleFrom:0}),[_,y]=S.useState(!0),[v,x]=S.useState(""),[k,A]=S.useState(!1),[N,O]=S.useState(""),M=S.useDeferredValue(N),[L,T]=S.useState(!0),[P,E]=S.useState(!1),[R,B]=Uke("logsPage.structuredFiltersExpanded",!0),[I,Q]=S.useState([]),[G,q]=S.useState(!1),[F,V]=S.useState(""),[H,ee]=S.useState(null),[X,U]=S.useState(!1),K=fCe({traceScopeKey:o,connectionStatus:i,config:r,requestLogDownloading:X}),$=S.useRef(null),J=S.useRef(null),ne=S.useRef(!1),D=S.useRef(!1),ie=S.useRef(0),Z=i!=="connected",se=async(he=!1)=>{if(i!=="connected"){y(!1);return}if(ne.current){he||(D.current=!0);return}ne.current=!0,he||y(!0),x("");try{const Ue=$.current,Kt=!he||nCe(Ue?.logViewerRef.current??null);Kt&&Ue?.requestScrollToBottom();const Xn=he&&ie.current>0?{after:ie.current}:{},Zn=await Gh.fetchLogs(Xn);Zn["latest-timestamp"]&&(ie.current=Zn["latest-timestamp"]);const an=Array.isArray(Zn.lines)?Zn.lines:[];if(he&&an.length>0)g(vi=>{const Gi=vi.buffer.length-vi.visibleFrom,Di=[...vi.buffer,...an],ls=Math.max(Di.length-$R,0),xs=ls>0?Di.slice(ls):Di;let Te=Math.max(vi.visibleFrom-ls,0);return Kt&&(Te=Math.max(xs.length-Gi,0)),{buffer:xs,visibleFrom:Te}});else if(!he){const vi=an.slice(-$R),Gi=Math.max(vi.length-EAe,0);g({buffer:vi,visibleFrom:Gi})}}catch(Ue){console.error("Failed to load logs:",Ue),he||x(_f(Ue)||t("logs.load_error"))}finally{he||y(!1),ne.current=!1,D.current&&(D.current=!1,se(!1))}};np(()=>se(!1));const me=async()=>{n({title:t("logs.clear_confirm_title",{defaultValue:"Clear Logs"}),message:t("logs.clear_confirm"),variant:"danger",confirmText:t("common.confirm"),onConfirm:async()=>{try{await Gh.clearLogs(),g({buffer:[],visibleFrom:0}),ie.current=0,e(t("logs.clear_success"),"success")}catch(he){const Ue=_f(he);e(`${t("notification.delete_failed")}${Ue?`: ${Ue}`:""}`,"error")}}})},Y=()=>{const he=p.buffer.join(`
+`);Sl({filename:"logs.txt",blob:new Blob([he],{type:"text/plain"})}),e(t("logs.download_success"),"success")},de=async()=>{if(i!=="connected"){q(!1);return}q(!0),V("");try{const he=await Gh.fetchErrorLogs();Q(Array.isArray(he.files)?he.files:[])}catch(he){console.error("Failed to load error logs:",he),Q([]);const Ue=_f(he);V(Ue?`${t("logs.error_logs_load_error")}: ${Ue}`:t("logs.error_logs_load_error"))}finally{q(!1)}},Ae=async he=>{try{const Ue=await Gh.downloadErrorLog(he);Sl({filename:he,blob:new Blob([Ue.data],{type:"text/plain"})}),e(t("logs.error_log_download_success"),"success")}catch(Ue){const Kt=_f(Ue);e(`${t("notification.download_failed")}${Kt?`: ${Kt}`:""}`,"error")}};S.useEffect(()=>{i==="connected"&&(ie.current=0,se(!1))},[i]),S.useEffect(()=>{d==="errors"&&i==="connected"&&de()},[d,i,c]),S.useEffect(()=>{if(!k||i!=="connected")return;const he=window.setInterval(()=>{se(!0)},8e3);return()=>window.clearInterval(he)},[k,i]);const Ve=S.useMemo(()=>p.buffer.slice(p.visibleFrom),[p.buffer,p.visibleFrom]),Ge=M.trim(),je=Ge.length>0,ze=je?p.buffer:Ve,xt=S.useMemo(()=>{let he=ze;if(L&&(he=he.filter(Ue=>!Ue.includes(T2))),Ge){const Ue=Ge.toLowerCase();he=he.filter(Kt=>Kt.toLowerCase().includes(Ue))}return he.map(Ue=>Yke(Ue))},[ze,L,Ge]),xe=Zke({parsedLines:xt}),ot="logs-structured-filters",ct=xe.methodFilters.length+xe.statusFilters.length+xe.pathFilters.length,{filteredParsedLines:ft,filteredLines:It,removedCount:yt}=S.useMemo(()=>{const he=xt.filter(Ue=>{if(xe.methodFilterSet.size>0&&(!Ue.method||!xe.methodFilterSet.has(Ue.method)))return!1;const Kt=kI(Ue.statusCode);return!(xe.statusFilterSet.size>0&&(!Kt||!xe.statusFilterSet.has(Kt))||xe.pathFilterSet.size>0&&(!Ue.path||!xe.pathFilterSet.has(Ue.path)))});return{filteredParsedLines:he,filteredLines:he.map(Ue=>Ue.raw),removedCount:Math.max(ze.length-he.length,0)}},[ze,xe.methodFilterSet,xe.pathFilterSet,xe.statusFilterSet,xt]),Mt=S.useMemo(()=>P?[]:ft,[ft,P]),dn=S.useMemo(()=>It.join(`
+`),[It]),ue=iCe({logState:p,setLogState:g,loading:_,isSearching:je,filteredLineCount:It.length,hasStructuredFilters:xe.hasStructuredFilters,showRawLogs:P});$.current=ue;const re=async he=>{await Dy(he)?e(t("logs.copy_success",{defaultValue:"Copied to clipboard"}),"success"):e(t("logs.copy_failed",{defaultValue:"Copy failed"}),"error")},Le=()=>{J.current?.timer&&(window.clearTimeout(J.current.timer),J.current.timer=null)},$e=(he,Ue)=>{c&&Ue&&(H||(Le(),J.current={timer:window.setTimeout(()=>{ee(Ue),J.current&&(J.current.fired=!0,J.current.timer=null)},jAe),startX:he.clientX,startY:he.clientY,fired:!1}))},ht=()=>{Le(),J.current=null},bt=he=>{const Ue=J.current;if(!Ue||Ue.timer===null||Ue.fired)return;const Kt=Math.abs(he.clientX-Ue.startX),Xn=Math.abs(he.clientY-Ue.startY);(Kt>XR||Xn>XR)&&ht()},At=()=>{X||ee(null)},St=async he=>{U(!0);try{const Ue=await Gh.downloadRequestLogById(he);Sl({filename:`request-${he}.log`,blob:new Blob([Ue.data],{type:"text/plain"})}),e(t("logs.request_log_download_success"),"success"),ee(null)}catch(Ue){const Kt=_f(Ue);e(`${t("notification.download_failed")}${Kt?`: ${Kt}`:""}`,"error")}finally{U(!1)}};return S.useEffect(()=>()=>{J.current?.timer&&(window.clearTimeout(J.current.timer),J.current.timer=null)},[]),h.jsxs("div",{className:Ce.container,children:[h.jsx("h1",{className:Ce.pageTitle,children:t("logs.title")}),h.jsxs("div",{className:Ce.tabBar,children:[h.jsx("button",{type:"button",className:`${Ce.tabItem} ${d==="logs"?Ce.tabActive:""}`,onClick:()=>f("logs"),children:t("logs.log_content")}),h.jsx("button",{type:"button",className:`${Ce.tabItem} ${d==="errors"?Ce.tabActive:""}`,onClick:()=>f("errors"),children:t("logs.error_logs_modal_title")})]}),h.jsxs("div",{className:Ce.content,children:[d==="logs"&&h.jsxs(jt,{className:Ce.logCard,children:[v&&h.jsx("div",{className:"error-box",children:v}),h.jsxs("div",{className:Ce.filters,children:[h.jsx("div",{className:Ce.searchWrapper,children:h.jsx(st,{value:N,onChange:he=>O(he.target.value),placeholder:t("logs.search_placeholder"),className:Ce.searchInput,rightElement:N?h.jsx("button",{type:"button",className:Ce.searchClear,onClick:()=>O(""),title:"Clear","aria-label":"Clear",children:h.jsx(Vc,{size:16})}):h.jsx(W3,{size:16,className:Ce.searchIcon})})}),h.jsx("div",{className:Ce.filterPanelHeader,children:h.jsx(fe,{type:"button",variant:"secondary",size:"sm",className:Ce.filterPanelToggle,onClick:()=>B(he=>!he),"aria-expanded":R,"aria-controls":ot,title:t(R?"logs.filter_panel_collapse":"logs.filter_panel_expand"),children:h.jsxs("span",{className:Ce.filterPanelButtonContent,children:[h.jsx(fz,{size:16}),h.jsx("span",{children:t("logs.filter_panel_title")}),ct>0&&h.jsx("span",{className:Ce.filterPanelCount,children:t("logs.filter_panel_active_count",{count:ct})}),R?h.jsx(Tw,{size:16}):h.jsx(Cy,{size:16})]})})}),R&&h.jsxs("div",{id:ot,className:Ce.structuredFilters,children:[h.jsxs("div",{className:Ce.filterChipGroup,children:[h.jsx("span",{className:Ce.filterChipLabel,children:t("logs.filter_method")}),h.jsx("div",{className:Ce.filterChipList,children:hC.map(he=>{const Ue=xe.methodFilters.includes(he),Kt=xe.methodCounts[he]??0;return h.jsxs("button",{type:"button",className:`${Ce.filterChip} ${Ue?Ce.filterChipActive:""}`,onClick:()=>xe.toggleMethodFilter(he),disabled:Kt===0&&!Ue,"aria-pressed":Ue,children:[he," (",Kt,")"]},he)})})]}),h.jsxs("div",{className:Ce.filterChipGroup,children:[h.jsx("span",{className:Ce.filterChipLabel,children:t("logs.filter_status")}),h.jsx("div",{className:Ce.filterChipList,children:Bke.map(he=>{const Ue=xe.statusFilters.includes(he),Kt=xe.statusCounts[he]??0;return h.jsxs("button",{type:"button",className:`${Ce.filterChip} ${Ue?Ce.filterChipActive:""}`,onClick:()=>xe.toggleStatusFilter(he),disabled:Kt===0&&!Ue,"aria-pressed":Ue,children:[t(`logs.filter_status_${he}`)," (",Kt,")"]},he)})})]}),h.jsxs("div",{className:Ce.filterChipGroup,children:[h.jsx("span",{className:Ce.filterChipLabel,children:t("logs.filter_path")}),h.jsx("div",{className:Ce.filterChipList,children:xe.pathOptions.length===0?h.jsx("span",{className:Ce.filterChipHint,children:t("logs.filter_path_empty")}):xe.pathOptions.map(({path:he,count:Ue})=>{const Kt=xe.pathFilters.includes(he);return h.jsxs("button",{type:"button",className:`${Ce.filterChip} ${Kt?Ce.filterChipActive:""}`,onClick:()=>xe.togglePathFilter(he),"aria-pressed":Kt,title:he,children:[he," (",Ue,")"]},he)})})]}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:xe.clearStructuredFilters,disabled:!xe.hasStructuredFilters,children:t("logs.clear_filters")})]}),h.jsx(bi,{checked:L,onChange:T,label:h.jsxs("span",{className:Ce.switchLabel,children:[h.jsx(G3,{size:16}),t("logs.hide_management_logs",{prefix:T2})]})}),h.jsx(bi,{checked:P,onChange:E,label:h.jsxs("span",{className:Ce.switchLabel,title:t("logs.show_raw_logs_hint",{defaultValue:"Show original log text for easier multi-line copy"}),children:[h.jsx(A0,{size:16}),t("logs.show_raw_logs",{defaultValue:"Show raw logs"})]})}),h.jsxs("div",{className:Ce.toolbar,children:[h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>se(!1),disabled:Z||_,className:Ce.actionButton,children:h.jsxs("span",{className:Ce.buttonContent,children:[h.jsx(Nw,{size:16}),t("logs.refresh_button")]})}),h.jsx(bi,{checked:k,onChange:he=>A(he),disabled:Z,label:h.jsxs("span",{className:Ce.switchLabel,children:[h.jsx(C0,{size:16}),t("logs.auto_refresh")]})}),h.jsx(fe,{variant:"secondary",size:"sm",onClick:Y,disabled:p.buffer.length===0,className:Ce.actionButton,children:h.jsxs("span",{className:Ce.buttonContent,children:[h.jsx(H3,{size:16}),t("logs.download_button")]})}),h.jsx(fe,{variant:"danger",size:"sm",onClick:me,disabled:Z,className:Ce.actionButton,children:h.jsxs("span",{className:Ce.buttonContent,children:[h.jsx(ky,{size:16}),t("logs.clear_button")]})})]})]}),_?h.jsx("div",{className:"hint",children:t("logs.loading")}):p.buffer.length>0&&It.length>0?h.jsxs("div",{ref:ue.logViewerRef,className:Ce.logPanel,onScroll:ue.handleLogScroll,children:[ue.canLoadMore&&h.jsxs("div",{className:Ce.loadMoreBanner,children:[h.jsx("span",{children:t("logs.load_more_hint")}),h.jsxs("div",{className:Ce.loadMoreStats,children:[h.jsx("span",{children:t("logs.loaded_lines",{count:It.length})}),yt>0&&h.jsx("span",{className:Ce.loadMoreCount,children:t("logs.filtered_lines",{count:yt})}),h.jsx("span",{className:Ce.loadMoreCount,children:t("logs.hidden_lines",{count:p.visibleFrom})})]})]}),P?h.jsx("pre",{className:Ce.rawLog,spellCheck:!1,children:dn}):h.jsx("div",{className:Ce.logList,children:Mt.map((he,Ue)=>{const Kt=AI(he.path),Xn=[Ce.logRow];return he.level==="warn"&&Xn.push(Ce.rowWarn),(he.level==="error"||he.level==="fatal")&&Xn.push(Ce.rowError),h.jsxs("div",{className:Xn.join(" "),onDoubleClick:()=>{re(he.raw)},onPointerDown:Zn=>$e(Zn,he.requestId),onPointerUp:ht,onPointerLeave:ht,onPointerCancel:ht,onPointerMove:bt,title:t("logs.double_click_copy_hint",{defaultValue:"Double-click to copy"}),children:[h.jsx("div",{className:Ce.timestamp,children:he.timestamp||""}),h.jsxs("div",{className:Ce.rowMain,children:[he.level&&h.jsx("span",{className:[Ce.badge,he.level==="info"?Ce.levelInfo:"",he.level==="warn"?Ce.levelWarn:"",he.level==="error"||he.level==="fatal"?Ce.levelError:"",he.level==="debug"?Ce.levelDebug:"",he.level==="trace"?Ce.levelTrace:""].filter(Boolean).join(" "),children:he.level.toUpperCase()}),he.source&&h.jsx("span",{className:Ce.source,title:he.source,children:he.source}),he.requestId&&h.jsx("span",{className:[Ce.badge,Ce.requestIdBadge].join(" "),title:he.requestId,children:he.requestId}),typeof he.statusCode=="number"&&h.jsx("span",{className:[Ce.badge,Ce.statusBadge,he.statusCode>=200&&he.statusCode<300?Ce.statusSuccess:he.statusCode>=300&&he.statusCode<400?Ce.statusInfo:he.statusCode>=400&&he.statusCode<500?Ce.statusWarn:Ce.statusError].join(" "),children:he.statusCode}),he.latency&&h.jsx("span",{className:Ce.pill,children:he.latency}),he.ip&&h.jsx("span",{className:Ce.pill,children:he.ip}),he.method&&h.jsx("span",{className:[Ce.badge,Ce.methodBadge].join(" "),children:he.method}),he.path&&h.jsx("span",{className:Ce.path,title:he.path,children:he.path}),he.message&&h.jsx("span",{className:Ce.message,children:he.message}),Kt&&h.jsx("button",{type:"button",className:Ce.traceButton,onClick:Zn=>{Zn.stopPropagation(),ht(),K.openTraceModal(he)},title:t("logs.trace_button"),children:t("logs.trace_button")})]})]},`${p.visibleFrom+Ue}-${he.raw}`)})})]}):p.buffer.length>0?h.jsx(is,{title:t("logs.search_empty_title"),description:t("logs.search_empty_desc")}):h.jsx(is,{title:t("logs.empty_title"),description:t("logs.empty_desc")})]}),d==="errors"&&h.jsx(jt,{extra:h.jsx(fe,{variant:"secondary",size:"sm",onClick:de,loading:G,disabled:Z,children:t("common.refresh")}),children:h.jsxs("div",{className:"stack",children:[h.jsx("div",{className:"hint",children:t("logs.error_logs_description")}),c&&h.jsx("div",{children:h.jsx("div",{className:"status-badge warning",children:t("logs.error_logs_request_log_enabled")})}),F&&h.jsx("div",{className:"error-box",children:F}),h.jsx("div",{className:Ce.errorPanel,children:G?h.jsx("div",{className:"hint",children:t("common.loading")}):I.length===0?h.jsx("div",{className:"hint",children:t("logs.error_logs_empty")}):h.jsx("div",{className:"item-list",children:I.map(he=>h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsx("div",{className:"item-title",children:he.name}),h.jsxs("div",{className:"item-subtitle",children:[he.size?`${(he.size/1024).toFixed(1)} KB`:""," ",he.modified?uG(he.modified):""]})]}),h.jsx("div",{className:"item-actions",children:h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>Ae(he.name),disabled:Z,children:t("logs.error_logs_download")})})]},he.name))})})]})})]}),h.jsx(vs,{open:!!K.traceLogLine,onClose:K.closeTraceModal,title:t("logs.trace_title"),footer:h.jsxs(h.Fragment,{children:[K.traceLogLine?.requestId&&h.jsx(fe,{variant:"secondary",onClick:()=>{K.traceLogLine?.requestId&&St(K.traceLogLine.requestId)},loading:X,children:t("logs.trace_download_request_log")}),h.jsx(fe,{variant:"secondary",onClick:K.closeTraceModal,disabled:X,children:t("common.close")})]}),children:K.traceLogLine&&h.jsxs("div",{className:Ce.tracePanel,children:[h.jsx("div",{className:Ce.traceNotice,children:t("logs.trace_notice")}),h.jsx("h3",{className:Ce.traceSectionTitle,children:t("logs.trace_log_info")}),h.jsxs("div",{className:Ce.traceInfoGrid,children:[h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_request_id")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.requestId||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_method")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.method||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_path")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.path||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_status_code")}),h.jsx("span",{className:Ce.traceInfoValue,children:typeof K.traceLogLine.statusCode=="number"?K.traceLogLine.statusCode:"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_latency")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.latency||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_ip")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.ip||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_timestamp")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.timestamp||"-"})]}),h.jsxs("div",{className:`${Ce.traceInfoItem} ${Ce.traceInfoItemWide}`,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_message")}),h.jsx("span",{className:Ce.traceInfoValue,children:K.traceLogLine.message||"-"})]})]}),h.jsxs("div",{className:Ce.traceCandidatesHeader,children:[h.jsx("h3",{className:Ce.traceSectionTitle,children:t("logs.trace_candidates_title")}),h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>{K.refreshTraceUsageDetails().catch(()=>{})},loading:K.traceLoading,disabled:X,children:t("common.refresh")})]}),K.traceLoading?h.jsx("div",{className:"hint",children:t("logs.trace_loading")}):K.traceError?h.jsx("div",{className:"error-box",children:K.traceError}):K.traceCandidates.length===0?h.jsx("div",{className:"hint",children:t("logs.trace_no_match")}):h.jsx("div",{className:Ce.traceCandidates,children:K.traceCandidates.map(he=>{const Ue=K.resolveTraceSourceInfo(String(he.detail.source??""),he.detail.auth_index);return h.jsxs("div",{className:Ce.traceCandidate,children:[h.jsxs("div",{className:Ce.traceCandidateHeader,children:[he.modelMatched&&h.jsx("span",{className:Ce.traceModelBadge,children:t("logs.trace_model_matched")}),he.timeDeltaMs!==null&&h.jsx("span",{className:Ce.traceDelta,children:t("logs.trace_delta_seconds",{seconds:(he.timeDeltaMs/1e3).toFixed(2)})})]}),h.jsxs("div",{className:Ce.traceCandidateGrid,children:[h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_endpoint")}),h.jsx("span",{className:Ce.traceInfoValue,children:he.detail.__endpoint})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_model")}),h.jsx("span",{className:Ce.traceInfoValue,children:he.detail.__modelName||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_source")}),h.jsxs("span",{className:Ce.traceInfoValue,title:String(he.detail.source||"-"),children:[h.jsx("span",{children:Ue.displayName}),Ue.type&&h.jsx("span",{className:Ce.traceSourceType,children:Ue.type})]})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_auth_index")}),h.jsx("span",{className:Ce.traceInfoValue,children:he.detail.auth_index??"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_timestamp")}),h.jsx("span",{className:Ce.traceInfoValue,children:he.detail.timestamp||"-"})]}),h.jsxs("div",{className:Ce.traceInfoItem,children:[h.jsx("span",{className:Ce.traceInfoLabel,children:t("logs.trace_result")}),h.jsx("span",{className:Ce.traceInfoValue,children:he.detail.failed?t("stats.failure"):t("stats.success")})]})]})]},`${he.detail.__endpoint}-${he.detail.__modelName}-${he.detail.timestamp}-${he.detail.source}`)})})]})}),h.jsx(vs,{open:!!H,onClose:At,title:t("logs.request_log_download_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(fe,{variant:"secondary",onClick:At,disabled:X,children:t("common.cancel")}),h.jsx(fe,{onClick:()=>{H&&St(H)},loading:X,disabled:!H,children:t("common.confirm")})]}),children:H?t("logs.request_log_download_confirm",{id:H}):null})]})}const DAe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eZhipu%3c/title%3e%3cpath%20d='M11.991%2023.503a.24.24%200%2000-.244.248.24.24%200%2000.244.249.24.24%200%2000.245-.249.24.24%200%2000-.22-.247l-.025-.001zM9.671%205.365a1.697%201.697%200%20011.099%202.132l-.071.172-.016.04-.018.054c-.07.16-.104.32-.104.498-.035.71.47%201.279%201.186%201.314h.366c1.309.053%202.338%201.173%202.286%202.523-.052%201.332-1.152%202.38-2.478%202.327h-.174c-.715.018-1.274.64-1.239%201.368%200%20.124.018.23.053.337.209.373.54.658.96.8.75.23%201.517-.125%201.9-.782l.018-.035c.402-.64%201.17-.96%201.92-.711.854.284%201.378%201.226%201.099%202.167a1.661%201.661%200%2001-2.077%201.102%201.711%201.711%200%2001-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646%201.646%200%2000-1.954.746%201.66%201.66%200%2001-1.065.764%201.677%201.677%200%2001-1.989-1.279c-.209-.906.332-1.83%201.257-2.043a1.51%201.51%200%2001.296-.035h.018c.68-.071%201.151-.622%201.116-1.333a1.307%201.307%200%2000-.227-.693%202.515%202.515%200%2001-.366-1.403%202.39%202.39%200%2001.366-1.208c.14-.195.21-.444.227-.693.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.43%201.43%200%2001-.299-.07l-.05-.019a1.7%201.7%200%2001-1.047-2.114%201.68%201.68%200%20012.094-1.101zm-5.575%2010.11c.26-.264.639-.367.994-.27.355.096.633.379.728.74.095.362-.007.748-.267%201.013-.402.41-1.053.41-1.455%200a1.062%201.062%200%20010-1.482zm14.845-.294c.359-.09.738.024.992.297.254.274.344.665.237%201.025-.107.36-.396.634-.756.718-.551.128-1.1-.22-1.23-.781a1.05%201.05%200%2001.757-1.26zm-.064-4.39c.314.32.49.753.49%201.206%200%20.452-.176.886-.49%201.206-.315.32-.74.5-1.185.5-.444%200-.87-.18-1.184-.5a1.727%201.727%200%20010-2.412%201.654%201.654%200%20012.369%200zm-11.243.163c.364.484.447%201.128.218%201.691a1.665%201.665%200%2001-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68%201.68%200%20011.33-1.038c.593-.08%201.183.169%201.547.652zm11.545-4.221c.368%200%20.708.2.892.524.184.324.184.724%200%201.048a1.026%201.026%200%2001-.892.524c-.568%200-1.03-.47-1.03-1.048%200-.579.462-1.048%201.03-1.048zm-14.358%200c.368%200%20.707.2.891.524.184.324.184.724%200%201.048a1.026%201.026%200%2001-.891.524c-.569%200-1.03-.47-1.03-1.048%200-.579.461-1.048%201.03-1.048zm10.031-1.475c.925%200%201.675.764%201.675%201.706s-.75%201.705-1.675%201.705-1.674-.763-1.674-1.705c0-.942.75-1.706%201.674-1.706zm-2.626-.684c.362-.082.653-.356.761-.718a1.062%201.062%200%2000-.238-1.028%201.017%201.017%200%2000-.996-.294c-.547.14-.881.7-.752%201.257.13.558.675.907%201.225.783zm0%2016.876c.359-.087.644-.36.75-.72a1.062%201.062%200%2000-.237-1.019%201.018%201.018%200%2000-.985-.301%201.037%201.037%200%2000-.762.717c-.108.361-.017.754.239%201.028.245.263.606.377.953.305l.043-.01zM17.19%203.5a.631.631%200%2000.628-.64c0-.355-.279-.64-.628-.64a.631.631%200%2000-.628.64c0%20.355.28.64.628.64zm-10.38%200a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64a.631.631%200%2000-.628.64c0%20.355.279.64.628.64zm-5.182%207.852a.631.631%200%2000-.628.64c0%20.354.28.639.628.639a.63.63%200%2000.627-.606l.001-.034a.62.62%200%2000-.628-.64zm5.182%209.13a.631.631%200%2000-.628.64c0%20.355.279.64.628.64a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64zm10.38.018a.631.631%200%2000-.628.64c0%20.355.28.64.628.64a.631.631%200%2000.628-.64c0-.355-.279-.64-.628-.64zm5.182-9.148a.631.631%200%2000-.628.64c0%20.354.279.639.628.639a.631.631%200%2000.628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24%200%2000.244-.249.24.24%200%2000-.244-.249.24.24%200%2000-.244.249c0%20.142.122.249.244.249zM11.991.497a.24.24%200%2000.245-.248A.24.24%200%200011.99%200a.24.24%200%2000-.244.249c0%20.133.108.236.223.247l.021.001zM2.011%206.36a.24.24%200%2000.245-.249.24.24%200%2000-.244-.249.24.24%200%2000-.244.249.24.24%200%2000.244.249zm0%2011.263a.24.24%200%2000-.243.248.24.24%200%2000.244.249.24.24%200%2000.244-.249.252.252%200%2000-.244-.248zm19.995-.018a.24.24%200%2000-.245.248.24.24%200%2000.245.25.24.24%200%2000.244-.25.252.252%200%2000-.244-.248z'%20fill='%233859FF'%20fill-rule='nonzero'%3e%3c/path%3e%3c/svg%3e",FAe="data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGrok%3c/title%3e%3cpath%20d='M9.27%2015.29l7.978-5.897c.391-.29.95-.177%201.137.272.98%202.369.542%205.215-1.41%207.169-1.951%201.954-4.667%202.382-7.149%201.406l-2.711%201.257c3.889%202.661%208.611%202.003%2011.562-.953%202.341-2.344%203.066-5.539%202.388-8.42l.006.007c-.983-4.232.242-5.924%202.75-9.383.06-.082.12-.164.179-.248l-3.301%203.305v-.01L9.267%2015.292M7.623%2016.723c-2.792-2.67-2.31-6.801.071-9.184%201.761-1.763%204.647-2.483%207.166-1.425l2.705-1.25a7.808%207.808%200%2000-1.829-1A8.975%208.975%200%20005.984%205.83c-2.533%202.536-3.33%206.436-1.962%209.764%201.022%202.487-.653%204.246-2.34%206.022-.599.63-1.199%201.259-1.682%201.925l7.62-6.815'%3e%3c/path%3e%3c/svg%3e",IAe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDeepSeek%3c/title%3e%3cpath%20d='M23.748%204.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434%201.202-.422%201.84.027%201.436.633%202.58%201.838%203.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526%205.526%200%2001-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365%2011.365%200%2000-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055%203.055%200%2001-.465.137%209.597%209.597%200%2000-2.883-.102c-1.885.21-3.39%201.102-4.497%202.623C.082%208.606-.231%2010.684.152%2012.85c.403%202.284%201.569%204.175%203.36%205.653%201.858%201.533%203.997%202.284%206.438%202.14%201.482-.085%203.133-.284%204.994-1.86.47.234.962.327%201.78.397.63.059%201.236-.03%201.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926%201.096-1.296%202.746-2.642%203.392-7.003.05-.347.007-.565%200-.845-.004-.17.035-.237.23-.256a4.173%204.173%200%20001.545-.475c1.396-.763%201.96-2.015%202.093-3.517.02-.23-.004-.467-.247-.588zM11.581%2018c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696%204.696%200%20011.529-.039c2.132.312%203.946%201.265%205.468%202.774.868.86%201.525%201.887%202.202%202.891.72%201.066%201.494%202.082%202.48%202.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306%200%2001.415-.287.302.302%200%2001.2.288.306.306%200%2001-.31.307.303.303%200%2001-.304-.308zm3.11%201.596c-.2.081-.399.151-.59.16a1.245%201.245%200%2001-.798-.254c-.274-.23-.47-.358-.552-.758a1.73%201.73%200%2001.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559%200%2001-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136%201.146.016.352.144.618.408%201.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z'%20fill='%234D6BFE'%3e%3c/path%3e%3c/svg%3e",UAe="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eMinimax%3c/title%3e%3cdefs%3e%3clinearGradient%20id='lobe-icons-minimax-fill'%20x1='0%25'%20x2='100.182%25'%20y1='50.057%25'%20y2='50.057%25'%3e%3cstop%20offset='0%25'%20stop-color='%23E2167E'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%23FE603C'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3cpath%20d='M16.278%202c1.156%200%202.093.927%202.093%202.07v12.501a.74.74%200%2000.744.709.74.74%200%2000.743-.709V9.099a2.06%202.06%200%20012.071-2.049A2.06%202.06%200%200124%209.1v6.561a.649.649%200%2001-.652.645.649.649%200%2001-.653-.645V9.1a.762.762%200%2000-.766-.758.762.762%200%2000-.766.758v7.472a2.037%202.037%200%2001-2.048%202.026%202.037%202.037%200%2001-2.048-2.026v-12.5a.785.785%200%2000-.788-.753.785.785%200%2000-.789.752l-.001%2015.904A2.037%202.037%200%200113.441%2022a2.037%202.037%200%2001-2.048-2.026V18.04c0-.356.292-.645.652-.645.36%200%20.652.289.652.645v1.934c0%20.263.142.506.372.638.23.131.514.131.744%200a.734.734%200%2000.372-.638V4.07c0-1.143.937-2.07%202.093-2.07zm-5.674%200c1.156%200%202.093.927%202.093%202.07v11.523a.648.648%200%2001-.652.645.648.648%200%2001-.652-.645V4.07a.785.785%200%2000-.789-.78.785.785%200%2000-.789.78v14.013a2.06%202.06%200%2001-2.07%202.048%202.06%202.06%200%2001-2.071-2.048V9.1a.762.762%200%2000-.766-.758.762.762%200%2000-.766.758v3.8a2.06%202.06%200%2001-2.071%202.049A2.06%202.06%200%20010%2012.9v-1.378c0-.357.292-.646.652-.646.36%200%20.653.29.653.646V12.9c0%20.418.343.757.766.757s.766-.339.766-.757V9.099a2.06%202.06%200%20012.07-2.048%202.06%202.06%200%20012.071%202.048v8.984c0%20.419.343.758.767.758.423%200%20.766-.339.766-.758V4.07c0-1.143.937-2.07%202.093-2.07z'%20fill='url(%23lobe-icons-minimax-fill)'%20fill-rule='nonzero'%3e%3c/path%3e%3c/svg%3e",BAe="SystemPage-module__container___KAydo",qAe="SystemPage-module__pageTitle___DiF5E",zAe="SystemPage-module__content___SauLn",KAe="SystemPage-module__aboutCard___v2-ui",VAe="SystemPage-module__aboutHeader___hT4-J",HAe="SystemPage-module__aboutLogo___KXoLr",WAe="SystemPage-module__aboutTitle___BTLGy",GAe="SystemPage-module__aboutInfoGrid___b7AR0",$Ae="SystemPage-module__infoTile___6AuIY",XAe="SystemPage-module__tapTile___-9SaX",QAe="SystemPage-module__tileLabel___eMn4v",YAe="SystemPage-module__tileHeader___w4Ej0",JAe="SystemPage-module__tileAction___WKXuS",ZAe="SystemPage-module__tileValue___Up02X",eNe="SystemPage-module__tileSub___ysVDj",tNe="SystemPage-module__sectionDescription___nI7Jo",nNe="SystemPage-module__clearLoginActions___4ek-m",iNe="SystemPage-module__modelTags___M0sci",sNe="SystemPage-module__groupTitle___bTqIN",aNe="SystemPage-module__groupIcon___-XXrb",oNe="SystemPage-module__modelTag___5Ar53",rNe="SystemPage-module__modelName___LKdAK",lNe="SystemPage-module__modelAlias___zioM-",cNe="SystemPage-module__quickLinks___QTmT3",uNe="SystemPage-module__linkCard___iSrVF",dNe="SystemPage-module__linkIcon___gNqz2",hNe="SystemPage-module__github___V8I3m",fNe="SystemPage-module__docs___cA-rG",mNe="SystemPage-module__linkContent___Rfh7h",pNe="SystemPage-module__linkTitle___Zpr4Q",gNe="SystemPage-module__linkDesc___KKavC",gt={container:BAe,pageTitle:qAe,content:zAe,aboutCard:KAe,aboutHeader:VAe,aboutLogo:HAe,aboutTitle:WAe,aboutInfoGrid:GAe,infoTile:$Ae,tapTile:XAe,tileLabel:QAe,tileHeader:YAe,tileAction:JAe,tileValue:ZAe,tileSub:eNe,sectionDescription:tNe,clearLoginActions:nNe,modelTags:iNe,groupTitle:sNe,groupIcon:aNe,modelTag:oNe,modelName:rNe,modelAlias:lNe,quickLinks:cNe,linkCard:uNe,linkIcon:dNe,github:hNe,docs:fNe,linkContent:mNe,linkTitle:pNe,linkDesc:gNe},_Ne={gpt:{light:Hw,dark:Ww},claude:ep,gemini:Nc,qwen:Qw,kimi:{light:Xw,dark:$w},glm:DAe,grok:FAe,deepseek:IAe,minimax:UAe},QR=t=>{if(!t)return null;const e=t.trim().replace(/^v/i,"");if(!e)return null;const n=e.split(/[^0-9]+/).filter(Boolean).map(i=>Number.parseInt(i,10)).filter(Number.isFinite);return n.length?n:null},yNe=(t,e)=>{const n=QR(t),i=QR(e);if(!n||!i)return null;const s=Math.max(n.length,i.length);for(let a=0;ar)return 1;if(oY.resolvedTheme),a=Zt(),o=zt(Y=>Y.config),r=zt(Y=>Y.fetchConfig),c=zt(Y=>Y.clearCache),d=zt(Y=>Y.updateConfigValue),f=yc(Y=>Y.models),p=yc(Y=>Y.loading),g=yc(Y=>Y.error),_=yc(Y=>Y.fetchModels),[y,v]=S.useState(),[x,k]=S.useState(!1),[A,N]=S.useState(!1),[O,M]=S.useState(!1),[L,T]=S.useState(!1),[P,E]=S.useState(!1),R=S.useRef([]),B=S.useRef(0),I=S.useRef(null),Q=S.useMemo(()=>e.language?.toLowerCase().startsWith("zh")?"其他":"Other",[e.language]),G=S.useMemo(()=>FG(f,{otherLabel:Q}),[f,Q]),q=o?.requestLog??!1,F=A!==q,V=a.connectionStatus==="connected"&&!!o,H="v1.7.19",ee=a.serverVersion||t("system_info.version_unknown"),X=a.serverBuildDate?new Date(a.serverBuildDate).toLocaleString(e.language):t("system_info.version_unknown"),U=Y=>{const de=_Ne[Y];return de?typeof de=="string"?de:s==="dark"?de.dark:de.light:null},K=Y=>{if(!Array.isArray(Y))return[];const de=new Set,Ae=[];return Y.forEach(Ve=>{const Ge=Ve!==null&&typeof Ve=="object"&&!Array.isArray(Ve)?Ve:null,je=typeof Ve=="string"?Ve:Ge?Ge["api-key"]??Ge.apiKey??Ge.key??Ge.Key:"",ze=String(je??"").trim();!ze||de.has(ze)||(de.add(ze),Ae.push(ze))}),Ae},$=S.useCallback(async()=>{if(R.current.length)return R.current;const Y=K(o?.apiKeys);if(Y.length)return R.current=Y,Y;try{const de=await D2.list(),Ae=K(de);return Ae.length&&(R.current=Ae),Ae}catch(de){return console.warn("Auto loading API keys for models failed:",de),[]}},[o?.apiKeys]),J=async({forceRefresh:Y=!1}={})=>{if(a.connectionStatus!=="connected"){v({type:"warning",message:t("notification.connection_required")});return}if(!a.apiBase){n(t("notification.connection_required"),"warning");return}Y&&(R.current=[]),v({type:"muted",message:t("system_info.models_loading")});try{const Ae=(await $())[0],Ve=await _(a.apiBase,Ae,Y),Ge=Ve.length>0;v({type:Ge?"success":"warning",message:Ge?t("system_info.models_count",{count:Ve.length}):t("system_info.models_empty")})}catch(de){const Ae=de instanceof Error?de.message:typeof de=="string"?de:"",Ve=Ae?`: ${Ae}`:"",Ge=`${t("system_info.models_error")}${Ve}`;v({type:"error",message:Ge})}},ne=()=>{i({title:t("system_info.clear_login_title",{defaultValue:"Clear Login Storage"}),message:t("system_info.clear_login_confirm"),variant:"danger",confirmText:t("common.confirm"),onConfirm:()=>{if(a.logout(),typeof localStorage>"u")return;[X3,"isLoggedIn","apiBase","apiUrl","managementKey"].forEach(de=>localStorage.removeItem(de)),n(t("notification.login_storage_cleared"),"success")}})},D=S.useCallback(()=>{M(!1),N(q),k(!0)},[q]),ie=S.useCallback(()=>{if(B.current+=1,I.current&&clearTimeout(I.current),B.current>=7){B.current=0,I.current=null,D();return}I.current=setTimeout(()=>{B.current=0,I.current=null},1500)},[D]),Z=S.useCallback(()=>{k(!1),M(!1)},[]),se=async()=>{if(!V)return;if(!F){k(!1);return}const Y=q;T(!0),d("request-log",A);try{await O4.updateRequestLog(A),c("request-log"),n(t("notification.request_log_updated"),"success"),k(!1)}catch(de){const Ae=de instanceof Error?de.message:typeof de=="string"?de:"";d("request-log",Y),n(`${t("notification.update_failed")}${Ae?`: ${Ae}`:""}`,"error")}finally{T(!1)}},me=S.useCallback(async()=>{E(!0);try{const Y=await RG.checkLatest(),de=Y?.["latest-version"]??Y?.latest_version??Y?.latest??"",Ae=typeof de=="string"?de:String(de??""),Ve=yNe(Ae,a.serverVersion);if(!Ae){n(t("system_info.version_check_error"),"error");return}if(Ve===null){n(t("system_info.version_current_missing"),"warning");return}Ve>0?n(t("system_info.version_update_available",{version:Ae}),"warning"):n(t("system_info.version_is_latest"),"success")}catch(Y){const de=Y instanceof Error?Y.message:typeof Y=="string"?Y:"",Ae=de?`: ${de}`:"";n(`${t("system_info.version_check_error")}${Ae}`,"error")}finally{E(!1)}},[a.serverVersion,n,t]);return S.useEffect(()=>{r().catch(()=>{})},[r]),S.useEffect(()=>{x&&!O&&N(q)},[x,O,q]),S.useEffect(()=>()=>{I.current&&clearTimeout(I.current)},[]),S.useEffect(()=>{J()},[a.connectionStatus,a.apiBase]),h.jsxs("div",{className:gt.container,children:[h.jsx("h1",{className:gt.pageTitle,children:t("system_info.title")}),h.jsxs("div",{className:gt.content,children:[h.jsxs(jt,{className:gt.aboutCard,children:[h.jsxs("div",{className:gt.aboutHeader,children:[h.jsx("img",{src:_d,alt:"CPAMC",className:gt.aboutLogo}),h.jsx("div",{className:gt.aboutTitle,children:t("system_info.about_title")})]}),h.jsxs("div",{className:gt.aboutInfoGrid,children:[h.jsxs("button",{type:"button",className:`${gt.infoTile} ${gt.tapTile}`,onClick:ie,children:[h.jsx("div",{className:gt.tileHeader,children:h.jsx("div",{className:gt.tileLabel,children:t("footer.version")})}),h.jsx("div",{className:gt.tileValue,children:H})]}),h.jsxs("div",{className:gt.infoTile,children:[h.jsxs("div",{className:gt.tileHeader,children:[h.jsx("div",{className:gt.tileLabel,children:t("footer.api_version")}),h.jsx(fe,{type:"button",variant:"ghost",size:"sm",className:gt.tileAction,onClick:()=>void me(),loading:P,title:t("system_info.version_check_button"),"aria-label":t("system_info.version_check_button"),children:t("system_info.version_check_button")})]}),h.jsx("div",{className:gt.tileValue,children:ee})]}),h.jsxs("div",{className:gt.infoTile,children:[h.jsx("div",{className:gt.tileLabel,children:t("footer.build_date")}),h.jsx("div",{className:gt.tileValue,children:X})]}),h.jsxs("div",{className:gt.infoTile,children:[h.jsx("div",{className:gt.tileLabel,children:t("connection.status")}),h.jsx("div",{className:gt.tileValue,children:t(`common.${a.connectionStatus}_status`)}),h.jsx("div",{className:gt.tileSub,children:a.apiBase||"-"})]})]})]}),h.jsxs(jt,{title:t("system_info.quick_links_title"),children:[h.jsx("p",{className:gt.sectionDescription,children:t("system_info.quick_links_desc")}),h.jsxs("div",{className:gt.quickLinks,children:[h.jsxs("a",{href:"https://github.com/router-for-me/CLIProxyAPI",target:"_blank",rel:"noopener noreferrer",className:gt.linkCard,children:[h.jsx("div",{className:`${gt.linkIcon} ${gt.github}`,children:h.jsx(Sz,{size:22})}),h.jsxs("div",{className:gt.linkContent,children:[h.jsxs("div",{className:gt.linkTitle,children:[t("system_info.link_main_repo"),h.jsx(Ix,{size:14})]}),h.jsx("div",{className:gt.linkDesc,children:t("system_info.link_main_repo_desc")})]})]}),h.jsxs("a",{href:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",target:"_blank",rel:"noopener noreferrer",className:gt.linkCard,children:[h.jsx("div",{className:`${gt.linkIcon} ${gt.github}`,children:h.jsx(A0,{size:22})}),h.jsxs("div",{className:gt.linkContent,children:[h.jsxs("div",{className:gt.linkTitle,children:[t("system_info.link_webui_repo"),h.jsx(Ix,{size:14})]}),h.jsx("div",{className:gt.linkDesc,children:t("system_info.link_webui_repo_desc")})]})]}),h.jsxs("a",{href:"https://help.router-for.me/",target:"_blank",rel:"noopener noreferrer",className:gt.linkCard,children:[h.jsx("div",{className:`${gt.linkIcon} ${gt.docs}`,children:h.jsx(wz,{size:22})}),h.jsxs("div",{className:gt.linkContent,children:[h.jsxs("div",{className:gt.linkTitle,children:[t("system_info.link_docs"),h.jsx(Ix,{size:14})]}),h.jsx("div",{className:gt.linkDesc,children:t("system_info.link_docs_desc")})]})]})]})]}),h.jsxs(jt,{title:t("system_info.models_title"),extra:h.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>J({forceRefresh:!0}),loading:p,children:t("common.refresh")}),children:[h.jsx("p",{className:gt.sectionDescription,children:t("system_info.models_desc")}),y&&h.jsx("div",{className:`status-badge ${y.type}`,children:y.message}),g&&h.jsx("div",{className:"error-box",children:g}),p?h.jsx("div",{className:"hint",children:t("common.loading")}):f.length===0?h.jsx("div",{className:"hint",children:t("system_info.models_empty")}):h.jsx("div",{className:"item-list",children:G.map(Y=>{const de=U(Y.id);return h.jsxs("div",{className:"item-row",children:[h.jsxs("div",{className:"item-meta",children:[h.jsxs("div",{className:gt.groupTitle,children:[de&&h.jsx("img",{src:de,alt:"",className:gt.groupIcon}),h.jsx("span",{className:"item-title",children:Y.label})]}),h.jsx("div",{className:"item-subtitle",children:t("system_info.models_count",{count:Y.items.length})})]}),h.jsx("div",{className:gt.modelTags,children:Y.items.map(Ae=>h.jsxs("span",{className:gt.modelTag,title:Ae.description||"",children:[h.jsx("span",{className:gt.modelName,children:Ae.name}),Ae.alias&&h.jsx("span",{className:gt.modelAlias,children:Ae.alias})]},`${Ae.name}-${Ae.alias??"default"}`))})]},Y.id)})})]}),h.jsxs(jt,{title:t("system_info.clear_login_title"),children:[h.jsx("p",{className:gt.sectionDescription,children:t("system_info.clear_login_desc")}),h.jsx("div",{className:gt.clearLoginActions,children:h.jsx(fe,{variant:"danger",onClick:ne,children:t("system_info.clear_login_button")})})]})]}),h.jsx(vs,{open:x,onClose:Z,title:t("basic_settings.request_log_title"),footer:h.jsxs(h.Fragment,{children:[h.jsx(fe,{variant:"secondary",onClick:Z,disabled:L,children:t("common.cancel")}),h.jsx(fe,{onClick:se,loading:L,disabled:!V||!F,children:t("common.save")})]}),children:h.jsxs("div",{className:"request-log-modal",children:[h.jsx("div",{className:"status-badge warning",children:t("basic_settings.request_log_warning")}),h.jsx(bi,{label:t("basic_settings.request_log_enable"),labelPosition:"left",checked:A,disabled:!V||L,onChange:Y=>{N(Y),M(!0)}})]})})]})}const vNe=[{path:"/",element:h.jsx(oO,{})},{path:"/dashboard",element:h.jsx(oO,{})},{path:"/settings",element:h.jsx(Df,{to:"/config",replace:!0})},{path:"/api-keys",element:h.jsx(Df,{to:"/config",replace:!0})},{path:"/ai-providers/gemini/new",element:h.jsx(vO,{})},{path:"/ai-providers/gemini/:index",element:h.jsx(vO,{})},{path:"/ai-providers/codex/new",element:h.jsx(bO,{})},{path:"/ai-providers/codex/:index",element:h.jsx(bO,{})},{path:"/ai-providers/claude/new",element:h.jsx(fO,{}),children:[{index:!0,element:h.jsx(_O,{})},{path:"models",element:h.jsx(yO,{})}]},{path:"/ai-providers/claude/:index",element:h.jsx(fO,{}),children:[{index:!0,element:h.jsx(_O,{})},{path:"models",element:h.jsx(yO,{})}]},{path:"/ai-providers/vertex/new",element:h.jsx(NO,{})},{path:"/ai-providers/vertex/:index",element:h.jsx(NO,{})},{path:"/ai-providers/openai/new",element:h.jsx(wO,{}),children:[{index:!0,element:h.jsx(CO,{})},{path:"models",element:h.jsx(AO,{})}]},{path:"/ai-providers/openai/:index",element:h.jsx(wO,{}),children:[{index:!0,element:h.jsx(CO,{})},{path:"models",element:h.jsx(AO,{})}]},{path:"/ai-providers/ampcode",element:h.jsx(HJ,{})},{path:"/ai-providers",element:h.jsx(cO,{})},{path:"/ai-providers/*",element:h.jsx(cO,{})},{path:"/auth-files",element:h.jsx(Goe,{})},{path:"/auth-files/oauth-excluded",element:h.jsx(_re,{})},{path:"/auth-files/oauth-model-alias",element:h.jsx(qre,{})},{path:"/oauth",element:h.jsx(yle,{})},{path:"/quota",element:h.jsx(ble,{})},{path:"/usage",element:h.jsx(Lpe,{})},{path:"/config",element:h.jsx(Ike,{})},{path:"/logs",element:h.jsx(RAe,{})},{path:"/system",element:h.jsx(bNe,{})},{path:"*",element:h.jsx(Df,{to:"/",replace:!0})}];function xNe({location:t}){return d9(vNe,t)}const cr={dashboard:h.jsx(kz,{size:18}),aiProviders:h.jsx(Az,{size:18}),authFiles:h.jsx(Nz,{size:18}),oauth:h.jsx(Tz,{size:18}),quota:h.jsx(Mz,{size:18}),usage:h.jsx(Lz,{size:18}),config:h.jsx(Cz,{size:18}),logs:h.jsx(Oz,{size:18}),system:h.jsx(Pz,{size:18})},fo={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},mo={refresh:h.jsxs("svg",{...fo,children:[h.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),h.jsx("path",{d:"M21 3v5h-5"})]}),menu:h.jsxs("svg",{...fo,children:[h.jsx("path",{d:"M4 7h16"}),h.jsx("path",{d:"M4 12h16"}),h.jsx("path",{d:"M4 17h16"})]}),chevronLeft:h.jsx("svg",{...fo,children:h.jsx("path",{d:"m14 18-6-6 6-6"})}),chevronRight:h.jsx("svg",{...fo,children:h.jsx("path",{d:"m10 6 6 6-6 6"})}),language:h.jsxs("svg",{...fo,children:[h.jsx("circle",{cx:"12",cy:"12",r:"10"}),h.jsx("path",{d:"M2 12h20"}),h.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),sun:h.jsxs("svg",{...fo,children:[h.jsx("circle",{cx:"12",cy:"12",r:"4"}),h.jsx("path",{d:"M12 2v2"}),h.jsx("path",{d:"M12 20v2"}),h.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),h.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),h.jsx("path",{d:"M2 12h2"}),h.jsx("path",{d:"M20 12h2"}),h.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),h.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]}),moon:h.jsx("svg",{...fo,children:h.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"})}),whiteTheme:h.jsxs("svg",{...fo,children:[h.jsx("circle",{cx:"12",cy:"12",r:"7"}),h.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})]}),autoTheme:h.jsxs("svg",{...fo,children:[h.jsx("defs",{children:h.jsx("clipPath",{id:"mainLayoutAutoThemeSunLeftHalf",children:h.jsx("rect",{x:"0",y:"0",width:"12",height:"24"})})}),h.jsx("circle",{cx:"12",cy:"12",r:"4"}),h.jsx("circle",{cx:"12",cy:"12",r:"4",clipPath:"url(#mainLayoutAutoThemeSunLeftHalf)",fill:"currentColor"}),h.jsx("path",{d:"M12 2v2"}),h.jsx("path",{d:"M12 20v2"}),h.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),h.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),h.jsx("path",{d:"M2 12h2"}),h.jsx("path",{d:"M20 12h2"}),h.jsx("path",{d:"M6.34 17.66l-1.41 1.41"}),h.jsx("path",{d:"M19.07 4.93l-1.41 1.41"})]}),logout:h.jsxs("svg",{...fo,children:[h.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),h.jsx("path",{d:"m16 17 5-5-5-5"}),h.jsx("path",{d:"M21 12H9"})]})},SNe=[{key:"auto",labelKey:"theme.auto",colors:{bg:"linear-gradient(135deg, #ffffff 0 50%, #111111 50% 100%)",card:"linear-gradient(135deg, #ffffff 0 50%, #1a1a1a 50% 100%)",border:"#bdbdbd",text:"#2d2a26",textMuted:"linear-gradient(135deg, #c9c9c9 0 50%, #5a5a5a 50% 100%)"}},{key:"white",labelKey:"theme.white",colors:{bg:"#ffffff",card:"#ffffff",border:"#e5e5e5",text:"#2d2a26",textMuted:"#a29c95"}},{key:"light",labelKey:"theme.light",colors:{bg:"#faf9f5",card:"#f0eee8",border:"#e3e1db",text:"#2d2a26",textMuted:"#a29c95"}},{key:"dark",labelKey:"theme.dark",colors:{bg:"#151412",card:"#1d1b18",border:"#3a3530",text:"#f6f4f1",textMuted:"#9c958d"}}];function wNe(){const{t}=nt(),{showNotification:e}=pn(),n=$n(),i=Zt(D=>D.apiBase),s=Zt(D=>D.connectionStatus),a=Zt(D=>D.logout),o=zt(D=>D.config),r=zt(D=>D.fetchConfig),c=zt(D=>D.clearCache),d=Aa(D=>D.theme),f=Aa(D=>D.setTheme),p=bd(D=>D.language),g=bd(D=>D.setLanguage),[_,y]=S.useState(!1),[v,x]=S.useState(!1),[k,A]=S.useState(!1),[N,O]=S.useState(!1),[M,L]=S.useState(!0),T=S.useRef(null),P=S.useRef(null),E=S.useRef(null),R=S.useRef(null),B=S.useRef(null),I="CLI Proxy API Management Center",Q=t("title.abbr"),G=n.pathname.startsWith("/logs");S.useLayoutEffect(()=>{const D=()=>{const Z=B.current?.offsetHeight;Z&&document.documentElement.style.setProperty("--header-height",`${Z}px`)};D();const ie=typeof ResizeObserver<"u"&&B.current?new ResizeObserver(D):null;return ie&&B.current&&ie.observe(B.current),window.addEventListener("resize",D),()=>{ie&&ie.disconnect(),window.removeEventListener("resize",D)}},[]),S.useLayoutEffect(()=>{const D=()=>{const Z=T.current;if(!Z)return;const se=Z.getBoundingClientRect(),me=se.left+se.width/2;document.documentElement.style.setProperty("--content-center-x",`${me}px`)};D();const ie=typeof ResizeObserver<"u"&&T.current?new ResizeObserver(D):null;return ie&&T.current&&ie.observe(T.current),window.addEventListener("resize",D),()=>{ie&&ie.disconnect(),window.removeEventListener("resize",D),document.documentElement.style.removeProperty("--content-center-x")}},[]),S.useEffect(()=>(R.current=setTimeout(()=>{L(!1)},5e3),()=>{R.current&&clearTimeout(R.current)}),[]),S.useEffect(()=>{if(!k)return;const D=Z=>{P.current?.contains(Z.target)||A(!1)},ie=Z=>{Z.key==="Escape"&&A(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",ie),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",ie)}},[k]),S.useEffect(()=>{if(!N)return;const D=Z=>{E.current?.contains(Z.target)||O(!1)},ie=Z=>{Z.key==="Escape"&&O(!1)};return document.addEventListener("mousedown",D),document.addEventListener("keydown",ie),()=>{document.removeEventListener("mousedown",D),document.removeEventListener("keydown",ie)}},[N]);const q=S.useCallback(()=>{M||(L(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{L(!1)},5e3))},[M]),F=S.useCallback(()=>{A(D=>!D),O(!1)},[]),V=S.useCallback(()=>{O(D=>!D),A(!1)},[]),H=S.useCallback(D=>{f(D),O(!1)},[f]),ee=S.useCallback(D=>{yd(D)&&(g(D),A(!1))},[g]);S.useEffect(()=>{r().catch(()=>{})},[r]);const X=s==="connected"?"success":s==="connecting"?"warning":s==="error"?"error":"muted",U=[{path:"/",label:t("nav.dashboard"),icon:cr.dashboard},{path:"/config",label:t("nav.config_management"),icon:cr.config},{path:"/ai-providers",label:t("nav.ai_providers"),icon:cr.aiProviders},{path:"/auth-files",label:t("nav.auth_files"),icon:cr.authFiles},{path:"/oauth",label:t("nav.oauth",{defaultValue:"OAuth"}),icon:cr.oauth},{path:"/quota",label:t("nav.quota_management"),icon:cr.quota},{path:"/usage",label:t("nav.usage_stats"),icon:cr.usage},...o?.loggingToFile?[{path:"/logs",label:t("nav.logs"),icon:cr.logs}]:[],{path:"/system",label:t("nav.system_info"),icon:cr.system}],K=U.map(D=>D.path),$=D=>{const ie=D.length>1&&D.endsWith("/")?D.slice(0,-1):D,Z=ie==="/dashboard"?"/":ie,se=K.indexOf("/ai-providers");if(se!==-1){if(Z==="/ai-providers")return se;if(Z.startsWith("/ai-providers/"))return Z.startsWith("/ai-providers/gemini")?se+.1:Z.startsWith("/ai-providers/codex")?se+.2:Z.startsWith("/ai-providers/claude")?se+.3:Z.startsWith("/ai-providers/vertex")?se+.4:Z.startsWith("/ai-providers/ampcode")?se+.5:Z.startsWith("/ai-providers/openai")?se+.6:se+.05}const me=K.indexOf("/auth-files");if(me!==-1){if(Z==="/auth-files")return me;if(Z.startsWith("/auth-files/"))return Z.startsWith("/auth-files/oauth-excluded")?me+.1:Z.startsWith("/auth-files/oauth-model-alias")?me+.2:me+.05}const Y=K.indexOf(Z);if(Y!==-1)return Y;const de=K.findIndex(Ae=>Ae!=="/"&&Z.startsWith(`${Ae}/`));return de===-1?null:de},J=S.useCallback((D,ie)=>{const Z=Ae=>{const Ve=Ae.length>1&&Ae.endsWith("/")?Ae.slice(0,-1):Ae;return Ve==="/dashboard"?"/":Ve},se=Z(D),me=Z(ie),Y=Ae=>Ae==="/auth-files"||Ae.startsWith("/auth-files/"),de=Ae=>Ae==="/ai-providers"||Ae.startsWith("/ai-providers/");return Y(se)&&Y(me)||de(se)&&de(me)?"ios":"vertical"},[]),ne=async()=>{c();const ie=(await Promise.allSettled([r(void 0,!0),X4()])).find(Z=>Z.status==="rejected");if(ie&&ie.status==="rejected"){const Z=ie.reason,se=typeof Z=="string"?Z:Z instanceof Error?Z.message:"";e(`${t("notification.refresh_failed")}${se?`: ${se}`:""}`,"error");return}e(t("notification.data_refreshed"),"success")};return h.jsxs("div",{className:"app-shell",children:[h.jsxs("header",{className:"main-header",ref:B,children:[h.jsxs("div",{className:"left",children:[h.jsx("button",{className:"sidebar-toggle-header",onClick:()=>x(D=>!D),title:v?t("sidebar.expand",{defaultValue:"展开"}):t("sidebar.collapse",{defaultValue:"收起"}),children:v?mo.chevronRight:mo.chevronLeft}),h.jsx("img",{src:_d,alt:"CPAMC logo",className:"brand-logo"}),h.jsxs("div",{className:`brand-header ${M?"expanded":"collapsed"}`,onClick:q,title:M?void 0:I,children:[h.jsx("span",{className:"brand-full",children:I}),h.jsx("span",{className:"brand-abbr",children:Q})]})]}),h.jsxs("div",{className:"right",children:[h.jsxs("div",{className:"connection",children:[h.jsx("span",{className:`status-badge ${X}`,children:t(s==="connected"?"common.connected_status":s==="connecting"?"common.connecting_status":"common.disconnected_status")}),h.jsx("span",{className:"base",children:i||"-"})]}),h.jsxs("div",{className:"header-actions",children:[h.jsx(fe,{className:"mobile-menu-btn",variant:"ghost",size:"sm",onClick:()=>y(D=>!D),children:mo.menu}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:ne,title:t("header.refresh_all"),children:mo.refresh}),h.jsxs("div",{className:`language-menu ${k?"open":""}`,ref:P,children:[h.jsx(fe,{variant:"ghost",size:"sm",onClick:F,title:t("language.switch"),"aria-label":t("language.switch"),"aria-haspopup":"menu","aria-expanded":k,children:mo.language}),k&&h.jsx("div",{className:"notification entering language-menu-popover",role:"menu","aria-label":t("language.switch"),children:ad.map(D=>h.jsxs("button",{type:"button",className:`language-menu-option ${p===D?"active":""}`,onClick:()=>ee(D),role:"menuitemradio","aria-checked":p===D,children:[h.jsx("span",{children:t(Y3[D])}),p===D?h.jsx("span",{className:"language-menu-check",children:"✓"}):null]},D))})]}),h.jsxs("div",{className:`theme-menu ${N?"open":""}`,ref:E,children:[h.jsx(fe,{variant:"ghost",size:"sm",onClick:V,title:t("theme.switch"),"aria-label":t("theme.switch"),"aria-haspopup":"menu","aria-expanded":N,children:d==="auto"?mo.autoTheme:d==="dark"?mo.moon:d==="white"?mo.whiteTheme:mo.sun}),N&&h.jsx("div",{className:"notification entering theme-menu-popover",role:"menu","aria-label":t("theme.switch"),children:SNe.map(D=>h.jsxs("button",{type:"button",className:`theme-card ${d===D.key?"active":""}`,onClick:()=>H(D.key),role:"menuitemradio","aria-checked":d===D.key,children:[h.jsxs("div",{className:"theme-card-preview",style:{background:D.colors.bg,border:`1px solid ${D.colors.border}`},children:[h.jsx("div",{className:"theme-card-header",style:{background:D.colors.card,borderBottom:`1px solid ${D.colors.border}`}}),h.jsxs("div",{className:"theme-card-body",children:[h.jsx("div",{className:"theme-card-sidebar",style:{background:D.colors.card,borderRight:`1px solid ${D.colors.border}`}}),h.jsxs("div",{className:"theme-card-content",style:{background:D.colors.bg},children:[h.jsx("div",{className:"theme-card-line",style:{background:D.colors.textMuted}}),h.jsx("div",{className:"theme-card-line short",style:{background:D.colors.textMuted}})]})]})]}),h.jsx("span",{className:"theme-card-label",children:t(D.labelKey)})]},D.key))})]}),h.jsx(fe,{variant:"ghost",size:"sm",onClick:a,title:t("header.logout"),children:mo.logout})]})]})]}),h.jsxs("div",{className:"main-body",children:[h.jsx("button",{type:"button",className:`sidebar-backdrop ${_?"visible":""}`,onClick:()=>y(!1),"aria-label":t("common.close"),"aria-hidden":!_,tabIndex:_?0:-1}),h.jsx("aside",{className:`sidebar ${_?"open":""} ${v?"collapsed":""}`,children:h.jsx("div",{className:"nav-section",children:U.map(D=>h.jsxs(P3,{to:D.path,className:({isActive:ie})=>`nav-item ${ie?"active":""}`,onClick:()=>y(!1),title:v?D.label:void 0,children:[h.jsx("span",{className:"nav-icon",children:D.icon}),!v&&h.jsx("span",{className:"nav-label",children:D.label})]},D.path))})}),h.jsx("div",{className:`content${G?" content-logs":""}`,ref:T,children:h.jsx("main",{className:`main-content${G?" main-content-logs":""}`,children:h.jsx(gX,{render:D=>h.jsx(xNe,{location:D}),getRouteOrder:$,getTransitionVariant:J,scrollContainerRef:T})})})]})]})}function kNe({children:t}){const e=$n(),n=Zt(c=>c.isAuthenticated),i=Zt(c=>c.managementKey),s=Zt(c=>c.apiBase),a=Zt(c=>c.checkAuth),[o,r]=S.useState(!1);return S.useEffect(()=>{(async()=>{if(!n&&i&&s){r(!0);try{await a()}finally{r(!1)}}})()},[s,n,i,a]),o?h.jsx("div",{className:"main-content",children:h.jsx(jc,{})}):n?t:h.jsx(Df,{to:"/login",replace:!0,state:{from:e}})}function CNe(){return h.jsxs(h.Fragment,{children:[h.jsx(L$,{}),h.jsx(D$,{}),h.jsx(Sw,{})]})}const ANe=iq([{element:h.jsx(CNe,{}),children:[{path:"/login",element:h.jsx(M$,{})},{path:"/*",element:h.jsx(kNe,{children:h.jsx(wNe,{})})}]}]);function NNe(){const t=Aa(i=>i.initializeTheme),e=bd(i=>i.language),n=bd(i=>i.setLanguage);return S.useEffect(()=>t(),[t]),S.useEffect(()=>{n(e)},[]),S.useEffect(()=>{document.documentElement.lang=e},[e]),h.jsx(mq,{router:ANe})}document.title="CLI Proxy API Management Center";const p2=document.querySelector('link[rel="icon"]');if(p2)p2.href=_d,p2.type="image/jpeg";else{const t=document.createElement("link");t.rel="icon",t.type="image/jpeg",t.href=_d,document.head.appendChild(t)}VB.createRoot(document.getElementById("root")).render(h.jsx(S.StrictMode,{children:h.jsx(NNe,{})}));
+