import{_ as R,a as M}from"./Qlbn3NkC.js";import{g as T,m as U,n as L,r as f,p as P,c as V,b as o,w as n,y as v,o as D,a as l,t as a,q as t,z as E,d as i,s as q,B as A}from"./Czresmtb.js";import{_ as z,a as F}from"./wiezadD9.js";import{_ as $,a as j}from"./Bbw6XuZN.js";import{_ as G}from"./D3k1Qa3g.js";import{_ as J}from"./D2-kdKzx.js";import{_ as K}from"./DxTvTv-W.js";import"./DlAUqK2U.js";import"./Bk_rJcZu.js";import"./BwhG0EbZ.js";import"./CFdxo1g5.js";import"./D4t6JTJM.js";const O={class:"text-2xl font-bold"},Q={class:"text-xs text-gray-500"},W={class:"list-disc list-inside space-y-1 text-sm"},ue=T({__name:"settings",setup(X){const{t:e}=U(),c=L(),u=f({serverHost:"",api:{baseURL:""},s3:{endpoint:"",region:""}}),r=f({serverHost:""}),p=f(!1),C=async()=>{try{const s=await v.loadConfig();u.value=s,r.value.serverHost=s.serverHost}catch{c.error(e("Failed to load current configuration"))}},g=async()=>{if(!r.value.serverHost){c.error(e("Please enter server address"));return}p.value=!0;try{let s=r.value.serverHost.trim();s.match(/^https?:\/\//)||(s="https://"+s);const d=new URL(s),m=r.value.serverHost.match(/^https?:\/\//)?r.value.serverHost:s;localStorage.setItem("rustfs-server-host",m),r.value.serverHost.match(/^https?:\/\//)||(r.value.serverHost=s),v.clearCache(),c.success(e("Configuration saved successfully")),setTimeout(()=>{window.location.reload()},200)}catch{c.error(e("Invalid server address format"))}finally{p.value=!1}},H=async()=>{localStorage.removeItem("rustfs-server-host"),v.clearCache(),c.success(e("Configuration reset successfully")),setTimeout(()=>{window.location.reload()},200)};return P(()=>{C()}),(s,d)=>{const m=R,_=F,x=z,h=E,w=K,b=j,y=A,S=G,k=$,N=J,B=M;return D(),V("div",null,[o(m,null,{title:n(()=>[l("h1",O,a(t(e)("Settings")),1)]),_:1}),o(B,null,{default:n(()=>[o(h,{title:t(e)("Current Configuration"),class:"mb-6"},{default:n(()=>[o(x,{columns:1,bordered:!0},{default:n(()=>[o(_,{label:t(e)("Server Host")},{default:n(()=>[i(a(u.value.serverHost||t(e)("Not configured")),1)]),_:1},8,["label"]),o(_,{label:t(e)("API Base URL")},{default:n(()=>[i(a(u.value.api.baseURL||t(e)("Not configured")),1)]),_:1},8,["label"]),o(_,{label:t(e)("S3 Endpoint")},{default:n(()=>[i(a(u.value.s3.endpoint||t(e)("Not configured")),1)]),_:1},8,["label"]),o(_,{label:t(e)("S3 Region")},{default:n(()=>[i(a(u.value.s3.region||t(e)("Not configured")),1)]),_:1},8,["label"])]),_:1})]),_:1},8,["title"]),o(h,{title:t(e)("Server Configuration")},{default:n(()=>[o(k,{onSubmit:q(g,["prevent"])},{default:n(()=>[o(b,{label:t(e)("Server Address"),required:""},{feedback:n(()=>[l("div",Q,a(t(e)("Example: http://localhost:9000 or https://your-domain.com")),1)]),default:n(()=>[o(w,{value:r.value.serverHost,"onUpdate:value":d[0]||(d[0]=I=>r.value.serverHost=I),placeholder:t(e)("Please enter server address (e.g., http://localhost:9000)"),clearable:""},null,8,["value","placeholder"])]),_:1},8,["label"]),o(b,null,{default:n(()=>[o(S,null,{default:n(()=>[o(y,{type:"primary",onClick:g,loading:p.value},{default:n(()=>[i(a(t(e)("Save Configuration")),1)]),_:1},8,["loading"]),o(y,{onClick:H},{default:n(()=>[i(a(t(e)("Reset to Default")),1)]),_:1})]),_:1})]),_:1})]),_:1}),o(N,{type:"info",title:t(e)("Configuration Information"),class:"mt-4"},{default:n(()=>[l("ul",W,[l("li",null,a(t(e)("Configuration is saved locally in your browser")),1),l("li",null,a(t(e)("Page will refresh automatically after saving configuration")),1),l("li",null,a(t(e)("Make sure the server address is accessible from your network")),1)])]),_:1},8,["title"])]),_:1},8,["title"])]),_:1})])}}});export{ue as default};
