import{u as S,a as y,b as C,c as A,r,t as d,j as e}from"./index-CHN8jahE.js";import{S as u}from"./select-BUmRG0LY.js";import{u as _}from"./use-providers-Cdxr4Jbz.js";import"./utils-CkSf8FUe.js";import"./chevron-down-CuPdBAx-.js";const w=[{value:"zh-CN",label:"简体中文"},{value:"en",label:"English"}],i="__follow_task__";function k(){const{locale:p,setLocale:h,t}=S(),{data:l}=y(),{data:g}=_(),{data:o}=C(),a=A(),[b,x]=r.useState(i),[m,c]=r.useState(""),[v,n]=r.useState(!1);r.useEffect(()=>{!l||!o||(x(l.commitMessageProviderId||i),c(l.commitMessagePrompt||o.prompt),n(!1))},[l,o]);const f=[{value:i,label:t("跟随任务")},...(g??[]).filter(s=>s.availability.type!=="NOT_FOUND").map(s=>({value:s.provider.id,label:s.provider.name}))],j=r.useCallback(s=>{x(s);const P=s===i?null:s;a.mutate({commitMessageProviderId:P},{onError:()=>d.error(t("保存失败"))})},[a,t]),N=r.useCallback(()=>{const s=m.trim()||null;a.mutate({commitMessagePrompt:s},{onSuccess:()=>{n(!1),d.success(t("已保存"))},onError:()=>d.error(t("保存失败"))})},[m,a,t]);return e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-3xl space-y-8",children:[e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:t("通用设置")}),e.jsx("p",{className:"mt-1 text-sm text-neutral-500",children:t("选择界面语言。设置会保存到本地 Agent Tower 数据库，并在重新打开后继续生效。")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("显示语言")}),e.jsx(u,{value:p,onChange:s=>h(s),options:w.map(s=>({value:s.value,label:s.label}))})]}),e.jsxs("section",{className:"border-t border-neutral-100 pt-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:t("Git Commit Message")}),e.jsx("p",{className:"mt-1 text-sm text-neutral-500",children:t("配置自动生成 commit message 时使用的 Agent 渠道和提示词。")}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("Agent 渠道")}),e.jsx("p",{className:"text-xs text-neutral-400 mb-1.5",children:t('"跟随任务"表示使用当前任务所用的 Agent 渠道。选择具体渠道可使用更经济的模型。')}),e.jsx(u,{value:b,onChange:j,options:f})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("提示词模板")}),e.jsx("p",{className:"text-xs text-neutral-400 mb-1.5",children:t("自定义生成 commit message 的提示词。留空则使用内置默认模板。")}),e.jsx("textarea",{value:m,onChange:s=>{c(s.target.value),n(!0)},rows:6,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm bg-white focus:outline-none focus:border-neutral-400 resize-y font-mono"}),v&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("button",{onClick:N,disabled:a.isPending,className:"px-3 py-1.5 text-xs font-medium text-white bg-neutral-900 rounded-md hover:bg-neutral-800 disabled:opacity-50 transition-colors",children:a.isPending?t("保存中..."):t("保存")}),e.jsx("button",{onClick:()=>{c(l?.commitMessagePrompt||o?.prompt||""),n(!1)},className:"px-3 py-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors",children:t("取消")})]})]})]})]})]})}export{k as GeneralSettingsPage};
