1import{b as D,a as S,ay as R,W as O,av as N,c as Q,l as p,h as i,s as t,g as H,A as _,C as f,j as r,t as z,q as s,B as n,H as B,p as F}from"./Co3cvlEU.js";import{au as G,d as v,C as L,T as A,i as l,$ as U,M as w,L as J,bT as K,A as V,dc as X}from"./app-B3k0Lwm3.js";import{M as W}from"./D2uYig_p.js";import{M as Y}from"./Bp8k5YvA.js";import{_ as Z}from"./BXzDS2KU.js";import{M as ee}from"./CLMhbo-f.js";import"./BTqQ_sdn.js";import"./DqgMm5jf.js";import"./CnR_GWqg.js";import"./6drVeEjp.js";import"./D9Dt_0kx.js";import"./CEZh6Qhs.js";import"./ByFpuFxB.js";import"./Drs5sOD9.js";import"./WKljyoCF.js";import"./CsxMLT3g.js";import"./CbLbUK32.js";import"./CxGp7-du.js";import"./PKzrjJx1.js";import"./BcMDoZSP.js";const te={class:"_gaps"},se={class:"_gaps"},le={class:"_gaps_m"},ae={key:0,value:"all"},oe={value:"local"},re={key:1,value:"server"},ne={value:"user"},ue={class:"_gaps"},ie={key:0},ce={style:{overflow:"hidden"}},Re=D({__name:"search.note",props:{query:{default:""},userId:{default:void 0},username:{default:void 0},host:{default:""}},async setup(j){let c,x;const d=j,k=G(),I=S(0),C=S(),$=S(R(d,"query").value),g=S(R(d,"host").value),u=O(null),b=v.noteSearchableScope??"local";let h=null;d.userId&&(h=([c,x]=N(()=>L("users/show",{userId:d.userId}).catch(()=>null)),c=await c,x(),c)),d.username&&h==null&&(h=([c,x]=N(()=>L("users/show",{username:d.username,...d.host?{host:d.host}:{}}).catch(()=>null)),c=await c,x(),c)),h!=null&&(b==="local"&&h.host!=null||(u.value=h));const m=S(u.value!=null?"user":b==="local"?"local":g.value?"server":"all"),M=a=>!a||a===J?".":a,o=Q(()=>{const a=$.value.trim();if(!a)return null;if(m.value==="user")return u.value==null?null:{query:a,host:M(u.value.host),userId:u.value.id};if(v.federation!=="none"&&m.value==="server"){let e=g.value?.trim();if(!e)return null;if(e.startsWith("https://")||e.startsWith("http://"))try{e=new URL(e).host}catch{}return{query:a,host:M(e)}}return v.federation==="none"||m.value==="local"?{query:a,host:"."}:{query:a}});function E(){K({includeSelf:!0,localOnly:v.noteSearchableScope==="local"}).then(a=>{u.value=a})}function P(){u.value=U}function T(){u.value=null}async function q(){if(o.value!=null){if(o.value.query.startsWith("https://")&&!o.value.query.includes(" ")&&!(await V({type:"info",text:l.ts.lookupConfirm})).canceled){const e=await X(o.value.query);e.type==="User"?k.push(`/@${e.object.username}@${e.object.host}`):e.type==="Note"&&k.push(`/notes/${e.object.id}`);return}if(o.value.query.length>1&&!o.value.query.includes(" ")){if(o.value.query.startsWith("@")&&!(await V({type:"info",text:l.ts.lookupConfirm})).canceled){k.push(`/${o.value.query}`);return}if(o.value.query.startsWith("#")&&!(await V({type:"info",text:l.ts.openTagPageConfirm})).canceled){k.push(`/tags/${encodeURIComponent(o.value.query.substring(1))}`);return}}C.value={endpoint:"notes/search",limit:10,params:{...o.value}},I.value++}}return(a,e)=>(i(),p("div",te,[t("div",se,[f(A,{modelValue:$.value,"onUpdate:modelValue":e[0]||(e[0]=y=>$.value=y),large:"",autofocus:"",type:"search",onEnter:z(q,["prevent"])},{prefix:r(()=>e[3]||(e[3]=[t("i",{class:"ti ti-search"},null,-1)])),_:1},8,["modelValue"]),f(W,{expanded:""},{header:r(()=>[B(n(s(l).ts.options),1)]),default:r(()=>[t("div",le,[f(Z,{modelValue:m.value,"onUpdate:modelValue":e[1]||(e[1]=y=>m.value=y)},{default:r(()=>[s(v).federation!=="none"&&s(b)==="global"?(i(),p("option",ae,n(s(l).ts._search.searchScopeAll),1)):_("",!0),t("option",oe,n(s(v).federation==="none"?s(l).ts._search.searchScopeAll:s(l).ts._search.searchScopeLocal),1),s(v).federation!=="none"&&s(b)==="global"?(i(),p("option",re,n(s(l).ts._search.searchScopeServer),1)):_("",!0),t("option",ne,n(s(l).ts._search.searchScopeUser),1)]),_:1},8,["modelValue"]),s(v).federation!=="none"&&m.value==="server"?(i(),p("div",{key:0,class:"xpgtz"},[f(A,{modelValue:g.value,"onUpdate:modelValue":e[2]||(e[2]=y=>g.value=y),placeholder:s(l).ts._search.serverHostPlaceholder,onEnter:z(q,["prevent"])},{label:r(()=>[B(n(s(l).ts._search.pleaseEnterServerHost),1)]),prefix:r(()=>e[4]||(e[4]=[t("i",{class:"ti ti-server"},null,-1)])),_:1},8,["modelValue","placeholder"])],2)):_("",!0),m.value==="user"?(i(),p("div",{key:1,class:"xpgtz"},[t("div",{class:"x9I4U"},n(s(l).ts._search.pleaseSelectUser),3),t("div",ue,[u.value==null?(i(),p("div",{key:0,class:"x4VND"},[s(U)!=null?(i(),p("div",ie,[f(w,{transparent:"",class:"xeH3r",onClick:P},{default:r(()=>[t("div",{class:"xl2Be"},[e[5]||(e[5]=t("span",null,[t("i",{class:"ti ti-plus"}),t("i",{class:"ti ti-user"})],-1)),t("span",null,n(s(l).ts.selectSelf),1)],2)]),_:1},8,["class"])])):_("",!0),t("div",{style:F(s(U)==null?"grid-column: span 2;":void 0)},[f(w,{transparent:"",class:"xeH3r",onClick:E},{default:r(()=>[t("div",{class:"xl2Be"},[e[6]||(e[6]=t("span",null,[t("i",{class:"ti ti-plus"})],-1)),t("span",null,n(s(l).ts.selectUser),1)],2)]),_:1},8,["class"])],4)],2)):(i(),p("div",{key:1,class:"xn3kz"},[t("div",ce,[f(ee,{user:u.value,withChart:!1,class:""},null,8,["user","class"])]),t("div",null,[t("button",{class:"_button xo0S4",onClick:T},e[7]||(e[7]=[t("i",{class:"ti ti-x"},null,-1)]),2)])],2))])],2)):_("",!0)])]),_:1}),t("div",null,[f(w,{large:"",primary:"",gradate:"",rounded:"",disabled:o.value==null,style:{margin:"0 auto"},onClick:q},{default:r(()=>[B(n(s(l).ts.search),1)]),_:1},8,["disabled"])])]),C.value?(i(),H(W,{key:0},{header:r(()=>[B(n(s(l).ts.searchResult),1)]),default:r(()=>[(i(),H(Y,{key:`searchNotes:${I.value}`,pagination:C.value},null,8,["pagination"]))]),_:1})):_("",!0)]))}});
1export{Re as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.