import{Q as T,x as v,w as y,o as I,a2 as a,b as A,Z as g,B as d,U as w,S as i,R as n,a9 as m,a0 as t,G as V,$ as C,a5 as o,a4 as B}from"./index-orrnp8a1.js";import{H as c}from"./HomeWidgetRow-ChtBFClq.js";import{I as L}from"./ItemsListing-BPCoDFMa.js";import{C as O}from"./Container-C-MxRHLg.js";import{T as R}from"./Toolbar-CE2HDv9i.js";import{V as $}from"./VTextField-DaF8PfrV.js";import{a as U,b as D}from"./VChip-DzIcRFdM.js";import{f as P}from"./VBtn-BJolvyKt.js";import"./PanelviewItemCompact-Bf1Qb2IB.js";import"./MediaItemThumb-BFLLxiOJ.js";import"./ProviderIcon.vue_vue_type_style_index_0_lang-DgYavPcK.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VCheckbox-BaanYS4J.js";import"./VCheckboxBtn-CICj8ZxL.js";import"./VToolbar-BlKUHnwt.js";import"./VAlert-BhQ3L7Kc.js";import"./ListItem-BOpEb2vA.js";import"./VSpacer-FMK5QbR9.js";/* empty css              */import"./VInfiniteScroll-CDme3Tib.js";import"./layout-BTr25AHs.js";import"./VRow-C4MwkXJh.js";import"./VVirtualScroll-Q9Rc10mA.js";import"./VContainer-DvR1uhzJ.js";const _={key:1},x={key:2},ne=T({__name:"Search",setup(F){const p=v(!1),e=v(),s=v(!1),f=v();y(()=>a.globalSearchTerm,()=>{clearTimeout(f.value),f.value=setTimeout(()=>{b(a.globalSearchTerm,a.globalSearchType)},1e3)},{immediate:!0}),y(()=>a.globalSearchType,()=>{b(a.globalSearchTerm,a.globalSearchType)});const b=async function(l,u){s.value=!0,localStorage.setItem("globalsearch",l||"");const r=a.globalSearchType?50:8,S=u?[u]:void 0;l?e.value=await B.search(l,S,r):e.value=void 0,s.value=!1};I(()=>{if(!a.globalSearchTerm){const l=localStorage.getItem("globalsearch");l&&l!=="null"&&(a.globalSearchTerm=l)}});const h=function(l){!p.value&&l.key=="Backspace"&&a.globalSearchTerm?a.globalSearchTerm=a.globalSearchTerm.slice(0,-1):!p.value&&l.key.length==1&&(a.globalSearchTerm+=l.key)};document.addEventListener("keyup",h),A(()=>{document.removeEventListener("keyup",h)});const k=function(l){return e.value?l==o.TRACK?e.value.tracks:l==o.ARTIST?e.value.artists:l==o.ALBUM?e.value.albums:l==o.PLAYLIST?e.value.playlists:l==o.PODCAST?e.value.podcasts:l==o.AUDIOBOOK?e.value.audiobooks:l==o.RADIO?e.value.radio:[]:[]};return(l,u)=>(i(),g("section",null,[d(R,{icon:"mdi-magnify",title:l.$t("global_search")},null,8,["title"]),d(O,{variant:"default"},{default:w(()=>[d($,{id:"searchInput",modelValue:t(a).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=r=>t(a).globalSearchTerm=r),clearable:"","prepend-inner-icon":"mdi-magnify",label:l.$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(U,{modelValue:t(a).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=r=>t(a).globalSearchType=r),style:{"margin-top":"10px","margin-left":"10px"}},{default:w(()=>[(i(!0),g(V,null,C([void 0,t(o).TRACK,t(o).ARTIST,t(o).ALBUM,t(o).PLAYLIST,t(o).PODCAST,t(o).AUDIOBOOK,t(o).RADIO],r=>(i(),n(D,{key:r,text:l.$t(r?r+"s":"searchtype_all"),value:r},null,8,["text","value"]))),128))]),_:1},8,["modelValue"]),s.value?(i(),n(P,{key:0,color:"primary",indeterminate:"",title:l.$t("tooltip.loading")},null,8,["title"])):m("",!0),t(a).globalSearchType?s.value?m("",!0):(i(),g("div",x,[d(L,{itemtype:`${t(a).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async r=>k(t(a).globalSearchType),title:l.$t(`${t(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",_,[e.value&&!s.value?(i(),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&&!s.value?(i(),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&&!s.value?(i(),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&&!s.value?(i(),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&&!s.value?(i(),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&&!s.value?(i(),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&&!s.value?(i(),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{ne as default};
