import{d as S,v as C,a7 as A,b as p,a5 as L,_ as j}from"./app-QjDgb7aF.js";import{F as q}from"./split-B5EOpoau.js";import{b as z,c as G,j as a,g as H,i as u,q as c,k as n,I as f,u as t,J as k,D as _,p as d,F as B,G as E,x as h,H as F,a as m,E as M}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const J={class:"tbhwbxda"},O={class:"form"},R={key:0,class:"users"},T=["onClick"],W={class:"body"},X={key:1,class:"empty"},K={key:1,class:"recent"},P={class:"users"},Q=["onClick"],Y={class:"body"},Z=z({__name:"MkUserSelectDialog",emits:["ok","cancel","closed"],setup(ee,{emit:I}){const V=I;let i=m(""),r=m(""),v=m([]),g=m([]),l=m(null),b=m();const w=()=>{if(i.value===""&&r.value===""){v.value=[];return}S("users/search-by-username-and-host",{username:i.value,host:r.value,limit:10,detail:!1}).then(o=>{v.value=o})},y=()=>{if(l.value==null)return;V("ok",l.value),b.value.close();let o=C.state.recentlyUsedUsers;o=o.filter(s=>s!==l.value.id),o.unshift(l.value.id),C.set("recentlyUsedUsers",o.splice(0,16))},x=()=>{V("cancel"),b.value.close()};return G(()=>{S("users/show",{userIds:C.state.recentlyUsedUsers}).then(o=>{g.value=o})}),(o,s)=>{const $=M("MkAvatar"),D=M("MkUserName"),N=M("MkAcct");return a(),H(L,{ref_key:"dialogEl",ref:b,"with-ok-button":!0,"ok-button-disabled":t(l)==null,onClick:s[4]||(s[4]=e=>x()),onClose:s[5]||(s[5]=e=>x()),onOk:s[6]||(s[6]=e=>y()),onClosed:s[7]||(s[7]=e=>o.$emit("closed"))},{header:u(()=>[k(_(t(p).ts.selectUser),1)]),default:u(()=>[c("div",J,[c("div",O,[n(q,{"min-width":170},{default:u(()=>[n(A,{modelValue:t(i),"onUpdate:modelValue":[s[0]||(s[0]=e=>f(i)?i.value=e:i=e),w],autofocus:!0},{label:u(()=>[k(_(t(p).ts.username),1)]),prefix:u(()=>[...s[8]||(s[8]=[k("@",-1)])]),_:1},8,["modelValue"]),n(A,{modelValue:t(r),"onUpdate:modelValue":[s[1]||(s[1]=e=>f(r)?r.value=e:r=e),w]},{label:u(()=>[k(_(t(p).ts.host),1)]),prefix:u(()=>[...s[9]||(s[9]=[k("@",-1)])]),_:1},8,["modelValue"])]),_:1})]),t(i)!=""||t(r)!=""?(a(),d("div",{key:0,class:h(["result",{hit:t(v).length>0}])},[t(v).length>0?(a(),d("div",R,[(a(!0),d(B,null,E(t(v),e=>(a(),d("div",{key:e.id,class:h(["user",{selected:t(l)&&t(l).id===e.id}]),onClick:U=>f(l)?l.value=e:l=e,onDblclick:s[2]||(s[2]=U=>y())},[n($,{user:e,class:"avatar","show-indicator":!0,disableLink:""},null,8,["user"]),c("div",W,[n(D,{user:e,class:"name"},null,8,["user"]),n(N,{user:e,class:"acct"},null,8,["user"])])],42,T))),128))])):(a(),d("div",X,[c("span",null,_(t(p).ts.noUsers),1)]))],2)):F("",!0),t(i)==""&&t(r)==""?(a(),d("div",K,[c("div",P,[(a(!0),d(B,null,E(t(g),e=>(a(),d("div",{key:e.id,class:h(["user",{selected:t(l)&&t(l).id===e.id}]),onClick:U=>f(l)?l.value=e:l=e,onDblclick:s[3]||(s[3]=U=>y())},[n($,{user:e,class:"avatar","show-indicator":!0,disableLink:""},null,8,["user"]),c("div",Y,[n(D,{user:e,class:"name"},null,8,["user"]),n(N,{user:e,class:"acct"},null,8,["user"])])],42,Q))),128))])])):F("",!0)])]),_:1},8,["ok-button-disabled"])}}}),ne=j(Z,[["__scopeId","data-v-515e0cbc"]]);export{ne as default};
//# sourceMappingURL=MkUserSelectDialog-B1Lt0Wmh.js.map
