1import{u as K,a as Y,r as s,j as t,m as Z,p as J}from"./index-L9AYrVUw.js";import{s as ee,b as te,a as re,c as ae}from"./ProductPickerModal-DZV-fDl_.js";import{aG as oe,d as se,bi as ie,u as m,bj as le,bk as ne,C as c,bl as de,R as M,n as ce,bm as ue,bn as me,bo as pe,bp as ge,ah as be}from"./PlanAccessModal-P_W2GThH.js";import{l as fe}from"./UploadSimple.es-BDJIa312.js";import{P as n,a as he,b as ye}from"./promptBox-D9Xxfn9U.js";import{o as xe}from"./overImage-BfLII5AZ.js";import{S as Se,V as ve,Z as Ie,C as Ae}from"./StarterModalShell-BqsuvlPe.js";import{P as O}from"./PillSelect-DrQvPMFB.js";import{C as je}from"./ChatSubmitButton-Bm0hHp2J.js";import{A as Ce}from"./aspectRatios-DDqw6bsx.js";import{n as Pe}from"./resolveCasting-1-rDPxyF.js";import{e as Re}from"./overrides-DxGb-X-q.js";import{C as Ee}from"./CastingTagPill-Dxy3OzJ5.js";import{u as De}from"./useFileDrop-Bndg9qCI.js";import{u as ke}from"./useGenerationCreditCost-DQbGS72G.js";import"./firstAsset-DWUwvZpm.js";import"./modal-close-button-BhLoO4jQ.js";import"./tabs-CmDZA0dx.js";import"./index-BKpKuXmL.js";import"./locale-Cctu0V3Y.js";import"./index-Eo00qZvG.js";import"./productFunnel-DiJFcMU2.js";import"./SearchInput-h5gAN-Be.js";import"./ImageSquare.es-Ckk4CjAE.js";import"./pill-dropdown-menu-CmrSXir-.js";import"./use-exclusive-open-LN4OUcjO.js";import"./eligibility-B5UjMwH6.js";import"./scoring-Oj4SgCwH.js";import"./visualDirection-6RyRmTlC.js";import"./productHeight-D88Bzh8q.js";import"./qaSignal-BzonQWWb.js";import"./shadow-1gm38VU4.js";import"./types-YVLQw7aQ.js";import"./User.es-DVlkNLFL.js";import"./castingThumbnail-BTwl0DD5.js";const Le=380,U=380,C=ve,Te=U+C+Le+Ae*2,Me={id:"format",default:"1:1",isAspectRatio:!0,options:Ce.map(a=>({id:a.id,label:a.label}))},Oe={id:"quality",default:"hd",options:[{id:"hd",label:"HD"},{id:"2k",label:"2K"},{id:"4k",label:"4K"}]};function yt({info:a,onExigirConta:P,onPlanGate:R}){const E=K(),_=oe(),{user:w,loading:N}=se(),{lang:D}=Y(),i=D==="pt-BR",l=Z(window.location.hostname)?null:w,x=_||!N&&!l,[G,q]=s.useState(!1),[r,S]=s.useState(null),[p,B]=s.useState(""),[g,F]=s.useState("1:1"),[b,$]=s.useState("hd"),[k,L]=s.useState(!1),[Ue,v]=s.useState(null),[H,I]=s.useState(!1),f=s.useRef(!1),A=ke("nano-banana-2",b),[z,j]=s.useState(!1),[h,V]=s.useState(()=>{var e,o;return((e=Re(a.styleId??""))==null?void 0:e.castMemberId)??((o=ie())==null?void 0:o.id)??null}),X=s.useCallback(async e=>{if(e){L(!0),v(null);try{const o=await ee(e,(l==null?void 0:l.id)??"guest");S({url:o.image,nome:o.name,id:o.id})}catch(o){const u=o instanceof Error?o.message:"Não foi possÃvel salvar a imagem. Tente outro arquivo.";v(u),m.error(u)}finally{L(!1)}}},[l==null?void 0:l.id]),Q=s.useCallback(()=>{const e="Use uma imagem JPEG, PNG ou WebP.";v(e),m.error(e)},[]),d=De(e=>X(e[0]),{accept:ae,onReject:Q}),y=s.useMemo(()=>{const e=a.styleId;if(!e)return!1;const o=le(e);return o?Pe(o):ne(e)},[a.styleId]),W=async()=>{if(!r||!a.styleId||k||f.current)return;if(f.current=!0,I(!0),!l){if(!await ue({productImageUrl:r.url,productLabel:r.nome,productId:r.id??null,prompt:p,format:g,quality:b,styleId:a.styleId,styleName:a.styleName??null,castMemberId:y?h:null})){f.current=!1,I(!1),m.error("Could not save your creation. Try a smaller image and generate again.");return}P?P():E(J(D));return}const e=me(),o=e==="CREDITS_EXHAUSTED"&&!be;if(o&&pe(),e&&e!=="CREDITS_EXHAUSTED"){m.error(e==="BILLING_UNAVAILABLE"?"Your credits could not be checked. Please try again shortly.":e==="AUTH_REQUIRED"?"Sign in to generate.":"Please wait for your credits to be confirmed before generating."),f.current=!1,I(!1);return}if(o&&R){R({styleId:a.styleId,styleName:a.styleName??null,productImageUrl:r.url,productLabel:r.nome,productId:r.id??null,prompt:p,format:g,castMemberId:y?h:null});return}const u=ge({productImageUrl:r.url,productLabel:r.nome,productId:r.id??null,prompt:p,format:g,quality:b,timestamp:Date.now(),styles:[{id:a.styleId,name:a.styleName,castMemberId:y?h:null}]});o&&(u.planGate=!0),E("/board",{replace:!0,state:u})},T=!!r&&!!a.styleId&&!k&&!H;return G?null:t.jsx(Se,{width:Te,onClose:()=>q(!0),panelStyle:{display:"flex",gap:C},fora:x?null:t.jsx("div",{style:{pointerEvents:"auto"},children:t.jsx(re,{zIndex:Ie+10,open:z,onClose:()=>j(!1),onPick:e=>{if(j(!1),!e.image){m.error("Este produto está sem imagem â a geração precisa dela.");return}S({url:e.image,nome:e.name,id:e.id})}})}),children:t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{position:"relative",width:U,flexShrink:0},children:[t.jsx("div",{style:{width:"100%",aspectRatio:"3 / 4",borderRadius:n.radius,background:a.styleThumb?`url(${a.styleThumb}) center/cover no-repeat, hsl(${c.bg.tertiary})`:`hsl(${c.bg.tertiary})`}}),y&&t.jsx("div",{style:{position:"absolute",left:12,bottom:12},children:t.jsx(Ee,{castMemberId:h,boardScale:1,onPick:e=>{V(e.id),de(e.id)}})})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",flex:1,minWidth:0},children:[t.jsx("h2",{className:"text-[15px] text-foreground",style:{paddingRight:36,marginBottom:C},children:i?"Aplique este preset no seu produto":"Apply this preset to your product"}),t.jsxs("div",{...d.dropProps,onClick:()=>x?d.abrir():j(!0),style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,padding:16,borderRadius:n.radius,background:n.bg,boxShadow:n.shadow,border:`1px dashed hsl(${d.dragging?c.border.primary:c.border.secondary}
1)`,cursor:"pointer",transition:"border-color 120ms ease"},className:"hover:border-foreground/30",children:[r?t.jsxs("div",{style:{position:"relative"},children:[t.jsx("img",{src:r.url,alt:r.nome,title:r.nome,style:{height:128,width:128,objectFit:"cover",borderRadius:M.md}}),t.jsx("button",{type:"button","aria-label":"Remover produto",onClick:e=>{e.stopPropagation(),S(null)},style:{...xe(24),position:"absolute",top:6,right:6},children:t.jsx(ce,{size:12,weight:"bold"})})]}):x?t.jsxs(t.Fragment,{children:[t.jsx("span",{style:{width:40,height:40,borderRadius:M.pill,background:`hsl(${c.bg.secondary})`,display:"flex",alignItems:"center",justifyContent:"center"},className:"text-muted-foreground",children:t.jsx(fe,{size:18})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4},children:[t.jsx("span",{className:"text-[13px] font-medium text-foreground",children:d.dragging?i?"Solte a imagem":"Drop the image":i?"Enviar a foto do seu produto":"Upload your product photo"}),t.jsx("span",{className:"text-[11px] leading-snug text-muted-foreground",children:i?"clique ou arraste uma imagem aqui":"
1click or drag an image here"})]})]}):t.jsx(te,{dragging:d.dragging}),d.input]}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:16,marginTop:16,padding:16,background:n.bg,borderRadius:n.radius,boxShadow:n.shadow},children:[t.jsx("textarea",{value:p,onChange:e=>B(e.target.value),placeholder:i?"O que você quer mudar?":"What do you want to change?",className:he,style:{...ye(96),flex:1,color:`hsl(${c.text.primary})`,boxSizing:"border-box"}}),!r&&t.jsx("p",{id:"style-starter-generate-help",className:"text-[11px] leading-snug text-muted-foreground",children:i?"Adicione uma foto do produto para habilitar a geração.":"Add a product photo to enable generation."}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(O,{pill:Me,value:g,onChange:F}),t.jsx(O,{pill:Oe,value:b,onChange:e=>$(e)}),t.jsx("div",{style:{flex:1}}),t.jsx(je,{credits:A,state:T?"active":"disabled",onClick:W,label:i?"Gerar":"Generate",creditLabel:i?"créditos":"credits",ariaLabel:T?i?`Gerar por ${A} créditos`:`Generate for ${A} credits`:i?"Adicione uma foto do produto para gerar":"Add a product photo to generate",ariaDescribedBy:r?void 0:"style-starter-generate-help"})]})]})]})]})})}export{Te as LARGURA_CAIXA_EDICAO,yt 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.