Githubgemini / assets /AiImageGenerator-CoAidnKa.js
admin08077's picture
Upload 121 files
e025d49 verified
import{r as o,j as e}from"./react-DKy9e2uO.js";import{J as f,K as b,L as m,S as j,A as y}from"./index-Ykf-MVva.js";import"./bottleneck-Cpj98o6Y.js";import"./react-dom-CpxHE_eW.js";import"./scheduler-DYLXRpC5.js";import"./idb-Dob3nYDb.js";import"./@google-D80DdW2m.js";import"./marked-CesSW9Du.js";import"./jszip-s56H2EZ-.js";const p=["A majestic lion wearing a crown, painted in the style of Van Gogh.","A futuristic cityscape on another planet with two moons in the sky.","A cozy, magical library inside a giant tree.","A surreal image of a ship sailing on a sea of clouds.","An astronaut riding a space-themed bicycle on the moon."],E=()=>{const[t,i]=o.useState("A photorealistic image of a futuristic city at sunset, with flying cars."),[s,c]=o.useState(null),[a,d]=o.useState(!1),[n,l]=o.useState(""),u=o.useCallback(async()=>{if(!t.trim()){l("Please enter a prompt to generate an image.");return}d(!0),l(""),c(null);try{const r=await f(t);c(r)}catch(r){const h=r instanceof Error?r.message:"An unknown error occurred.";l(`Failed to generate image: ${h}`)}finally{d(!1)}},[t]),g=()=>{const r=p[Math.floor(Math.random()*p.length)];i(r)},x=()=>{if(!s)return;const r=document.createElement("a");r.href=s,r.download=`${t.slice(0,30).replace(/\s/g,"_")}.png`,document.body.appendChild(r),r.click(),document.body.removeChild(r)};return e.jsxs("div",{className:"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary",children:[e.jsxs("header",{className:"mb-6",children:[e.jsxs("h1",{className:"text-3xl font-bold flex items-center",children:[e.jsx(b,{}),e.jsx("span",{className:"ml-3",children:"AI Image Generator"})]}),e.jsx("p",{className:"text-text-secondary mt-1",children:"Generate stunning, high-quality images from text prompts using Imagen 3."})]}),e.jsxs("div",{className:"flex flex-col gap-4 mb-4",children:[e.jsx("label",{htmlFor:"prompt-input",className:"text-sm font-medium text-text-secondary",children:"Your Prompt"}),e.jsx("textarea",{id:"prompt-input",value:t,onChange:r=>i(r.target.value),placeholder:"e.g., A cute cat wearing a wizard hat",className:"w-full p-3 rounded-md bg-surface border border-border focus:ring-2 focus:ring-primary focus:outline-none resize-y",rows:3}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:u,disabled:a,className:"btn-primary w-full flex items-center justify-center px-6 py-3",children:a?e.jsx(m,{}):"Generate Image"}),e.jsx("button",{onClick:g,disabled:a,className:"px-4 py-3 bg-surface border border-border rounded-md hover:bg-gray-100 transition-colors",title:"Surprise Me!",children:e.jsx(j,{})})]})]}),e.jsxs("div",{className:"flex-grow flex items-center justify-center bg-background border-2 border-dashed border-border rounded-lg p-4 relative overflow-auto",children:[a&&e.jsx(m,{}),n&&e.jsx("p",{className:"text-red-500 text-center",children:n}),s&&!a&&e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s,alt:t||"Generated by AI",className:"max-w-full max-h-full object-contain rounded-md shadow-lg"}),e.jsx("button",{onClick:x,className:"absolute top-4 right-4 p-2 bg-black/30 text-white rounded-full hover:bg-black/50 backdrop-blur-sm",title:"Download Image",children:e.jsx(y,{})})]}),!a&&!s&&!n&&e.jsx("div",{className:"text-center text-text-secondary",children:e.jsx("p",{children:"Your generated image will appear here."})})]})]})};export{E as AiImageGenerator};
//# sourceMappingURL=AiImageGenerator-CoAidnKa.js.map