import{Q as T,x as v,w as h,o as $,a2 as a,b as I,Z as g,B as c,U as w,S as i,R as n,a9 as m,a0 as l,bm as A,G as V,$ as L,a5 as o,bn as B,bo as C,a4 as O}from"./index-Bduq4vJM.js";import{W as d}from"./WidgetRow-Dh5C0NEV.js";import{I as R}from"./ItemsListing-Be0Rl7jr.js";import{C as U}from"./Container-Ps6BlEWu.js";import{T as K}from"./Toolbar-MtNZFNYL.js";import{V as D}from"./VTextField-lpT7m_Xn.js";import"./PanelviewItemCompact-C9loINH4.js";import"./MediaItemThumb-CN4TRL8T.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VCheckbox-BiGeI08h.js";import"./VCheckboxBtn-DLibXb0-.js";import"./VBtn-DWiYTBpb.js";import"./VToolbar-CG7bivmQ.js";import"./VAlert-BjDi0iTj.js";import"./ListItem-B-hzVPBy.js";import"./Button-DDaesvMx.js";import"./VSpacer-BnmXZ56R.js";/* empty css              */import"./VInfiniteScroll-Ar7Xm9mt.js";import"./layout-B2wBEHPQ.js";import"./VRow-Cj9YdJtG.js";import"./VVirtualScroll-VdTkqEkN.js";import"./VContainer-BVUS8uFb.js";const P={key:1},F={key:2},ue=T({__name:"Search",setup(M){const p=v(!1),t=v(),s=v(!1),f=v();h(()=>a.globalSearchTerm,()=>{clearTimeout(f.value),f.value=setTimeout(()=>{y(a.globalSearchTerm,a.globalSearchType)},1e3)},{immediate:!0}),h(()=>a.globalSearchType,()=>{y(a.globalSearchTerm,a.globalSearchType)});const y=async function(e,u){s.value=!0,localStorage.setItem("globalsearch",e||"");const r=a.globalSearchType?50:8,k=u?[u]:void 0;e?t.value=await O.search(e,k,r):t.value=void 0,s.value=!1};$(()=>{if(!a.globalSearchTerm){const e=localStorage.getItem("globalsearch");e&&e!=="null"&&(a.globalSearchTerm=e)}});const b=function(e){e.ctrlKey||e.altKey||e.metaKey||(!p.value&&e.key=="Backspace"&&a.globalSearchTerm?a.globalSearchTerm=a.globalSearchTerm.slice(0,-1):!p.value&&e.key.length==1&&(a.globalSearchTerm+=e.key))};document.addEventListener("keyup",b),I(()=>{document.removeEventListener("keyup",b)});const S=function(e){return t.value?e==o.TRACK?t.value.tracks:e==o.ARTIST?t.value.artists:e==o.ALBUM?t.value.albums:e==o.PLAYLIST?t.value.playlists:e==o.PODCAST?t.value.podcasts:e==o.AUDIOBOOK?t.value.audiobooks:e==o.RADIO?t.value.radio:[]:[]};return(e,u)=>(i(),g("section",null,[c(K,{icon:"mdi-magnify",title:e.$t("global_search")},null,8,["title"]),c(U,{variant:"default"},{default:w(()=>[c(D,{id:"searchInput",modelValue:l(a).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>l(a).globalSearchTerm=r),clearable:"","prepend-inner-icon":"mdi-magnify",label:e.$t("type_to_search"),"hide-details":"",variant:"outlined",onFocus:u[1]||(u[1]=r=>p.value=!0),onBlur:u[2]||(u[2]=r=>p.value=!1)},null,8,["modelValue","label"]),c(A,{modelValue:l(a).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>l(a).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:w(()=>[(i(!0),g(V,null,L([void 0,l(o).TRACK,l(o).ARTIST,l(o).ALBUM,l(o).PLAYLIST,l(o).PODCAST,l(o).AUDIOBOOK,l(o).RADIO],r=>(i(),n(C,{key:r,text:e.$t(r?r+"s":"searchtype_all"),value:r},null,8,["text","value"]))),128))]),_:1},8,["modelValue"]),s.value?(i(),n(B,{key:0,color:"accent",height:"4",indeterminate:"",rounded:"",style:{"margin-top":"15px"}})):m("",!0),l(a).globalSearchType?s.value?m("",!0):(i(),g("div",F,[c(R,{itemtype:`${l(a).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>S(l(a).globalSearchType),title:e.$t(`${l(a).globalSearchType}s`),"allow-key-hooks":!1,"show-search-button":!1,"infinite-scroll":!0,"sort-keys":[],style:{padding:"0"}},null,8,["itemtype","load-items","title"])])):(i(),g("div",P,[t.value&&!s.value?(i(),n(d,{key:0,"widget-row":{title:e.$t("tracks"),icon:"mdi-file-music",items:t.value.tracks}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:1,"widget-row":{title:e.$t("artists"),icon:"mdi-account-music",items:t.value.artists}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:2,"widget-row":{title:e.$t("albums"),icon:"mdi-album",items:t.value.albums}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:3,"widget-row":{title:e.$t("playlists"),icon:"mdi-playlist-music",items:t.value.playlists}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:4,"widget-row":{title:e.$t("podcasts"),icon:"mdi-podcast",items:t.value.podcasts}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:5,"widget-row":{title:e.$t("audiobooks"),icon:"mdi-book-play-outline",items:t.value.audiobooks}},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(d,{key:6,"widget-row":{title:e.$t("radios"),icon:"mdi-radio",items:t.value.radio}},null,8,["widget-row"])):m("",!0)]))]),_:1})]))}});export{ue as default};
