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