import{Q as $,be as C,bf as D,x as r,w as V,R as M,U as m,S as U,B as t,W as g,Y as A,bg as I,al as y,aa as c,a7 as h,a5 as w,a4 as v,b1 as N,a2 as R}from"./index-orrnp8a1.js";import{T as S}from"./Toolbar-CE2HDv9i.js";import{V as L}from"./VDialog-oxeMlk6d.js";import{V as f}from"./VTextField-DaF8PfrV.js";import{V as W}from"./VSpacer-FMK5QbR9.js";import{a as T}from"./VBtn-BJolvyKt.js";const x={style:{padding:"15px"}},_=$({__name:"AddManualLink",props:C({type:{}},{modelValue:{type:Boolean},modelModifiers:{}}),emits:["update:modelValue"],setup(p){const s=D(p,"modelValue"),B=p,u=r(""),n=r(""),d=r(""),i=r(!1),l=r();V(()=>s.value,e=>{e!=null&&(R.dialogActive=e),e==!1&&(u.value="",n.value="",d.value="",l.value=void 0)},{immediate:!0}),V(()=>l.value,e=>{if(e){n.value||(n.value=e.name);for(const a of e.metadata.images||[])if(a.type=="thumb"){d.value=a.path;break}}});const b=()=>{!u.value||!u.value.startsWith("http")||(i.value=!0,B.type==w.RADIO?v.getRadio(u.value,"builtin").then(e=>{l.value=e}).catch(e=>{console.error(e),l.value=void 0}).finally(()=>{i.value=!1}):v.getTrack(u.value,"builtin").then(e=>{l.value=e}).catch(e=>{console.error(e),l.value=void 0}).finally(()=>{i.value=!1}))},k=function(){b(),l.value&&(l.value.name=n.value||l.value.name,delete l.value.sort_name,d.value&&(l.value.metadata.images=[{type:N.THUMB,path:d.value,provider:"builtin",remotely_accessible:!0}]),v.addItemToLibrary(l.value,!0).then(()=>{s.value=!1}))};return(e,a)=>(U(),M(L,{modelValue:s.value,"onUpdate:modelValue":a[4]||(a[4]=o=>s.value=o),transition:"dialog-bottom-transition"},{default:m(()=>[t(h,null,{default:m(()=>[t(S,{icon:"mdi-playlist-plus",title:e.$t("add_url_item")},null,8,["title"]),t(A),a[5]||(a[5]=g("br",null,null,-1)),g("div",x,[t(f,{modelValue:u.value,"onUpdate:modelValue":a[0]||(a[0]=o=>u.value=o),variant:"outlined",label:e.$t("enter_url"),disabled:i.value,onBlur:b},null,8,["modelValue","label","disabled"]),t(f,{modelValue:n.value,"onUpdate:modelValue":a[1]||(a[1]=o=>n.value=o),variant:"outlined",label:e.$t("enter_name"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(f,{modelValue:d.value,"onUpdate:modelValue":a[2]||(a[2]=o=>d.value=o),variant:"outlined",label:e.$t("image_url"),disabled:i.value},null,8,["modelValue","label","disabled"]),t(I,null,{default:m(()=>[t(W),t(T,{variant:"outlined",onClick:a[3]||(a[3]=o=>s.value=!1)},{default:m(()=>[y(c(e.$t("cancel")),1)]),_:1}),t(T,{variant:"flat",color:"primary",disabled:i.value,onClick:k},{default:m(()=>[y(c(e.$t("save")),1)]),_:1},8,["disabled"])]),_:1})])]),_:1})]),_:1},8,["modelValue"]))}});export{_};
