PageSourceSearch

https://elixeum.ai/assets/AdminMedia-C8wtSEX6.js

js elixeum.ai collected 2026-10-05 13:48:39 UTC 6,692 bytes, 1 lines download raw bytes

1import{r as l,s as i,t as s,j as e}from"./index-Bvy_5jmS.js";import{B as d}from"./button-D5sF9850.js";import{T as A,a as D,b as S,c as T}from"./tabs-q9bmE0la.js";import{I as E}from"./image-DS2ZMRaN.js";import{W as z}from"./wand-sparkles-D2UXbd5i.js";import{L as h}from"./loader-circle-B8gGzI5I.js";import{U as B}from"./upload-B7SoysaR.js";import{C as F}from"./copy-BcziWyvy.js";import{T as I}from"./trash-2-CdIvh_2-.js";import"./index-DRx4Xw02.js";import"./index-Dpewa1sE.js";import"./index-nWgqpm3H.js";const Y=()=>{const[f,b]=l.useState([]),[G,v]=l.useState(!0),[g,j]=l.useState(!1),[c,y]=l.useState(""),[m,N]=l.useState(!1),[p,u]=l.useState(null),[w,k]=l.useState(!1),x=l.useCallback(async()=>{v(!0);const{data:a,error:t}=await i.storage.from("media").list("uploads",{limit:200,sortBy:{column:"created_at",order:"desc"}});if(t)s({title:"Chyba",description:t.message,variant:"destructive"});else{const o=(a||[]).filter(r=>r.name!==".emptyFolderPlaceholder").map(r=>{const{data:n}=i.storage.from("media").getPublicUrl(`uploads/${r.name}`);return{name:r.name,url:n.publicUrl,created_at:r.created_at||""}});b(o)}v(!1)},[]);l.useEffect(()=>{x()},[x]);const U=async a=>{const t=a.target.files;if(t!=null&&t.length){j(!0);for(const o of Array.from(t)){const r=o.name.split(".").pop(),n=`uploads/${Date.now()}_${Math.random().toString(36).slice(2,8)}.${r}`,{error:C}=await i.storage.from("media").upload(n,o,{contentType:o.type,upsert:!1});C&&s({title:"Chyba uploadu",description:C.message,variant:"destructive"})}s({title:"Nahráno"}),await x(),j(!1),a.target.value=""}},$=async a=>{if(!confirm(`Smazat ${a}?`))return;const{error:t}=await i.storage.from("media").remove([`uploads/${a}`]);t?s({title:"Chyba",description:t.message,variant:"destructive"}):(s({title:"Smazáno"}),b(o=>o.filter(r=>r.name!==a)))},P=a=>{navigator.clipboard.writeText(a),s({title:"URL zkopírováno"})},L=async()=>{var a;if(c.trim()){N(!0),u(null);try{const t=await i.functions.invoke("generate-media",{body:{prompt:c.trim()}});if(t.error)throw t.error;(a=t.data)!=null&&a.url?(u(t.data.url),s({title:"Obrázek vygenerován"})):s({title:"Chyba",description:"Nepodařilo se vygenerovat obrázek",variant:"destructive"})}catch(t){s({title:"Chyba generování",description:t.message,variant:"destructive"})}finally{N(!1)}}},_=async()=>{if(p){k(!0);try{const t=await(await fetch(p)).blob(),o=t.type.includes("png")?"png":"jpg",r=`uploads/ai_${Date.now()}.${o}`,{error:n}=await i.storage.from("media").upload(r,t,{contentType:t.type,upsert:!1});if(n)throw n;s({title:"Uloženo do knihovny"}),u(null),y(""),await x()}catch(a){s({title:"Chyba",description:a.message,variant:"destructive"})}finally{k(!1)}}};return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-heading font-bold text-foreground mb-6",children:"Média"}),e.jsxs(A,{defaultValue:"library",className:"space-y-6",children:[e.jsxs(D,{className:"bg-muted border border-purple-500/15",children:[e.jsxs(S,{value:"library",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-300",children:[e.jsx(E,{className:"w-4 h-4 mr-2"})," Knihovna"]}),e.jsxs(S,{value:"generate",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-300",children:[e.jsx(z,{className:"w-4 h-4 mr-2"})," Generovat AI"]})]}),e.jsxs(T,{value:"library",className:"space-y-6",children:[e.jsxs("label",{className:"flex items-center justify-center w-full h-32 border-2 border-dashed border-purple-500/30 rounded-xl cursor-pointer hover:border-purple-500/60 transition-colors bg-muted/50",children:[e.jsxs("div",{className:"flex flex-col items-center gap-2 text-muted-foreground",children:[g?e.jsx(h,{className:"w-6 h-6 animate-spin"}):e.jsx(B,{className:"w-6 h-6"}),e.jsx("span",{className:"text-sm",children:g?"Nahrávám…":"Klikněte nebo přetáhněte soubory"})]}),e.jsx("input",{type:"file",className:"hidden",multiple:!0,accept:"image/*",onChange:U,disabled:g})]}),G?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(h,{className:"w-6 h-6 animate-spin text-purple-400"})}):f.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-12",children:"Žádné soubory"}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 ga
1p-4",children:f.map(a=>e.jsxs("div",{className:"group relative rounded-xl overflow-hidden border border-purple-500/15 bg-muted",children:[e.jsx("img",{src:a.url,alt:a.name,className:"w-full aspect-square object-cover",loading:"lazy"}),e.jsxs("div",{className:"absolute inset-0 bg-background/80 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx(d,{size:"icon",variant:"ghost",className:"text-foreground hover:text-purple-300",onClick:()=>P(a.url),children:e.jsx(F,{className:"w-4 h-4"})}),e.jsx(d,{size:"icon",variant:"ghost",className:"text-foreground hover:text-red-400",onClick:()=>$(a.name),children:e.jsx(I,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"p-2",children:e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.name})})]},a.name))})]}),e.jsxs(T,{value:"generate",className:"space-y-6",children:[e.jsxs("div",{className:"glass-bg rounded-xl border border-purple-500/15 p-6 space-y-4",children:[e.jsx("label",{className:"block text-sm font-medium text-foreground/70",children:"Prompt (anglicky pro nejlepší výsledky)"}),e.jsx("textarea",{className:"w-full h-28 rounded-lg bg-muted border border-purple-500/15 p-3 text-sm text-foreground placeholder:text-muted-foreground focus:border-purple-500 focus:outline-none transition-colors resize-none",placeholder:"A modern ERP dashboard with purple gradient accents…",value:c,onChange:a=>y(a.target.value)}),e.jsxs(d,{onClick:L,disabled:m||!c.trim(),className:"brand-gradient text-white",children:[m?e.jsx(h,{className:"w-4 h-4 animate-spin mr-2"}):e.jsx(z,{className:"w-4 h-4 mr-2"}),m?"Generuji…":"Generovat obrázek"]})]}),m&&e.jsx("div",{className:"h-64 rounded-xl bg-muted border border-purple-500/15 animate-pulse flex items-center justify-center",children:e.jsx("span",{className:"text-muted-foreground text-sm",children:"Generuji obrázek…"})}),p&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("img",{src:p,alt:"Generated",className:"w-full max-w-2xl rounded-xl border border-purple-500/20"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(d,{onClick:_,disabled:w,className:"brand-gradient text-white",children:[w?e.jsx(h,{className:"w-4 h-4 animate-spin mr-2"}):null,"Uložit do knihovny"]}),e.jsx(d,{variant:"outline",onClick:()=>{u(null)},className:"border-purple-500/30 text-foreground/70 hover:text-foreground",children:"Zahodit"})]})]})]})]})]})};export{Y as default};

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.