1import{r as c,j as e,f as n,ag as w,X as N,e as r,s as o,t as d}from"./index-BTKcJhd6.js";import{L as t}from"./label-DfndO0Af.js";import{T as y}from"./textarea-sZDrAvhf.js";import{u as k,V as C}from"./VideoPlayer-CvKL9uP0.js";import{M as m}from"./MediaUpload-BId8sBuq.js";import{P as S}from"./plus-_lmLxQSS.js";import{S as z}from"./square-pen-CF5YtIjj.js";import"./images-AGqU-pFp.js";import"./upload-CWym_CQQ.js";const T={title:"",description:"",category:"zpravodajstvi",youtube_id:"",video_url:null,thumbnail_url:null,duration:"",views:"",show_name:"",show_id:null,is_live:!1,is_featured:!1,status:"published"};function M(){const{genres:x}=k(!0),[v,p]=c.useState([]),[h,j]=c.useState([]),[a,i]=c.useState(null),u=async()=>{const[{data:s},{data:l}]=await Promise.all([o.from("videos").select("*").order("published_at",{ascending:!1}),o.from("shows").select("id, name").order("name")]);p(s??[]),j(l??[])};c.useEffect(()=>{u()},[]);const g=async()=>{if(!a)return;if(!a.title)return d.error("Titulek je povinný");if(!a.youtube_id&&!a.video_url)return d.error("Zadej YouTube ID nebo URL videa");const s={...a,thumbnail_url:a.thumbnail_url||(a.youtube_id?`https://img.youtube.com/vi/${a.youtube_id}/maxresdefault.jpg`:null),published_at:a.status==="published"?new Date().toISOString():null},l=a.id?await o.from("videos").update(s).eq("id",a.id):await o.from("videos").insert(s);if(l.error)return d.error(l.error.message);d.success("Uloženo"),i(null),u()},b=async s=>{if(!confirm("Smazat video?"))return;const{error:l}=await o.from("videos").delete().eq("id",s);if(l)return d.error(l.message);d.success("Smazáno"),u()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-3xl font-bold",children:"Videa"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Správa video obsahu (TV, Shorts, Live)."})]}),e.jsxs(n,{onClick:()=>i({...T}),children:[e.jsx(S,{className:"mr-1.5 h-4 w-4"})," Nové video"]})]}),e.jsx("div",{className:"mt-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:v.map(s=>e.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-surface/40",children:[e.jsxs("div",{className:"relative aspect-video bg-muted",children:[s.thumbnail_url&&e.jsx("img",{src:s.thumbnail_url,alt:"",className:"h-full w-full object-cover"}),s.is_live&&e.jsx("span",{className:"absolute left-2 top-2 rounded bg-live px-1.5 py-0.5 text-[10px] font-bold uppercase text-white",children:"LIVE"}),s.is_featured&&e.jsx("span",{className:"absolute right-2 top-2 rounded bg-primary px-1.5 py-0.5 text-[10px] font-bold uppercase text-primary-foreground",children:"Featured"})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"line-clamp-2 text-sm font-semibold",children:s.title}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.category," ⢠",s.duration||"â"," ⢠",s.views||"â"]}),e.jsxs("div",{className:"mt-2 flex justify-end gap-1",children:[e.jsx(n,{size:"icon",variant:"ghost",onClick:()=>i(s),children:e.jsx(z,{className:"h-4 w-4"})}),e.jsx(n,{size:"icon",variant:"ghost",onClick:()=>b(s.id),children:e.jsx(w,{className:"h-4 w-4 text-destructive"})})]})]})]},s.id))}),a&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:e.jsxs("div",{className:"max-h-[90vh] w-full max-w-2xl overflow-auto rounded-2xl border border-border bg-background p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-display text-xl font-bold",children:a.id?"Upravit video":"Nové video"}),e.jsx(n,{size:"icon",variant:"ghost",onClick:()=>{confirm("ZavÅÃt bez uloženÃ? ZmÄny budou ztraceny.")&&i(null)},children:e.jsx(N,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-4 space-y-3",children:[(a.youtube_id||a.video_url)&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-lg bg-black",children:e.jsx(C,{youtubeId:a.youtube_id,videoUrl:a.video_url,poster:a.thumbnail_url,title:a.title})}),e.jsxs("div",{children:[e.jsx(t,{children:"Titulek"}),e.jsx(r,{value:a.title,onChange:s=>i({...a,title:s.target.value})})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Popis"}),e.jsx(y,{rows:3,value:a.description??"",onChange:s=>i({...a,description:s.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(t,{children:"YouTube ID"}),e.jsx(r,{value:a.youtube_id??"",onChange:s=>i({...a,youtube_id:s.target.value||null}),placeholder:"EhAemz1v7dQ"})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Vlastnà video (MP4)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{value:a.video_url??"",onChange:s=>i({...a,video_url:s.target.value||null}),placeholder:"URL"}),e.jsx(m,{kind:"video",accept:"video/*",label:"Nahrát",onUploaded:({url:s,mime:l})=>i({...a,video_url:s,youtube_id:null,...l?{}:{}})})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(t,{children:"Kategorie"}),e.jsx("select",{className:"h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm",value:a.category,onChange:s=>i({...a,category:s.target.value}),children:x.map(s=>e.jsx("option",{value:s.slug,children:s.name},s.slug))})]}),e.jsxs("div",{children:[e.jsx(t,{children:"PoÅad"}),e.jsxs("select",{className:"h-9 w-full rounded-md border border-input bg-transparent px-3 text-sm",value:a.show_id??"",onChange:s=>{const l=s.target.value||null,f=h.find(_=>_.id===l)?.name??a.show_name;i({...a,show_id:l,show_name:f})},children:[e.jsx("option",{value:"",children:"â žádný â"}),h.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(t,{children:"Délka"}),e.jsx(r,{value:a.duration??"",onChange:s=>i({...a,duration:s.target.value}),placeholder:"42:18"})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Views"}),e.jsx(r,{value:a.views??"",onChange:s=>i({...a,views:s.target.value}),placeholder:"128K"})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Show (text)"}),e.jsx(r,{value:a.show_name??"",onChange:s=>i({...a,show_name:s.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(t,{children:"Thumbnail"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{value:a.thumbnail_url??"",onChange:s=>i({...a,thumbnail_url:s.target.value}),placeholder:"URL (auto pro YouTube)"}),e.jsx(m,{kind:"image",accept:"image/*",label:"Nahrát",onUploaded:({url:s})=>i({...a,thumbnail_url:s})})]}),a.thumbnail_url&&e.jsx("img",{src:a.thumbnail_url,alt:"",className:"mt-2 aspect-video w-full rounded-md object-cover"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a.is_live,onChange:s=>i({...a,is_live:s.target.checked})})," Live"]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:a.is_featured,onChange:s=>i({...a,is_featured:s.target.checked})})," Featured"]}),e.jsxs("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs",value:a.status,onChange:s=>i({...a,status:s.target.value}),children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Publikováno"})]})]}),e.jsx(n,{className:"w-full",onClick:g,children:"Uložit"})]})]})})]})}export{M as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.