import{a as x,R as h,j as e}from"./FontSizeProvider-Cy0K7gvl.js";import{t as u,u as b,v as j,x as f,a as g,y as v,z as w,A as p,B as y}from"./SaveButton-DAQL8oi6.js";import{F as l,e as m,I as d,j as N}from"./trash-2-Dx96Ty-c.js";import{D as S}from"./webui-C025Pd1b.js";const k=()=>{const[i]=l.useForm(),c=l.useWatch("urlRewriteEnabled",i),{t:s}=x("settings"),o=async()=>{try{const[a,n,r,t]=await Promise.all([v(),w(),p(),y()]);i.setFieldsValue({urlRewriteEnabled:a,rewriteUrl:n,headers:r,autoCORSFix:t})}catch(a){console.error(a)}};return h.useEffect(()=>{o()},[]),e.jsxs(l,{onFinish:a=>{var r;const n=(r=a==null?void 0:a.headers)==null?void 0:r.filter(t=>t.key&&t.value);u(a.urlRewriteEnabled),b(a.rewriteUrl),j(n),f(a.autoCORSFix)},form:i,layout:"vertical",className:"space-y-4",children:[e.jsx(l.Item,{name:"urlRewriteEnabled",label:s("ollamaSettings.settings.advanced.urlRewriteEnabled.label"),children:e.jsx(m,{})}),e.jsx(l.Item,{required:c,name:"rewriteUrl",label:s("ollamaSettings.settings.advanced.rewriteUrl.label"),children:e.jsx(d,{disabled:!c,className:"w-full",placeholder:s("ollamaSettings.settings.advanced.rewriteUrl.placeholder")})}),e.jsx(l.Item,{name:"autoCORSFix",label:s("ollamaSettings.settings.advanced.autoCORSFix.label"),children:e.jsx(m,{})}),e.jsx(l.List,{name:"headers",children:(a,{add:n,remove:r})=>e.jsxs("div",{className:"flex flex-col ",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("h3",{className:"text-md font-semibold",children:s("ollamaSettings.settings.advanced.headers.label")}),e.jsx("button",{type:"button",className:"dark:bg-white dark:text-black text-white bg-black p-1.5 text-xs rounded-md",onClick:()=>{n()},children:s("ollamaSettings.settings.advanced.headers.add")})]}),a.map((t,R)=>e.jsxs("div",{className:"flex items-center   w-full",children:[e.jsxs("div",{className:"flex-grow flex mt-3 space-x-4",children:[e.jsx(l.Item,{label:s("ollamaSettings.settings.advanced.headers.key.label"),name:[t.name,"key"],className:"flex-1 mb-0",children:e.jsx(d,{className:"w-full",placeholder:s("ollamaSettings.settings.advanced.headers.key.placeholder")})}),e.jsx(l.Item,{label:s("ollamaSettings.settings.advanced.headers.value.label"),name:[t.name,"value"],className:"flex-1 mb-0",children:e.jsx(d,{className:"w-full",placeholder:s("ollamaSettings.settings.advanced.headers.value.placeholder")})})]}),e.jsx("button",{type:"button",onClick:()=>{r(t.name)},className:"shrink-0 ml-2 text-red-500 dark:text-red-400",children:e.jsx(N,{className:"w-5 h-5"})})]},t.key))]})}),e.jsx(S,{}),e.jsx(l.Item,{className:"flex justify-end",children:e.jsx(g,{btnType:"submit"})})]})};export{k as A};
