1import{j as e}from"./vendor-query-CtIF-MNZ.js";import{C as V,a as F}from"./card-GdQB7DL8.js";import{c as G,B as d,g as W,t as z}from"./index-BfEqxQPi.js";import{B as $}from"./badge-_Q0w0Wgx.js";import{T as q,a as Y,b as J,c as K}from"./tooltip-CMWaDq-g.js";import{S as T}from"./shimmer-image-DO136dW3.js";import{e as X,r as l,a as H}from"./vendor-react-BfTl68nP.js";import{i as Q,s as E}from"./mobileImageSave-BV8C2R4r.js";import{U as ee}from"./UpscaleModal-717i0pg-.js";import{C as se}from"./ContextualFeedbackCard-D_p8RiT0.js";import{f as te,e as ae,X as re,a as oe,c as le,D as P,ad as ne,s as ie,bg as ce,aJ as de,d as U,_ as me,b as pe,ak as ue}from"./vendor-icons-hHTr3Gms.js";import{d as he}from"./dropDownload-YeYVr9jl.js";import{u as ge}from"./useProductImageScenes-DJsnvTYa.js";import"./vendor-radix-q0rzatl0.js";import"./enqueueGeneration-D4M7QE8C.js";import"./NoCreditsModal-CDq_2Gmb.js";import"./jszip.min-BvJYAAfF.js";const xe={"1:1":"1 / 1","3:4":"3 / 4","4:3":"4 / 3","4:5":"4 / 5","5:4":"5 / 4","9:16":"9 / 16","16:9":"16 / 9","2:3":"2 / 3","3:2":"3 / 2"};function fe({open:i,onClose:c,items:p,initialIndex:j}){const N=X(),[R,k]=l.useState(j),[S,I]=l.useState(!1),[C,h]=l.useState(!1);l.useEffect(()=>{i&&k(j)},[i,j]);const g=p.length>1,s=p[R],x=l.useCallback(()=>{k(o=>o>0?o-1:p.length-1)},[p.length]),f=l.useCallback(()=>{k(o=>o<p.length-1?o+1:0)},[p.length]);if(l.useEffect(()=>(i?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[i]),l.useEffect(()=>{if(!i)return;const o=b=>{b.key==="Escape"&&c(),g&&b.key==="ArrowLeft"&&x(),g&&b.key==="ArrowRight"&&f()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[i,c,g,x,f]),!i||!s)return null;const v=s.aspectRatio&&xe[s.aspectRatio]||"4 / 5",y=async()=>{const o=s.productName.replace(/[^a-zA-Z0-9Ã-ÿ _-]/g,"").replace(/\s+/g,"_"),b=s.sceneName.replace(/[^a-zA-Z0-9Ã-ÿ _-]/g,"").replace(/\s+/g,"_");await E(s.url,`${o}_${b}`)};return H.createPortal(e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-[200] animate-in fade-in duration-200",style:{margin:0,padding:0},onClick:c,children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 bg-black/90"}),e.jsxs("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-10 flex flex-col md:flex-row",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"relative w-full md:w-[60%] h-[45vh] md:h-full flex items-center justify-center p-6 md:p-12 group/img",children:[e.jsx(T,{src:s.url,alt:`${s.productName} â ${s.sceneName}`,aspectRatio:v,className:"w-full h-full object-contain rounded-lg shadow-2xl",wrapperClassName:"max-w-full max-h-[calc(45vh-2rem)] md:max-h-[calc(100vh-6rem)] flex items-center justify-center",wrapperStyle:{aspectRatio:v,width:"auto",height:"auto"},fetchPriority:"high"}),g&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:x,className:"absolute left-3 md:left-4 top-1/2 -translate-y-1/2 z-30 w-11 h-11 rounded-full bg-black/20 dark:bg-white/15 backdrop-blur-md border border-white/10 flex items-center justify-center text-white/80 hover:bg-black/30 dark:hover:bg-white/25 hover:text-white transition-all md:opacity-0 md:group-hover/img:opacity-100",children:e.jsx(te,{className:"w-5 h-5"})}),e.jsx("button",{onClick:f,className:"absolute right-3 md:right-4 top-1/2 -translate-y-1/2 z-30 w-11 h-11 rounded-full bg-black/20 dark:bg-white/15 backdrop-blur-md border border-white/10 flex items-center justify-center text-white/80 hover:bg-black/30 dark:hover:bg-white/25 hover:text-white transition-all md:opacity-0 md:group-hover/img:opacity-100",children:e.jsx(ae,{className:"w-5 h-5"})})]})]}),e.jsxs("div",{className:"relative w-full md:w-[40%] h-[55vh] md:h-full overflow-y-auto bg-background/95 backdrop-blur-xl border-l border-border/20",children:[e.jsx("button",{onClick:c,className:"absolute top-4 right-4 z-20 text-foreground/70 hover:text-foreground transition-colors",children:e.jsx(re,{className:"w-7 h-7",strokeWidth:2})}),e.jsxs("div",{className:"flex flex-col gap-6 p-6 md:p-8 lg:p-10 pt-8 md:pt-10",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-[0.2em] text-muted-foreground
1/70",children:"Product Visuals"}),e.jsx("h2",{className:"text-2xl md:text-3xl font-semibold tracking-tight text-foreground leading-tight",children:s.productName}),s.sceneName&&e.jsx("p",{className:"text-sm text-muted-foreground",children:s.sceneName}),s.jobId&&e.jsx("div",{className:"flex items-center gap-2 pt-1",children:e.jsxs("button",{type:"button",onClick:async o=>{o.stopPropagation();try{await navigator.clipboard.writeText(s.jobId),h(!0),setTimeout(()=>h(!1),1400)}catch{}},title:"Reference ID â click to copy (share with support)",className:G("inline-flex items-center gap-1.5 font-mono text-[10px] px-1.5 py-0.5 rounded-md border transition-colors",C?"border-foreground/30 text-foreground bg-muted/40":"border-border/60 text-muted-foreground/80 hover:text-foreground hover:border-border"),children:[C?e.jsx(oe,{className:"h-3 w-3"}):e.jsx(le,{className:"h-3 w-3"}),e.jsx("span",{className:"uppercase tracking-wider",children:"ID"}),e.jsx("span",{children:s.jobId.slice(-8)}),C&&e.jsx("span",{className:"normal-case tracking-normal",children:"Copied"})]})})]}),e.jsxs("div",{className:"space-y-2.5 pt-2",children:[e.jsxs(d,{onClick:y,size:"pill",className:"w-full font-medium shadow-lg shadow-primary/10 hover:shadow-xl hover:shadow-primary/20 transition-shadow duration-300",children:[e.jsx(P,{className:"w-4 h-4 mr-2"})," ",Q()?"Save to Photos":"Download Image"]}),e.jsxs(d,{variant:"outline",onClick:()=>{N(`/app/freestyle?editImage=${encodeURIComponent(s.url)}&imageRole=edit`),c()},className:"w-full font-medium",children:[e.jsx(ne,{className:"w-4 h-4 mr-2"}),"Edit Image"]}),e.jsxs(d,{variant:"outline",onClick:()=>{N(`/app/perspectives?source=${encodeURIComponent(s.url)}`),c()},className:"w-full font-medium",children:[e.jsx(ie,{className:"w-4 h-4 mr-2"}),"Generate More Angles",e.jsx("span",{className:"ml-1.5 text-[9px] uppercase tracking-wider font-semibold px-1.5 py-0.5 rounded-full bg-primary text-primary-foreground",children:"New"})]}),e.jsxs(d,{variant:"outline",onClick:()=>{N(`/app/product-swap?scene=${encodeURIComponent(s.url)}`),c()},className:"w-full font-medium",children:[e.jsx(ce,{className:"w-4 h-4 mr-2"}),"Swap Product"]}),e.jsxs(d,{variant:"outline",onClick:()=>{N(`/app/video/animate?imageUrl=${encodeURIComponent(s.url)}`),c()},className:"w-full font-medium",children:[e.jsx(de,{className:"w-4 h-4 mr-2"}),"Generate Video"]}),s.jobId&&e.jsxs(d,{variant:"outline",onClick:()=>I(!0),className:"w-full font-medium",children:[e.jsx(U,{className:"w-4 h-4 mr-2"}),"Enhance to 4K"]})]}),e.jsx(se,{workflow:"product-visuals",questionText:"Is this visual ready to use?",buttonLabels:{yes:"Yes, ready",almost:"Almost",no:"No"},reasonChips:["Need better background","Wrong angle / shot","Product details off","Lighting / shadows","Not consistent enough","Missing shot type","Needs higher realism","Other"],textPlaceholder:"What is missing? e.g. cleaner background, sharper details",resultId:s.jobId,imageUrl:s.url,triggerType:"result_ready",className:"[&>div]:bg-transparent [&>div]:border-border/40"})]})]})]})]}),S&&s.jobId&&e.jsx(ee,{open:S,onClose:()=>I(!1),items:[{imageUrl:s.url,sourceType:"generation",sourceId:s.jobId}],onComplete:()=>I(!1)})]}),document.body)}function ze({results:i,onGenerateMore:c,onGoToLibrary:p,onStartNew:j}){const[N,R]=l.useState(!1),[k,S]=l.useState([]),[I,C]=l.useState(0),[h,g]=l.useState(!1),{rawScenes:s}=ge(),x=l.useMemo(()=>{const r=new Map;for(const a of s)r.set(a.scene_id,a.sort_order);return r},[s]),f=l.useMemo(()=>{const r=new Map;for(const[a,{images:n,productName:t}]of i.entries()){const m=[...n].sort((w,u)=>{const A=w.sceneId?w.sceneId.split("::")[0]:"",D=u.sceneId?u.sceneId.split("::")[0]:"",_=A?x.get(A)??9999:9999,L=D?x.get(D)??9999:9999;if(_!==L)return _-L;const M=!!w.angleLabel,Z=!!u.angleLabel;return M!==Z?M?1:-1:(w.angleLabel||"").localeCompare(u.angleLabel||"")});r.set(a,{images:m,productName:t})}return r},[i,x]),v=Array.from(f.values()).flatMap(r=>r.images),y=v.length,o=l.useMemo(()=>new Set(v.map(a=>a.aspectRatio).filter(Boolean)).size>1,[v]),b=(r,a,n)=>{S(r.map(t=>({url:t.url,productName:n,sceneName:t.sceneName,aspectRatio:t.aspectRatio,jobId:t.jobId}))),C(a),R(!0)},O=async()=>
1{if(!(h||y===0)){g(!0);try{const r=[];for(const[,{images:a,productName:n}]of f.entries())for(const t of a)r.push({url:t.url,workflow_name:"Product Images",product_title:n,scene_name:t.sceneName});await he(r,"Product_Images"),z.success("Download complete")}catch{z.error("Download failed")}finally{g(!1)}}},B=(r,a,n)=>{const t=a.replace(/[^a-zA-Z0-9Ã-ÿ _-]/g,"").replace(/\s+/g,"_"),m=n.replace(/[^a-zA-Z0-9Ã-ÿ _-]/g,"").replace(/\s+/g,"_");E(r,`${t}_${m}`)};return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-semibold tracking-tight",children:"Your visuals are ready"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[y," image",y!==1?"s":""," generated successfully"]})]}),Array.from(f.entries()).map(([r,{images:a,productName:n}])=>e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate",children:n}),e.jsxs($,{variant:"secondary",className:"text-[10px] flex-shrink-0 whitespace-nowrap",children:[a.length," image",a.length!==1?"s":""]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-3",children:a.map((t,m)=>{var w;return e.jsxs("button",{onClick:()=>b(a,m,n),className:"rounded-xl overflow-hidden border border-border hover:border-primary/40 transition-all cursor-pointer group relative",children:[e.jsx("div",{className:"bg-muted/40 overflow-hidden",style:{aspectRatio:(t.aspectRatio||((w=a.find(u=>u.aspectRatio))==null?void 0:w.aspectRatio)||"1:1").replace(":","/")},children:e.jsx(T,{src:W(t.url,{quality:65}),alt:`${n} - ${t.sceneName} - ${m+1}`,loading:m<4?"eager":"lazy",fetchPriority:m<4?"high":"auto",className:"w-full h-full object-contain group-hover:scale-105 transition-transform duration-300"})}),e.jsxs("div",{className:"px-2 py-1.5 bg-card border-t border-border flex items-center gap-1.5",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:t.sceneName}),o&&t.aspectRatio&&e.jsx($,{variant:"outline",className:"text-[8px] px-1.5 py-0 h-3.5 shrink-0 font-medium",children:t.aspectRatio})]}),e.jsx("span",{role:"button",onClick:u=>{u.stopPropagation(),B(t.url,n,t.sceneName)},className:"absolute top-2 right-2 w-8 h-8 rounded-full bg-background/80 backdrop-blur-sm flex items-center justify-center text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 md:opacity-0 md:group-hover:opacity-100 transition-opacity",title:"Download",children:e.jsx(P,{className:"w-4 h-4"})})]},m)})})]},r)),e.jsx(V,{children:e.jsxs(F,{className:"p-4 flex flex-wrap gap-3 items-center justify-center",children:[e.jsxs(d,{variant:"outline",onClick:c,className:"gap-1.5",children:[e.jsx(me,{className:"w-4 h-4"}),"Generate More"]}),j&&e.jsx(q,{delayDuration:200,children:e.jsxs(Y,{children:[e.jsx(J,{asChild:!0,children:e.jsxs(d,{variant:"outline",onClick:j,className:"gap-1.5",children:[e.jsx(U,{className:"w-4 h-4"}),"Start New"]})}),e.jsx(K,{children:"Begin a fresh project with new products"})]})}),e.jsxs(d,{variant:"outline",onClick:O,disabled:h||y===0,className:"gap-1.5",children:[h?e.jsx(pe,{className:"w-4 h-4 animate-spin"}):e.jsx(ue,{className:"w-4 h-4"}),h?"Downloadingâ¦":"Download All"]}),e.jsxs(d,{variant:"outline",onClick:p,className:"gap-1.5",children:[e.jsx(P,{className:"w-4 h-4"}),"View in Library"]})]})}),e.jsx(fe,{open:N,onClose:()=>R(!1),items:k,initialIndex:I})]})}export{ze as ProductImagesStep6Results,ze 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.