Files
SnowCatQQ/release-tools/webui-static/assets/index-BMgeCmqo.js
T
2026-11-12 06:29:38 +08:00

20 lines
90 KiB
JavaScript

import{r as h,R as Ne,j as e}from"./react-vendor-jWT2yUdV.js";import{a as ce,c as ue}from"./chunk-5PILOUBS-KHYNqMZE.js";import{t as _e,a as H}from"./chunk-ML27DD5T-ZFWrMOn-.js";import{E as tr,n as Fe,D as ze,c as D,b as z,P as q,W as E,F as pe,G as fe,H as be,I as Be,J as sr,u as de,k as te,K as Qe}from"./index-DiaaLdUu.js";import{u as ar,i as T}from"./chunk-2QAN2V2R-B2qCPZrG.js";import{d as or}from"./chunk-IHO36JMK-DJPUeGG0.js";import{a as ir}from"./chunk-SXMLSBOY-NckgDZ9w.js";import{u as he}from"./useRequest-B1BwPztr.js";import{u as Q,C,a as nr}from"./react-hook-form-DTbqnRcd.js";import{z as x}from"./react-hot-toast-cGcFZPSt.js";import{a as Oe,f as Te}from"./index-DvErMbt6.js";import{G as lr,Q as dr}from"./index-D6HfLP9Q.js";import{Q as K}from"./qq_manager-BfRTEAby.js";import{P as cr,w as ur,s as hr}from"./process_utils-Bjmp-2dU.js";import{S as A}from"./switch_card-5j4Yjx-K.js";import{u as mr}from"./use-config-Cu0QvgCe.js";import{s as Ve,l as G}from"./chunk-KVDW62ZT-CGYYmJoP.js";import{_ as xr,g as gr}from"./codemirror-core-782AVq39.js";import{C as pr}from"./chunk-M3MASYO7-B4fjH-eW.js";import{c as Ke}from"./chunk-D5XJWRAV-DVN21qSw.js";import{c as qe}from"./chunk-NAV3ZXLI-ChbUTMf0.js";import{G as Se}from"./iconBase-B7bT1FlI.js";import{b as fr}from"./index-_HIxriDC.js";import{b as br,a as wr}from"./index-DE7yoXMZ.js";import{p as vr,a as yr,b as jr}from"./chunk-2QQAR2RD-YG5LNmAk.js";import{F as le}from"./file_manager-BG19iFYW.js";import{l as kr,m as Nr}from"./index-FvTxWQTZ.js";import{i as Sr}from"./chunk-MLPFQTYO-DSnBqIsb.js";import{u as Xe,c as Cr}from"./react-router-dom-C6k78GT4.js";import{c as Lr,d as Ir}from"./index-BBhZPeTB.js";import"./qface-BZLvZXJ8.js";import"./index-BV9-YCKp.js";import"./chunk-UX7UMZL5-CMHjUaC_.js";import"./SelectionManager-Dl9uHsLK.js";import"./usePress-BrNwsdVw.js";import"./layout-Buao20KT.js";import"./gestures-BHfQC-M8.js";import"./features-animation-BkV7kg8P.js";import"./Item-D8Sud-UP.js";import"./chunk-SLABUSGS-Cmz8sGrU.js";import"./useFocusable-DA5Croun.js";import"./chunk-RJKRL3AU-CjtrMR1U.js";import"./chunk-AXSF7SRE-Cr4elNVq.js";import"./index-BsnVex0g.js";import"./use-dialog-CRIMuzeE.js";import"./chunk-J6JGI6RM-Djlxjgjl.js";import"./chunk-EN4B57RQ-Ief8qCCd.js";import"./useToggle-B3ZYBe5S.js";import"./chunk-WQVQ7P2I-BJd1EiqP.js";import"./DOMLayoutDelegate-DOgfSALU.js";import"./useHover-DC1o5-bm.js";import"./chunk-FGM523TA-CgSvUh2a.js";var Mr=h.useLayoutEffect,Fr=function(s){var t=Ne.useRef(s);return Mr(function(){t.current=s}),t},Pe=function(s,t){if(typeof s=="function"){s(t);return}s.current=t},zr=function(s,t){var a=Ne.useRef();return Ne.useCallback(function(d){s.current=d,a.current&&Pe(a.current,null),a.current=t,t&&Pe(t,d)},[t])},Re={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},Tr=function(s){Object.keys(Re).forEach(function(t){s.style.setProperty(t,Re[t],"important")})},Ee=Tr,W=null,We=function(s,t){var a=s.scrollHeight;return t.sizingStyle.boxSizing==="border-box"?a+t.borderSize:a-t.paddingSize};function Pr(r,s,t,a){t===void 0&&(t=1),a===void 0&&(a=1/0),W||(W=document.createElement("textarea"),W.setAttribute("tabindex","-1"),W.setAttribute("aria-hidden","true"),Ee(W)),W.parentNode===null&&document.body.appendChild(W);var d=r.paddingSize,o=r.borderSize,i=r.sizingStyle,m=i.boxSizing;Object.keys(i).forEach(function(n){var j=n;W.style[j]=i[j]}),Ee(W),W.value=s;var l=We(W,r);W.value=s,l=We(W,r),W.value="x";var u=W.scrollHeight-d,c=u*t;m==="border-box"&&(c=c+d+o),l=Math.max(c,l);var g=u*a;return m==="border-box"&&(g=g+d+o),l=Math.min(g,l),[l,u]}var Ue=function(){},Rr=function(s,t){return s.reduce(function(a,d){return a[d]=t[d],a},{})},Er=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],Wr=!!document.documentElement.currentStyle,Ur=function(s){var t=window.getComputedStyle(s);if(t===null)return null;var a=Rr(Er,t),d=a.boxSizing;if(d==="")return null;Wr&&d==="border-box"&&(a.width=parseFloat(a.width)+parseFloat(a.borderRightWidth)+parseFloat(a.borderLeftWidth)+parseFloat(a.paddingRight)+parseFloat(a.paddingLeft)+"px");var o=parseFloat(a.paddingBottom)+parseFloat(a.paddingTop),i=parseFloat(a.borderBottomWidth)+parseFloat(a.borderTopWidth);return{sizingStyle:a,paddingSize:o,borderSize:i}},Ar=Ur;function Ce(r,s,t){var a=Fr(t);h.useLayoutEffect(function(){var d=function(i){return a.current(i)};if(r)return r.addEventListener(s,d),function(){return r.removeEventListener(s,d)}},[])}var Hr=function(s,t){Ce(document.body,"reset",function(a){s.current.form===a.target&&t(a)})},Dr=function(s){Ce(window,"resize",s)},$r=function(s){Ce(document.fonts,"loadingdone",s)},_r=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],Br=function(s,t){var a=s.cacheMeasurements,d=s.maxRows,o=s.minRows,i=s.onChange,m=i===void 0?Ue:i,l=s.onHeightChange,u=l===void 0?Ue:l,c=xr(s,_r),g=c.value!==void 0,n=h.useRef(null),j=zr(n,t),k=h.useRef(0),f=h.useRef(),w=function(){var L=n.current,F=a&&f.current?f.current:Ar(L);if(F){f.current=F;var y=Pr(F,L.value||L.placeholder||"x",o,d),I=y[0],P=y[1];k.current!==I&&(k.current=I,L.style.setProperty("height",I+"px","important"),u(I,{rowHeight:P}))}},b=function(L){g||w(),m(L)};return h.useLayoutEffect(w),Hr(n,function(){if(!g){var N=n.current.value;requestAnimationFrame(function(){var L=n.current;L&&N!==L.value&&w()})}}),Dr(w),$r(w),h.createElement("textarea",gr({},c,{onChange:b,ref:j}))},Qr=h.forwardRef(Br),Ge=tr(({style:r,minRows:s=3,maxRows:t=8,cacheMeasurements:a=!1,disableAutosize:d=!1,onHeightChange:o,...i},m)=>{const{Component:l,label:u,description:c,startContent:g,endContent:n,hasHelper:j,shouldLabelBeOutside:k,shouldLabelBeInside:f,isInvalid:w,errorMessage:b,getBaseProps:N,getLabelProps:L,getInputProps:F,getInnerWrapperProps:y,getInputWrapperProps:I,getHelperWrapperProps:P,getDescriptionProps:p,getErrorMessageProps:S,isClearable:U,getClearButtonProps:O}=ar({...i,ref:m,isMultiline:!0}),[$,J]=h.useState(s>1),[Z,B]=h.useState(!1),se=u?e.jsx("label",{...L(),children:u}):null,V=F(),ae=(ee,re)=>{if(s===1&&J(ee>=re.rowHeight*2),t>s){const ne=ee>=t*re.rowHeight;B(ne)}o==null||o(ee,re)},oe=d?e.jsx("textarea",{...V,style:Fe(V.style,r??{})}):e.jsx(Qr,{...V,cacheMeasurements:a,"data-hide-scroll":ze(!Z),maxRows:t,minRows:s,style:Fe(V.style,r??{}),onHeightChange:ae}),me=h.useMemo(()=>U?e.jsx("button",{...O(),children:e.jsx(pr,{})}):null,[U,O]),X=h.useMemo(()=>g||n?e.jsxs("div",{...y(),children:[g,oe,n]}):e.jsx("div",{...y(),children:oe}),[g,V,n,y]),ie=w&&b,xe=ie||c;return e.jsxs(l,{...N(),children:[k?se:null,e.jsxs("div",{...I(),"data-has-multiple-rows":ze($),children:[f?se:null,X,me]}),j&&xe?e.jsx("div",{...P(),children:ie?e.jsx("div",{...S(),children:b}):e.jsx("div",{...p(),children:c})}):null]})});Ge.displayName="HeroUI.Textarea";var Ae=Ge;const Y=({onSubmit:r,reset:s,isSubmitting:t,refresh:a,className:d})=>e.jsx("div",{className:D("w-full flex flex-col justify-center gap-3",d),children:e.jsxs("div",{className:"flex items-center justify-center gap-2.5 mt-6 pt-5 border-t border-white/50 dark:border-white/[0.06]",children:[e.jsx(z,{radius:"full",variant:"flat",className:"font-medium bg-white/60 dark:bg-white/[0.06] text-default-600 border border-white/50 dark:border-white/10 px-5",onPress:()=>{s(),x.success("重置成功")},children:"取消更改"}),e.jsx(z,{color:"primary",radius:"full",className:"font-semibold px-7 bg-gradient-to-r from-primary-400 to-primary-600 shadow-md shadow-primary-500/30",isLoading:t,onPress:()=>r(),children:"保存"}),a&&e.jsx(z,{isIconOnly:!0,radius:"full",variant:"flat",className:"text-default-500 bg-white/60 dark:bg-white/[0.06] border border-white/50 dark:border-white/10",onPress:()=>a(),children:e.jsx(Oe,{size:20})})]})}),Or=()=>{const[r,s]=h.useState(!1),[t,a]=h.useState([]),[d,o]=h.useState(!1),{data:i,loading:m,error:l,refreshAsync:u}=he(K.getQuickLoginQQ),{control:c,handleSubmit:g,formState:{isSubmitting:n},setValue:j,watch:k}=Q({defaultValues:{quickLoginQQ:""}}),f=k("quickLoginQQ"),w=()=>{j("quickLoginQQ",i??"")},b=async()=>{try{o(!0);const y=await K.getQQQuickLoginListNew();a(y??[])}catch(y){const I=y.message;x.error(`获取账号列表失败: ${I}`)}finally{o(!1)}},N=g(async y=>{try{await K.setQuickLoginQQ(y.quickLoginQQ),x.success("保存成功")}catch(I){const P=I.message;x.error(`保存失败: ${P}`)}}),L=async()=>{try{await u(),x.success("刷新成功")}catch(y){const I=y.message;x.error(`刷新失败: ${I}`)}},F=async()=>{s(!0);try{const y=await cr.restartProcess();x.success(y.message||"进程重启请求已发送"),await ur(3e4,()=>{s(!1),x.success("进程重启完成")},()=>{s(!1),x.error("后端在 30 秒内未响应,请检查 SnowCat 运行日志")})||s(!1)}catch(y){const I=y.message;x.error(`进程重启失败: ${I}`),s(!1)}};return h.useEffect(()=>{w()},[i]),m?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"登录配置 - SnowCat WebUI"}),e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"快速登录QQ"}),e.jsx(C,{control:c,name:"quickLoginQQ",render:({field:y})=>e.jsx(T,{...y,label:"快速登录QQ",placeholder:"请输入QQ号",isDisabled:!!l,errorMessage:l?"获取快速登录QQ失败":void 0,classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{size:"sm",color:"primary",variant:"flat",onPress:b,isLoading:d,children:"获取已登录账号列表"}),t.length>0&&e.jsxs("span",{className:"text-xs text-default-400",children:["共 ",t.length," 个账号,点击选择"]})]}),t.length>0&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[t.filter(y=>y.isQuickLogin).map(y=>{var I;return e.jsxs("button",{type:"button",onClick:()=>j("quickLoginQQ",y.uin),className:`flex items-center gap-3 p-3 rounded-xl border transition-all cursor-pointer text-left
${f===y.uin?"border-primary bg-primary/10 dark:bg-primary/20 shadow-sm":"border-default-200 dark:border-default-100/10 bg-default-100/50 dark:bg-white/5 hover:bg-default-200/50 dark:hover:bg-white/10"}`,children:[e.jsx(ir,{src:y.faceUrl,name:((I=y.nickName)==null?void 0:I.charAt(0))||y.uin.charAt(0),size:"sm",className:"flex-shrink-0"}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"text-sm font-medium text-default-700 truncate",children:y.nickName||"未知昵称"}),e.jsx("span",{className:"text-xs text-default-400 truncate",children:y.uin})]}),f===y.uin&&e.jsx("span",{className:"ml-auto text-xs text-primary font-medium flex-shrink-0",children:"已选择"})]},y.uin)}),t.filter(y=>!y.isQuickLogin).length>0&&e.jsxs("div",{className:"col-span-full text-xs text-default-400 mt-1",children:["以下账号不支持快速登录:",t.filter(y=>!y.isQuickLogin).map(y=>y.uin).join("、")]})]})]}),e.jsx(Y,{onSubmit:N,reset:w,isSubmitting:n||m,refresh:L}),e.jsxs("div",{className:"flex-shrink-0 w-full mt-6 pt-6 border-t border-divider",children:[e.jsx("div",{className:"mb-3 text-sm text-default-600",children:"进程管理"}),e.jsx(z,{color:"warning",variant:"flat",onPress:F,isLoading:r,isDisabled:r,fullWidth:!0,children:r?"正在重启进程...":"重启进程"}),e.jsx("div",{className:"mt-2 text-xs text-default-500",children:"重启进程将关闭当前 Worker 进程,等待 3 秒后启动新进程"})]}),e.jsx(or,{className:"mt-6"}),e.jsxs("div",{className:"flex-shrink-0 w-full mt-4",children:[e.jsx("div",{className:"mb-3 text-sm text-default-600",children:"设备 GUID 管理"}),e.jsx("div",{className:"text-xs text-default-400 mb-3",children:"GUID 是设备登录唯一识别码,存储在 Registry20 文件中。修改后需重启生效。"}),e.jsx(lr,{showRestart:!1})]})]})},Vr=()=>{const{config:r,saveConfigWithoutNetwork:s,refreshConfig:t}=mr(),[a,d]=h.useState(!1),{control:o,handleSubmit:i,formState:{isSubmitting:m},setValue:l}=Q({defaultValues:{musicSignUrl:"",enableLocalFile2Url:!1,parseMultMsg:!1,imageDownloadProxy:"",timeout:{baseTimeout:1e4,uploadSpeedKBps:256,downloadSpeedKBps:256,maxTimeout:18e5}}}),u=()=>{l("musicSignUrl",r.musicSignUrl),l("enableLocalFile2Url",r.enableLocalFile2Url),l("parseMultMsg",r.parseMultMsg),l("imageDownloadProxy",r.imageDownloadProxy),l("timeout",r.timeout??{baseTimeout:1e4,uploadSpeedKBps:256,downloadSpeedKBps:1e3,maxTimeout:18e5})},c=i(async n=>{try{await s(n),x.success("保存成功")}catch(j){const k=j.message;x.error(`保存失败: ${k}`)}}),g=async(n=!0)=>{try{d(!0),await t(),n&&x.success("刷新成功")}catch(j){const k=j.message;x.error(`刷新失败: ${k}`)}finally{d(!1)}};return h.useEffect(()=>{u()},[r]),h.useEffect(()=>{g(!1)},[]),a?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"OneBot配置 - SnowCat WebUI"}),e.jsx(C,{control:o,name:"musicSignUrl",render:({field:n})=>e.jsx(T,{...n,label:"音乐签名地址",placeholder:"请输入音乐签名地址",classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}),e.jsx(C,{control:o,name:"enableLocalFile2Url",render:({field:n})=>e.jsx(A,{...n,description:"启用本地文件到URL",label:"启用本地文件到URL"})}),e.jsx(C,{control:o,name:"parseMultMsg",render:({field:n})=>e.jsx(A,{...n,description:"启用上报解析合并消息",label:"启用上报解析合并消息"})}),e.jsx(C,{control:o,name:"imageDownloadProxy",render:({field:n})=>e.jsx(T,{...n,label:"图片下载代理",placeholder:"请输入代理地址,如 http://127.0.0.1:7890",classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}),e.jsx(C,{control:o,name:"timeout.baseTimeout",render:({field:n})=>{var j;return e.jsx(T,{...n,type:"number",label:"基础超时时间(毫秒)",placeholder:"10000",value:((j=n.value)==null?void 0:j.toString())??"",onChange:k=>n.onChange(parseInt(k.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}}),e.jsx(C,{control:o,name:"timeout.uploadSpeedKBps",render:({field:n})=>{var j;return e.jsx(T,{...n,type:"number",label:"预估上传速度(KB/s)",placeholder:"256",value:((j=n.value)==null?void 0:j.toString())??"",onChange:k=>n.onChange(parseInt(k.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}}),e.jsx(C,{control:o,name:"timeout.downloadSpeedKBps",render:({field:n})=>{var j;return e.jsx(T,{...n,type:"number",label:"预估下载速度(KB/s)",placeholder:"1000",value:((j=n.value)==null?void 0:j.toString())??"",onChange:k=>n.onChange(parseInt(k.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}}),e.jsx(C,{control:o,name:"timeout.maxTimeout",render:({field:n})=>{var j;return e.jsx(T,{...n,type:"number",label:"最大超时时间(毫秒)",placeholder:"1800000",value:((j=n.value)==null?void 0:j.toString())??"",onChange:k=>n.onChange(parseInt(k.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}}),e.jsx(Y,{onSubmit:c,reset:u,isSubmitting:m,refresh:g})]})},Kr=()=>{const{data:r,loading:s,error:t,refreshAsync:a}=he(E.getWebUIConfig),[d,o]=h.useState(""),{control:i,handleSubmit:m,formState:{isSubmitting:l},setValue:u,watch:c}=Q({defaultValues:{host:"0.0.0.0",port:6099,loginRate:10,disableWebUI:!1,accessControlMode:"none",ipWhitelist:[],ipBlacklist:[],enableXForwardedFor:!1}}),g=c("accessControlMode"),n=()=>{r&&(u("host",r.host),u("port",r.port),u("loginRate",r.loginRate),u("disableWebUI",r.disableWebUI),u("accessControlMode",r.accessControlMode||"none"),u("ipWhitelist",r.ipWhitelist||[]),u("ipBlacklist",r.ipBlacklist||[]),u("enableXForwardedFor",r.enableXForwardedFor||!1),r.accessControlMode==="whitelist"?o((r.ipWhitelist||[]).join(`
`)):r.accessControlMode==="blacklist"&&o((r.ipBlacklist||[]).join(`
`)))},j=m(async f=>{try{const w=d.split(`
`).map(N=>N.trim()).filter(N=>N.length>0),b={...f,ipWhitelist:f.accessControlMode==="whitelist"?w:[],ipBlacklist:f.accessControlMode==="blacklist"?w:[]};await E.updateWebUIConfig(b),x.success("保存成功")}catch(w){const b=w.message;x.error(`保存失败: ${b}`)}}),k=async()=>{try{await a(),x.success("刷新成功")}catch(f){const w=f.message;x.error(`刷新失败: ${w}`)}};return h.useEffect(()=>{n()},[r]),h.useEffect(()=>{(async()=>{if(r)if(g==="whitelist"){const w=r.ipWhitelist||[];if(w.length===0)try{const b=await E.getClientIP();b!=null&&b.ip?o(b.ip):o("")}catch(b){console.error("获取客户端IP失败:",b),o("")}else o(w.join(`
`))}else o(g==="blacklist"?(r.ipBlacklist||[]).join(`
`):"")})()},[g,r]),s?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"服务器配置 - SnowCat WebUI"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"服务器配置"}),e.jsx(C,{control:i,name:"host",render:({field:f})=>e.jsx(T,{...f,label:"监听地址",placeholder:"请输入监听地址",description:"服务器监听的IP地址,0.0.0.0表示监听所有网卡",isDisabled:!!t,errorMessage:t?"获取配置失败":void 0,classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400"}})}),e.jsx(C,{control:i,name:"port",render:({field:f})=>{var w;return e.jsx(T,{...f,type:"number",value:((w=f.value)==null?void 0:w.toString())||"",label:"监听端口",placeholder:"请输入监听端口",description:"服务器监听的端口号,范围1-65535",isDisabled:!!t,errorMessage:t?"获取配置失败":void 0,onChange:b=>f.onChange(parseInt(b.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-gray-800 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500"}})}}),e.jsx(C,{control:i,name:"loginRate",render:({field:f})=>{var w;return e.jsx(T,{...f,type:"number",value:((w=f.value)==null?void 0:w.toString())||"",label:"登录速率限制",placeholder:"请输入登录速率限制",description:"每小时允许的登录尝试次数",isDisabled:!!t,errorMessage:t?"获取配置失败":void 0,onChange:b=>f.onChange(parseInt(b.target.value)||0),classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-gray-800 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500"}})}})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"安全配置"}),e.jsx(C,{control:i,name:"disableWebUI",render:({field:f})=>e.jsx(A,{value:f.value,onValueChange:w=>f.onChange(w),disabled:!!t,label:"禁用WebUI",description:"启用后将完全禁用WebUI服务,需要重启生效"})}),e.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[e.jsx("div",{className:"text-sm font-medium text-default-700 dark:text-default-300 px-1",children:"网络访问控制"}),e.jsx(C,{control:i,name:"accessControlMode",render:({field:f})=>e.jsxs(Ve,{...f,label:"访问控制模式",placeholder:"选择访问控制模式",description:"选择如何控制网络访问",selectedKeys:[f.value],onSelectionChange:w=>{const b=Array.from(w)[0];f.onChange(b)},isDisabled:!!t,classNames:{trigger:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35"},children:[e.jsx(G,{value:"none",children:"不限制"},"none"),e.jsx(G,{value:"whitelist",children:"白名单模式"},"whitelist"),e.jsx(G,{value:"blacklist",children:"黑名单模式"},"blacklist")]})}),g!=="none"&&e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-sm font-medium text-default-700 dark:text-default-300",children:g==="whitelist"?"IP白名单":"IP黑名单"}),e.jsx("textarea",{value:d,onChange:f=>o(f.target.value),placeholder:`每行一个IP地址或规则
支持格式:
IPv4:
- 精确IP: 192.168.1.100
- 通配符: 192.168.1.*
- CIDR: 192.168.1.0/24
IPv6:
- 精确IP: 2001:db8::1
- CIDR: 2001:db8::/32`,disabled:!!t,rows:10,className:"w-full px-3 py-2 bg-default-100/50 dark:bg-white/5 backdrop-blur-md border border-transparent hover:bg-default-200/50 dark:hover:bg-white/10 transition-all shadow-sm hover:border-default-300 rounded-lg text-default-700 dark:text-default-300 placeholder:text-default-400 font-mono text-sm resize-y focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("p",{className:"text-xs text-default-500",children:g==="whitelist"?"只有列表中的IP可以访问":"列表中的IP将被拒绝访问"})]}),e.jsxs("div",{className:"text-xs text-default-500 px-1",children:[e.jsx("div",{className:"font-medium mb-1",children:"示例规则:"}),e.jsxs("div",{className:"space-y-0.5 font-mono",children:[e.jsx("div",{children:"• 127.0.0.1 (IPv4 本地回环)"}),e.jsx("div",{children:"• 192.168.1.* (IPv4 通配符)"}),e.jsx("div",{children:"• 10.0.0.0/8 (IPv4 CIDR)"}),e.jsx("div",{children:"• ::1 (IPv6 本地回环)"}),e.jsx("div",{children:"• 2001:db8::/32 (IPv6 CIDR)"})]})]})]}),e.jsx(C,{control:i,name:"enableXForwardedFor",render:({field:f})=>e.jsx(A,{value:f.value,onValueChange:w=>f.onChange(w),disabled:!!t,label:"启用 X-Forwarded-For",description:"启用后将从 X-Forwarded-For 头部获取真实IP地址(适用于反向代理场景)"})})]})]})]}),e.jsx(Y,{onSubmit:j,reset:n,isSubmitting:l||s,refresh:k})]})},qr=()=>{const{data:r,loading:s,refreshAsync:t}=he(E.getSSLStatus),[a,d]=h.useState(""),[o,i]=h.useState(""),[m,l]=h.useState(!1);h.useEffect(()=>{r&&(d(r.certContent||""),i(r.keyContent||""))},[r]);const u=async()=>{if(!a.trim()||!o.trim()){x.error("证书和私钥内容不能为空");return}l(!0);try{const n=await E.saveSSLCert(a,o);x.success(n.message||"SSL证书保存成功"),await t()}catch(n){const j=n.message;x.error(`保存SSL证书失败: ${j}`)}finally{l(!1)}},c=async()=>{l(!0);try{const n=await E.deleteSSLCert();x.success(n.message||"SSL证书已删除"),d(""),i(""),await t()}catch(n){const j=n.message;x.error(`删除SSL证书失败: ${j}`)}finally{l(!1)}},g=async()=>{try{await t(),x.success("刷新成功")}catch(n){const j=n.message;x.error(`刷新失败: ${j}`)}};return s?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"SSL配置 - SnowCat WebUI"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"SSL/HTTPS 配置"}),(r==null?void 0:r.enabled)&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-success-100 text-success-700 dark:bg-success-900/30 dark:text-success-400 rounded-full whitespace-nowrap",children:"已启用"})]}),e.jsx("p",{className:"text-sm text-default-500 px-1",children:"配置SSL证书后重启即可启用HTTPS。将证书(cert.pem)和私钥(key.pem)的内容粘贴到下方文本框中。"}),e.jsx("div",{className:"p-3 bg-warning-50/70 dark:bg-warning-900/20 rounded-xl border border-warning-200/70 dark:border-warning-800/40",children:e.jsxs("p",{className:"text-xs leading-relaxed text-warning-700 dark:text-warning-400",children:[e.jsx("strong",{children:"注意:"}),"保存证书后需要重启服务才能生效。删除证书后同样需要重启才能切换回HTTP模式。"]})})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Ae,{label:"证书内容 (cert.pem)",placeholder:`-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----`,value:a,onValueChange:d,minRows:6,maxRows:12,classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400 font-mono text-sm"}}),e.jsx(Ae,{label:"私钥内容 (key.pem)",placeholder:`-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----`,value:o,onValueChange:i,minRows:6,maxRows:12,classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 placeholder:text-default-400 font-mono text-sm"}})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-4 border-t border-white/50 dark:border-white/[0.06]",children:[e.jsx(z,{variant:"flat",radius:"full",className:"bg-white/60 dark:bg-white/[0.06] text-default-600 border border-white/50 dark:border-white/10",isLoading:m||s,onPress:g,size:"sm",children:"刷新"}),(r==null?void 0:r.enabled)&&e.jsx(z,{color:"danger",variant:"flat",radius:"full",isLoading:m||s,onPress:c,size:"sm",children:"删除SSL证书"}),e.jsx(z,{color:"primary",radius:"full",className:"font-semibold bg-gradient-to-r from-primary-400 to-primary-600 shadow-md shadow-primary-500/25 px-5",isLoading:m||s,onPress:u,size:"sm",children:"保存SSL证书"})]})]})]})};function Ye(r){return Se({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"},child:[]}]})(r)}function He(r){return Se({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 416h-23.41L277.88 53.69A32 32 0 0 0 247.58 32h-47.16a32 32 0 0 0-30.3 21.69L39.41 416H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16h-19.58l23.3-64h152.56l23.3 64H304a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h128a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM176.85 272L224 142.51 271.15 272z"},child:[]}]})(r)}function Xr(r){return Se({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M64 224h13.5c24.7 56.5 80.9 96 146.5 96s121.8-39.5 146.5-96H384c8.8 0 16-7.2 16-16v-96c0-8.8-7.2-16-16-16h-13.5C345.8 39.5 289.6 0 224 0S102.2 39.5 77.5 96H64c-8.8 0-16 7.2-16 16v96c0 8.8 7.2 16 16 16zm40-88c0-22.1 21.5-40 48-40h144c26.5 0 48 17.9 48 40v24c0 53-43 96-96 96h-48c-53 0-96-43-96-96v-24zm72 72l12-36 36-12-36-12-12-36-12 36-36 12 36 12 12 36zm151.6 113.4C297.7 340.7 262.2 352 224 352s-73.7-11.3-103.6-30.6C52.9 328.5 0 385 0 454.4v9.6c0 26.5 21.5 48 48 48h80v-64c0-17.7 14.3-32 32-32h128c17.7 0 32 14.3 32 32v64h80c26.5 0 48-21.5 48-48v-9.6c0-69.4-52.9-125.9-120.4-133zM272 448c-8.8 0-16 7.2-16 16s7.2 16 16 16 16-7.2 16-16-7.2-16-16-16zm-96 0c-8.8 0-16 7.2-16 16v48h32v-48c0-8.8-7.2-16-16-16z"},child:[]}]})(r)}const Gr={dark:{"--heroui-background":"0 0% 0%","--heroui-foreground-50":"240 5.88% 10%","--heroui-foreground-100":"240 3.7% 15.88%","--heroui-foreground-200":"240 5.26% 26.08%","--heroui-foreground-300":"240 5.2% 33.92%","--heroui-foreground-400":"240 3.83% 46.08%","--heroui-foreground-500":"240 5.03% 64.9%","--heroui-foreground-600":"240 4.88% 83.92%","--heroui-foreground-700":"240 5.88% 90%","--heroui-foreground-800":"240 4.76% 95.88%","--heroui-foreground-900":"0 0% 98.04%","--heroui-foreground":"210 5.56% 92.94%","--heroui-focus":"212.01999999999998 100% 46.67%","--heroui-overlay":"0 0% 0%","--heroui-divider":"0 0% 100%","--heroui-divider-opacity":"0.15","--heroui-content1":"240 5.88% 10%","--heroui-content1-foreground":"0 0% 98.04%","--heroui-content2":"240 3.7% 15.88%","--heroui-content2-foreground":"240 4.76% 95.88%","--heroui-content3":"240 5.26% 26.08%","--heroui-content3-foreground":"240 5.88% 90%","--heroui-content4":"240 5.2% 33.92%","--heroui-content4-foreground":"240 4.88% 83.92%","--heroui-default-50":"240 5.88% 10%","--heroui-default-100":"240 3.7% 15.88%","--heroui-default-200":"240 5.26% 26.08%","--heroui-default-300":"240 5.2% 33.92%","--heroui-default-400":"240 3.83% 46.08%","--heroui-default-500":"240 5.03% 64.9%","--heroui-default-600":"240 4.88% 83.92%","--heroui-default-700":"240 5.88% 90%","--heroui-default-800":"240 4.76% 95.88%","--heroui-default-900":"0 0% 98.04%","--heroui-default-foreground":"0 0% 100%","--heroui-default":"240 5.26% 26.08%","--heroui-danger-50":"340 84.91% 10.39%","--heroui-danger-100":"339.33 86.54% 20.39%","--heroui-danger-200":"339.11 85.99% 30.78%","--heroui-danger-300":"339 86.54% 40.78%","--heroui-danger-400":"339.2 90.36% 51.18%","--heroui-danger-500":"339 90% 60.78%","--heroui-danger-600":"339.11 90.6% 70.78%","--heroui-danger-700":"339.33 90% 80.39%","--heroui-danger-800":"340 91.84% 90.39%","--heroui-danger-900":"339.13 92% 95.1%","--heroui-danger-foreground":"0 0% 100%","--heroui-danger":"339.2 90.36% 51.18%","--heroui-primary-50":"205.5 85% 9.61%","--heroui-primary-100":"205.5 85% 19.22%","--heroui-primary-200":"206 85% 28.82%","--heroui-primary-300":"205.5 85% 38.43%","--heroui-primary-400":"206 85% 46.67%","--heroui-primary-500":"206 78% 58.43%","--heroui-primary-600":"206 78% 68.82%","--heroui-primary-700":"205.5 78% 79.22%","--heroui-primary-800":"205.5 78% 89.61%","--heroui-primary-900":"206.5 78% 94.9%","--heroui-primary-foreground":"0 0% 100%","--heroui-primary":"206 85% 46.67%","--heroui-secondary-50":"270 66.67% 9.41%","--heroui-secondary-100":"270 66.67% 18.82%","--heroui-secondary-200":"270 66.67% 28.24%","--heroui-secondary-300":"270 66.67% 37.65%","--heroui-secondary-400":"270 66.67% 47.06%","--heroui-secondary-500":"270 59.26% 57.65%","--heroui-secondary-600":"270 59.26% 68.24%","--heroui-secondary-700":"270 59.26% 78.82%","--heroui-secondary-800":"270 59.26% 89.41%","--heroui-secondary-900":"270 61.54% 94.9%","--heroui-secondary-foreground":"0 0% 100%","--heroui-secondary":"270 59.26% 57.65%","--heroui-success-50":"145.71 77.78% 8.82%","--heroui-success-100":"146.2 79.78% 17.45%","--heroui-success-200":"145.79 79.26% 26.47%","--heroui-success-300":"146.01 79.89% 35.1%","--heroui-success-400":"145.96 79.46% 43.92%","--heroui-success-500":"146.01 62.45% 55.1%","--heroui-success-600":"145.79 62.57% 66.47%","--heroui-success-700":"146.2 61.74% 77.45%","--heroui-success-800":"145.71 61.4% 88.82%","--heroui-success-900":"146.67 64.29% 94.51%","--heroui-success-foreground":"0 0% 0%","--heroui-success":"145.96 79.46% 43.92%","--heroui-warning-50":"37.14 75% 10.98%","--heroui-warning-100":"37.14 75% 21.96%","--heroui-warning-200":"36.96 73.96% 33.14%","--heroui-warning-300":"37.01 74.22% 44.12%","--heroui-warning-400":"37.03 91.27% 55.1%","--heroui-warning-500":"37.01 91.26% 64.12%","--heroui-warning-600":"36.96 91.24% 73.14%","--heroui-warning-700":"37.14 91.3% 81.96%","--heroui-warning-800":"37.14 91.3% 90.98%","--heroui-warning-900":"54.55 91.67% 95.29%","--heroui-warning-foreground":"0 0% 0%","--heroui-warning":"37.03 91.27% 55.1%","--heroui-code-background":"240 5.56% 7.06%","--heroui-strong":"190.14 94.67% 44.12%","--heroui-code-mdx":"190.14 94.67% 44.12%","--heroui-divider-weight":"1px","--heroui-disabled-opacity":".5","--heroui-font-size-tiny":"0.75rem","--heroui-font-size-small":"0.875rem","--heroui-font-size-medium":"1rem","--heroui-font-size-large":"1.125rem","--heroui-line-height-tiny":"1rem","--heroui-line-height-small":"1.25rem","--heroui-line-height-medium":"1.5rem","--heroui-line-height-large":"1.75rem","--heroui-radius-small":"8px","--heroui-radius-medium":"12px","--heroui-radius-large":"14px","--heroui-border-width-small":"1px","--heroui-border-width-medium":"2px","--heroui-border-width-large":"3px","--heroui-box-shadow-small":"0px 0px 5px 0px rgba(0, 0, 0, .05), 0px 2px 10px 0px rgba(0, 0, 0, .2), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-box-shadow-medium":"0px 0px 15px 0px rgba(0, 0, 0, .06), 0px 2px 30px 0px rgba(0, 0, 0, .22), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-box-shadow-large":"0px 0px 30px 0px rgba(0, 0, 0, .07), 0px 30px 60px 0px rgba(0, 0, 0, .26), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-hover-opacity":".9"},light:{"--heroui-background":"0 0% 100%","--heroui-foreground-50":"240 5.88% 95%","--heroui-foreground-100":"240 3.7% 90%","--heroui-foreground-200":"240 5.26% 80%","--heroui-foreground-300":"240 5.2% 70%","--heroui-foreground-400":"240 3.83% 60%","--heroui-foreground-500":"240 5.03% 50%","--heroui-foreground-600":"240 4.88% 40%","--heroui-foreground-700":"240 5.88% 30%","--heroui-foreground-800":"240 4.76% 20%","--heroui-foreground-900":"0 0% 10%","--heroui-foreground":"210 5.56% 7.06%","--heroui-focus":"212.01999999999998 100% 53.33%","--heroui-overlay":"0 0% 100%","--heroui-divider":"0 0% 0%","--heroui-divider-opacity":"0.85","--heroui-content1":"240 5.88% 95%","--heroui-content1-foreground":"0 0% 10%","--heroui-content2":"240 3.7% 90%","--heroui-content2-foreground":"240 4.76% 20%","--heroui-content3":"240 5.26% 80%","--heroui-content3-foreground":"240 5.88% 30%","--heroui-content4":"240 5.2% 70%","--heroui-content4-foreground":"240 4.88% 40%","--heroui-default-50":"240 5.88% 95%","--heroui-default-100":"240 3.7% 90%","--heroui-default-200":"240 5.26% 80%","--heroui-default-300":"240 5.2% 70%","--heroui-default-400":"240 3.83% 60%","--heroui-default-500":"240 5.03% 50%","--heroui-default-600":"240 4.88% 40%","--heroui-default-700":"240 5.88% 30%","--heroui-default-800":"240 4.76% 20%","--heroui-default-900":"0 0% 10%","--heroui-default-foreground":"0 0% 0%","--heroui-default":"240 5.26% 80%","--heroui-danger-50":"339.13 92% 95.1%","--heroui-danger-100":"340 91.84% 90.39%","--heroui-danger-200":"339.33 90% 80.39%","--heroui-danger-300":"339.11 90.6% 70.78%","--heroui-danger-400":"339 90% 60.78%","--heroui-danger-500":"339.2 90.36% 51.18%","--heroui-danger-600":"339 86.54% 40.78%","--heroui-danger-700":"339.11 85.99% 30.78%","--heroui-danger-800":"339.33 86.54% 20.39%","--heroui-danger-900":"340 84.91% 10.39%","--heroui-danger-foreground":"0 0% 100%","--heroui-danger":"339.2 90.36% 51.18%","--heroui-primary-50":"206.5 78% 94.9%","--heroui-primary-100":"205.5 78% 89.61%","--heroui-primary-200":"205.5 78% 79.22%","--heroui-primary-300":"206 78% 68.82%","--heroui-primary-400":"206 78% 58.43%","--heroui-primary-500":"206 85% 46.67%","--heroui-primary-600":"205.5 85% 38.43%","--heroui-primary-700":"206 85% 28.82%","--heroui-primary-800":"205.5 85% 19.22%","--heroui-primary-900":"205.5 85% 9.61%","--heroui-primary-foreground":"0 0% 100%","--heroui-primary":"206 85% 46.67%","--heroui-secondary-50":"270 61.54% 94.9%","--heroui-secondary-100":"270 59.26% 89.41%","--heroui-secondary-200":"270 59.26% 78.82%","--heroui-secondary-300":"270 59.26% 68.24%","--heroui-secondary-400":"270 59.26% 57.65%","--heroui-secondary-500":"270 66.67% 47.06%","--heroui-secondary-600":"270 66.67% 37.65%","--heroui-secondary-700":"270 66.67% 28.24%","--heroui-secondary-800":"270 66.67% 18.82%","--heroui-secondary-900":"270 66.67% 9.41%","--heroui-secondary-foreground":"0 0% 100%","--heroui-secondary":"270 66.67% 47.06%","--heroui-success-50":"146.67 64.29% 94.51%","--heroui-success-100":"145.71 61.4% 88.82%","--heroui-success-200":"146.2 61.74% 77.45%","--heroui-success-300":"145.79 62.57% 66.47%","--heroui-success-400":"146.01 62.45% 55.1%","--heroui-success-500":"145.96 79.46% 43.92%","--heroui-success-600":"146.01 79.89% 35.1%","--heroui-success-700":"145.79 79.26% 26.47%","--heroui-success-800":"146.2 79.78% 17.45%","--heroui-success-900":"145.71 77.78% 8.82%","--heroui-success-foreground":"0 0% 0%","--heroui-success":"145.96 79.46% 43.92%","--heroui-warning-50":"54.55 91.67% 95.29%","--heroui-warning-100":"37.14 91.3% 90.98%","--heroui-warning-200":"37.14 91.3% 81.96%","--heroui-warning-300":"36.96 91.24% 73.14%","--heroui-warning-400":"37.01 91.26% 64.12%","--heroui-warning-500":"37.03 91.27% 55.1%","--heroui-warning-600":"37.01 74.22% 44.12%","--heroui-warning-700":"36.96 73.96% 33.14%","--heroui-warning-800":"37.14 75% 21.96%","--heroui-warning-900":"37.14 75% 10.98%","--heroui-warning-foreground":"0 0% 0%","--heroui-warning":"37.03 91.27% 55.1%","--heroui-code-background":"221.25 17.39% 18.04%","--heroui-strong":"316.95 100% 65.29%","--heroui-code-mdx":"316.95 100% 65.29%","--heroui-divider-weight":"1px","--heroui-disabled-opacity":".5","--heroui-font-size-tiny":"0.75rem","--heroui-font-size-small":"0.875rem","--heroui-font-size-medium":"1rem","--heroui-font-size-large":"1.125rem","--heroui-line-height-tiny":"1rem","--heroui-line-height-small":"1.25rem","--heroui-line-height-medium":"1.5rem","--heroui-line-height-large":"1.75rem","--heroui-radius-small":"8px","--heroui-radius-medium":"12px","--heroui-radius-large":"14px","--heroui-border-width-small":"1px","--heroui-border-width-medium":"2px","--heroui-border-width-large":"3px","--heroui-box-shadow-small":"0px 0px 5px 0px rgba(0, 0, 0, .02), 0px 2px 10px 0px rgba(0, 0, 0, .06), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-box-shadow-medium":"0px 0px 15px 0px rgba(0, 0, 0, .03), 0px 2px 30px 0px rgba(0, 0, 0, .08), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-box-shadow-large":"0px 0px 30px 0px rgba(0, 0, 0, .04), 0px 30px 60px 0px rgba(0, 0, 0, .12), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-hover-opacity":".8"}},Yr={theme:Gr,author:"HeroUI",name:"heroui",description:"HeroUI Default Theme"},Jr={dark:{"--heroui-background":"0 0% 0%","--heroui-foreground-50":"240 5.88% 10%","--heroui-foreground-100":"240 3.7% 15.88%","--heroui-foreground-200":"240 5.26% 26.08%","--heroui-foreground-300":"240 5.2% 33.92%","--heroui-foreground-400":"240 3.83% 46.08%","--heroui-foreground-500":"240 5.03% 64.9%","--heroui-foreground-600":"240 4.88% 83.92%","--heroui-foreground-700":"240 5.88% 90%","--heroui-foreground-800":"240 4.76% 95.88%","--heroui-foreground-900":"0 0% 98.04%","--heroui-foreground":"210 5.56% 92.94%","--heroui-focus":"212.01999999999998 100% 46.67%","--heroui-overlay":"0 0% 0%","--heroui-divider":"0 0% 100%","--heroui-divider-opacity":"0.15","--heroui-content1":"240 5.88% 10%","--heroui-content1-foreground":"0 0% 98.04%","--heroui-content2":"240 3.7% 15.88%","--heroui-content2-foreground":"240 4.76% 95.88%","--heroui-content3":"240 5.26% 26.08%","--heroui-content3-foreground":"240 5.88% 90%","--heroui-content4":"240 5.2% 33.92%","--heroui-content4-foreground":"240 4.88% 83.92%","--heroui-default-50":"240 5.88% 10%","--heroui-default-100":"240 3.7% 15.88%","--heroui-default-200":"240 5.26% 26.08%","--heroui-default-300":"240 5.2% 33.92%","--heroui-default-400":"240 3.83% 46.08%","--heroui-default-500":"240 5.03% 64.9%","--heroui-default-600":"240 4.88% 83.92%","--heroui-default-700":"240 5.88% 90%","--heroui-default-800":"240 4.76% 95.88%","--heroui-default-900":"0 0% 98.04%","--heroui-default-foreground":"0 0% 100%","--heroui-default":"240 5.26% 26.08%","--heroui-danger-50":"301.89 82.61% 22.55%","--heroui-danger-100":"308.18 76.39% 28.24%","--heroui-danger-200":"313.85 70.65% 36.08%","--heroui-danger-300":"319.73 65.64% 44.51%","--heroui-danger-400":"325.82 69.62% 53.53%","--heroui-danger-500":"331.82 75% 65.49%","--heroui-danger-600":"337.84 83.46% 73.92%","--heroui-danger-700":"343.42 90.48% 83.53%","--heroui-danger-800":"350.53 90.48% 91.76%","--heroui-danger-900":"324 90.91% 95.69%","--heroui-danger-foreground":"0 0% 100%","--heroui-danger":"325.82 69.62% 53.53%","--heroui-primary-50":"340 84.91% 10.39%","--heroui-primary-100":"339.33 86.54% 20.39%","--heroui-primary-200":"339.11 85.99% 30.78%","--heroui-primary-300":"339 86.54% 40.78%","--heroui-primary-400":"339.2 90.36% 51.18%","--heroui-primary-500":"339 90% 60.78%","--heroui-primary-600":"339.11 90.6% 70.78%","--heroui-primary-700":"339.33 90% 80.39%","--heroui-primary-800":"340 91.84% 90.39%","--heroui-primary-900":"339.13 92% 95.1%","--heroui-primary-foreground":"0 0% 100%","--heroui-primary":"339.2 90.36% 51.18%","--heroui-secondary-50":"270 66.67% 9.41%","--heroui-secondary-100":"270 66.67% 18.82%","--heroui-secondary-200":"270 66.67% 28.24%","--heroui-secondary-300":"270 66.67% 37.65%","--heroui-secondary-400":"270 66.67% 47.06%","--heroui-secondary-500":"270 59.26% 57.65%","--heroui-secondary-600":"270 59.26% 68.24%","--heroui-secondary-700":"270 59.26% 78.82%","--heroui-secondary-800":"270 59.26% 89.41%","--heroui-secondary-900":"270 61.54% 94.9%","--heroui-secondary-foreground":"0 0% 100%","--heroui-secondary":"270 59.26% 57.65%","--heroui-success-50":"145.71 77.78% 8.82%","--heroui-success-100":"146.2 79.78% 17.45%","--heroui-success-200":"145.79 79.26% 26.47%","--heroui-success-300":"146.01 79.89% 35.1%","--heroui-success-400":"145.96 79.46% 43.92%","--heroui-success-500":"146.01 62.45% 55.1%","--heroui-success-600":"145.79 62.57% 66.47%","--heroui-success-700":"146.2 61.74% 77.45%","--heroui-success-800":"145.71 61.4% 88.82%","--heroui-success-900":"146.67 64.29% 94.51%","--heroui-success-foreground":"0 0% 0%","--heroui-success":"145.96 79.46% 43.92%","--heroui-warning-50":"37.14 75% 10.98%","--heroui-warning-100":"37.14 75% 21.96%","--heroui-warning-200":"36.96 73.96% 33.14%","--heroui-warning-300":"37.01 74.22% 44.12%","--heroui-warning-400":"37.03 91.27% 55.1%","--heroui-warning-500":"37.01 91.26% 64.12%","--heroui-warning-600":"36.96 91.24% 73.14%","--heroui-warning-700":"37.14 91.3% 81.96%","--heroui-warning-800":"37.14 91.3% 90.98%","--heroui-warning-900":"54.55 91.67% 95.29%","--heroui-warning-foreground":"0 0% 0%","--heroui-warning":"37.03 91.27% 55.1%","--heroui-code-background":"240 5.56% 7.06%","--heroui-strong":"190.14 94.67% 44.12%","--heroui-code-mdx":"190.14 94.67% 44.12%","--heroui-divider-weight":"1px","--heroui-disabled-opacity":".5","--heroui-font-size-tiny":"0.75rem","--heroui-font-size-small":"0.875rem","--heroui-font-size-medium":"1rem","--heroui-font-size-large":"1.125rem","--heroui-line-height-tiny":"1rem","--heroui-line-height-small":"1.25rem","--heroui-line-height-medium":"1.5rem","--heroui-line-height-large":"1.75rem","--heroui-radius-small":"8px","--heroui-radius-medium":"12px","--heroui-radius-large":"14px","--heroui-border-width-small":"1px","--heroui-border-width-medium":"2px","--heroui-border-width-large":"3px","--heroui-box-shadow-small":"0px 0px 5px 0px rgba(0, 0, 0, .05), 0px 2px 10px 0px rgba(0, 0, 0, .2), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-box-shadow-medium":"0px 0px 15px 0px rgba(0, 0, 0, .06), 0px 2px 30px 0px rgba(0, 0, 0, .22), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-box-shadow-large":"0px 0px 30px 0px rgba(0, 0, 0, .07), 0px 30px 60px 0px rgba(0, 0, 0, .26), inset 0px 0px 1px 0px hsla(0, 0%, 100%, .15)","--heroui-hover-opacity":".9"},light:{"--heroui-background":"0 0% 100%","--heroui-foreground-50":"240 5.88% 95%","--heroui-foreground-100":"240 3.7% 90%","--heroui-foreground-200":"240 5.26% 80%","--heroui-foreground-300":"240 5.2% 70%","--heroui-foreground-400":"240 3.83% 60%","--heroui-foreground-500":"240 5.03% 50%","--heroui-foreground-600":"240 4.88% 40%","--heroui-foreground-700":"240 5.88% 30%","--heroui-foreground-800":"240 4.76% 20%","--heroui-foreground-900":"0 0% 10%","--heroui-foreground":"210 5.56% 7.06%","--heroui-focus":"212.01999999999998 100% 53.33%","--heroui-overlay":"0 0% 100%","--heroui-divider":"0 0% 0%","--heroui-divider-opacity":"0.85","--heroui-content1":"240 5.88% 95%","--heroui-content1-foreground":"0 0% 10%","--heroui-content2":"240 3.7% 90%","--heroui-content2-foreground":"240 4.76% 20%","--heroui-content3":"240 5.26% 80%","--heroui-content3-foreground":"240 5.88% 30%","--heroui-content4":"240 5.2% 70%","--heroui-content4-foreground":"240 4.88% 40%","--heroui-default-50":"240 5.88% 95%","--heroui-default-100":"240 3.7% 90%","--heroui-default-200":"240 5.26% 80%","--heroui-default-300":"240 5.2% 70%","--heroui-default-400":"240 3.83% 60%","--heroui-default-500":"240 5.03% 50%","--heroui-default-600":"240 4.88% 40%","--heroui-default-700":"240 5.88% 30%","--heroui-default-800":"240 4.76% 20%","--heroui-default-900":"0 0% 10%","--heroui-default-foreground":"0 0% 0%","--heroui-default":"240 5.26% 80%","--heroui-danger-50":"324 90.91% 95.69%","--heroui-danger-100":"350.53 90.48% 91.76%","--heroui-danger-200":"343.42 90.48% 83.53%","--heroui-danger-300":"337.84 83.46% 73.92%","--heroui-danger-400":"331.82 75% 65.49%","--heroui-danger-500":"325.82 69.62% 53.53%","--heroui-danger-600":"319.73 65.64% 44.51%","--heroui-danger-700":"313.85 70.65% 36.08%","--heroui-danger-800":"308.18 76.39% 28.24%","--heroui-danger-900":"301.89 82.61% 22.55%","--heroui-danger-foreground":"0 0% 100%","--heroui-danger":"325.82 69.62% 53.53%","--heroui-primary-50":"339.13 92% 95.1%","--heroui-primary-100":"340 91.84% 90.39%","--heroui-primary-200":"339.33 90% 80.39%","--heroui-primary-300":"339.11 90.6% 70.78%","--heroui-primary-400":"339 90% 60.78%","--heroui-primary-500":"339.2 90.36% 51.18%","--heroui-primary-600":"339 86.54% 40.78%","--heroui-primary-700":"339.11 85.99% 30.78%","--heroui-primary-800":"339.33 86.54% 20.39%","--heroui-primary-900":"340 84.91% 10.39%","--heroui-primary-foreground":"0 0% 100%","--heroui-primary":"339.2 90.36% 60%","--heroui-secondary-50":"270 61.54% 94.9%","--heroui-secondary-100":"270 59.26% 89.41%","--heroui-secondary-200":"270 59.26% 78.82%","--heroui-secondary-300":"270 59.26% 68.24%","--heroui-secondary-400":"270 59.26% 57.65%","--heroui-secondary-500":"270 66.67% 47.06%","--heroui-secondary-600":"270 66.67% 37.65%","--heroui-secondary-700":"270 66.67% 28.24%","--heroui-secondary-800":"270 66.67% 18.82%","--heroui-secondary-900":"270 66.67% 9.41%","--heroui-secondary-foreground":"0 0% 100%","--heroui-secondary":"270 66.67% 47.06%","--heroui-success-50":"146.67 64.29% 94.51%","--heroui-success-100":"145.71 61.4% 88.82%","--heroui-success-200":"146.2 61.74% 77.45%","--heroui-success-300":"145.79 62.57% 66.47%","--heroui-success-400":"146.01 62.45% 55.1%","--heroui-success-500":"145.96 79.46% 43.92%","--heroui-success-600":"146.01 79.89% 35.1%","--heroui-success-700":"145.79 79.26% 26.47%","--heroui-success-800":"146.2 79.78% 17.45%","--heroui-success-900":"145.71 77.78% 8.82%","--heroui-success-foreground":"0 0% 0%","--heroui-success":"145.96 79.46% 43.92%","--heroui-warning-50":"54.55 91.67% 95.29%","--heroui-warning-100":"37.14 91.3% 90.98%","--heroui-warning-200":"37.14 91.3% 81.96%","--heroui-warning-300":"36.96 91.24% 73.14%","--heroui-warning-400":"37.01 91.26% 64.12%","--heroui-warning-500":"37.03 91.27% 55.1%","--heroui-warning-600":"37.01 74.22% 44.12%","--heroui-warning-700":"36.96 73.96% 33.14%","--heroui-warning-800":"37.14 75% 21.96%","--heroui-warning-900":"37.14 75% 10.98%","--heroui-warning-foreground":"0 0% 0%","--heroui-warning":"37.03 91.27% 55.1%","--heroui-code-background":"221.25 17.39% 18.04%","--heroui-strong":"316.95 100% 65.29%","--heroui-code-mdx":"316.95 100% 65.29%","--heroui-divider-weight":"1px","--heroui-disabled-opacity":".5","--heroui-font-size-tiny":"0.75rem","--heroui-font-size-small":"0.875rem","--heroui-font-size-medium":"1rem","--heroui-font-size-large":"1.125rem","--heroui-line-height-tiny":"1rem","--heroui-line-height-small":"1.25rem","--heroui-line-height-medium":"1.5rem","--heroui-line-height-large":"1.75rem","--heroui-radius-small":"8px","--heroui-radius-medium":"12px","--heroui-radius-large":"14px","--heroui-border-width-small":"1px","--heroui-border-width-medium":"2px","--heroui-border-width-large":"3px","--heroui-box-shadow-small":"0px 0px 5px 0px rgba(0, 0, 0, .02), 0px 2px 10px 0px rgba(0, 0, 0, .06), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-box-shadow-medium":"0px 0px 15px 0px rgba(0, 0, 0, .03), 0px 2px 30px 0px rgba(0, 0, 0, .08), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-box-shadow-large":"0px 0px 30px 0px rgba(0, 0, 0, .04), 0px 30px 60px 0px rgba(0, 0, 0, .12), 0px 0px 1px 0px rgba(0, 0, 0, .3)","--heroui-hover-opacity":".8"}},Zr={theme:Jr,author:"SnowCat",name:"nc_pink",description:"SnowCat Pink Theme"},we=[Zr,Yr],De=r=>{const s=r.match(/hsl\((\d+(?:\.\d+)?),\s*(\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%\)/);return s?{h:parseFloat(s[1]),s:parseFloat(s[2]),l:parseFloat(s[3])}:{h:0,s:0,l:0}},et=r=>{let s=0,t=0,a=0;r.length===4?(s=parseInt("0x"+r[1]+r[1]),t=parseInt("0x"+r[2]+r[2]),a=parseInt("0x"+r[3]+r[3])):r.length===7&&(s=parseInt("0x"+r[1]+r[2]),t=parseInt("0x"+r[3]+r[4]),a=parseInt("0x"+r[5]+r[6])),s/=255,t/=255,a/=255;const d=Math.min(s,t,a),o=Math.max(s,t,a),i=o-d;let m=0,l=0,u=0;return i===0?m=0:o===s?m=(t-a)/i%6:o===t?m=(a-s)/i+2:m=(s-t)/i+4,m=Math.round(m*60),m<0&&(m+=360),u=(o+d)/2,l=i===0?0:i/(1-Math.abs(2*u-1)),l=+(l*100).toFixed(1),u=+(u*100).toFixed(1),{h:m,s:l,l:u}},ve=(r,s,t)=>{s/=100,t/=100;const a=(1-Math.abs(2*t-1))*s,d=a*(1-Math.abs(r/60%2-1)),o=t-a/2;let i=0,m=0,l=0;r>=0&&r<60?(i=a,m=d,l=0):r>=60&&r<120?(i=d,m=a,l=0):r>=120&&r<180?(i=0,m=a,l=d):r>=180&&r<240?(i=0,m=d,l=a):r>=240&&r<300?(i=d,m=0,l=a):r>=300&&r<360&&(i=a,m=0,l=d),i=Math.round((i+o)*255),m=Math.round((m+o)*255),l=Math.round((l+o)*255);const u=c=>{const g=c.toString(16);return g.length===1?"0"+g:g};return"#"+u(i)+u(m)+u(l)},Je=h.memo(({hsl:r,onChange:s})=>{const t=h.useRef(null),[a,d]=h.useState(!1),o=h.useRef(r);h.useEffect(()=>{o.current=r},[r]);const i=h.useCallback((w,b)=>{if(!t.current)return;const N=t.current.getBoundingClientRect(),L=Math.max(0,Math.min(1,(w-N.left)/N.width)),F=Math.max(0,Math.min(1,(b-N.top)/N.height)),y=L,I=1-F,P=I*(1-y/2);let p=0;P===0||P===1?p=0:p=(I-P)/Math.min(P,1-P),s({h:o.current.h,s:p*100,l:P*100})},[s]),m=(w,b)=>{d(!0),i(w,b)},l=w=>{w.preventDefault(),m(w.clientX,w.clientY)},u=w=>{w.preventDefault();const b=w.touches[0];m(b.clientX,b.clientY)};h.useEffect(()=>{const w=L=>{a&&(L.preventDefault(),i(L.clientX,L.clientY))},b=L=>{if(a){L.preventDefault();const F=L.touches[0];i(F.clientX,F.clientY)}},N=()=>{d(!1)};return a&&(window.addEventListener("mousemove",w),window.addEventListener("mouseup",N),window.addEventListener("touchmove",b,{passive:!1}),window.addEventListener("touchend",N)),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",N),window.removeEventListener("touchmove",b),window.removeEventListener("touchend",N)}},[a,i]);const c=r.l/100,g=r.s/100,n=c+g*Math.min(c,1-c),k=(n===0?0:2*(1-c/n))*100,f=(1-n)*100;return e.jsx("div",{ref:t,className:"w-full h-40 rounded-lg relative cursor-crosshair overflow-hidden shadow-inner touch-none",style:{backgroundColor:"hsl("+r.h+", 100%, 50%)",backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"},onMouseDown:l,onTouchStart:u,children:e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow-md absolute transform -translate-x-1/2 -translate-y-1/2 pointer-events-none",style:{left:k+"%",top:f+"%",backgroundColor:"hsl("+r.h+", "+r.s+"%, "+r.l+"%)"}})})});Je.displayName="SatLightPanel";const Ze=h.memo(({hsl:r,onChange:s})=>{const t=h.useRef(null),[a,d]=h.useState(!1),o=h.useRef(r);h.useEffect(()=>{o.current=r},[r]);const i=h.useCallback(c=>{if(!t.current)return;const g=t.current.getBoundingClientRect();let n=(c-g.left)/g.width;n=Math.max(0,Math.min(1,n)),s({...o.current,h:n*360})},[s]),m=c=>{d(!0),i(c)},l=c=>{c.preventDefault(),m(c.clientX)},u=c=>{c.preventDefault();const g=c.touches[0];m(g.clientX)};return h.useEffect(()=>{const c=j=>{a&&(j.preventDefault(),i(j.clientX))},g=j=>{if(a){j.preventDefault();const k=j.touches[0];i(k.clientX)}},n=()=>{d(!1)};return a&&(window.addEventListener("mousemove",c),window.addEventListener("mouseup",n),window.addEventListener("touchmove",g,{passive:!1}),window.addEventListener("touchend",n)),()=>{window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",n),window.removeEventListener("touchmove",g),window.removeEventListener("touchend",n)}},[a,i]),e.jsx("div",{ref:t,className:"w-full h-4 rounded-full relative cursor-pointer mt-3 shadow-inner touch-none",style:{background:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)"},onMouseDown:l,onTouchStart:u,children:e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-white shadow-md absolute top-0 transform -translate-x-1/2 pointer-events-none bg-white",style:{left:r.h/360*100+"%"}})})});Ze.displayName="HueSlider";const rt=({color:r,onChange:s})=>{const[t,a]=h.useState(De(r)),[d,o]=h.useState(ve(t.h,t.s,t.l)),i=h.useRef(!1);h.useEffect(()=>{if(i.current)return;const u=De(r);(Math.abs(u.h-t.h)>.1||Math.abs(u.s-t.s)>.1||Math.abs(u.l-t.l)>.1)&&(a(u),o(ve(u.h,u.s,u.l)))},[r]);const m=h.useCallback(u=>{a(u),o(ve(u.h,u.s,u.l)),s("hsl("+Math.round(u.h)+", "+Math.round(u.s)+"%, "+Math.round(u.l)+"%)")},[s]),l=u=>{if(o(u),/^#[0-9A-Fa-f]{6}$/.test(u)){const c=et(u);m(c)}};return e.jsxs(vr,{triggerScaleOnOpen:!1,placement:"bottom",children:[e.jsx(yr,{children:e.jsxs("div",{className:"flex items-center gap-2 cursor-pointer group",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg shadow-sm border-2 border-default-200 transition-transform group-hover:scale-105",style:{background:r}}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-xs font-mono text-default-500",children:d}),e.jsxs("span",{className:"text-xs font-mono text-default-400",children:["HSL(",Math.round(t.h),", ",Math.round(t.s),"%, ",Math.round(t.l),"%)"]})]})]})}),e.jsx(jr,{className:"w-72 p-4 bg-background/80 backdrop-blur-xl border border-default-200 shadow-2xl rounded-2xl",onMouseDownCapture:()=>{i.current=!0},onMouseUpCapture:()=>{i.current=!1},onTouchStartCapture:()=>{i.current=!0},onTouchEndCapture:()=>{i.current=!1},children:e.jsxs("div",{className:"flex flex-col w-full gap-2",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm font-bold text-default-700",children:"选择颜色"}),e.jsx("div",{className:"w-6 h-6 rounded-full border border-default-200 shadow-sm",style:{background:r}})]}),e.jsx(Je,{hsl:t,onChange:m}),e.jsx(Ze,{hsl:t,onChange:m}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 mt-2 items-center",children:[e.jsx("span",{className:"text-xs text-default-500 col-span-1",children:"HEX"}),e.jsx(T,{size:"sm",variant:"flat",value:d,onChange:u=>l(u.target.value),className:"col-span-3 font-mono",classNames:{input:"text-xs uppercase",inputWrapper:"h-8 min-h-8"}})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2 items-center",children:[e.jsx("span",{className:"text-xs text-default-500 col-span-1",children:"HSL"}),e.jsxs("div",{className:"col-span-3 flex gap-1",children:[e.jsx(T,{size:"sm",variant:"flat",type:"number",value:Math.round(t.h).toString(),onChange:u=>m({...t,h:Number(u.target.value)}),endContent:e.jsx("span",{className:"text-xs text-default-400",children:"H"}),classNames:{input:"text-xs",inputWrapper:"h-8 min-h-8 px-1"}}),e.jsx(T,{size:"sm",variant:"flat",type:"number",value:Math.round(t.s).toString(),onChange:u=>m({...t,s:Number(u.target.value)}),endContent:e.jsx("span",{className:"text-xs text-default-400",children:"S"}),classNames:{input:"text-xs",inputWrapper:"h-8 min-h-8 px-1"}}),e.jsx(T,{size:"sm",variant:"flat",type:"number",value:Math.round(t.l).toString(),onChange:u=>m({...t,l:Number(u.target.value)}),endContent:e.jsx("span",{className:"text-xs text-default-400",children:"L"}),classNames:{input:"text-xs",inputWrapper:"h-8 min-h-8 px-1"}})]})]}),e.jsx("div",{className:"flex gap-1 mt-2 flex-wrap justify-between",children:["#006FEE","#17C964","#F5A524","#F31260","#7828C8","#000000","#FFFFFF"].map(u=>e.jsx("button",{className:"w-6 h-6 rounded-full border border-default-200 shadow-sm transition-transform hover:scale-110 active:scale-95",style:{backgroundColor:u},onClick:()=>l(u)},u))})]})})]})},tt=({onChange:r,onDelete:s,label:t,accept:a,placeholder:d})=>{const o=h.useRef(null),[i,m]=h.useState(!1);return e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("div",{className:"flex-grow",children:e.jsx(T,{isDisabled:i,ref:o,label:t,type:"file",placeholder:d||"选择文件",accept:a,classNames:{inputWrapper:"bg-default-100/50 dark:bg-white/5 backdrop-blur-md border border-transparent hover:bg-default-200/50 dark:hover:bg-white/10 transition-all shadow-sm data-[hover=true]:border-default-300",input:"bg-transparent text-default-700 placeholder:text-default-400"},onChange:async l=>{var u;try{m(!0);const c=(u=l.target.files)==null?void 0:u[0];c&&await r(c)}catch(c){console.error(c)}finally{m(!1),o.current&&(o.current.value="")}}})}),e.jsx(z,{isDisabled:i,onPress:async()=>{try{m(!0),s&&await s()}catch(l){console.error(l)}finally{m(!1),o.current&&(o.current.value="")}},color:"primary",variant:"flat",size:"sm",children:"删除"})]})},st=["","-50","-100","-200","-300","-400","-500","-600","-700","-800","-900"],at=["primary","secondary","success","danger","warning","default"];function ot({theme:r,onPreview:s,isSelected:t}){const a=document.createElement("style");a.innerHTML=Be(r.theme,r.name);const d=h.useRef(null);return h.useEffect(()=>(document.head.appendChild(a),()=>{document.head.removeChild(a)}),[]),e.jsxs(ce,{ref:d,shadow:"sm",radius:"sm",isPressable:!0,onPress:s,className:D("text-primary bg-primary-50 relative transition-all",r.name,t&&"ring-2 ring-primary ring-offset-2"),children:[t&&e.jsx("div",{className:"absolute top-1 right-1 z-10",children:e.jsx(qe,{size:"sm",color:"primary",variant:"solid",children:e.jsx(Ye,{size:10})})}),e.jsxs(Ke,{className:"pb-0 flex flex-col items-start gap-1",children:[e.jsx("div",{className:"px-1 rounded-md bg-primary text-primary-foreground",children:r.name}),e.jsxs("div",{className:"text-xs flex items-center gap-1 text-primary-300",children:[e.jsx(Xr,{}),r.author??"未知"]}),e.jsx("div",{className:"text-xs text-primary-200 whitespace-nowrap overflow-hidden text-ellipsis w-full",children:r.description})]}),e.jsx(ue,{children:e.jsx("div",{className:"flex flex-col gap-1",children:at.map(o=>e.jsxs("div",{className:"flex gap-1 items-center flex-nowrap",children:[e.jsx("div",{className:"text-xs w-4 text-right flex-shrink-0",children:o[0].toUpperCase()}),st.map(i=>e.jsx("div",{className:D("w-2 h-2 rounded-full shadow-small flex-shrink-0",`bg-${o}${i}`)},i))]},o))})})]})}const ye=(r,s)=>{var d,o,i,m;if(!r||!s)return!1;const t=[...Object.keys(r.light||{}),...Object.keys(r.dark||{})],a=[...Object.keys(s.light||{}),...Object.keys(s.dark||{})];if(t.length!==a.length)return!1;for(const l of Object.keys(r.light||{}))if(((d=r.light)==null?void 0:d[l])!==((o=s.light)==null?void 0:o[l]))return!1;for(const l of Object.keys(r.dark||{}))if(((i=r.dark)==null?void 0:i[l])!==((m=s.dark)==null?void 0:m[l]))return!1;return!0},it={aacute:"Aa 偷吃可爱长大的",system:"系统默认",custom:"自定义字体"},nt=()=>{const{data:r,loading:s,error:t,refreshAsync:a}=he(E.getThemeConfig),{control:d,handleSubmit:o,formState:{isSubmitting:i},setValue:m}=Q({defaultValues:{theme:{dark:{},light:{},fontMode:"aacute"}}}),[l,u]=h.useState(!1),[c,g]=h.useState(!1),[n,j]=h.useState(!1),k=h.useRef(null),f=h.useRef(null),w=h.useRef(!1);h.useEffect(()=>{w.current=c},[c]),h.useEffect(()=>{const p=document.createElement("style");return document.head.appendChild(p),k.current=p,()=>{var S;w.current&&((S=f.current)!=null&&S.fontMode)&&pe(f.current.fontMode),k.current&&document.head.removeChild(k.current)}},[]);const b=nr({control:d,name:"theme"});h.useEffect(()=>{if(f.current&&l){const p=!ye(b,f.current),S=b.fontMode!==f.current.fontMode;g(p||S)}},[b,l]);const N=h.useCallback(()=>{r&&(m("theme",r),f.current=r,r.fontMode&&pe(r.fontMode)),u(!0),g(!1),le.checkWebUIFontExists().then(p=>{j(p)}).catch(p=>console.error("Failed to check custom font:",p))},[r,m]);h.useEffect(()=>{l&&b.fontMode&&pe(b.fontMode)},[b.fontMode,l]);const L=o(async p=>{try{await E.setThemeConfig(p.theme),f.current=p.theme,p.theme.fontMode&&fe(p.theme.fontMode),g(!1),x.success("保存成功"),be()}catch(S){const U=S.message;x.error(`保存失败: ${U}`)}}),F=async()=>{try{await a(),x.success("刷新成功")}catch(p){const S=p.message;x.error(`刷新失败: ${S}`)}};h.useEffect(()=>{N()},[r,N]),h.useEffect(()=>{if(b&&k.current){const p=Be(b);k.current.innerHTML=p}},[b]);const y=h.useMemo(()=>{var p;return(p=we.find(S=>ye(S.theme,b)))==null?void 0:p.name},[b]),I=h.useMemo(()=>{var S;const p=f.current||r;return p?((S=we.find(U=>ye(U.theme,p)))==null?void 0:S.name)||"自定义":null},[r,l,c]),P=h.useMemo(()=>{const p=f.current||r,S=(p==null?void 0:p.fontMode)||"aacute";return it[S]||S},[r,l,c]);return s?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):t?e.jsx("div",{className:"py-24 text-danger-500 text-center",children:t.message}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"主题配置 - SnowCat WebUI"}),e.jsx("div",{className:"w-full pb-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("h1",{className:"text-base font-semibold text-default-800 dark:text-white tracking-tight",children:"外观设置"}),e.jsxs("div",{className:"flex items-center gap-3 text-tiny text-default-500",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Te,{className:"text-primary",size:16}),e.jsx("span",{className:"font-medium text-default-700",children:I||"加载中..."})]}),e.jsx("div",{className:"w-px h-2.5 bg-default-300"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(He,{className:"text-secondary",size:12}),e.jsx("span",{className:"font-medium text-default-700",children:P})]}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-2.5 bg-default-300"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-warning animate-pulse"}),e.jsx("span",{className:"text-warning font-semibold",children:"待保存"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(z,{size:"sm",variant:"flat",color:"default",className:"font-medium bg-white/60 dark:bg-white/[0.06] border border-white/50 dark:border-white/10 h-9",onPress:()=>{N(),x.success("已重置")},isDisabled:!c,children:"重置"}),e.jsx(z,{size:"sm",color:"primary",className:"font-semibold bg-gradient-to-r from-primary-400 to-primary-600 shadow-md shadow-primary-500/25 px-6 h-9",isLoading:i,onPress:()=>L(),isDisabled:!c,children:"保存应用"}),e.jsx("div",{className:"w-px h-6 bg-divider mx-1 hidden sm:block"}),e.jsx(z,{size:"sm",isIconOnly:!0,variant:"light",className:"text-default-500 hover:text-default-900 hidden sm:flex",onPress:F,children:e.jsx(Oe,{size:20})})]})]})}),e.jsx("div",{className:"w-full pb-4",children:e.jsxs(_e,{"aria-label":"Theme Config Options",color:"primary",variant:"underlined",disableAnimation:!0,classNames:{tabList:"gap-8 w-full relative rounded-none p-0 border-b border-divider overflow-x-auto no-scrollbar",cursor:"w-full bg-primary h-[3px] -bottom-[1.5px]",tab:"max-w-fit px-0 h-12 hover:opacity-100 opacity-70 data-[selected=true]:opacity-100",tabContent:"font-semibold py-2",panel:"py-4"},children:[e.jsx(H,{title:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(He,{}),e.jsx("span",{children:"字体设置"})]}),children:e.jsx(ce,{className:"shadow-sm border border-white/60 dark:border-white/10 bg-white/50 dark:bg-white/[0.03] backdrop-blur-xl w-full rounded-2xl",children:e.jsx(ue,{className:"p-5 md:p-6",children:e.jsxs("div",{className:"flex flex-col gap-6 w-full",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold mb-1",children:"WebUI 字体"}),e.jsx("p",{className:"text-xs text-default-500 mb-4",children:"自定义界面显示的字体风格"}),e.jsx(C,{control:d,name:"theme.fontMode",render:({field:p})=>e.jsxs(Ve,{label:"选择字体",variant:"bordered",selectedKeys:p.value?[p.value]:["aacute"],onChange:S=>p.onChange(S.target.value),className:"max-w-xs",disallowEmptySelection:!0,children:[e.jsx(G,{children:"Aa 偷吃可爱长大的"},"aacute"),e.jsx(G,{children:"系统默认"},"system"),e.jsx(G,{children:"自定义字体"},"custom")]})})]}),b.fontMode==="custom"&&e.jsxs("div",{className:"p-4 rounded-xl bg-default-50 border border-default-100",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"text-sm font-medium",children:"自定义字体文件"}),n&&e.jsx(qe,{size:"sm",color:"success",variant:"flat",startContent:e.jsx(Ye,{size:10}),children:"已上传"})]}),e.jsx(tt,{label:"上传字体文件",placeholder:"拖拽或点击上传 (.woff/.woff2/.ttf/.otf)",accept:".ttf,.otf,.woff,.woff2",onChange:async p=>{try{if(n)try{await le.deleteWebUIFont()}catch(U){console.warn("Failed to delete existing font before upload:",U)}await le.uploadWebUIFont(p);const S={...b,fontMode:"custom"};await E.setThemeConfig(S),f.current=S,fe("custom"),g(!1),be(),x.success("上传并保存成功,即将刷新页面"),setTimeout(()=>window.location.reload(),1e3)}catch(S){x.error("上传或保存失败: "+S.message)}},onDelete:async()=>{try{if(await le.deleteWebUIFont(),b.fontMode==="custom"){const p={...b,fontMode:"system"};await E.setThemeConfig(p),f.current=p,fe("system"),g(!1),be()}x.success("删除成功,即将刷新页面"),setTimeout(()=>window.location.reload(),1e3)}catch(p){x.error("删除失败: "+p.message)}}}),e.jsx("p",{className:"text-xs text-default-400 mt-2",children:"注意:上传新字体会覆盖旧字体文件,更改后需要刷新页面生效。"})]})]})})})},"font"),e.jsx(H,{title:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Te,{size:18}),e.jsx("span",{children:"选择主题"})]}),children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:we.map(p=>e.jsx(ot,{theme:p,isSelected:y===p.name,onPreview:()=>{m("theme",{...p.theme,fontMode:b.fontMode})}},p.name))})},"theme"),e.jsx(H,{title:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(fr,{}),e.jsx("span",{children:"自定义配色"})]}),children:e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:["light","dark"].map(p=>e.jsxs(ce,{className:D("border shadow-sm",p==="dark"?"bg-[#18181b] border-zinc-800":"bg-white border-zinc-200"),children:[e.jsxs(Ke,{className:"pb-0 pt-4 px-4 flex-col items-start",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[p==="dark"?e.jsx(br,{className:"text-zinc-400",size:20}):e.jsx(wr,{className:"text-orange-400",size:20}),e.jsx("h4",{className:D("font-bold text-large",p==="dark"?"text-white":"text-black"),children:p==="dark"?"深色模式":"浅色模式"})]}),e.jsxs("p",{className:D("text-tiny",p==="dark"?"text-zinc-400":"text-zinc-500"),children:["调整",p==="dark"?"深色":"浅色","主题下的颜色变量"]})]}),e.jsx(ue,{className:"p-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:sr.map(S=>e.jsxs("div",{className:D("flex items-center gap-3 p-2 rounded-lg border transition-colors",p==="dark"?"bg-zinc-900/50 border-zinc-800 hover:bg-zinc-900":"bg-zinc-50 border-zinc-100 hover:bg-zinc-100"),children:[e.jsx(C,{control:d,name:`theme.${p}.${S}`,render:({field:{value:U,onChange:O}})=>{const $=(U==null?void 0:U.split(" "))??[0,0,0],J=`hsl(${$[0]}, ${$[1]}, ${$[2]})`;return e.jsx(rt,{color:J,onChange:Z=>{const B=Z.match(/hsl\((\d+(?:\.\d+)?),\s*(\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%\)/);B&&O(`${B[1]} ${B[2]}% ${B[3]}%`)}})}}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsx("span",{className:D("text-xs font-medium truncate",p==="dark"?"text-zinc-300":"text-zinc-700"),children:S.replace("--heroui-","")}),e.jsx("span",{className:D("text-[10px] truncate",p==="dark"?"text-zinc-500":"text-zinc-400"),children:"Variable"})]})]},S))})})]},p))})},"custom-color")]})})]})},$e=({onChange:r,value:s,label:t})=>{const a=h.useRef(null);return e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 flex-shrink-0 rounded-xl overflow-hidden bg-white/60 dark:bg-white/[0.06] border border-black/[0.07] dark:border-white/10 flex items-center justify-center",children:s?e.jsx(Sr,{src:s,alt:t,className:"w-full h-full object-cover rounded-none"}):e.jsx("span",{className:"text-[10px] text-default-300",children:"无图"})}),e.jsx(T,{ref:a,label:t,type:"file",placeholder:"选择图片",accept:"image/*",size:"sm",classNames:{inputWrapper:"bg-white/80 dark:bg-white/[0.06] backdrop-blur-md border border-black/[0.08] dark:border-white/12 hover:bg-white/95 dark:hover:bg-white/[0.09] transition-all shadow-sm data-[hover=true]:border-primary/35",input:"bg-transparent text-default-700 dark:text-default-200 placeholder:text-default-400"},onChange:async d=>{var i;const o=(i=d.target.files)==null?void 0:i[0];if(o){const m=new FileReader;m.onload=async()=>{const l=m.result;r(l)},m.readAsDataURL(o)}}}),e.jsx(z,{onPress:()=>{r(""),a.current&&(a.current.value="")},color:"danger",variant:"flat",size:"sm",radius:"full",isDisabled:!s,className:"flex-shrink-0 text-xs px-3",children:"清除"})]})};function je(r){const s=r.replace(/-/g,"+").replace(/_/g,"/"),t=window.atob(s),a=new Uint8Array(t.length);for(let d=0;d<t.length;++d)a[d]=t.charCodeAt(d);return a}function ke(r){return window.btoa(String.fromCharCode(...r)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const lt=()=>{const{control:r,handleSubmit:s,formState:{isSubmitting:t},setValue:a}=Q({defaultValues:{background:"",customIcons:{}}}),[d,o]=de(te.backgroundImage,""),[i,m]=de(te.customIcons,{}),[l,u]=h.useState(null),[c,g]=h.useState(!1),[n,j]=h.useState({enable2FA:!1,hasSecret:!1}),[k,f]=h.useState(""),[w,b]=h.useState(""),[N,L]=h.useState(""),[F,y]=h.useState(""),[I,P]=h.useState(!1),[p,S]=h.useState(!1),[U,O]=h.useState(!1),$=async()=>{try{const v=await E.get2FAStatus();j(v)}catch(v){console.error("获取2FA状态失败:",v)}},J=async()=>{P(!0);try{const v=await E.generate2FASecret();f(v.secret),b(v.qrCodeUrl),x.success("密钥已生成,请使用Authenticator应用扫码")}catch(v){x.error(`生成密钥失败: ${v.message}`)}finally{P(!1)}},Z=async()=>{if(!k||!N){x.error("请先生成密钥并输入验证码");return}if(N.length!==6){x.error("验证码必须是6位数字");return}S(!0);try{await E.enable2FA(k,N),await $(),f(""),b(""),L(""),x.success("双因素认证已启用")}catch(v){x.error(`启用失败: ${v.message}`)}finally{S(!1)}},B=async()=>{if(!F||F.length!==6){x.error("请输入6位验证码");return}O(!0);try{await E.disable2FA(F),await $(),y(""),x.success("双因素认证已禁用")}catch(v){x.error(`禁用失败: ${v.message}`)}finally{O(!1)}};h.useEffect(()=>{$()},[]);const se=Xe(),[,V]=de(te.token,""),{control:ae,handleSubmit:oe,formState:{isSubmitting:me,errors:X},watch:ie}=Q({defaultValues:{oldToken:"",newToken:""}}),xe=ie("oldToken"),ee=oe(async v=>{try{await E.changePassword(v.oldToken,v.newToken),x.success("修改成功"),V(""),localStorage.removeItem(te.token),se("/web_login")}catch(M){const R=M.message;x.error(`修改失败: ${R}`)}}),re=async()=>{g(!0);try{console.log("预先获取注册选项...");const v=await E.generatePasskeyRegistrationOptions();u(v),console.log("✅ 注册选项已获取并存储"),x.success("注册选项已准备就绪,请点击注册按钮")}catch(v){console.error("❌ 获取注册选项失败:",v),x.error("获取注册选项失败,请重试")}finally{g(!1)}},ne=()=>{a("customIcons",i),a("background",d)},er=s(v=>{try{m(v.customIcons),o(v.background),x.success("保存成功")}catch(M){const R=M.message;x.error(`保存失败: ${R}`)}});return h.useEffect(()=>{ne()},[i,d]),e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"WebUI配置 - SnowCat WebUI"}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"修改密码"}),e.jsx(C,{control:ae,name:"oldToken",rules:{required:"旧密码不能为空",validate:v=>!v||v.trim().length===0?"旧密码不能为空":!0},render:({field:v})=>{var M;return e.jsx(T,{...v,label:"旧密码",placeholder:"请输入旧密码",type:"password",isRequired:!0,isInvalid:!!X.oldToken,errorMessage:(M=X.oldToken)==null?void 0:M.message})}}),e.jsx(C,{control:ae,name:"newToken",rules:{required:"新密码不能为空",minLength:{value:6,message:"新密码至少需要6个字符"},validate:v=>!v||v.trim().length===0?"新密码不能为空":v.trim().length!==v.length?"新密码不能包含前后空格":v===xe?"新密码不能与旧密码相同":/[a-zA-Z]/.test(v)?/[0-9]/.test(v)?!0:"新密码必须包含数字":"新密码必须包含字母"},render:({field:v})=>{var M;return e.jsx(T,{...v,label:"新密码",placeholder:"至少6位,包含字母和数字",type:"password",isRequired:!0,isInvalid:!!X.newToken,errorMessage:(M=X.newToken)==null?void 0:M.message})}}),e.jsx("div",{className:"flex justify-end",children:e.jsx(z,{color:"primary",radius:"full",className:"font-semibold bg-gradient-to-r from-primary-400 to-primary-600 shadow-md shadow-primary-500/25 px-6",onPress:()=>{ee()},isLoading:me,children:"确认修改密码"})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"背景图"}),e.jsx(C,{control:r,name:"background",render:({field:v})=>e.jsx($e,{...v})})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[12px] uppercase tracking-[0.1em] text-default-500 border-l-2 border-primary-400/60 pl-2.5",children:"自定义图标"}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-2",children:hr.navItems.map(v=>e.jsx(C,{control:r,name:`customIcons.${v.label}`,render:({field:M})=>e.jsx($e,{...M,label:v.label})},v.label))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("div",{className:"flex-shrink-0 w-full font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400 border-l-2 border-primary-400/50 pl-2.5",children:"Passkey认证"}),window.isSecureContext?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-sm text-default-400 mb-2",children:"注册Passkey后,您可以更便捷地登录WebUI,无需每次输入token"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(z,{color:"secondary",variant:"flat",onPress:re,isLoading:c,className:"w-fit",children:[!c,"准备选项"]}),e.jsx(z,{color:"primary",variant:"flat",onPress:()=>{var v;if(!l){x.error('请先点击"准备选项"按钮获取注册选项');return}if(console.log("开始Passkey注册..."),console.log("使用预先获取的选项:",l),!navigator.credentials||!navigator.credentials.create){x.error("当前浏览器环境不支持 Passkey 注册。");return}navigator.credentials.create({publicKey:{challenge:je(l.challenge),rp:{name:l.rp.name,id:l.rp.id},user:{id:je(l.user.id),name:l.user.name,displayName:l.user.displayName},pubKeyCredParams:l.pubKeyCredParams,timeout:3e4,excludeCredentials:((v=l.excludeCredentials)==null?void 0:v.map(M=>({id:je(M.id),type:M.type,transports:M.transports})))||[],attestation:l.attestation}}).then(async M=>{var Ie,Me;console.log("✅ 注册成功!凭据已创建"),console.log("凭据ID:",M.id),console.log("凭据类型:",M.type);const R=M,Le={id:R.id,rawId:ke(new Uint8Array(R.rawId)),response:{attestationObject:ke(new Uint8Array(R.response.attestationObject)),clientDataJSON:ke(new Uint8Array(R.response.clientDataJSON)),transports:((Me=(Ie=R.response).getTransports)==null?void 0:Me.call(Ie))||[]},type:R.type};console.log("准备验证响应:",Le);try{if((await E.verifyPasskeyRegistration(Le)).verified)x.success("Passkey注册成功!现在您可以使用Passkey自动登录"),u(null);else throw new Error("Passkey registration failed")}catch(ge){console.error("❌ 验证失败:",ge);const rr=ge;x.error(`Passkey验证失败: ${rr.message}`)}}).catch(M=>{console.error("❌ 注册失败:",M);const R=M;console.error("错误名称:",R.name),console.error("错误信息:",R.message),R.name==="NotAllowedError"?x.error("Passkey注册被拒绝。请确保您允许了生物识别认证权限。"):R.name==="NotSupportedError"?x.error("您的浏览器不支持Passkey功能。"):R.name==="SecurityError"?x.error("安全错误:请确保使用HTTPS或localhost环境。"):x.error(`Passkey注册失败: ${R.message}`)})},disabled:!l,className:"w-fit",children:"注册Passkey"})]}),l&&e.jsx("div",{className:"text-xs text-green-600",children:"注册选项已准备就绪,可以开始注册"})]}):e.jsxs("div",{className:"text-xs leading-relaxed text-warning-700 dark:text-warning-400 bg-warning-50/70 dark:bg-warning-900/20 p-3 rounded-xl border border-warning-200/70 dark:border-warning-800/40",children:["⚠️ 当前处于非安全环境(即既非 HTTPS 也非 localhost),浏览器已禁用 WebAuthn 功能。",e.jsx("br",{}),"如果您是通过局域网 IP 访问 WebUI,将无法注册和使用 Passkey。"]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex-shrink-0 w-full flex items-center gap-2 border-l-2 border-primary-400/50 pl-2.5",children:[e.jsx("span",{className:"font-semibold text-[11px] uppercase tracking-[0.12em] text-default-400",children:"双因素认证 (2FA)"}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${n.enable2FA?"bg-success-100 text-success-700 dark:bg-success-900/30 dark:text-success-300":"bg-default-100 text-default-500 dark:bg-white/10"}`,children:n.enable2FA?"已启用":"未启用"})]}),n.enable2FA?e.jsxs("div",{className:"bg-success-50/60 dark:bg-success-900/15 border border-success-200/70 dark:border-success-800/40 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-success-700 dark:text-success-300 mb-4",children:[e.jsx(kr,{className:"text-base"}),"双因素认证已启用"]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-xs text-default-500 mb-2",children:"输入验证码以禁用"}),e.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:F,onChange:v=>y(v.target.value.replace(/\D/g,"")),placeholder:"000000",className:"w-36 px-3 py-2.5 bg-white/80 dark:bg-white/[0.06] border border-white/70 dark:border-white/10 rounded-xl text-center text-lg font-mono tracking-[0.3em] outline-none focus:border-primary/50 transition-colors"})]}),e.jsx(z,{color:"danger",variant:"flat",radius:"full",onPress:B,isLoading:U,disabled:!F||F.length!==6,className:"w-fit font-medium",children:"禁用双因素认证"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-xs text-default-400 mb-2 leading-relaxed",children:"启用后登录需额外输入 Authenticator 应用生成的 6 位验证码。"}),e.jsxs("div",{className:"bg-white/45 dark:bg-white/[0.03] border border-white/60 dark:border-white/10 rounded-2xl p-4",children:[e.jsxs(z,{variant:"flat",radius:"full",onPress:J,isLoading:I,className:"w-fit mb-4 font-medium bg-white/70 dark:bg-white/[0.06] text-default-700 dark:text-default-200 border border-white/60 dark:border-white/10",children:[e.jsx(Nr,{className:"mr-2"}),"生成密钥"]}),k&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-xs text-default-500 mb-2",children:"使用 Authenticator 应用扫描下方二维码"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[e.jsx("div",{className:"bg-white rounded-2xl p-3 shadow-sm ring-1 ring-black/5",children:e.jsx(dr,{value:w,size:128,level:"M",includeMargin:!1})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[11px] text-default-400 mb-1",children:"密钥(手动输入用)"}),e.jsx("div",{className:"font-mono text-xs bg-white/70 dark:bg-white/[0.06] border border-white/60 dark:border-white/10 px-3 py-2 rounded-xl break-all max-w-[220px] select-all",children:k})]})]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-xs text-default-500 mb-2",children:"输入 Authenticator 验证码"}),e.jsx("input",{type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,value:N,onChange:v=>L(v.target.value.replace(/\D/g,"")),placeholder:"000000",className:"w-36 px-3 py-2.5 bg-white/80 dark:bg-white/[0.06] border border-white/70 dark:border-white/10 rounded-xl text-center text-lg font-mono tracking-[0.3em] outline-none focus:border-primary/50 transition-colors"})]}),e.jsx(z,{color:"primary",radius:"full",onPress:Z,isLoading:p,disabled:!N||N.length!==6,className:"w-fit font-semibold bg-gradient-to-r from-primary-400 to-primary-600 shadow-md shadow-primary-500/25",children:"启用双因素认证"})]})]})]})]}),e.jsx(Y,{onSubmit:er,reset:ne,isSubmitting:t})]})},dt=async r=>{var t,a,d;const s=(t=r.target.files)==null?void 0:t[0];if(s){if(!s.name.endsWith(".zip")){x.error("请选择zip格式的配置文件");return}try{const o=new FormData;o.append("configFile",s);const i=await Qe("/OB11Config/ImportConfig",{method:"POST",body:o});if(!i.ok){const l=await i.json();throw new Error(l.message||"导入配置失败")}const m=await i.json();m.code===0?x.success(((a=m.data)==null?void 0:a.message)||"配置导入成功。"):x.error(`配置导入失败: ${((d=m.data)==null?void 0:d.message)||"未知错误"}`)}catch(o){const i=o.message;x.error(`导入配置失败: ${i}`)}finally{r.target.value=""}}},ct=async()=>{var r,s;try{const t=await Qe("/OB11Config/ExportConfig",{method:"GET"});if(!t.ok)throw new Error("导出配置失败");const a=await t.blob(),d=window.URL.createObjectURL(a),o=document.createElement("a");o.href=d;const i=((s=(r=t.headers.get("Content-Disposition"))==null?void 0:r.split("=")[1])==null?void 0:s.replace(/"/g,""))||"config_backup.zip";o.download=i,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(d),document.body.removeChild(o),x.success("配置导出成功")}catch(t){const a=t.message;x.error(`导出配置失败: ${a}`)}},ut=()=>e.jsx("div",{className:"space-y-5",children:e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-default-800 dark:text-white mb-1.5",children:"备份与恢复"}),e.jsx("p",{className:"text-sm text-default-500 mb-5 leading-relaxed",children:"导出当前全部配置为 zip 备份,或从备份文件恢复。适合换机迁移与升级前留档。"}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsx(z,{className:"bg-gradient-to-r from-primary-400 to-primary-600 text-white font-semibold shadow-md shadow-primary-500/25",radius:"full",startContent:e.jsx(Lr,{size:17}),onPress:ct,children:"导出配置"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:".zip",onChange:dt,className:"hidden"}),e.jsx(z,{className:"bg-white/60 dark:bg-white/[0.06] text-default-700 dark:text-default-200 border border-white/60 dark:border-white/10 font-medium",radius:"full",variant:"flat",as:"span",startContent:e.jsx(Ir,{size:17}),children:"导入配置"})]})]}),e.jsx("div",{className:"mt-5 p-3.5 bg-warning-50/70 dark:bg-warning-900/20 border border-warning-200/60 dark:border-warning-800/40 rounded-2xl",children:e.jsx("p",{className:"text-xs text-warning-700 dark:text-warning-400 leading-relaxed",children:"导入配置会覆盖当前所有设置,请谨慎操作。导入前建议先导出当前配置作为备份。"})})]})}),ht=()=>{const[r,s]=h.useState(!0),{control:t,handleSubmit:a,formState:{isSubmitting:d},setValue:o}=Q(),i=async(c=!1)=>{try{s(!0);const g=await K.getSnowCatConfig(),n=g.bypass??{};o("hook",n.hook??!1),o("window",n.window??!1),o("module",n.module??!1),o("process",n.process??!1),o("container",n.container??!1),o("js",n.js??!1),o("o3HookMode",g.o3HookMode===1),c&&x.success("刷新成功")}catch(g){const n=g.message;x.error(`获取配置失败: ${n}`)}finally{s(!1)}},m=a(async c=>{try{const{o3HookMode:g,...n}=c;await K.setSnowCatConfig({bypass:n,o3HookMode:g?1:0}),x.success("保存成功,重启后生效")}catch(g){const n=g.message;x.error(`保存失败: ${n}`)}}),l=()=>{i()},u=async()=>{await i(!0)};return h.useEffect(()=>{i()},[]),r?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"反检测配置 - SnowCat WebUI"}),e.jsxs("div",{className:"flex flex-col gap-1 mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-default-800 dark:text-white",children:"反检测开关配置"}),e.jsx("p",{className:"text-xs text-default-500 leading-relaxed",children:"控制 Napi2Native 模块的各项反检测功能,修改后需重启生效。"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(C,{control:t,name:"hook",render:({field:c})=>e.jsx(A,{...c,label:"Hook",description:"hook特征隐藏"})}),e.jsx(C,{control:t,name:"window",render:({field:c})=>e.jsx(A,{...c,label:"Window",description:"窗口伪造"})}),e.jsx(C,{control:t,name:"module",render:({field:c})=>e.jsx(A,{...c,label:"Module",description:"加载模块隐藏"})}),e.jsx(C,{control:t,name:"process",render:({field:c})=>e.jsx(A,{...c,label:"Process",description:"进程反检测"})}),e.jsx(C,{control:t,name:"container",render:({field:c})=>e.jsx(A,{...c,label:"Container",description:"容器反检测"})}),e.jsx(C,{control:t,name:"js",render:({field:c})=>e.jsx(A,{...c,label:"JS",description:"JS反检测"})}),e.jsx(C,{control:t,name:"o3HookMode",render:({field:c})=>e.jsx(A,{...c,label:"o3HookMode",description:"O3 Hook 模式"})})]}),e.jsx(Y,{onSubmit:m,reset:l,isSubmitting:d,refresh:u})]})},mt=()=>{const[r,s]=h.useState(!0),{control:t,handleSubmit:a,formState:{isSubmitting:d},setValue:o}=Q(),i=async(c=!1)=>{try{s(!0);const g=await K.getSnowCatUinConfig();o("fileLog",g.fileLog??!1),o("consoleLog",g.consoleLog??!0),o("autoTimeSync",g.autoTimeSync??!0),c&&x.success("刷新成功")}catch(g){const n=g.message;x.error(`获取配置失败: ${n}`)}finally{s(!1)}},m=a(async c=>{try{await K.setSnowCatUinConfig(c),x.success("保存成功,重启后生效")}catch(g){const n=g.message;x.error(`保存失败: ${n}`)}}),l=()=>{i()},u=async()=>{await i(!0)};return h.useEffect(()=>{i()},[]),r?e.jsx("div",{className:"relative w-full min-h-[220px]",children:e.jsx(q,{loading:!0})}):e.jsxs(e.Fragment,{children:[e.jsx("title",{children:"核心配置 - SnowCat WebUI"}),e.jsxs("div",{className:"flex flex-col gap-1 mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-default-800 dark:text-white",children:"SnowCat 核心配置"}),e.jsx("p",{className:"text-xs text-default-500 leading-relaxed",children:"控制 SnowCat 框架底层的核心行为设定,修改后需重启生效。"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[e.jsx(C,{control:t,name:"autoTimeSync",render:({field:c})=>e.jsx(A,{...c,label:"自动对时",description:"自动校验并矫正系统时间偏差"})}),e.jsx(C,{control:t,name:"fileLog",render:({field:c})=>e.jsx(A,{...c,label:"文件日志",description:"是否将登录后日志写入到本地文件"})}),e.jsx(C,{control:t,name:"consoleLog",render:({field:c})=>e.jsx(A,{...c,label:"控制台日志",description:"是否在终端标准输出显示日志"})})]}),e.jsx(Y,{onSubmit:m,reset:l,isSubmitting:d,refresh:u})]})},_=({children:r,size:s="md"})=>{const[t]=de(te.backgroundImage,""),a=!!t;return e.jsx(ce,{className:D("w-full mx-auto backdrop-blur-xl border border-white/60 dark:border-white/10 rounded-2xl transition-all shadow-sm",a?"bg-black/20":"bg-white/65 dark:bg-white/[0.04]",{"max-w-xl":s==="sm","max-w-3xl":s==="md","max-w-[1400px]":s==="lg"}),children:e.jsx(ue,{className:"py-6 px-4 md:py-8 md:px-12",children:e.jsx("div",{className:"w-full flex flex-col gap-5",children:r})})})};function hs(){const r=Xe(),t=Cr({tab:"onebot"})[0].get("tab")??"onebot";return e.jsxs("section",{className:"sc-page",children:[e.jsx("title",{children:"系统配置 - SnowCat WebUI"}),e.jsxs(_e,{"aria-label":"config tab",fullWidth:!1,className:"w-full",selectedKey:t,onSelectionChange:a=>{r(`/config?tab=${a}`)},classNames:{base:"w-full flex-col items-center",tabList:"sc-tablist mb-4 md:mb-6 w-full md:w-fit mx-auto overflow-x-auto hide-scrollbar",cursor:"sc-tab-cursor",tab:"h-9 px-4 md:px-6",tabContent:"text-default-600 dark:text-default-300 font-medium group-data-[selected=true]:text-primary",panel:"w-full relative p-0"},children:[e.jsx(H,{title:"OneBot配置",children:e.jsx(_,{children:e.jsx(Vr,{})})},"onebot"),e.jsx(H,{title:"服务器配置",children:e.jsx(_,{children:e.jsx(Kr,{})})},"server"),e.jsx(H,{title:"SSL配置",children:e.jsx(_,{size:"sm",children:e.jsx(qr,{})})},"ssl"),e.jsx(H,{title:"WebUI配置",children:e.jsx(_,{children:e.jsx(lt,{})})},"webui"),e.jsx(H,{title:"登录配置",children:e.jsx(_,{children:e.jsx(Or,{})})},"login"),e.jsx(H,{title:"主题配置",children:e.jsx(_,{size:"lg",children:e.jsx(nt,{})})},"theme"),e.jsx(H,{title:"备份与恢复",children:e.jsx(_,{children:e.jsx(ut,{})})},"backup"),e.jsx(H,{title:"核心配置",children:e.jsx(_,{children:e.jsx(mt,{})})},"core"),e.jsx(H,{title:"反检测",children:e.jsx(_,{children:e.jsx(ht,{})})},"bypass")]})]})}export{hs as default};