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