import{At as e,B as t,Bt as n,Dt as r,F as i,G as a,L as o,Mt as s,N as c,P as l,Q as u,R as d,T as f,Tt as p,Ut as m,bt as h,ot as g,qt as _,w as v,y}from"./vue-3bs2-dMU.js";import{K as b,S as x,U as S}from"./stores-DmetsdTd.js";import{t as C}from"./ServerPathField-DLutqYNk.js";import{t as w}from"./HistoryKey-C5zPCBlq.js";import{C as T,D as E,G as D,I as O,K as k,S as A,T as j,dt as M,ht as N,mt as P,w as F,y as I}from"./vuetify-gGrfRH2I.js";a(),p(),m(),y();var L={key:0,class:`text-warning`},R=t({__name:`CategoryFormDialog`,props:{guid:{},initialCategory:{}},emits:[`submit`],setup(t,{emit:a}){let p=t,m=a,{t:y}=b(),R=x(),{isOpened:z}=S(p.guid),B=s(!1),V=[e=>!!e||y(`dialogs.category.nameRequired`)],H=s(),U=s(),W=e({name:``,savePath:``,downloadPathEnabled:!1,downloadPath:``});async function G(){B.value&&(U.value?.saveValueToHistory(),H.value?.saveValueToHistory(),p.initialCategory?await R.editCategory(W,p.initialCategory.name===W.name?void 0:p.initialCategory.name):await R.createCategory(W),m(`submit`,W),K())}function K(){z.value=!1}return u(()=>{W.name=p.initialCategory?.name||``,W.savePath=p.initialCategory?.savePath||``,W.downloadPathEnabled=p.initialCategory?.downloadPathEnabled||!1,W.downloadPath=p.initialCategory?.downloadPath||``}),(e,a)=>(g(),c(A,{modelValue:n(z),"onUpdate:modelValue":a[6]||=e=>r(z)?z.value=e:null},{default:h(()=>[d(T,null,{default:h(()=>[d(j,null,{default:h(()=>[o(_(e.$t(`dialogs.category.title.${t.initialCategory?`edit`:`create`}`)),1)]),_:1}),d(F,null,{default:h(()=>[d(n(I),{ref:`form`,modelValue:B.value,"onUpdate:modelValue":a[4]||=e=>B.value=e,onSubmit:a[5]||=f(()=>{},[`prevent`]),onKeydown:v(f(G,[`prevent`]),[`enter`])},{default:h(()=>[t.initialCategory?(g(),c(D,{key:0,"model-value":t.initialCategory.name,disabled:``,label:e.$t(`dialogs.category.oldName`)},null,8,[`model-value`,`label`])):l(``,!0),d(D,{modelValue:W.name,"onUpdate:modelValue":a[0]||=e=>W.name=e,rules:V,autofocus:!t.initialCategory,label:e.$t(`dialogs.category.name`)},null,8,[`modelValue`,`autofocus`,`label`]),d(C,{ref_key:`savePathField`,ref:U,modelValue:W.savePath,"onUpdate:modelValue":a[1]||=e=>W.savePath=e,"history-key":n(w).TORRENT_PATH,title:n(y)(`dialogs.category.savePath`),"hide-details":``},{prepend:h(()=>[d(P,{color:`accent`},{default:h(()=>[...a[7]||=[o(`mdi-content-save`,-1)]]),_:1})]),_:1},8,[`modelValue`,`history-key`,`title`]),d(O,{modelValue:W.downloadPathEnabled,"onUpdate:modelValue":a[2]||=e=>W.downloadPathEnabled=e,"hide-details":``,density:`compact`,label:n(y)(`dialogs.category.downloadPathEnabled`)},null,8,[`modelValue`,`label`]),d(C,{ref_key:`downloadPathField`,ref:H,modelValue:W.downloadPath,"onUpdate:modelValue":a[3]||=e=>W.downloadPath=e,"history-key":n(w).TORRENT_PATH,title:n(y)(`dialogs.category.downloadPath`),disabled:!W.downloadPathEnabled,"hide-details":``},{prepend:h(()=>[d(P,{color:`accent`},{default:h(()=>[...a[8]||=[o(`mdi-tray-arrow-down`,-1)]]),_:1})]),_:1},8,[`modelValue`,`history-key`,`title`,`disabled`]),d(M,null,{default:h(()=>[t.initialCategory&&t.initialCategory.name!==W.name?(g(),i(`div`,L,[d(P,null,{default:h(()=>[...a[9]||=[o(`mdi-alert`,-1)]]),_:1}),o(` `+_(e.$t(`dialogs.category.warnEdit`)),1)])):l(``,!0)]),_:1})]),_:1},8,[`modelValue`,`onKeydown`])]),_:1}),d(E,null,{default:h(()=>[d(N),d(k,{color:`error`,onClick:K},{default:h(()=>[o(_(e.$t(`common.cancel`)),1)]),_:1}),d(k,{color:`accent`,disabled:!B.value,onClick:G},{default:h(()=>[o(_(e.$t(`common.save`)),1)]),_:1},8,[`disabled`])]),_:1})]),_:1})]),_:1},8,[`modelValue`]))}});export{R as default};