import{C as A}from"./Container-CwfZ2VgM.js";import{I}from"./ItemsListing-D6AMqIYc.js";import{T as L}from"./Toolbar-MwYpbj3t.js";import{W as c}from"./WidgetRow-BRl9d1wg.js";import{u as V}from"./userPreferences-ln7cf3P6.js";import{s as r,M as a,c as C}from"./index-CxiRlsCY.js";import{d as B,r as v,w as y,o as O,a0 as R,b as f,e as i,H as d,u as o,aq as P,E as b,D as n,I as m,F as U,M as D}from"./lucide-C2DU1LFb.js";import{m as K,S as M,T as F,o as E}from"./vuetify-RelkxOq-.js";import"./index-kQIztB-E.js";import"./utils-CDN07tui.js";import"./vue-router-BgJK_hRC.js";import"./Button-DBt8j7D4.js";import"./ListItem-DzUpG5Dm.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-D7lqdhVg.js";import"./MediaItemThumb-C7OhU3lK.js";import"./ProviderIcon.vue_vue_type_style_index_0_lang-C17dV9_V.js";import"./vue-i18n-DySrp6mW.js";import"./PanelviewItemCompact-Cjl_ij1h.js";import"./qrcode-DSFhiIp2.js";import"./marked-C0Rlrcoy.js";import"./color-BTziYnFN.js";import"./vueuse-DIaEWNCo.js";/* empty css            */import"./swiper-Jy9GbtzK.js";const H={key:1},N={key:2},pe=B({__name:"Search",setup(W){const p=v(!1),t=v(),s=v(!1),g=v(),{getPreference:S,setPreference:k}=V();y(()=>r.globalSearchTerm,()=>{clearTimeout(g.value),g.value=setTimeout(()=>{h(r.globalSearchTerm,r.globalSearchType)},1e3)},{immediate:!0}),y(()=>r.globalSearchType,()=>{h(r.globalSearchTerm,r.globalSearchType)});const h=async function(e,u){s.value=!0,k("globalSearch",e||"");const l=r.globalSearchType?50:8,$=u?[u]:void 0;e?t.value=await C.search(e,$,l):t.value=void 0,s.value=!1};O(()=>{if(!r.globalSearchTerm){const e=S("globalSearch").value;e&&e!=="null"&&(r.globalSearchTerm=e)}});const w=function(e){e.ctrlKey||e.altKey||e.metaKey||(!p.value&&e.key=="Backspace"&&r.globalSearchTerm?r.globalSearchTerm=r.globalSearchTerm.slice(0,-1):!p.value&&e.key.length==1&&(r.globalSearchTerm+=e.key))};document.addEventListener("keyup",w),R(()=>{document.removeEventListener("keyup",w)});const T=function(e){return t.value?e==a.TRACK?t.value.tracks:e==a.ARTIST?t.value.artists:e==a.ALBUM?t.value.albums:e==a.PLAYLIST?t.value.playlists:e==a.PODCAST?t.value.podcasts:e==a.AUDIOBOOK?t.value.audiobooks:e==a.RADIO?t.value.radio:[]:[]};return(e,u)=>(i(),f("section",null,[d(L,{icon:o(P),title:e.$t("global_search")},null,8,["icon","title"]),d(A,{variant:"default"},{default:b(()=>[d(K,{id:"searchInput",modelValue:o(r).globalSearchTerm,"onUpdate:modelValue":u[0]||(u[0]=l=>o(r).globalSearchTerm=l),clearable:"","prepend-inner-icon":"mdi-magnify",label:e.$t("type_to_search"),"hide-details":"",variant:"outlined",onFocus:u[1]||(u[1]=l=>p.value=!0),onBlur:u[2]||(u[2]=l=>p.value=!1)},null,8,["modelValue","label"]),d(M,{modelValue:o(r).globalSearchType,"onUpdate:modelValue":u[3]||(u[3]=l=>o(r).globalSearchType=l),style:{"margin-top":"10px","margin-left":"10px"}},{default:b(()=>[(i(!0),f(U,null,D([void 0,o(a).TRACK,o(a).ARTIST,o(a).ALBUM,o(a).PLAYLIST,o(a).PODCAST,o(a).AUDIOBOOK,o(a).RADIO],l=>(i(),n(E,{key:l,text:e.$t(l?l+"s":"searchtype_all"),value:l},null,8,["text","value"]))),128))]),_:1},8,["modelValue"]),s.value?(i(),n(F,{key:0,color:"accent",height:"4",indeterminate:"",rounded:"",style:{"margin-top":"15px"}})):m("",!0),o(r).globalSearchType?s.value?m("",!0):(i(),f("div",N,[d(I,{itemtype:`${o(r).globalSearchType}s`,"show-provider":!0,"show-favorites-only-filter":!1,"show-select-button":!1,"show-refresh-button":!1,"load-items":async l=>T(o(r).globalSearchType),title:e.$t(`${o(r).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(),f("div",H,[t.value&&!s.value?(i(),n(c,{key:0,"widget-row":{title:e.$t("tracks"),icon:"mdi-file-music",items:t.value.tracks},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:1,"widget-row":{title:e.$t("artists"),icon:"mdi-account-music",items:t.value.artists},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:2,"widget-row":{title:e.$t("albums"),icon:"mdi-album",items:t.value.albums},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:3,"widget-row":{title:e.$t("playlists"),icon:"mdi-playlist-music",items:t.value.playlists},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:4,"widget-row":{title:e.$t("podcasts"),icon:"mdi-podcast",items:t.value.podcasts},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:5,"widget-row":{title:e.$t("audiobooks"),icon:"mdi-book-play-outline",items:t.value.audiobooks},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0),t.value&&!s.value?(i(),n(c,{key:6,"widget-row":{title:e.$t("radios"),icon:"mdi-radio",items:t.value.radio},"show-provider-on-cover":!0},null,8,["widget-row"])):m("",!0)]))]),_:1})]))}});export{pe as default};
