import{a as e,n as t,r as n}from"./useStore-CusP06SD.js";import{L as r}from"./sidebar-y9WJu7Jw.js";import{t as i}from"./Page-C7KClZ28.js";import{t as a}from"./button-1cIaa9Lf.js";import{t as o}from"./input-CsfmMUT5.js";import{t as s}from"./DeleteOption-dxKSbv6N.js";import{f as c,i as l}from"./index-DinSQfHc.js";import{S as u,a as d,b as f,d as p,f as m,h,i as g,r as _,s as v,t as y}from"./use-settings-form-submit-D87nmJRy.js";import{t as b}from"./FieldInfo-FLjtPgL4.js";var x=e(n()),S=t();function C(){let{isFieldRequired:e}=p(h),{data:t}=c(r().settings.get.queryOptions(void 0,{select:e=>_(h,m(e.config),{includeUndefined:!0})})),n=y(),C=d({defaultValues:t??v,onSubmit:n,validators:{onSubmit:h}}),[w,T]=(0,x.useState)(null);return(0,x.useEffect)(()=>{w&&(document.getElementById(w)?.focus(),T(null))},[w]),(0,S.jsx)(i,{children:(0,S.jsxs)(`div`,{className:`space-y-4`,children:[(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Directory & Path Settings`}),(0,S.jsx)(`p`,{className:`text-muted-foreground`,children:`Manage the directories and paths used by cross-seed.`})]}),(0,S.jsx)(g,{isFieldRequired:e,children:(0,S.jsx)(`form`,{className:`form flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),e.stopPropagation(),C.handleSubmit()},noValidate:!0,children:(0,S.jsxs)(`div`,{className:`flex flex-wrap gap-6`,children:[(0,S.jsxs)(`fieldset`,{className:`form-fieldset w-full gap-6`,children:[(0,S.jsx)(`div`,{className:``,children:(0,S.jsx)(C.Field,{name:`dataDirs`,mode:`array`,children:t=>(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(l,{htmlFor:t.name,className:`block w-full`,children:[`Data Directories`,e(t.name)&&(0,S.jsx)(`span`,{className:`pl-1 text-red-500`,children:`*`})]}),t.state.value.map((e,n)=>(0,S.jsx)(C.Field,{name:`dataDirs[${n}]`,validators:{onBlur:f()},children:e=>(0,S.jsxs)(`div`,{className:`mb-3 flex flex-col gap-y-1`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(o,{type:`text`,className:`form-input`,value:e.state.value,"aria-invalid":!!(e.state.meta.isTouched&&e.state.meta.errorMap.onBlur),onBlur:e.handleBlur,onChange:t=>e.handleChange(t.target.value)}),t.state.value.length>1&&(0,S.jsx)(s,{onClick:()=>{t.removeValue(n)}})]}),e.state.meta.isTouched&&e.state.meta.errors&&(0,S.jsx)(b,{fieldMeta:e.state.meta})]})},`${t.name}-${n}`)),(0,S.jsx)(a,{variant:`secondary`,type:`button`,onClick:()=>{t.pushValue(``),T(`${t.name}-${t.state.value.length-1}`)},title:`Add ${t.name}`,children:`Add`})]})})}),(0,S.jsx)(C.AppField,{name:`flatLinking`,children:e=>(0,S.jsx)(e.SwitchField,{label:`Flat Linking`,className:`form-field__switch flex flex-col items-start gap-5`})}),(0,S.jsx)(`div`,{className:``,children:(0,S.jsx)(C.AppField,{name:`linkType`,children:e=>(0,S.jsx)(e.SelectField,{label:`Link Type`,options:u})})}),(0,S.jsx)(`div`,{className:``,children:(0,S.jsx)(C.Field,{name:`linkDirs`,mode:`array`,children:t=>(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(l,{htmlFor:t.name,className:`block w-full`,children:[`Link Directories`,e(t.name)&&(0,S.jsx)(`span`,{className:`pl-1 text-red-500`,children:`*`})]}),t.state.value?.map((e,n)=>(0,S.jsxs)(`div`,{className:`gap-y- mb-3 flex flex-col`,children:[(0,S.jsx)(C.AppField,{name:`linkDirs[${n}]`,validators:{onBlur:f()},children:e=>(0,S.jsx)(e.ArrayField,{showDelete:(t.state.value&&t.state.value?.length>1)??void 0,index:n,onDelete:()=>{t.removeValue(n)}})}),(0,S.jsx)(C.Subscribe,{selector:e=>e.fieldMeta[`${t.name}[${n}]`],children:e=>(0,S.jsx)(b,{fieldMeta:e})})]},n)),(0,S.jsx)(a,{variant:`secondary`,type:`button`,onClick:()=>{t.pushValue(``),T(`${t.name}-${t.state.value?.length?t.state.value.length-1:0}`)},title:`Add ${t.name}`,children:`Add`})]})})}),(0,S.jsx)(`div`,{className:``,children:(0,S.jsx)(C.AppField,{name:`maxDataDepth`,children:e=>(0,S.jsx)(e.NumberField,{label:`Max Data Depth`})})})]}),(0,S.jsx)(C.AppForm,{children:(0,S.jsx)(C.SubmitButton,{})})]})})})]})})}export{C as component};