import{f as D,b as g,r as z,O as F,J as C,K as f,M as t,n as l,P as s,Q as r,u as b,R as K,S as c,T,U as N,V as B}from"./vue-BhpnMDi9.js";import{e as R,g as G,h as q,i as E,j as M,k as O,V as p,l as I,a as j,n as A,o as J,p as $,q as Q,r as H}from"./index-ChuS1rKu.js";import{V as X}from"./VForm-DyhOXLXH.js";const L={key:0,class:"text-warning"},_=D({__name:"CategoryFormDialog",props:{guid:{},initialCategory:{}},emits:["submit"],setup(w,{emit:k}){const i=w,S=k,{t:m}=R(),v=G(),{isOpened:d}=q(i.guid),U=g(),u=g(!1),P=[e=>!!e||m("dialogs.category.nameRequired")],o=z({name:"",savePath:""});async function V(){u.value&&(i.initialCategory?await v.editCategory(o,i.initialCategory.name===o.name?void 0:i.initialCategory.name):await v.createCategory(o),S("submit",o),y())}function y(){d.value=!1}return F(()=>{o.name=i.initialCategory?.name||"",o.savePath=i.initialCategory?.savePath||""}),(e,a)=>(f(),C(Q,{modelValue:b(d),"onUpdate:modelValue":a[4]||(a[4]=n=>B(d)?d.value=n:null)},{default:t(()=>[l(E,null,{default:t(()=>[l(M,null,{default:t(()=>[s(r(e.$t(`dialogs.category.title.${e.initialCategory?"edit":"create"}`)),1)]),_:1}),l(O,null,{default:t(()=>[l(b(X),{ref_key:"form",ref:U,modelValue:u.value,"onUpdate:modelValue":a[2]||(a[2]=n=>u.value=n),onSubmit:a[3]||(a[3]=c(()=>{},["prevent"])),onKeydown:K(c(V,["prevent"]),["enter"])},{default:t(()=>[e.initialCategory?(f(),C(p,{key:0,"model-value":e.initialCategory.name,disabled:"",label:e.$t("dialogs.category.oldName")},null,8,["model-value","label"])):T("",!0),l(p,{modelValue:o.name,"onUpdate:modelValue":a[0]||(a[0]=n=>o.name=n),rules:P,autofocus:!e.initialCategory,label:e.$t("dialogs.category.name")},null,8,["modelValue","autofocus","label"]),l(p,{modelValue:o.savePath,"onUpdate:modelValue":a[1]||(a[1]=n=>o.savePath=n),autofocus:!!e.initialCategory,label:e.$t("dialogs.category.savePath")},null,8,["modelValue","autofocus","label"]),l(I,null,{default:t(()=>[e.initialCategory&&e.initialCategory.name!==o.name?(f(),N("div",L,[l(j,null,{default:t(()=>a[5]||(a[5]=[s("mdi-alert",-1)])),_:1,__:[5]}),s(" "+r(e.$t("dialogs.category.warnEdit")),1)])):T("",!0)]),_:1})]),_:1},8,["modelValue","onKeydown"])]),_:1}),l(A,null,{default:t(()=>[l(J),l($,{color:"error",onClick:y},{default:t(()=>[s(r(e.$t("common.cancel")),1)]),_:1}),l($,{color:"accent",disabled:!u.value,onClick:V},{default:t(()=>[s(r(e.$t("common.save")),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}}),W={key:0,class:"text-warning"},x=D({__name:"TagFormDialog",props:{guid:{},initialTag:{}},emits:["submit"],setup(w,{emit:k}){const i=w,S=k,{isOpened:m}=q(i.guid),{t:v}=R(),d=H(),U=g(),u=g(!1),P=g([e=>!!e||v("dialogs.tag.required"),e=>!i.initialTag||!!i.initialTag&&!e.includes(",")||v("dialogs.tag.comma")]),o=g("");async function V(){if(!u.value)return;let e;i.initialTag?(e=[o.value],await d.editTag(i.initialTag,o.value)):(e=o.value.split(","),await d.createTags(e)),S("submit",e),y()}function y(){m.value=!1}return F(()=>{o.value=i.initialTag||""}),(e,a)=>(f(),C(Q,{modelValue:b(m),"onUpdate:modelValue":a[3]||(a[3]=n=>B(m)?m.value=n:null)},{default:t(()=>[l(E,null,{default:t(()=>[l(M,null,{default:t(()=>[s(r(e.$t(`dialogs.tag.title.${e.initialTag?"rename":"create"}`)),1)]),_:1}),l(O,null,{default:t(()=>[l(b(X),{ref_key:"form",ref:U,modelValue:u.value,"onUpdate:modelValue":a[1]||(a[1]=n=>u.value=n),onSubmit:a[2]||(a[2]=c(()=>{},["prevent"])),onKeydown:K(c(V,["prevent"]),["enter"])},{default:t(()=>[e.initialTag?(f(),C(p,{key:0,"model-value":e.initialTag,disabled:"",label:e.$t("dialogs.tag.oldName")},null,8,["model-value","label"])):T("",!0),l(p,{modelValue:o.value,"onUpdate:modelValue":a[0]||(a[0]=n=>o.value=n),rules:P.value,autofocus:"",hint:e.$t("dialogs.tag.hint"),label:e.$t("dialogs.tag.name")},null,8,["modelValue","rules","hint","label"]),l(I,null,{default:t(()=>[e.initialTag&&e.initialTag!==o.value?(f(),N("div",W,[l(j,null,{default:t(()=>a[4]||(a[4]=[s("mdi-alert",-1)])),_:1,__:[4]}),s(" "+r(e.$t("dialogs.tag.warnEdit")),1)])):T("",!0)]),_:1})]),_:1},8,["modelValue","onKeydown"])]),_:1}),l(A,null,{default:t(()=>[l(J),l($,{color:"error",onClick:y},{default:t(()=>[s(r(e.$t("common.cancel")),1)]),_:1}),l($,{color:"accent",disabled:!u.value,onClick:V},{default:t(()=>[s(r(e.$t("common.save")),1)]),_:1},8,["disabled"])]),_:1})]),_:1})]),_:1},8,["modelValue"]))}});export{x as _,_ as a};
