import{O as e,Q as t,Rt as n,S as r,T as i,_t as a,b as o,ft as s,gt as c,kt as l,n as u,q as d,u as f,v as p}from"./vue-i18n-Bp4YYb-2.js";import{D as m,Lt as h}from"./index-BOiiIZox.js";var g={class:`flex pl-4 py-2 text-2xl overflow-hidden items-center`},_=e({__name:`EntityTitleRename`,props:{currentName:{},saveNameFunction:{type:Function}},setup(e){let _=e,v=h(),{t:y}=u(),b=l(!1),x=l(``),S=l(),C=l(!1),w=p(()=>`${(x.value.length||1)+1}ch`),T=()=>{x.value=_.currentName,b.value=!0,setTimeout(()=>S.value?.$el?.focus())},E=async()=>{let e=v.sanitizeString(x.value);await _.saveNameFunction(e)||(x.value=_.currentName),b.value=!1},D=e=>{e.preventDefault(),C.value=!0,S.value?.$el?.blur(),b.value=!1},O=()=>{if(C.value){C.value=!1;return}b.value&&E()};return(e,l)=>{let u=t(`tooltip`);return d(),r(`div`,g,[b.value?(d(),o(n(m),{key:0,ref_key:`nameInputRef`,ref:S,id:`alert-name-input`,modelValue:x.value,"onUpdate:modelValue":l[0]||(l[0]=e=>x.value=e),class:`font-bold mt-[1px] !border-none !p-0 text-text-color-secondary`,style:c({width:w.value}),onKeydown:[f(E,[`enter`]),f(D,[`esc`])],onBlur:O},null,8,[`modelValue`,`style`])):s((d(),r(`span`,{key:1,class:`font-bold overflow-hidden overflow-ellipsis cursor-pointer hover:text-text-color-secondary`,onClick:T},[i(a(_.currentName),1)])),[[u,n(y)(`layout.menu.tooltips.rename`),void 0,{bottom:!0}]])])}}});export{_ as t};