import{Q as T,x as v,w as y,o as I,a2 as l,b as A,Z as g,B as d,U as w,S as s,R as n,a9 as m,a0 as t,bo as V,G as L,$ as B,a5 as o,bp as C,bq as O,a4 as R}from"./index-Cnj5GSC_.js";import{H as c}from"./HomeWidgetRow-BJBNr_ff.js";import{I as $}from"./ItemsListing-h_wzDhTj.js";import{C as U}from"./Container-CqBJ32Ya.js";import{T as K}from"./Toolbar-DxStkeCe.js";import{V as x}from"./VTextField-Cx6b3lol.js";import"./PanelviewItemCompact-B9DJU3rz.js";import"./MediaItemThumb-nl-JfHWK.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VCheckbox-fyxRs1hM.js";import"./VCheckboxBtn-DBChwn76.js";import"./VBtn-BSF6Iwig.js";import"./VToolbar-CdqhLlRP.js";import"./VAlert-CG-We4CK.js";import"./ListItem-DX1YePCJ.js";import"./VSpacer-DOrvwmKC.js";/* empty css              */import"./VInfiniteScroll-D66OEY1T.js";import"./layout-BKwEErqq.js";import"./VRow-CehpvRw1.js";import"./VVirtualScroll-LMBSx8GT.js";import"./VContainer-B3bIWEaT.js";const D={key:1},_={key:2},ie=T({__name:"Search",setup(P){const p=v(!1),e=v(),i=v(!1),b=v();y(()=>l.globalSearchTerm,()=>{clearTimeout(b.value),b.value=setTimeout(()=>{h(l.globalSearchTerm,l.globalSearchType)},1e3)},{immediate:!0}),y(()=>l.globalSearchType,()=>{h(l.globalSearchTerm,l.globalSearchType)});const h=async function(a,u){i.value=!0,localStorage.setItem("globalsearch",a||"");const r=l.globalSearchType?50:8,S=u?[u]:void 0;a?e.value=await R.search(a,S,r):e.value=void 0,i.value=!1};I(()=>{if(!l.globalSearchTerm){const a=localStorage.getItem("globalsearch");a&&a!=="null"&&(l.globalSearchTerm=a)}});const f=function(a){a.ctrlKey||a.altKey||a.metaKey||(!p.value&&a.key=="Backspace"&&l.globalSearchTerm?l.globalSearchTerm=l.globalSearchTerm.slice(0,-1):!p.value&&a.key.length==1&&(l.globalSearchTerm+=a.key))};document.addEventListener("keyup",f),A(()=>{document.removeEventListener("keyup",f)});const k=function(a){return e.value?a==o.TRACK?e.value.tracks:a==o.ARTIST?e.value.artists:a==o.ALBUM?e.value.albums:a==o.PLAYLIST?e.value.playlists:a==o.PODCAST?e.value.podcasts:a==o.AUDIOBOOK?e.value.audiobooks:a==o.RADIO?e.value.radio:[]:[]};return(a,u)=>(s(),g("section",null,[d(K,{icon:"mdi-magnify",title:a.$t("global_search")},null,8,["title"]),d(U,{variant:"default"},{default:w(()=>[d(x,{id:"searchInput",modelValue:t(l).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>t(l).globalSearchTerm=r),clearable:"","prepend-inner-icon":"mdi-magnify",label:a.$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"]),d(V,{modelValue:t(l).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>t(l).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:w(()=>[(s(!0),g(L,null,B([void 0,t(o).TRACK,t(o).ARTIST,t(o).ALBUM,t(o).PLAYLIST,t(o).PODCAST,t(o).AUDIOBOOK,t(o).RADIO],r=>(s(),n(O,{key:r,text:a.$t(r?r+"s":"searchtype_all"),value:r},null,8,["text","value"]))),128))]),_:1},8,["modelValue"]),i.value?(s(),n(C,{key:0,color:"accent",height:"4",indeterminate:"",rounded:"",style:{"margin-top":"15px"}})):m("",!0),t(l).globalSearchType?i.value?m("",!0):(s(),g("div",_,[d($,{itemtype:`${t(l).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>k(t(l).globalSearchType),title:a.$t(`${t(l).globalSearchType}s`),"allow-key-hooks":!1,"show-search-button":!1,"infinite-scroll":!0,"sort-keys":[],style:{padding:"0"}},null,8,["itemtype","load-items","title"])])):(s(),g("div",D,[e.value&&!i.value?(s(),n(c,{key:0,"widget-row":{label:"tracks",icon:"mdi-file-music",items:e.value.tracks,count:e.value.tracks.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:1,"widget-row":{label:"artists",icon:"mdi-account-music",items:e.value.artists,count:e.value.artists.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:2,"widget-row":{label:"albums",icon:"mdi-album",items:e.value.albums,count:e.value.albums.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:3,"widget-row":{label:"playlists",icon:"mdi-playlist-music",items:e.value.playlists,count:e.value.playlists.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:4,"widget-row":{label:"podcasts",icon:"mdi-podcast",items:e.value.podcasts,count:e.value.podcasts.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:5,"widget-row":{label:"audiobooks",icon:"mdi-book-play-outline",items:e.value.audiobooks,count:e.value.audiobooks.length}},null,8,["widget-row"])):m("",!0),e.value&&!i.value?(s(),n(c,{key:6,"widget-row":{label:"radios",icon:"mdi-radio",items:e.value.radio,count:e.value.radio.length}},null,8,["widget-row"])):m("",!0)]))]),_:1})]))}});export{ie as default};
