import{ax as A,d as k,aA as D,b as l,a7 as E,aB as j,M as _,at as C,aC as q}from"./app-QjDgb7aF.js";import{b as F,w as J,f as b,E as I,j as g,g as M,i as t,k as c,q as r,I as y,u as a,J as m,D as v,p as $,H as z,a as f}from"./vue-Cm77DuTi.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const G={class:"_formRoot"},K={class:"banner"},L={key:1},O=["src"],Q={class:"_formBlock"},ee=F({__name:"channel-editor",props:{channelId:{}},setup(B){const V=A(),d=B;let p=f(null),u=f(null),i=f(null),h=f(null),n=f(null);J(()=>n.value,async()=>{n.value==null?h.value=null:h.value=(await k("drive/files/show",{fileId:n.value})).url});async function w(){d.channelId!=null&&(p.value=await k("channels/show",{channelId:d.channelId}),u.value=p.value.name,i.value=p.value.description,n.value=p.value.bannerId,h.value=p.value.bannerUrl)}w();function x(){const s={name:u.value,description:i.value,bannerId:n.value};d.channelId?(s.channelId=d.channelId,k("channels/update",s).then(()=>{C()})):k("channels/create",s).then(e=>{C(),V.push(`/channels/${e.id}`)})}function S(s){q(s.currentTarget??s.target,null).then(e=>{n.value=e.id})}function N(){n.value=null}const T=b(()=>[]),U=b(()=>[]);return D(b(()=>d.channelId?{title:l.ts._channel.edit,icon:"ph-television ph-bold ph-lg"}:{title:l.ts._channel.create,icon:"ph-television ph-bold ph-lg"})),(s,e)=>{const H=I("MkPageHeader"),P=I("MkSpacer"),R=I("MkStickyContainer");return g(),M(R,null,{header:t(()=>[c(H,{actions:T.value,tabs:U.value},null,8,["actions","tabs"])]),default:t(()=>[c(P,{"content-max":700},{default:t(()=>[r("div",G,[c(E,{modelValue:a(u),"onUpdate:modelValue":e[0]||(e[0]=o=>y(u)?u.value=o:u=o),class:"_formBlock"},{label:t(()=>[m(v(a(l).ts.name),1)]),_:1},8,["modelValue"]),c(j,{modelValue:a(i),"onUpdate:modelValue":e[1]||(e[1]=o=>y(i)?i.value=o:i=o),class:"_formBlock"},{label:t(()=>[m(v(a(l).ts.description),1)]),_:1},8,["modelValue"]),r("div",K,[a(n)==null?(g(),M(_,{key:0,onClick:S},{default:t(()=>[e[4]||(e[4]=r("i",{class:"ph-plus ph-bold ph-lg"},null,-1)),m(" "+v(a(l).ts._channel.setBanner),1)]),_:1})):a(h)?(g(),$("div",L,[r("img",{src:a(h),style:{width:"100%"}},null,8,O),c(_,{onClick:e[2]||(e[2]=o=>N())},{default:t(()=>[e[5]||(e[5]=r("i",{class:"ph-trash ph-bold ph-lg"},null,-1)),m(" "+v(a(l).ts._channel.removeBanner),1)]),_:1})])):z("",!0)]),r("div",Q,[c(_,{primary:"",onClick:e[3]||(e[3]=o=>x())},{default:t(()=>[e[6]||(e[6]=r("i",{class:"ph-floppy-disk-back ph-bold ph-lg"},null,-1)),m(" "+v(B.channelId?a(l).ts.save:a(l).ts.create),1)]),_:1})])])]),_:1})]),_:1})}}});export{ee as default};
//# sourceMappingURL=channel-editor-Bbq3DdVe.js.map
