PageSourceSearch

https://aiedit.com/assets/RemixPanel-B5fhEDdp.js

js aiedit.com collected 2026-10-02 00:28:14 UTC 45,857 bytes, 1 lines download raw bytes

1import{A as ye,j as e,u as Ss,e as Rs,i as Ls,a5 as Us,a4 as Is,l as Es,a9 as Oe,ae as $e,n as Fe,q as Te,t as ze,w as Ds,ac as As,ad as Ps}from"./index-QRiPE925.js";import{r as t,d as Os}from"./vendor-react-C2vrxknb.js";import{u as $s}from"./useDebounce-ClLI-4oZ.js";import{E as Fs}from"./ErrorOverlay-CgYLOVuA.js";import Ts from"./MaintenanceModal-YiITyeCQ.js";import{C as zs}from"./CustomCheckbox-lqS10wWM.js";import{R as Ws,a as Hs}from"./RemixGridResult-LKZzJ44a.js";import{a as _s,C as Bs}from"./ChatMediaModal-D3JWDUXa.js";import{A as Vs}from"./AspectRatioButton-DAlWChyf.js";import{R as Gs}from"./ResolutionToggle-BWuo-DYZ.js";import{R as qs}from"./ResolutionButton-CeRXLpAG.js";import{M as Ks}from"./ModelSelectorButton-B9yXiSWh.js";import{M as Js}from"./ModelSettingsModal-w12D5J3F.js";import{P as Xs}from"./PanelActionButton-Bd-VlIG4.js";import{i as We,c as Zs}from"./photoHelpers-DYeHDDqL.js";import"./DateFilterCalendar-DTkZ2pL4.js";import"./AudioWaveformPlayer-ewv8YM_7.js";import"./index-IFimuDji.js";const je=(n,g)=>n?.r2_urls?n.r2_urls[g]?n.r2_urls[g]:n.r2_urls.gallery?n.r2_urls.gallery:null:null,Qs=({isOpen:n,onClose:g})=>{const[m,S]=t.useState(null),[c,f]=t.useState(!0),[j,N]=t.useState(!1),[k,b]=t.useState("original"),i=t.useRef(null);t.useEffect(()=>{n&&(O(),b("original"))},[n]),t.useEffect(()=>{if(!m||c)return;const u=()=>{b("original");const p=setTimeout(()=>{b("grid")},2500),L=setTimeout(()=>{b("result")},5e3),P=setTimeout(()=>{u()},8e3);i.current={gridTimer:p,resultTimer:L,loopTimer:P}};return u(),()=>{i.current&&(clearTimeout(i.current.gridTimer),clearTimeout(i.current.resultTimer),clearTimeout(i.current.loopTimer))}},[m,c]);const O=async()=>{try{f(!0);const u=await fetch(`${ye}/api/gallery?filter=remix&limit=1&shuffle=1`);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);const p=await u.json();p.success&&p.items.length>0&&S(p.items[0])}catch(u){console.error("Failed to fetch remix examples:",u)}finally{f(!1)}},$=()=>{j&&localStorage.setItem("remixWelcomeOverlayDismissed","true"),g()},F=()=>{j&&localStorage.setItem("remixWelcomeOverlayDismissed","true"),g()};if(!n)return null;const R=m?.config?.settings||{},C=R.gridSize??m?.config?.gridSize??"3x3";let d;if(typeof C=="number"&&C>0)d=C;else if(typeof C=="string"){const u=parseInt(C.split("x")[0],10);d=u>0?u:3}else d=3;const X=d*d,I=R.gridCellToUpscale!=null?R.gridCellToUpscale-1:0,E=Math.min(Math.max(I,0),X-1),M=100/d,Z=R.gridAspectRatio||"1:1",A=u=>{switch(u){case"1:1":return"aspect-square";case"16:9":return"aspect-[16/9]";case"9:16":return"aspect-[9/16]";case"4:3":return"aspect-[4/3]";case"3:4":return"aspect-[3/4]";case"3:2":return"aspect-[3/2]";case"2:3":return"aspect-[2/3]";default:return"aspect-square"}};return e.jsx("div",{className:"fixed sm:absolute inset-0 bg-black/90 sm:bg-black/80 sm:rounded-lg md:rounded-xl lg:rou
1nded-2xl flex items-center justify-center z-50 p-2 xs:p-4",children:e.jsxs("div",{className:"bg-app-bg rounded-lg xs:rounded-xl w-full max-w-4xl max-h-[90%] overflow-hidden animate-slideUp flex flex-col",children:[e.jsxs("div",{className:"relative bg-panel-bg p-3 xs:p-4 border-b border-border-default/50",children:[e.jsx("button",{onClick:F,className:"absolute top-1/2 right-2 xs:right-3 transform -translate-y-1/2 p-1 text-gray-400 hover:text-white hover:bg-input-bg rounded-lg transition-all duration-200",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("div",{className:"flex items-center gap-2 xs:gap-3",children:[e.jsx("div",{className:"w-5 h-5 sm:w-6 sm:h-6 text-purple-400",children:e.jsx("svg",{className:"w-full h-full",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1v-4zM14 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})})}),e.jsx("div",{children:e.jsx("h2",{className:"text-lg xs:text-xl font-semibold text-gray-200",children:"Introduction"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 xs:p-4 sm:p-6",children:e.jsxs("div",{className:"flex flex-col lg:flex-row gap-3 sm:gap-4 lg:gap-6",children:[e.jsxs("div",{className:"flex-1 flex flex-col justify-center space-y-4 sm:space-y-6 lg:space-y-8",children:[e.jsx("div",{className:"flex items-center",children:e.jsxs("p",{className:"text-sm xs:text-base lg:text-base text-gray-300 leading-relaxed",children:[e.jsx("span",{className:"block sm:hidden",children:"Generate multiple creative variations of your image. Choose your favorite and upscale it to high resolution."}),e.jsx("span",{className:"hidden sm:block lg:hidden",children:"Generate multiple creative variations of your image. Choose your favorite and upscale it to high resolution."}),e.jsx("span",{className:"hidden lg:block",children:"Generate multiple creative variations of your image. Browse through the generated grid, select your favorite variation, and upscale it to high resolution for the best quality output."})]})}),e.jsxs("div",{className:"hidden sm:grid grid-cols-2 lg:grid-cols-2 gap-2 sm:gap-3 lg:gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 xs:gap-3 text-xs xs:text-sm",children:[e.jsx("div",{className:"w-5 h-5 xs:w-6 xs:h-6 lg:w-8 lg:h-8 bg-purple-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-2.5 h-2.5 xs:w-3 xs:h-3 lg:w-4 lg:h-4 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z"})})}),e.jsx("span",{className:"text-gray-300",children:"4/9 variations at once"})]}),e.jsxs("div",{className:"flex items-center gap-2 xs:gap-3 text-xs xs:text-sm",children:[e.jsx("div",{className:"w-5 h-5 xs:w-6 xs:h-6 lg:w-8 lg:h-8 bg-purple-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsxs("svg",{className:"w-2.5 h-2.5 xs:w-3 xs:h-3 lg:w-4 lg:h-4 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21 21l-4.35-4.35"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 8v6M8 11h6"})]})}),e.jsx("span",{className:"text-gray-300",children:"Upscale favorites"})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 xs:gap-3 text-xs xs:text-sm",children:[e.jsx("div",{className:"w-5 h-5 xs:w-6 xs:h-6 lg:w-8 lg:h-8 bg-purple-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-2.5 h-2.5 xs:w-3 xs:h-3 lg:w-4 lg:h-4 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),e.jsx("span",{className:"text-gray-300",children:"Text prompts"})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 xs:gap-3 text-xs xs:text-sm",children:[e.jsx("div",{className:"w-5 h-5 xs:w-6 xs:h-6 lg:w-8 lg:h-8 bg-purple-500/20 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-2.5 h-2.5 xs:w-3 xs:h-3 lg:w-4 lg:h-4 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 3.75H6A2.25 2.25 0 003.75 6v1.5M16.5 3.75H18A2.25 2.25 0 0120.25 6v1.5m0 9V18A2.25 2.25 0 0118 20.25h-1.5m-9 0H6A2.25 2.25 0 013.75 18v-1.5"})})}),e.jsx("span",{className:"text-gray-300",children:"Several aspect ratios"})]})]})]}),e.jsx("div",{className:"flex-1 lg:max-w-lg max-w-xs sm:max-w-sm mx-auto lg:mx-0 lg:[@media(max-height:800px)]:max-w-[350px]",children:c?e.jsx("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg rounded-lg sm:rounded-xl p-4 sm:p-6 lg:p-8 flex items-center justify-center border border-border-emphasis/20 min-h-[200px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-5 w-5 sm:h-6 sm:w-6 lg:h-8 lg:w-8 border-b-2 border-purple-400 mx-auto mb-2 lg:mb-3"}),e.jsx("p",{className:"text-gray-400 text-xs sm:text-sm",children:"Loading example..."})]})}):m?e.jsxs("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg rounded-lg sm:rounded-xl p-2 sm:p-3 lg:p-4 border border-border-emphasis/20",children:[e.jsx("div",{className:"relative flex items-center justify-center min-h-[240px] sm:min-h-[280px]",children:e.jsxs("div",{className:"relative bg-panel-bg rounded-md lg:rounded-lg overflow-hidden w-[240px] h-[240px] sm:w-[280px] sm:h-[280px] lg:w-[400px] lg:h-[400px]",children:[e.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[e.jsx("img",{src:je(m,"original"),alt:"Original image",className:`absolute inset-0 w-full h-full object-contain transition-opacity duration-700 ease-in-out ${k==="original"?"opacity-100":"opacity-0"}`}),e.jsx("div",{className:`absolute inset-0 w-full h-full flex items-center justify-center transition-opacity duration-700 ease-in-out ${k==="grid"?"opacity-100":"opacity-0"}`,children:e.jsxs("div",{className:`relative ${A(Z)} max-w-full max-h-full`,style:["9:16","3:4","2:3","1:1"].includes(Z)?{height:"9999px"}:{width:"9999px"},children:[e.jsx("img",{src:je(m,"grid"),alt:"Grid variations",className:"w-full h-full object-cover rounded-lg"}),e.jsx("div",{className:"absolute inset-0 pointer-events-none rounded-lg overflow-hidden",children:Array.from({length:X},(u,p)=>{const L=p===E,P=Math.floor(p/d),Q=p%d;return e.jsx("div",{className:`absolute ${L?"bg-purple-500/50":""}`,style:{left:`${Q*M}%`,top:`${P*M}%`,width:`${M}%`,height:`${M}
1%`},children:L&&e.jsx("div",{className:"absolute top-1 right-1 bg-purple-500 text-white text-xs font-bold w-4 h-4 rounded flex items-center justify-center",children:p+1})},p)})})]})}),e.jsx("img",{src:je(m,"upscaled"),alt:"Upscaled result",className:`absolute inset-0 w-full h-full object-contain transition-opacity duration-700 ease-in-out ${k==="result"?"opacity-100":"opacity-0"}`})]}),e.jsxs("div",{className:"absolute bottom-2 left-1/2 transform -translate-x-1/2 bg-black/70 px-3 py-1.5 rounded-lg text-xs text-white font-medium pointer-events-none flex items-center gap-2",children:[k==="original"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-2 h-2 bg-gray-400 rounded-full"}),"Original"]}),k==="grid"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-2 h-2 bg-purple-500 rounded-full animate-pulse"}),"Cell ",E+1," Selected"]}),k==="result"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Upscaled Result"]})]}),e.jsxs("div",{className:"absolute top-2 left-1/2 transform -translate-x-1/2 flex gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors duration-300 ${k==="original"?"bg-white":"bg-white/30"}`}),e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors duration-300 ${k==="grid"?"bg-purple-500":"bg-white/30"}`}),e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors duration-300 ${k==="result"?"bg-green-500":"bg-white/30"}`})]})]})}),R.prompt&&e.jsx("div",{className:"mt-2 sm:mt-3 px-1",children:e.jsxs("div",{className:"flex items-start gap-2 text-xs sm:text-sm text-gray-400",children:[e.jsx("svg",{className:"w-3.5 h-3.5 sm:w-4 sm:h-4 mt-0.5 flex-shrink-0 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})}),e.jsxs("span",{className:"italic line-clamp-2",children:['"',R.prompt,'"']})]})})]}):e.jsx("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg rounded-lg sm:rounded-xl p-4 sm:p-6 border border-border-emphasis/20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-6 h-6 sm:w-8 sm:h-8 lg:w-12 lg:h-12 bg-purple-500/20 rounded-full flex items-center justify-center mx-auto mb-2 lg:mb-3",children:e.jsx("svg",{className:"w-3 h-3 sm:w-4 sm:h-4 lg:w-6 lg:h-6 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}),e.jsxs("p",{className:"text-gray-400 text-xs sm:text-sm",children:[e.jsx("span",{className:"block sm:hidden",children:"Start remixing!"}),e.jsx("span",{className:"hidden sm:block",children:"Upload an image to see amazing remix variations!"})]})]})})})]})}),e.jsx("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg p-3 sm:p-4 lg:p-6 border-t border-border-emphasis/20",children:e.jsxs("div",{className:"flex flex-col xs:flex-row items-start xs:items-center justify-between gap-3 sm:gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs sm:text-sm text-gray-300 cursor-pointer group",children:[e.jsx(zs,{checked:j,onChange:u=>N(u.target.checked),colorFrom:"purple-500",colorTo:"pink-500",borderColor:"purple-500",size:"small"}),e.jsxs("span",{className:"select-none group-hover:text-white transition-colors duration-200",children:[e.jsx("span",{className:"block xs:hidden",children:"Don't show again"}),e.jsx("span",{className:"hidden xs:block",children:"Don't show again"})]})]}),e.jsxs("button",{onClick:$,className:"group relative w-full xs:w-auto px-4 sm:px-6 py-2.5 sm:py-3 rounded-xl font-medium sm:font-semibold transition-all duration-300 ease-out transform hover:scale-[1.02] focus:scale-[1.02] active:scale-95 focus:outline-none focus:ring-2 focus:ring-purple-400/50 focus:ring-offset-2 focus:ring-offset-app-bg overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-purple-500 to-pink-500 transition-all duration-300"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent -translate-x-full group-hover:translate-x-full transition-transform duration-1000 ease-out"}),e.jsxs("div",{className:"relative z-10 flex items-center justify-center gap-2 text-white",children:[e.jsx("span",{className:"text-sm sm:text-base",children:"Start Remixing"}),e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 transition-transform duration-200 group-hover:translate-x-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13 7l5 5m0 0l-5 5m5-5H6"})})]})]})]})})]})})},oe=["resolution","size"],Ge=[{id:"1:1",name:"Square",label:"1:1"},{id:"16:9",name:"Landscape",label:"16:9"},{id:"9:16",name:"Portrait",label:"9:16"}],Ys="google/nano-banana-pro",He=(n,g)=>{for(const m of g){const S=m.models.find(c=>c.id===n);if(S)return S}return null},_e=async n=>{if(n.status===503){const g=await n.json();return{isMaintenanceMode:!0,message:g.message||"Service is currently under maintenance. Please try again later.",duration:g.duration}}return{isMaintenanceMode:!1}},Be=(n,g)=>{const m=n/g;let S="1:1",c=1/0;return Ge.forEach(f=>{const[j,N]=f.id.split(":").map(Number),k=j/N,b=Math.abs(m-k);b<c&&(c=b,S=f.id)}),S},Ve=(n,g,m=3)=>new Promise((S,c)=>{const f=new Image;f.crossOrigin="anonymous",f.onload=()=>{try{const N=document.createElement("canvas"),k=N.getContext("2d"),b=f.width/m,i=f.height/m,O=Math.floor(g/m),F=g%m*b,R=O*i;N.width=b,N.height=i,k.drawImage(f,F,R,b,i,0,0,b,i),N.toBlob(C=>{C?S({blob:C,width:b,height:i}):c(new Error("Failed to create blob from canvas"))},"image/png",1)}catch(N){c(N)}},f.onerror=()=>{c(new Error("Failed to load grid image"))};const j=n.includes("?")?`${n}&t=${Date.now()}`:`${n}?t=${Date.now()}`;f.src=j}),bt=({onShowAuthModal:n,className:g="",chats:m=[]})=>{const{isAuthenticated:S}=Ss();Os();const[c,f]=t.useState(null),[j,N]=t.useState(null),[k,b]=t.useState(null),[i,O]=t.useState(!1),[$,F]=t.useState(!1),[R,C]=t.useState(!1),[d,X]=t.useState(3),[I,E]=t.useState("1:1"),[M,Z]=t.useState(Ys),[A,u]=t.useState([]),[p,L]=t.useState("2k"),[P,Q]=t.useState(""),[Ne,x]=t.useState(null),[qe,h]=t.useState(null),[Ke,ne]=t.useState(!1),[Je,ke]=t.useState(""),[Xe,Ce]=t.useState(""),[Ze,Me]=t.useState(!1),[Y,T]=t.useState(null),[ie,V]=t.useState(null),[G,z]=t.useState([]),[Se,W]=t.useState(null),[Qe,de]=t.useState(!1),[w,ce]=t.useState(null),[Ye,me]=t.useState(!1),[D,ue]=t.useState(null),[es,pe]=t.useState(""),[ss,ts]=t.useState([]),[rs,Re]=t.useState(!1),[ee,Le]=t.useState({}),Ue=t.useRef(null),ls=t.useRef(null),[Ie,xe]=t.useState(!1),[Ee,he]=t.useState(!1),se=t.useRef(0),[q,te]=t.useState(!1),[as,ge]=t.useState(!1),[K,H]=t.useState(!1);t.useEffect(()=>{localStorage.getItem("remixWelcomeOverlayDismissed")||Me(!0)},[]),t.useEffect(()=>{(async()=>{await Ls(),ts(Us()),u(Is())})()},[]);const J=t.useMemo(()=>He(M,A),[M,A]),_=t.useMemo(()=>{const s=J?.displayParameters;return s&&(s.resolution||s.size||Object.values(s).find(l=>l?.displayName==="Resolution"))||null},[J]),fe=t.useMemo(()=>_?.parameterValues?.map(s=>({value:s.value,label:s.displayName}))||[],[_]);t.useEffect(()=>{_?.defaultValue&&L(_.defaultValue)},[_]);const os=t.useMemo(()=>J?.displayParameters?Object.keys(J.displayParameters).some(s=>!oe.includes(s)):!1,[J]);t.useEffect(()=>{Le({})},[M]);const ns=s=>{Le(s)},De=t.useMemo(()=>
1{if(!S||!M)return null;const s={};return p&&(s.resolution=p),Object.entries(ee||{}).forEach(([l,r])=>{oe.includes(l)||r===""||r===null||r===void 0||(s[l]=r)}),{operation:"remix",processingParams:{model:M,aspectRatio:I,displayParams:s}}},[S,M,I,p,ee]),is=De?JSON.stringify(De):null,be=$s(is,350),[ds,re]=t.useState(null);t.useEffect(()=>{if(!be){re(null);return}const s=JSON.parse(be);if(!s?.processingParams?.model){re(null);return}const l=new AbortController;return Rs(s.operation,s.processingParams,l.signal).then(r=>{r?.aborted||(r?.success&&typeof r.creditCost=="number"?re(r.creditCost):re(null))}),()=>l.abort()},[be]),t.useEffect(()=>{const s=l=>{!l.target.closest(".source-upload-action-menu")&&!l.target.closest(".source-uploader")&&q&&te(!1)};if(q)return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[q]);const Ae=async s=>{if(!s)return;te(!1);let l=s;if(await We(s)){he(!0);try{l=await Zs(s)}catch(a){console.error("HEIC conversion failed:",a),x("Failed to convert HEIC image. Please try a different format."),h("general"),he(!1);return}he(!1)}const r=URL.createObjectURL(l);f(l),N(r),T(null),V(null),z([]),W(null),x(null),h(null),H(!1);const o=new Image;o.onload=()=>{const{width:a,height:v}=o;b({width:a,height:v});const y=Be(a,v);E(y)},o.onerror=()=>{console.error("Failed to load image for dimension detection"),E("1:1")},o.src=r},cs=s=>{const l=s.target.files[0];Ae(l),s.target.value=""},ms=s=>{s.preventDefault(),s.stopPropagation(),se.current++,s.dataTransfer.types.includes("Files")&&xe(!0)},us=s=>{s.preventDefault(),s.stopPropagation(),se.current--,se.current===0&&xe(!1)},ps=s=>{s.preventDefault(),s.stopPropagation()},xs=async s=>{s.preventDefault(),s.stopPropagation(),xe(!1),se.current=0;const l=s.dataTransfer.files;if(l&&l.length>0){const r=l[0];(r.type.startsWith("image/")||await We(r))&&Ae(r)}},hs=()=>{te(!q)},gs=()=>{Ue.current?.click()},fs=()=>{te(!1),ge(!0)},bs=async s=>{ge(!1);try{f({url:s,isFromHistory:!0,isHistoryImage:!0}),N(s),T(null),V(null),z([]),W(null),x(null),h(null),H(!1);const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{const{width:a,height:v}=r;b({width:a,height:v});const y=Be(a,v);E(y)},r.onerror=()=>{console.error("Failed to load chat image for dimension detection"),E("1:1")};const o=s.includes("?")?`${s}&t=${Date.now()}`:`${s}?t=${Date.now()}`;r.src=o}catch(l){console.error("Error loading image from chat:",l),x("Failed to load image from chat"),h("general")}},vs=()=>{j&&j.startsWith("blob:")&&URL.revokeObjectURL(j),f(null),N(null),b(null),T(null),V(null),z([]),W(null),x(null),h(null),H(!1)},ws=s=>{s.key==="Enter"&&(s.metaKey||s.ctrlKey)&&(s.preventDefault(),Pe())},Pe=async()=>{if(!(!c||i)){if(!S){n?.();return}x(null),h(null),O(!0),T(null),z([]),W(null);try{const s=c&&(c.isFromHistory||c.isHistoryImage);let l;if(s)l=c.url;else if(l=(await Es({image:c})).image,!l)throw new Error("Failed to upload image");const r={};Object.entries(ee).forEach(([y,U])=>{oe.includes(y)||U===""||U===null||U===void 0||(r[y]=U)});const o=await fetch(`${ye}/api/processing/image/remix`,{method:"POST",headers:{"Content-Type":"application/json",...Oe()},body:JSON.stringify({image_url:l,model:M,grid_size:d,aspect_ratio:I,resolution:p,instruction:P.trim()||null,is_from_history:s,...Object.keys(r).length>0&&{display_params:r}})}),a=await _e(o);if(a.isMaintenanceMode){ke(a.message),Ce(a.duration||""),ne(!0);return}const v=await o.json();if(!o.ok)throw new Error(v.error||"Failed to generate remix");if(v.jobId){const y=await $e(v.jobId),U=y.output?.url||y.url;if(!U)throw new Error("No image was generated");T(`${U}?t=${Date.now()}`),V({gridSize:d,aspectRatio:I,originalImageUrl:l}),H(!0)}else if(v.success&&v.url)T(`${v.url}?t=${Date.now()}`),V({gridSize:d,aspectRatio:I,originalImageUrl:l}),H(!0);else throw new Error("No image was generated")}catch(s){console.error("Remix error:",s),Fe(s.message)?(x(s.message),h("credits")):Te(s.message)?(x(s.message),h("content_policy")):ze(s.message)?(x(s.message),h("rate-limit")):Ds(s.message)?(x("Please log in to use remix."),h("general"),n?.()):(x(s.message||"Something went wrong. Please try again."),h("general"))}finally{O(!1)}}},js=(s,l,r,o,a)=>{$||R||(ce({gridImageUrl:s,cellIndex:l,originalImageUrl:r,gridSize:o,aspectRatio:a}),de(!0))},ys=async(s,l,r,o)=>{if(!R){C(!0);try{const{blob:a}=await Ve(s,l,r),v=URL.createObjectURL(a);ue(v),pe(`Variation ${l+1}`),me(!0)}catch(a){console.error("Failed to extract cell for preview:",a),x("Failed to preview cell. Please try again."),h("general")}finally{C(!1)}}},Ns=async({model:s,aspectRatio:l,resolution:r})=>{if(!w)return;const o=w.cellIndex;de(!1),C(!0),F(!0),W(o),x(null),h(null);try{const{blob:a}=await Ve(w.gridImageUrl,w.cellIndex,w.gridSize),v=new File([a],`cell-${w.cellIndex}.png`,{type:"image/png"}),y=await As("remix-cell.png","image/png",v.size);if(!y.success)throw new Error(y.error||"Failed to generate upload URL");await Ps(y.uploadUrl,v);const U=y.publicUrl;C(!1);const ve=await fetch(`${ye}/api/processing/image/remix-upscale`,{method:"POST",headers:{"Content-Type":"application/json",...Oe()},body:JSON.stringify({model:s,cell_image_url:U,original_image_url:w.originalImageUrl,grid_image_url:w.gridImageUrl,cell_index:w.cellIndex,row:Math.floor(w.cellIndex/w.gridSize),col:w.cellIndex%w.gridSize,aspect_ratio:l,resolution:r})}),we=await _e(ve);if(we.isMaintenanceMode){ke(we.message),Ce(we.duration||""),ne(!0);return}const B=await ve.json();if(!ve.ok)throw new Error(B.error||"Failed to upscale");let le;if(B.jobId){const ae=await $e(B.jobId);if(le=ae.output?.url||ae.url,!le)throw new Error("No image was generated")}else if(B.success&&B.url)le=B.url;else throw new Error("No image was generated");const Ms={url:`${le}?t=${Date.now()}`,cellIndex:o,timestamp:Date.now()};z(ae=>[...ae,Ms])}catch(a){console.error("Upscale error:",a),Fe(a.message)?(x(a.message),h("credits")):Te(a.message)?(x(a.message),h("content_policy")):ze(a.message)?(x(a.message),h("rate-limit")):(x(a.message||"Something went wrong. Please try again."),h("general"))}finally{C(!1),F(!1),W(null),ce(null)}},ks=()=>{D&&D.startsWith("blob:")&&URL.revokeObjectURL(D),me(!1),ue(null),pe("")};t.useEffect(()=>()=>{j&&j.startsWith("blob:")&&URL.revokeObjectURL(j),D&&D.startsWith("blob:")&&URL.revokeObjectURL(D)},[]);const Cs=Y||G.length>0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:ls,className:`relative flex-1 bg-panel-bg rounded-lg sm:rounded-xl lg:rou
1nded-2xl p-2 sm:p-3 lg:p-4 flex flex-col md:flex-row gap-3 md:gap-4 min-h-0 h-full overflow-auto ${g}`,onDragEnter:ms,onDragLeave:us,onDragOver:ps,onDrop:xs,children:[e.jsx("input",{ref:Ue,type:"file",accept:"image/*,.heic,.heif",onChange:cs,className:"hidden"}),Ne&&e.jsx("div",{className:"absolute inset-0 z-50",children:e.jsx(Fs,{error:Ne,errorType:qe,onTopUpCredits:()=>console.log("Navigate to billing page"),onClose:()=>{x(null),h(null)},className:"rounded-lg sm:rounded-xl lg:rounded-2xl"})}),e.jsxs("div",{className:`flex-col flex-1 md:w-1/2 min-h-0 overflow-visible order-2 md:order-1 ${K?"hidden md:flex":"flex"}`,children:[e.jsx("div",{className:"flex-1 flex flex-col h-full min-h-0",children:e.jsx("div",{className:"flex-1 flex flex-col h-full overflow-visible min-h-0",children:e.jsxs("div",{className:"space-y-3 h-full flex flex-col min-h-0",children:[e.jsxs("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg rounded-lg sm:rounded-xl p-2.5 sm:p-3 border border-border-emphasis/20 flex-1 md:flex-[3] min-h-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 flex-shrink-0",children:[e.jsx("div",{className:"w-2 h-2 bg-purple-400 rounded-full"}),e.jsx("label",{className:"text-xs sm:text-sm font-semibold text-gray-200",children:"Source Image"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-600 scrollbar-track-gray-800/30",children:c?e.jsx("div",{className:"flex items-center justify-center h-full p-2 md:p-3",children:e.jsx("div",{className:"relative w-full h-full max-w-full md:max-w-[90%] group",children:e.jsx("div",{className:"relative h-full rounded-xl md:rounded-2xl overflow-hidden bg-gradient-to-br from-purple-500/10 via-pink-500/5 to-transparent p-[1px]",children:e.jsx("div",{className:"relative h-full bg-gradient-to-br from-app-bg to-panel-bg rounded-xl md:rounded-2xl overflow-hidden",children:e.jsxs("div",{className:"relative h-full w-full p-3 sm:p-4 md:p-5 flex items-center justify-center",children:[e.jsx("img",{src:j,alt:"Source image",className:"max-w-full max-h-full object-contain rounded-lg"}),e.jsx("button",{onClick:vs,disabled:i,className:"absolute top-1.5 right-1.5 w-5 h-5 sm:w-6 sm:h-6 bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 disabled:from-input-bg disabled:to-panel-bg disabled:cursor-not-allowed text-white rounded-full flex items-center justify-center transition-all md:opacity-0 md:group-hover:opacity-100 hover:scale-110 active:scale-95",title:"Remove image",children:e.jsx("svg",{className:"w-2.5 h-2.5 sm:w-3 sm:h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsx("div",{className:"absolute top-0 left-0 w-16 h-16 bg-gradient-to-br from-purple-500/10 to-transparent rounded-br-full pointer-events-none"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-16 h-16 bg-gradient-to-tl from-pink-500/10 to-transparent rounded-tl-full pointer-events-none"})]})})})})}):q?e.jsx("div",{className:"source-upload-action-menu h-full flex flex-col",children:e.jsxs("div",{className:"flex-1 flex flex-row gap-2 sm:gap-3 p-2 min-h-0",children:[e.jsxs("button",{onClick:gs,className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 rounded-xl border-2 border-dashed border-border-emphasis/40 bg-input-bg/50 hover:border-purple-500/50 hover:bg-purple-900/10 transition-all duration-300 group cursor-pointer",children:[e.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 mb-2 sm:mb-3 bg-gradient-to-br from-purple-600/20 to-pink-600/20 rounded-xl flex items-center justify-center group-hover:from-purple-600/30 group-hover:to-pink-600/30 transition-all duration-300",children:e.jsx("svg",{className:"w-6 h-6 sm:w-7 sm:h-7 text-purple-400 group-hover:text-purple-300 transition-colors duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5"})})}),e.jsx("h4",{className:"text-gray-200 font-semibold text-xs sm:text-sm mb-1 group-hover:text-white transition-colors",children:"Open from disk"}),e.jsx("p",{className:"text-gray-400 text-[10px] sm:text-xs text-center group-hover:text-gray-300 transition-colors",children:"Upload from your device"})]}),e.jsxs("button",{onClick:fs,className:"flex-1 flex flex-col items-center justify-center p-4 sm:p-6 rounded-xl border-2 border-dashed border-border-emphasis/40 bg-input-bg/50 hover:border-purple-500/50 hover:bg-purple-900/10 transition-all duration-300 group cursor-pointer",children:[e.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 mb-2 sm:mb-3 bg-gradient-to-br from-purple-600/20 to-pink-600/20 rounded-xl flex items-center justify-center group-hover:from-purple-600/30 group-hover:to-pink-600/30 transition-all duration-300",children:e.jsx("svg",{className:"w-6 h-6 sm:w-7 sm:h-7 text-purple-400 group-hover:text-purple-300 transition-colors duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 01-.825-.242m9.345-8.334a2.126 2.126 0 00-.476-.095 48.64 48.64 0 00-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0011.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155"})})}),e.jsx("h4",{className:"text-gray-200 font-semibold text-xs sm:text-sm mb-1 group-hover:text-white transition-colors",children:"Select from chat"}),e.jsx("p",{className:"text-gray-400 text-[10px] sm:text-xs text-center group-hover:text-gray-300 transition-colors",children:"Use an image from history"})]})]})}):e.jsx("div",{className:"source-uploader flex items-center justify-center h-full p-2",children:e.jsx("button",{onClick:hs,disabled:Ee,className:`w-full max-w-md lg:max-w-lg flex flex-col items-center justify-center border-2 border-dashed rounded-xl py-6 px-4 transition-all duration-300 cursor-pointer group ${Ie?"border-purple-400 bg-purple-500/10":"border-border-emphasis/40 bg-panel-bg hover:border-purple-500/50 hover:bg-purple-900/10"} disabled:opacity-50 disabled:cursor-not-allowed`,children:Ee?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-10 h-10 border-3 border-purple-400/30 border-t-purple-400 rounded-full animate-spin mb
1-4"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Converting HEIC image..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 mb-2 sm:mb-3 bg-gradient-to-br from-purple-600/20 to-pink-600/20 rounded-xl flex items-center justify-center group-hover:from-purple-600/30 group-hover:to-pink-600/30 transition-all duration-300",children:e.jsx("svg",{className:"w-6 h-6 sm:w-7 sm:h-7 text-purple-400 group-hover:text-purple-300 transition-colors duration-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m2.25 15.75 5.159-5.159a2.25 2.25 0 0 1 3.182 0l5.159 5.159m-1.5-1.5 1.409-1.409a2.25 2.25 0 0 1 3.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 0 0 1.5-1.5V6a1.5 1.5 0 0 0-1.5-1.5H3.75A1.5 1.5 0 0 0 2.25 6v12a1.5 1.5 0 0 0 1.5 1.5Zm10.5-11.25h.008v.008h-.008V8.25Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z"})})}),e.jsx("h4",{className:"text-gray-200 font-semibold text-xs sm:text-sm mb-1",children:"Upload Image"}),e.jsx("p",{className:"text-gray-400 text-xs sm:text-sm leading-snug text-center",children:"Drag & drop or click to select an image to remix"})]})})})})]}),e.jsxs("div",{className:"bg-gradient-to-br from-panel-bg to-input-bg rounded-lg sm:rounded-xl p-2.5 sm:p-3 border border-border-emphasis/20 flex-1 md:flex-[2] flex flex-col min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[e.jsx("div",{className:"w-2 h-2 bg-pink-400 rounded-full"}),e.jsx("label",{className:"text-xs sm:text-sm font-semibold text-gray-200",children:"Settings"}),e.jsxs("span",{className:"sm:hidden ml-1 px-1.5 py-0.5 text-[10px] font-medium text-purple-300 bg-purple-500/15 rounded border border-purple-500/20",children:["Grid ",d,"×",d]})]}),e.jsxs("div",{className:"flex-1 flex flex-col bg-input-bg border border-border-emphasis/40 rounded-lg min-h-0",children:[e.jsxs("div",{className:"flex-1 min-h-0 relative",children:[e.jsx("textarea",{value:P,onChange:s=>Q(s.target.value),onKeyDown:ws,placeholder:"Optionally describe how variations should differ...",disabled:i,className:"w-full h-full px-3 sm:px-4 py-3 sm:py-4 bg-transparent text-gray-200 text-base sm:text-sm placeholder-gray-500 resize-none focus:outline-none focus:ring-0 focus:border-0 border-0 outline-none transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed",style:{minHeight:"80px"}}),P.length>0&&e.jsx("button",{onClick:()=>Q(""),disabled:i,className:"absolute right-2 top-2 p-1 text-gray-500 hover:text-gray-300 transition-colors disabled:opacity-50",title:"Clear",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 sm:px-4 pb-3 sm:pb-4 flex-shrink-0",children:[e.jsx(Ks,{selectedModel:M,onModelChange:s=>{Z(s);const r=He(s,A)?.displayParameters,o=r?.resolution||r?.size||r&&Object.values(r).find(a=>a?.displayName==="Resolution");L(o?.defaultValue??null)},imageEditModels:A,showFilters:!1}),e.jsx(Vs,{selectedAspectRatio:I,onAspectRatioChange:E,disabled:i,customAspectRatios:Ge,colorScheme:"purple"}),e.jsx("div",{className:"relative group",children:e.jsxs("button",{onClick:()=>X(d===2?3:2),disabled:i,className:"group px-3 py-2 bg-hover-bg hover:bg-border-emphasis text-gray-300 hover:text-white rounded-lg transition-all duration-200 flex items-center gap-2 flex-shrink-0 transform hover:scale-105 active:scale-95 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100",title:`Grid Size: ${d}×${d}`,children:[e.jsx("div",{className:`grid gap-0.5 w-4 h-4 ${d===2?"grid-cols-2":"grid-cols-3"}`,children:[...Array(d*d)].map((s,l)=>e.jsx("div",{className:"bg-current rounded-[1px]"},l))}),e.jsxs("span",{className:"hidden sm:inline text-xs font-medium",children:[d,"×",d]})]})}),_&&fe.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden sm:block",children:e.jsx(Gs,{selectedResolution:p,onRes
1olutionChange:L,options:fe})}),e.jsx("div",{className:"sm:hidden",children:e.jsx(qs,{selectedResolution:p,onResolutionChange:L,resolutionOptions:fe,disabled:i,colorScheme:"purple"})})]}),os&&e.jsx("button",{type:"button",onClick:()=>Re(!0),disabled:i,className:"group px-3 py-2 bg-hover-bg hover:bg-border-emphasis text-gray-300 hover:text-white rounded-lg transition-all duration-200 flex items-center justify-center flex-shrink-0 transform hover:scale-105 active:scale-95 disabled:opacity-60 disabled:cursor-not-allowed",title:"Model Settings",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"})})})]})]})]})]})})}),e.jsx("div",{className:"flex-shrink-0 mt-3 md:mt-4 w-full",children:e.jsx(Xs,{onClick:Pe,isLoading:i,disabled:i||!c,text:"Remix",loadingText:"Generating...",colorScheme:"purple-pink",iconPath:null,creditCost:ds})})]}),e.jsx("div",{className:`flex-col flex-1 md:w-1/2 min-h-0 overflow-hidden relative order-1 md:order-2 ${K||Cs?"flex":"hidden md:flex"}`,children:e.jsx("div",{className:"h-full bg-app-bg rounded-lg sm:rounded-xl border border-border-emphasis/30 min-h-0 flex flex-col",children:Y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`${G.length>0?"flex-[2]":"flex-1"} min-h-0 overflow-hidden rounded-t-lg sm:rounded-t-xl relative flex flex-col`,children:[e.jsxs("div",{className:"flex items-center justify-between px-3 pt-3 pb-2 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-purple-400 rounded-full"}),e.jsx("span",{className:"text-xs sm:text-sm text-gray-300 font-medium",children:"Click a cell to upscale"})]}),e.jsx("button",{onClick:async()=>{try{const l=await(await fetch(Y)).blob(),r=window.URL.createObjectURL(l),o=document.createElement("a");o.href=r,o.download=`remix-grid-${Date.now()}.png`,document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(r)}catch(s){console.error("Download failed:",s)}},className:"w-8 h-8 bg-input-bg hover:bg-purple-600 text-gray-400 hover:text-white rounded-lg transition-all duration-200 flex items-center justify-center",title:"Download grid",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})})]}),e.jsxs("div",{className:"flex-1 relative min-h-0",children:[e.jsx("div",{className:`absolute inset-y-0 pb-3 flex items-center justify-center ${K?"inset-x-1 md:inset-x-3":"inset-x-3"}`,children:e.jsx(Ws,{gridImageUrl:Y,originalImageUrl:ie?.originalImageUrl,onCellClick:js,onPreviewClick:ys,disabled:$,isExtractingCell:R,gridSize:ie?.gridSize||3,aspectRatio:ie?.aspectRatio||"1:1"})}),$&&e.jsx("div",{className:`absolute inset-y-0 pb-3 bg-black/60 rounded-lg flex items-center justify-center z-10 ${K?"inset-x-1 md:inset-x-3":"inset-x-3"}`,children:e.jsxs("div",{className:"flex flex-col items-center gap-6 bg-panel-bg/90 px-10 py-8 rounded-2xl border border-purple-500/30",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-14 h-14 border-4 border-purple-400/30 rounded-full"}),e.jsx("div",{className:"absolute inset-0 w-14 h-14 border-4 border-purple-400 border-t-transparent rounded-full animate-spin"}),e.jsx("div",{className:"absolute inset-0 w-14 h-14 rounded-full bg-purple-500/20 animate-ping",style:{animationDuration:"1.5s"}})]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("p",{className:"text-white font-medium text-base",children:["Upscaling Cell ",Se!==null?Se+1:""]}),e.jsx("p",{className:"text-gray-400 text-sm",children:"This may take a moment..."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 bg-purple-400 rounded-full animate-bounce",style:{animationDelay:"0s"}}),e.jsx("div",{className:"w-2.5 h-2.5 bg-purple-400 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2.5 h-2.5 bg-purple-400 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})]})})]})]}),G.length>0&&e.jsxs("div",{className:"flex-shrink-0 border-t border-border-emphasis/30 bg-gradient-to-br from-panel-bg via-panel-bg to-purple-900/10 rounded-b-lg sm:rounded-b-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-gradient-to-r from-purple-400 to-pink-400 rounded-full"}),e.jsx("span",{className:"text-xs sm:text-sm font-semibold text-gray-200",children:"Upscaled Results"}),e.jsx("span",{className:"px-2 py-0.5 bg-purple-500/20 text-purple-300 text-[10px] font-medium rounded-full",children:G.length})]}),e.jsxs("button",{onClick:()=>z([]),className:"ml-auto text-xs text-gray-500 hover:text-gray-300 transition-colors flex items-center gap-1 px-2 py-1 rounded hover:bg-white/5",title:"Clear all",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}),"Clear"]})]}),e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-1 scrollbar-thin scrollbar-thumb-purple-600/50 scrollbar-track-transparent",children:G.map(s=>e.jsxs("div",{className:"relative flex-shrink-0 group cursor-pointer",onClick:()=>{ue(s.url),pe(`Upscaled Cell ${s.cellIndex+1}`),me(!0)},children:[e.jsx("div",{className:"relative rounded-xl p-[2px] bg-gradient-to-br from-purple-500/40 via-pink-500/20 to-transparent group-hover:from-purple-400 group-hover:via-pink-400 group-hover:to-purple-600 transition-all duration-300",children:e.jsxs("div",{className:"relative bg-panel-bg rounded-[10px] overflow-hidden",children:[e.jsx("img",{src:s.url,alt:`Upscaled cell ${s.cellIndex+1}`,className:"w-18 h-18 sm:w-22 sm:h-22 object-cover transition-transform duration-300 group-hover:scale-105",style:{width:"72px",height:"72px"}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/60 via-trans
1parent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200"})]})}),e.jsx("div",{className:"absolute -top-1 -left-1 w-6 h-6 bg-gradient-to-br from-purple-500 to-pink-500 text-white text-[10px] font-bold rounded-lg flex items-center justify-center ring-2 ring-panel-bg",children:s.cellIndex+1}),e.jsx("button",{onClick:l=>{l.stopPropagation();const r=document.createElement("a");r.href=s.url,r.download=`upscaled-cell-${s.cellIndex+1}-${s.timestamp}.png`,document.body.appendChild(r),r.click(),document.body.removeChild(r)},className:"absolute bottom-2 right-2 w-7 h-7 bg-black/70 hover:bg-gradient-to-r hover:from-purple-600 hover:to-pink-600 text-white rounded-lg opacity-0 group-hover:opacity-100 transition-all duration-200 flex items-center justify-center",title:"Download",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"})})})]},s.timestamp))})})]}),K&&e.jsx("div",{className:"flex-shrink-0 p-3 border-t border-border-emphasis/30 md:hidden",children:e.jsxs("button",{onClick:()=>H(!1),className:"w-full py-3 px-4 bg-input-bg hover:bg-hover-bg text-gray-300 hover:text-white rounded-lg transition-all duration-200 flex items-center justify-center gap-2 font-medium",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),"Back to Settings"]})})]}):e.jsx("div",{className:"h-full flex items-center justify-center text-gray-400 relative p-4",children:e.jsxs("div",{className:"w-full max-w-lg mx-auto border-2 border-dashed border-border-emphasis/40 rounded-xl p-8 text-center transition-all duration-300 bg-panel-bg flex flex-col items-center justify-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center bg-input-bg mb-4",children:e.jsx("svg",{className:"w-10 h-10 text-gray-300",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1v-4zM14 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"})})}),e.jsx("p",{className:"text-sm text-gray-400 max-w-xs mx-auto leading-relaxed",children:"Your remix grid will appear here"})]})})})}),Ie&&e.jsx("div",{className:"absolute inset-0 bg-purple-500/10 border-2 border-dashed border-purple-400 rounded-lg sm:rounded-xl lg:rou
1nded-2xl flex items-center justify-center z-40 pointer-events-none",children:e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("svg",{className:"w-12 h-12 text-purple-400 mb-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"})}),e.jsx("p",{className:"text-purple-300 font-medium",children:"Drop image here"})]})}),e.jsx(Ts,{isOpen:Ke,onClose:()=>ne(!1),message:Je,duration:Xe}),e.jsx(Hs,{isOpen:Qe,onClose:()=>{de(!1),ce(null)},onProceed:Ns,cellIndex:w?.cellIndex||0,gridImageUrl:w?.gridImageUrl,gridSize:w?.gridSize||3,models:ss}),Ye&&D&&e.jsx(_s,{image:{url:D,title:es},onClose:ks,showQuickEditButton:!1,showDownloadButton:!0})]}),e.jsx(Bs,{isOpen:as,onClose:()=>ge(!1),onImageSelectForUpload:bs,uploadSelectionMode:!0,imagesOnly:!0,chats:m}),e.jsx(Qs,{isOpen:Ze,onClose:()=>Me(!1)}),e.jsx(Js,{isOpen:rs,onClose:()=>Re(!1),onSave:ns,selectedModel:M,imageEditModels:A,quickEditType:"remix",currentSettings:ee,excludeParameters:oe})]})};export{bt 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.