1import{r as j,s as L,b3 as Ce,j as e,O as be,ag as pe,H as je,I as ye,J as z,K as W,n as B,aB as Se,a3 as p,Y as ke,B as G,Q as ve,U as Ne,k as J,R as Ae,u as Ie,L as de,A as Ee,ab as ue,S as Me,a as Re,b as Te,c as Be,d as Le,a_ as Fe}from"./index-BwaMfbd5.js";import{u as Pe}from"./useBrandKit-BlFiy30J.js";import{R as Q,u as De,A as Oe,a as qe,b as Ue}from"./RenderPreview-CdTjWjwU.js";import{I as Y}from"./image-C5Jyz2ta.js";import{U as $e}from"./upload-CtZ0_UDc.js";import{R as He}from"./rotate-ccw-BvIKsJnI.js";import{F as Ge}from"./film-DG_r2a6B.js";import{G as Ve}from"./git-compare-DMeME5gB.js";import{Q as ze}from"./quote-CFOTwTU4.js";import{L as We}from"./list-ordered-CR5MUYvK.js";import{P as Je}from"./package-Bm6lBh5O.js";import{T as Qe}from"./type-CfpVrT6l.js";import{H as me}from"./history-D7QBN2Yz.js";import{D as Ye}from"./dollar-sign-AcsFX6va.js";import{M as Ke}from"./maximize-2-Cdbk8l8X.js";import"./download-CIy4X3xv.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="bf2e11c6-2536-4059-b5a9-d9ca0813ba9e",a._sentryDebugIdIdentifier="sentry-dbid-bf2e11c6-2536-4059-b5a9-d9ca0813ba9e")}catch{}})();const O={energy:"energetic",grain:.06,glowOpacity:.55},Xe=new Set(["energetic","calm","sophisticated","playful"]),K={};function Ze(a){const[t,r]=j.useState(a&&K[a]||O),l=j.useRef(a);return j.useEffect(()=>{if(l.current=a,!a){r(O);return}if(K[a]){r(K[a]);return}let o=!1;return(async()=>{const{data:i}=await L.from("brand_dna").select("tone, mood_library").eq("project_id",a).maybeSingle();if(o||l.current!==a)return;const c=et(i==null?void 0:i.tone,i==null?void 0:i.mood_library);K[a]=c,r(c)})(),()=>{o=!0}},[a]),t}function et(a,t){const r=[];t&&typeof t=="object"&&r.push(t),a&&typeof a=="object"&&r.push(a);let l=O.energy,o=O.grain,i=O.glowOpacity;for(const c of r){const n=tt(c,["energy","vibe","mood","intensity"]);if(n&&Xe.has(n)){l=n;break}if(n){const s=at(n);if(s){l=s;break}}}for(const c of r){const n=X(c,["grain","noise","texture"]);if(n!=null&&n>=0&&n<=1){o=n;break}}for(const c of r){const n=X(c,["glow_opacity","glowOpacity","halo","glow"]);if(n!=null&&n>=0&&n<=1){i=n;break}}return r.some(c=>X(c,["grain","noise"])!=null)||(o=rt(l)),r.some(c=>X(c,["glow_opacity","glowOpacity"])!=null)||(i=st(l)),{energy:l,grain:o,glowOpacity:i}}function tt(a,t){for(const r of t){const l=a[r];if(typeof l=="string"&&l.trim().length>0)return l.trim().toLowerCase()}return null}function X(a,t){for(const r of t){const l=a[r];if(typeof l=="number"&&Number.isFinite(l))return l;if(typeof l=="string"&&/^[\d.]+$/.test(l))return Number(l)}return null}function at(a){const t=a.toLowerCase();return/(energet|vibrant|bold|dynamic|loud|fuerte|enérgic|vibrant)/.test(t)?"energetic":/(calm|serene|tranqu|soft|quiet|sereno|tranquil)/.test(t)?"calm":/(sophist|premium|luxe|elegant|refined|sobrio|elegan)/.test(t)?"sophisticated":/(playful|fun|friendly|warm|joyful|alegr|divert|juguet)/.test(t)?"playful":null}function rt(a){return a==="playful"?.08:a==="calm"?.04:a==="sophisticated"?.05:.06}function st(a){return a==="calm"?.4:a==="sophisticated"?.45:a==="playful"?.5:.55}const lt={product:"product_shot",product_shot:"product_shot",lifestyle:"lifestyle",detail:"detail",screenshot:"screenshot",founder:"founder",team:"team",facility:"facility",social_proof:"social_proof",before_after:"before_after",gimmick:"gimmick",logo:"logo"};function nt(a){const[t,r]=j.useState([]),[l,o]=j.useState([]),[i,c]=j.useState([]),[n,s]=j.useState(!1);return j.useEffect(()=>{if(!a){r([]),o([]),c([]);return}let x=!1;return s(!0),(async()=>{const[v,d,h]=await Promise.all([L.from("brand_visual_library").select("file_url, label, role, is_primary, is_active, sort_order").eq("project_id",a).order("sort_order",{ascending:!0}),L.from("brand_assets").select("file_url, asset_type, label, created_at").eq("project_id",a).order("created_at",{ascending:!1}),L.from("brand_dna").select("product_images, logo_url, logo_urls").eq("project_id",a).maybeSingle()]);if(x)return;r((v.data||[]).filter(N=>N.is_active!==!1)),o(d.data||[]);const b=h.data,g=[];if(Array.isArray(b==null?void 0:b.product_images))for(const N of b.product_images)typeof N=="string"&&N.length>0&&g.push(N);c(g),s(!1)})(),()=>{x=!0}},[a]),{assets:j.useMemo(()=>{const x=new Set,v=[];for(const d of t){const h=d.file_url;!h||x.has(h)||(x.add(h),v.push({url:h,label:d.label||null,role:d.role||"other",isPrimary:!!d.is_primary,source:"visual_library"}))}for(const d of l){const h=d.file_url;if(!h||x.has(h))continue;x.add(h);const b=lt[(d.asset_type||"").toLowerCase()]||"other";v.push({url:h,label:d.label||null,role:b,isPrimary:!1,source:"brand_assets"})}for(const d of i)!d||x.has(d)||(x.add(d),v.push({url:d,label:null,role:"product_shot",isPrimary:!1,source:"product_images"}));return v},[t,l,i]),loading:n}}const $={};function ot(a){const[t,r]=j.useState(a?$[a]??null:null);return j.useEffect(()=>{if(!a){r(null);return}if(a in $){r($[a]);return}let l=!1;return(async()=>{const{data:o,error:i}=await L.from("brand_dna").select("design_system").eq("project_id",a).maybeSingle();if(l)return;if(i){$[a]=null,r(null);return}const c=o==null?void 0:o.design_system,n=c&&typeof c=="object"?c:null;$[a]=n,r(n)})(),()=>{l=!0}},[a]),t}const Z={primary:"#1F2937",accent:"#6B7280",maasy:"#C428D4",fg:"#FFFFFF"};
1function it(a){return typeof a=="string"&&/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(a.trim())}function _e(a){const t=a.trim();if(t.length===4){const[,r,l,o]=t;return`#${r}${r}${l}${l}${o}${o}`.toUpperCase()}return t.toUpperCase()}function H(a,t){return it(a)?_e(a):t}function se(a){const t=_e(a),r=/^#([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/.exec(t);return r?[parseInt(r[1],16),parseInt(r[2],16),parseInt(r[3],16)]:[0,0,0]}function ce(a,t,r){const l=o=>Math.max(0,Math.min(255,Math.round(o))).toString(16).padStart(2,"0");return`#${l(a)}${l(t)}${l(r)}`.toUpperCase()}function q(a){const[t,r,l]=se(a),o=i=>{const c=i/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)};return .2126*o(t)+.7152*o(r)+.0722*o(l)}function ae(a,t){const r=q(a),l=q(t);return(Math.max(r,l)+.05)/(Math.min(r,l)+.05)}function ie(a){return q(a)>.55}function le(a,t){const[r,l,o]=se(a);return ce(r*(1-t),l*(1-t),o*(1-t))}function ct(a,t){const[r,l,o]=se(a);return ce(r+(255-r)*t,l+(255-l)*t,o+(255-o)*t)}function ne(a,t){const[r,l,o]=se(a),i=Math.max(r,l,o),c=Math.min(r,l,o),n=(i+c)/2/255;if(i===c)return a;const s=(i-c)/255,f=n>.5?s/(2-2*n):s/(2*n);let x=0;const v=r/255,d=l/255,h=o/255;i===r?x=(d-h)/(s||1)%6:i===l?x=(h-v)/(s||1)+2:x=(v-d)/(s||1)+4,x=(x*60+t+360)%360;const b=(1-Math.abs(2*n-1))*f,g=b*(1-Math.abs(x/60%2-1)),N=n-b/2;let S=0,k=0,_=0;return x<60?[S,k,_]=[b,g,0]:x<120?[S,k,_]=[g,b,0]:x<180?[S,k,_]=[0,b,g]:x<240?[S,k,_]=[0,g,b]:x<300?[S,k,_]=[g,0,b]:[S,k,_]=[b,0,g],ce((S+N)*255,(k+N)*255,(_+N)*255)}function dt(a,t){if(!a)return;const r=t?"dark_bg":"light_bg",o=(a.variants||[]).find(i=>(i==null?void 0:i.variant)===r&&i.url);return o?o.url:a.url||void 0}function ut(a){let{primary:t,accent:r,secondary:l}=a;return ae(t,r)<1.3&&(r=ne(r,40)),ae(t,l)<1.3&&(l=ne(l,-50)),ae(r,l)<1.3&&(l=ne(l,30)),{primary:t,accent:r,secondary:l}}function mt(a,t,r,l,o){var R,u;const i=a==null?void 0:a.colors,c=(l==null?void 0:l.dark)||(l==null?void 0:l.light)||null;let n=H((c==null?void 0:c.cta_bg)??(i==null?void 0:i.primary),Z.primary),s=H((c==null?void 0:c.accent)??(i==null?void 0:i.accent),Z.accent),f=H((c==null?void 0:c.brand_bg)??(i==null?void 0:i.secondary),Z.maasy);({primary:n,accent:s,secondary:f}=ut({primary:n,accent:s,secondary:f}));const x=H(i==null?void 0:i.background,""),v=x&&!ie(x),d=v?x:le(n,.88),h=v?le(x,.15):le(f,.85),b=H(i==null?void 0:i.text,Z.fg),N=ae(b,d)>=4?b:"#FFFFFF",S=ie(N)?"rgba(255,255,255,0.65)":"rgba(0,0,0,0.65)";let _=[n,s,f].sort((w,C)=>q(C)-q(w))[0];q(_)<.15&&(_=ct(_,.4));const F=((R=a==null?void 0:a.fonts)==null?void 0:R.heading)||"Poppins",M=((u=a==null?void 0:a.fonts)==null?void 0:u.body)||F;return{name:t||(a==null?void 0:a.name)||"Brand",logoText:(t||(a==null?void 0:a.name)||"Brand").toUpperCase(),palette:{primary:n,accent:s,maasy:_,bgFrom:d,bgTo:h,fg:N,fgMuted:S},typography:{display:F,displayWeight:800,body:M,bodyWeight:500},mood:{energy:(r==null?void 0:r.energy)??"energetic",grain:(r==null?void 0:r.grain)??.06,glowOpacity:(r==null?void 0:r.glowOpacity)??.55},designSystem:o?{geometric_grammar:o.geometric_grammar,decorative_density:o.decorative_density,accent_shapes:o.accent_shapes,image_masking:o.image_masking,color_application:o.color_application,texture_overlay:o.texture_overlay,typographic_personality:o.typographic_personality,border_treatment:o.border_treatment,inspiration_anchors:o.inspiration_anchors}:void 0}}function xt(a,t){const r=!ie(t.palette.bgFrom);return dt(a==null?void 0:a.logo,r)}const re={paletteRotation:0,bgMode:"brand",bgImageOverlay:.55};function gt(a,t){const r={...a.palette};if(t.paletteRotation===1){const l=r.primary;r.primary=r.accent,r.accent=r.maasy,r.maasy=l}else if(t.paletteRotation===2){const l=r.primary;r.primary=r.maasy,r.maasy=r.accent,r.accent=l}return t.bgMode==="solid"&&t.bgSolid&&(r.bgFrom=t.bgSolid,r.bgTo=t.bgSolid),{...a,palette:r,bgImage:t.bgMode==="image"&&t.bgImageUrl?{url:t.bgImageUrl,overlayOpacity:typeof t.bgImageOverlay=="number"?t.bgImageOverlay:.55}:void 0}}const xe="landing-images",ge={product_shot:"Productos",detail:"Detalle",lifestyle:"Lifestyle",founder:"Founder",team:"Equipo",screenshot:"Screenshots",gimmick:"Gimmick",facility:"Instalaciones",social_proof:"Social proof",before_after:"Antes/después",logo:"Logos",other:"Otros"},he=["product_shot","detail","lifestyle","screenshot","gimmick","founder","team","facility","social_proof","before_after","logo","other"];function V({label:a,hint:t,value:r,onChange:l,projectId:o,slotKey:i,brandOptions:c=[]}){const n=j.useRef(null),[s,f]=j.useState(!1),[x,v]=j.useState(""),[d,h]=j.useState("all"),{toast:b}=Ce(),g=j.useMemo(()=>{const u={};for(const w of c){const C=w.role||"other";(u[C]=u[C]||[]).push(w)}return u},[c]),N=j.useMemo(()=>{const u=Object.keys(g);return he.filter(w=>u.includes(w)).concat(u.filter(w=>!he.includes(w)))},[g]),S=j.useMemo(()=>{const u=d==="all"?c:g[d]||[];if(!x.trim())return u;const w=x.trim().toLowerCase();return u.filter(C=>(C.label||"").toLowerCase().includes(w)||(C.role||"").toLowerCase().includes(w))},[d,c,g,x]),k=async u=>{var w;if(u){if(u.size>10*1024*1024){b({title:"Imagen muy grande",description:"Máximo 10 MB.",variant:"destructive"});return}f(!0);try{const C=((w=u.name.split(".").pop())==null?void 0:w.toLowerCase())||"jpg",P=`${o}/motion-ads/${Date.now()}-${i}.${C}`,{error:U}=await L.storage.from(xe).upload(P,u,{upsert:!0,contentType:u.type});if(U)throw U;const{data:m}=L.storage.from(xe).getPublicUrl(P);if(!(m!=null&&m.publicUrl))throw new Error("Could not resolve public URL");l(m.publicUrl)}catch(C){const P=C instanceof Error?C.message:"Error desconocido";b({title:"No se pudo subir",description:P,variant:"destructive"})}finally{f(!1)}}},_=/^https?:\/\//.test(r),F=r&&!_,M=!!o,R=c.length>0;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(be,{className:"text-xs font-medium",children:a}),r&&e.jsxs("button",{type:"button",onClick:()=>l(""),className:"text-[10px] text-muted-foreground hover:text-destructive flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"Quitar"]})]}),r?e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded-md bg-muted/30 border border-border/40",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded bg-black/40 flex items-center justify-center overflow-hidden flex-shrink-0",children:_?e.jsx("img",{src:r,alt:"",className:"w-full h-full object-cover",onError:u=>{u.currentTarget.style.display="none"}}):e.jsx(Y,{className:"w-5 h-5 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs truncate",children:_?new URL(r).pathname.split("/").pop():r}),e.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:F?"Bundle asset (test)":"Asset cargado"})]})]}):null,e.jsxs(je,{defaultValue:M?"brand":"upload",children:[e.jsxs(ye,{className:"h-8",children:[M&&e.jsxs(z,{value:"brand",className:"text-xs h-6 px-2.5",children:["Marca (",c.length,")"]}),e.jsx(z,{value:"upload",className:"text-xs h-6 px-2.5",children:"Subir"}),e.jsx(z,{value:"url",className:"text-xs h-6 px-2.5",children:"URL"})]}),M&&e.jsxs(W,{value:"brand",className:"mt-2 space-y-2",children:[R?null:e.jsxs("div",{className:"rounded-md border border-dashed border-border/40 p-6 text-center bg-muted/10",children:[e.jsx(Y,{className:"w-6 h-6 mx-auto text-muted-foreground/50"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Esta marca aún no tiene imágenes en su biblioteca."}),e.jsxs("p",{className:"text-[11px] text-muted-foreground/70 mt-1",children:["Súbelas desde el perfil de la marca, o usa la pestaña ",e.jsx("strong",{children:"Subir"})," aquÃ."]})]}),R&&N.length>1&&e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>h("all"),className:B("text-[10px] px-2 py-1 rounded-full border transition",d==="all"?"bg-primary/15 border-primary text-primary":"border-border/40 text-muted-foreground hover:border-border"),children:["Todos (",c.length,")"]}),N.map(u=>e.jsxs("button",{type:"button",onClick:()=>h(u),className:B("text-[10px] px-2 py-1 rounded-full border transition",d===u?"bg-primary/15 border-primary text-primary":"border-border/40 text-muted-foreground hover:border-border"),children:[ge[u]||u," (",g[u].length,")"]},u))]}),R&&c.length>8&&e.jsxs("div",{className:"relative",children:[e.jsx(Se,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground"}),e.jsx(p,{value:x,onChange:u=>v(u.target.value),placeholder:"Buscar por etiqueta o categorÃaâ¦",className:"h-8 text-xs pl-7"})]}),R&&e.jsxs("div",{className:"grid grid-cols-4 gap-2 max-h-72 overflow-y-auto p-1",children:[S.map((u,w)=>{const C=u.url===r;return e.jsxs("button",{type:"button",onClick:()=>l(u.url),className:B("relative aspect-square rounded-md overflow-hidden border-2 transition-all bg-black/40 group",C?"border-primary ring-2 ring-primary/30":"border-border/40 hover:border-border"),title:u.label||u.role||"",children:[e.jsx("img",{src:u.url,className:"w-full h-full object-cover",alt:""}),u.role&&e.jsx("div",{className:"absolute top-0.5 left-0.5 text-[8px] bg-black/70 text-white px-1 rounded",children:ge[u.role]||u.role}),u.isPrimary&&e.jsx("div",{className:"absolute top-0.5 right-0.5 text-[8px] bg-primary text-white px-1 rounded",children:"â
"}),C&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-primary/40",children:e.jsx(ke,{className:"w-5 h-5 text-white"})})]},`${u.url}-${w}`)}),S.length===0&&e.jsx("div",{className:"col-span-4 text-center py-6 text-xs text-muted-foreground",children:x?"Sin resultados.":"No hay assets en esta categorÃa."})]})]}),e.jsxs(W,{value:"upload",className:"mt-2",children:[e.jsx(G,{type:"button",variant:"outline",size:"sm",onClick:()=>{var u;return(u=n.current)==null?void 0:u.click()},disabled:s||!o,className:"w-full h-9 text-xs",children:s?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"w-3.5 h-3.5 mr-2 animate-spin"}),"Subiendoâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx($e,{className:"w-3.5 h-3.5 mr-2"}),"Elegir archivo"]})}),e.jsx("input",{ref:n,type:"file",accept:"image/*",className:"hidden",onChange:u=>{var C;const w=(C=u.target.files)==null?void 0:C[0];w&&k(w),u.currentTarget.value=""}})]}),e.jsx(W,{value:"url",className:"mt-2",children:e.jsx(p,{type:"url",value:r,onChange:u=>l(u.target.value),placeholder:"https://â¦",className:"h-9 text-xs"})})]}),t&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t})]})}function ht({palette:a,overrides:t,onChange:r,projectId:l,bgImageOptions:o=[]}){const i=d=>r({...t,paletteRotation:d}),c=d=>r({...t,bgMode:d}),n=d=>r({...t,bgSolid:d}),s=d=>r({...t,bgImageUrl:d}),f=d=>r({...t,bgImageOverlay:d}),x=t.paletteRotation!==re.paletteRotation||t.bgMode!==re.bgMode||!!t.bgSolid||!!t.bgImageUrl,v=t.paletteRotation===1?[a.accent,a.maasy,a.primary]:t.paletteRotation===2?[a.maasy,a.primary,a.accent]:[a.primary,a.accent,a.maasy];return e.jsxs("div",{className:"space-y-3 rounded-lg border border-border/40 bg-background/40 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(Ne,{className:"w-3 h-3"}),"Ajustes visuales"]}),x&&e.jsxs("button",{type:"button",onClick:()=>r(re),className:"text-[10px] text-muted-foreground hover:text-foreground flex items-center gap-1",children:[e.jsx(He,{className:"w-3 h-3"}),"Reset"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Paleta â orden de colores"}),e.jsx("div",{className:"flex items-center gap-2",children:[0,1,2].map(d=>{const h=t.paletteRotation===d,b=["Marca","Rotada 1","Rotada 2"];return e.jsx("button",{type:"button",onClick:()=>i(d),className:B("flex-1 px-2 py-1.5 rounded-md border text-[10px] transition-colors",h?"border-primary bg-primary/15 text-primary":"border-border/40 hover:border-border"),children:b[d]},d)})}),e.jsx("div",{className:"flex items-center gap-1 pt-1",children:v.map((d,h)=>e.jsx("div",{className:"flex-1 h-7 rounded-md border border-border/30",style:{background:d},title:`Slot ${h===0?"primary":h===1?"accent":"glow"} â ${d}`},h))})]}),e.jsxs("div",{className:"space-y-1.5 pt-2 border-t border-border/30",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Fondo"}),e.jsx("div",{className:"flex items-center gap-2",children:[{key:"brand",label:"Gradiente marca"},{key:"solid",label:"Color sólido"},{key:"image",label:"Imagen"}].map(({key:d,label:h})=>{const b=t.bgMode===d;return e.jsx("button",{type:"button",onClick:()=>c(d),className:B("flex-1 px-2 py-1.5 rounded-md border text-[10px] transition-colors",b?"border-primary bg-primary/15 text-primary":"border-border/40 hover:border-border"),children:h},d)})}),t.bgMode==="solid"&&e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("input",{type:"color",value:t.bgSolid||a.bgFrom,onChange:d=>n(d.target.value.toUpperCase()),className:"w-9 h-9 rounded-md border border-border/40 bg-transparent cursor-pointer"}),e.jsx(p,{value:t.bgSolid||a.bgFrom,onChange:d=>{const h=d.target.value.trim();(/^#[0-9A-Fa-f]{0,6}$/.test(h)||h==="")&&n(h.toUpperCase())},placeholder:"#0A0F1E",className:"h-8 text-xs font-mono"})]}),t.bgMode==="image"&&e.jsxs("div",{className:"space-y-2 pt-1",children:[l?e.jsx(V,{label:"",value:t.bgImageUrl||"",onChange:d=>s(d),projectId:l,slotKey:"background",brandOptions:o}):e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Selecciona una marca activa para subir una imagen."}),t.bgImageUrl&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[e.jsx("span",{children:"Opacidad gradiente sobre la imagen"}),e.jsxs("span",{className:"font-mono",children:[Math.round((t.bgImageOverlay??.55)*100),"%"]})]}
1),e.jsx("input",{type:"range",min:0,max:1,step:.05,value:t.bgImageOverlay??.55,onChange:d=>f(Number(d.target.value)),className:"w-full"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[e.jsx(Y,{className:"w-3 h-3"}),"Imagen detrás · gradiente marca encima al"," ",Math.round((t.bgImageOverlay??.55)*100),"%"]}),e.jsxs("button",{type:"button",onClick:()=>s(""),className:"text-[10px] text-muted-foreground hover:text-destructive flex items-center gap-1",children:[e.jsx(pe,{className:"w-3 h-3"}),"Quitar imagen"]})]})]})]})]})}function ft(a){const[t,r]=j.useState(null),[l,o]=j.useState(!1);return j.useEffect(()=>{if(!a){r(null),o(!1);return}let i=!1;return(async()=>{try{const{data:c}=await Promise.resolve(L.from("brand_dna").select("color_system").eq("project_id",a).maybeSingle()).catch(()=>({data:null}));if(i)return;const n=c==null?void 0:c.color_system;n!=null&&n.light&&(n!=null&&n.dark)?r(n):r(null)}catch{i||r(null)}finally{i||o(!0)}})(),()=>{i=!0}},[a]),{colorSystem:t,loaded:l}}const bt={"kinetic-hero":J,"product-reveal":Je,listicle:We,"quote-stat":ze,"before-after":Ve,"multi-scene-story":Ge};function pt({selected:a,onSelect:t}){const r=Object.keys(Q);return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:r.map(l=>{const o=Q[l],i=bt[l],c=a===l;return e.jsxs("button",{type:"button",onClick:()=>t(l),className:B("text-left rounded-xl border p-4 transition-all","bg-card/40 hover:bg-card/70",c?"border-primary ring-2 ring-primary/30 shadow-[0_0_30px_rgba(56,97,196,0.25)]":"border-border/40 hover:border-border"),children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:B("flex-shrink-0 w-10 h-10 rounded-lg flex items-center justify-center",c?"bg-gradient-to-br from-primary to-accent text-white":"bg-muted text-muted-foreground"),children:e.jsx(i,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold text-sm leading-tight",children:o.title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[o.duration_seconds,"s · ",o.use_case]})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-3 leading-relaxed line-clamp-3",children:o.description})]},l)})})}const fe={"kinetic-hero":{logoImage:"",hook:"Tu marca",hookEmphasis:"merece más.",subline:"Una lÃnea que explica qué haces, cortita.",cta:"Empieza ahora"},"product-reveal":{productImage:"",logoImage:"",tagline:"Conoce el producto.",productName:"CategorÃa",bullets:["Beneficio uno","Beneficio dos","Beneficio tres"],cta:"Pruébalo"},listicle:{logoImage:"",number:"5",title:"errores que estás cometiendo",items:[{title:"Error uno",desc:"Una lÃnea que explica el error."},{title:"Error dos",desc:"Otra lÃnea."},{title:"Error tres",desc:"Otra lÃnea más."},{title:"Error cuatro",desc:"Otra lÃnea."},{title:"Error cinco",desc:"Ãltima lÃnea."}],cta:"AudÃtalo gratis"},"quote-stat":{logoImage:"",statValue:73,statSuffix:"%",caption:"de los X no sabe Y.",source:"â Fuente del dato",cta:"Ver el reporte"},"before-after":{logoImage:"",headline:"Mismo problema. Otro resultado.",beforeLabel:"Antes",afterLabel:"Con tu marca",beforeStats:["Métrica baja","Métrica mala","Métrica fea"],afterStats:["Métrica alta","Métrica buena","Métrica linda"],cta:"Ver cómo"},"multi-scene-story":{logoImage:"",brollImage:"",brollImage2:"",hookText:"EL HOOK",brollWord:"BASTA.",statBefore:"AHORRAS",statNumber:"12h",statSuffix:"/semana",iconsHeadline:"Headline corto",brandTonic:"Tagline marca",iconSet:"saas"}};function jt({recipeId:a,value:t,onChange:r,projectId:l,productOptions:o=[],logoOptions:i=[],preferredLogoUrl:c}){j.useEffect(()=>{var d,h,b,g;if(Object.keys(t).length>0)return;const s={...fe[a]},f=(d=o[0])==null?void 0:d.url,x=((h=o[1])==null?void 0:h.url)||((b=o[0])==null?void 0:b.url),v=c||((g=i[0])==null?void 0:g.url);f&&"productImage"in s&&(s.productImage=f),v&&"logoImage"in s&&(s.logoImage=v),f&&"brollImage"in s&&(s.brollImage=f),x&&"brollImage2"in s&&(s.brollImage2=x),r(s)},[a,o,i,c]),j.useEffect(()=>{var x,v,d,h,b,g,N,S;if(Object.keys(t).length===0)return;const s={},f=Object.keys(fe[a]);f.includes("logoImage")&&!t.logoImage&&(c||(x=i[0])!=null&&x.url)&&(s.logoImage=c||((v=i[0])==null?void 0:v.url)),f.includes("productImage")&&!t.productImage&&((d=o[0])!=null&&d.url)&&(s.productImage=o[0].url),f.includes("brollImage")&&!t.brollImage&&((h=o[0])!=null&&h.url)&&(s.brollImage=o[0].url),f.includes("brollImage2")&&!t.brollImage2&&((b=o[1])!=null&&b.url||(g=o[0])!=null&&g.url)&&(s.brollImage2=((N=o[1])==null?void 0:N.url)||((S=o[0])==null?void 0:S.url)),Object.keys(s).length>0&&r({...t,...s})},[c,o,i]);const n=(s,f)=>r({...t,[s]:f});switch(a){case"kinetic-hero":return e.jsxs(D,{children:[e.jsx(y,{label:"Hook (lÃnea 1)",hint:"Texto secundario que entra primero",children:e.jsx(p,{value:t.hook||"",onChange:s=>n("hook",s.target.value),placeholder:"Tu marca"})}),e.jsx(y,{label:"Ãnfasis (lÃnea 2)",hint:"Bold + underline magenta. La lÃnea principal.",children:e.jsx(p,{value:t.hookEmphasis||"",onChange:s=>n("hookEmphasis",s.target.value),placeholder:"merece más."})}),e.jsx(y,{label:"SubtÃtulo",children:e.jsx(p,{value:t.subline||"",onChange:s=>n("subline",s.target.value),placeholder:"Una lÃnea cortita que explica qué haces."})}),e.jsx(y,{label:"CTA",children:e.jsx(p,{value:t.cta||"",onChange:s=>
1n("cta",s.target.value),placeholder:"Empieza ahora"})})]});case"product-reveal":return e.jsxs(D,{children:[l?e.jsx(V,{label:"Producto",hint:"Pre-cargado de tu biblioteca de marca. Cambialo si querés.",value:t.productImage||"",onChange:s=>n("productImage",s),projectId:l,slotKey:"product",brandOptions:o}):e.jsx(y,{label:"Producto (asset)",hint:"Selecciona una marca para subir.",children:e.jsx(p,{value:t.productImage||"",onChange:s=>n("productImage",s.target.value)})}),l?e.jsx(V,{label:"Logo",hint:"Pre-cargado del DNA de tu marca.",value:t.logoImage||"",onChange:s=>n("logoImage",s),projectId:l,slotKey:"logo",brandOptions:i}):e.jsx(y,{label:"Logo (asset)",hint:"Selecciona una marca para subir.",children:e.jsx(p,{value:t.logoImage||"",onChange:s=>n("logoImage",s.target.value)})}),e.jsx(y,{label:"CategorÃa / eyebrow",children:e.jsx(p,{value:t.productName||"",onChange:s=>n("productName",s.target.value),placeholder:"Marketing as a Service"})}),e.jsx(y,{label:"Tagline",children:e.jsx(p,{value:t.tagline||"",onChange:s=>n("tagline",s.target.value),placeholder:"Conoce el producto."})}),e.jsx(oe,{label:"Bullets (3)",bullets:t.bullets||[],onChange:s=>n("bullets",s)}),e.jsx(y,{label:"CTA",children:e.jsx(p,{value:t.cta||"",onChange:s=>n("cta",s.target.value)})})]});case"listicle":return e.jsxs(D,{children:[e.jsx(y,{label:"Número grande",hint:"Eje. 5, 7, 10",children:e.jsx(p,{value:t.number||"",onChange:s=>n("number",s.target.value),maxLength:3})}),e.jsx(y,{label:"TÃtulo",children:e.jsx(p,{value:t.title||"",onChange:s=>n("title",s.target.value),placeholder:"errores que estás cometiendo"})}),e.jsx(yt,{label:"Items (5)",items:t.items||[],onChange:s=>n("items",s)}),e.jsx(y,{label:"CTA",children:e.jsx(p,{value:t.cta||"",onChange:s=>n("cta",s.target.value)})})]});case"quote-stat":return e.jsxs(D,{children:[e.jsx(y,{label:"Número (stat)",children:e.jsx(p,{type:"number",value:t.statValue??0,onChange:s=>n("statValue",Number(s.target.value))})}),e.jsx(y,{label:"Sufijo",hint:"Ej. %, x, M",children:e.jsx(p,{value:t.statSuffix||"",onChange:s=>n("statSuffix",s.target.value),maxLength:4})}),e.jsx(y,{label:"Caption",children:e.jsx(Ae,{value:t.caption||"",onChange:s=>n("caption",s.target.value),rows:2})}),e.jsx(y,{label:"Fuente",children:e.jsx(p,{value:t.source||"",onChange:s=>n("source",s.target.value),placeholder:"â Fuente del dato"})}),e.jsx(y,{label:"CTA",children:e.jsx(p,{value:t.cta||"",onChange:s=>n("cta",s.target.value)})})]});case"multi-scene-story":return e.jsxs(D,{children:[l?e.jsx(V,{label:"B-roll Escena 1 (hook)",hint:"Foto que abre el ad. Idealmente: persona, escritorio, contexto del dolor.",value:t.brollImage||"",onChange:s=>n("brollImage",s),projectId:l,slotKey:"broll1",brandOptions:o}):null,l?e.jsx(V,{label:"B-roll Escena 2 (BASTA)",hint:"Foto del corte. Lo que el user 'detiene'.",value:t.brollImage2||"",onChange:s=>n("brollImage2",s),projectId:l,slotKey:"broll2",brandOptions:o}):null,e.jsx(y,{label:"Hook (escena 1)",hint:"Pill 2-3 palabras MAYÃSCULAS. Tensión emocional inmediata.",children:e.jsx(p,{value:t.hookText||"",onChange:s=>n("hookText",s.target.value),maxLength:30})}),e.jsx(y,{label:"Palabra-corte (escena 2)",hint:"Una sola palabra. Imperativa. Termina en punto si querés.",children:e.jsx(p,{value:t.brollWord||"",onChange:s=>
1n("brollWord",s.target.value),maxLength:20})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(y,{label:"Stat: prefijo",children:e.jsx(p,{value:t.statBefore||"",onChange:s=>n("statBefore",s.target.value),placeholder:"AHORRAS",maxLength:20})}),e.jsx(y,{label:"Stat: número",children:e.jsx(p,{value:t.statNumber||"",onChange:s=>n("statNumber",s.target.value),placeholder:"12h",maxLength:10})}),e.jsx(y,{label:"Stat: sufijo",children:e.jsx(p,{value:t.statSuffix||"",onChange:s=>n("statSuffix",s.target.value),placeholder:"/semana",maxLength:20})})]}),e.jsx(y,{label:"Headline iconos (escena 4)",children:e.jsx(p,{value:t.iconsHeadline||"",onChange:s=>n("iconsHeadline",s.target.value),maxLength:60})}),e.jsx(y,{label:"Set de iconos",hint:"logistics: paquete/mapa/check/camión · saas: target/lightning/chart/loop · pet: bowl/heart/leaf/calendar",children:e.jsxs("select",{value:t.iconSet||"saas",onChange:s=>n("iconSet",s.target.value),className:"w-full h-9 rounded-md border border-input bg-background px-3 text-xs",children:[e.jsx("option",{value:"saas",children:"SaaS / B2B"}),e.jsx("option",{value:"logistics",children:"LogÃstica / EnvÃos"}),e.jsx("option",{value:"pet",children:"Pet care"})]})}),e.jsx(y,{label:"Tonic de cierre (escena 5)",hint:"Frase final encima del logo.",children:e.jsx(p,{value:t.brandTonic||"",onChange:s=>n("brandTonic",s.target.value),maxLength:50})})]});case"before-after":return e.jsxs(D,{children:[e.jsx(y,{label:"Headline",children:e.jsx(p,{value:t.headline||"",onChange:s=>n("headline",s.target.value)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(y,{label:"Label 'Antes'",children:e.jsx(p,{value:t.beforeLabel||"",onChange:s=>n("beforeLabel",s.target.value)})}),e.jsx(y,{label:"Label 'Después'",children:e.jsx(p,{value:t.afterLabel||"",onChange:s=>n("afterLabel",s.target.value)})})]}),e.jsx(oe,{label:"Métricas Antes (3)",bullets:t.beforeStats||[],onChange:s=>n("beforeStats",s),placeholder:"Métrica baja"}),e.jsx(oe,{label:"Métricas Después (3)",bullets:t.afterStats||[],onChange:s=>n("afterStats",s),placeholder:"Métrica alta"}),e.jsx(y,{label:"CTA",children:e.jsx(p,{value:t.cta||"",onChange:s=>n("cta",s.target.value)})})]});default:return null}}function D({children:a}){return e.jsx("div",{className:"space-y-3",children:a})}function y({label:a,hint:t,children:r}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(be,{className:"text-xs font-medium",children:a}),r,t&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:t})]})}function oe({label:a,bullets:t,onChange:r,placeholder:l}){const o=t.length?t:["","",""];return e.jsx(y,{label:a,children:e.jsx("div",{className:"space-y-2",children:o.map((i,c)=>e.jsx(p,{value:i,placeholder:l||`Bullet ${c+1}`,onChange:n=>{const s=[...o];s[c]=n.target.value,r(s)}},c))})})}function yt({label:a,items:t,onChange:r}){const l=t.length?t:Array.from({length:5},()=>({title:"",desc:""})),o=(i,c,n)=>{const s=[...l];s[i]={...s[i],[c]:n},r(s)};return e.jsx(y,{label:a,children:e.jsx("div",{className:"space-y-3",children:l.map((i,c)=>e.jsxs("div",{className:"space-y-1.5 p-3 rounded-md bg-muted/30 border border-border/40",children:[e.jsxs("div",{className:"text-[11px] text-muted-foreground font-medium",children:["#",String(c+1).padStart(2,"0")]}),e.jsx(p,{value:i.title,onChange:n=>o(c,"title",n.target.value),placeholder:"TÃtulo corto"}),e.jsx(p,{value:i.desc,onChange:n=>o(c,"desc",n.target.value),placeholder:"Descripción de 1 lÃnea"})]},c))})})}const vt={energetic:"Energética",calm:"Calma",sophisticated:"Sofisticada",playful:"Lúdica"};function Nt({brandDNA:a,logoUrl:t,assetsCount:r}){const{palette:l,typography:o,mood:i,name:c}=a;return e.jsxs("div",{className:"rounded-lg border border-border/40 bg-card/40 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-border/40 flex items-center gap-2",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-semibold",children:"Brand DNA aplicado"}),e.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto truncate",children:c})]}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 rounded-md overflow-hidden flex-shrink-0 flex items-center justify-center",style:{background:`linear-gradient(135deg, ${l.bgFrom} 0%, ${l.bgTo} 100%)`},children:t?e.jsx("img",{src:t,className:"max-w-full max-h-full object-contain p-1",alt:""}):e.jsx(Y,{className:"w-4 h-4 text-white/40"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:[e.jsx(Ne,{className:"w-2.5 h-2.5"}),"Paleta"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(ee,{color:l.primary,label:"Primary"}),e.jsx(ee,{color:l.accent,label:"Accent"}),e.jsx(ee,{color:l.maasy,label:"Glow"}),e.jsx(ee,{color:l.bgFrom,label:"Bg"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:[e.jsx(Qe,{className:"w-2.5 h-2.5"}),"TipografÃa"]}),e.jsx("div",{className:"text-xs font-medium truncate",style:{fontFamily:o.display},children:o.display})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground mb-1",children:"Mood"}),e.jsx("div",{className:"inline-block text-[10px] px-2 py-0.5 rounded-full",style:{background:`${l.maasy}22`,color:l.maasy,border:`1px solid ${l.maasy}55`},children:vt[i.energy]})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground border-t border-border/40 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),e.jsx("span",{children:"Biblioteca"})]}),e.jsxs("span",{className:"font-medium",children:[r," asset",r!==1?"s":""]})]})]})]})}function ee({color:a,label:t}){return e.jsx("div",{className:"w-6 h-6 rounded border border-border/40",style:{background:a},title:`${t}: ${a}`})}function Ut(){var U;
1const{activeBrandId:a,activeBrand:t}=Ie(),{brandKit:r}=Pe(a),l=Ze(a),{assets:o}=nt(a),{colorSystem:i}=ft(a),c=ot(a),n=j.useMemo(()=>[...o].sort((m,A)=>Number(A.isPrimary)-Number(m.isPrimary)).map(m=>({url:m.url,label:m.label,role:m.role,isPrimary:m.isPrimary})),[o]),s=j.useMemo(()=>{var A,I,T;const m=[];(A=r==null?void 0:r.logo)!=null&&A.url&&m.push({url:r.logo.url,label:"Logo principal",role:"logo",isPrimary:!0});for(const E of((I=r==null?void 0:r.logo)==null?void 0:I.variants)||[])E.url&&E.url!==((T=r==null?void 0:r.logo)==null?void 0:T.url)&&m.push({url:E.url,label:E.variant,role:"logo"});for(const E of o)E.role==="logo"&&!m.some(we=>we.url===E.url)&&m.push({url:E.url,label:E.label,role:"logo",isPrimary:E.isPrimary});return m},[r==null?void 0:r.logo,o]),[f,x]=j.useState("kinetic-hero"),[v,d]=j.useState("9x16"),[h,b]=j.useState({"kinetic-hero":{},"product-reveal":{},listicle:{},"quote-stat":{},"before-after":{},"multi-scene-story":{}}),g=De({projectId:a}),N=j.useMemo(()=>mt(r,t==null?void 0:t.brand_name,l,i,c),[r,t==null?void 0:t.brand_name,l,i,c]),[S,k]=j.useState(re),_=j.useMemo(()=>gt(N,S),[N,S]),F=j.useMemo(()=>xt(r,_),[r,_]),M=h[f]??{},R=m=>b(A=>({...A,[f]:m})),u=async()=>{a&&await g.generate({recipeId:f,brand:_,brief:M,aspectRatio:v})},w=async()=>{if(!a)return;const m=await g.generateBriefAi(f);m&&b(A=>{const I=A[f]||{},T={...m};return I.productImage&&(T.productImage=I.productImage),I.logoImage&&(T.logoImage=I.logoImage),{...A,[f]:T}})},C=Object.keys(M).length>0,P=Q[f];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(G,{asChild:!0,variant:"ghost",size:"sm",children:e.jsxs(de,{to:"/be-tools",children:[e.jsx(Ee,{className:"w-4 h-4 mr-1.5"}),"Volver"]})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl sm:text-2xl font-bold flex items-center gap-2",children:[e.jsx(ue,{className:"w-5 h-5 text-primary"}),"Motion Ads",e.jsx("span",{className:"text-[10px] uppercase tracking-wider px-2 py-0.5 rounded-full bg-primary/15 text-primary",children:"Beta"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Reels y ads animados con tu brand DNA. Sin VO, sin actores. Solo motion + texto + b-roll."})]})]}),(t==null?void 0:t.brand_name)&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"Marca activa"}),e.jsx("div",{className:"text-sm font-semibold truncate max-w-[180px]",children:t.brand_name})]})]}),a?e.jsxs(je,{defaultValue:"studio",className:"w-full",children:[e.jsxs(ye,{children:[e.jsxs(z,{value:"studio",children:[e.jsx(ue,{className:"w-3.5 h-3.5 mr-1.5"}),"Studio"]}),e.jsxs(z,{value:"history",children:[e.jsx(me,{className:"w-3.5 h-3.5 mr-1.5"}),"Historial (",g.history.length,")"]})]}),e.jsxs(W,{value:"studio",className:"mt-6 space-y-6",children:[e.jsxs("section",{children:[e.jsx(te,{index:1,title:"Elige una receta"}),e.jsx(pt,{selected:f,onSelect:x})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsxs("aside",{className:"lg:col-span-4 xl:col-span-3 lg:sticky lg:top-0 lg:self-start lg:max-h-[calc(100vh-5rem)] lg:overflow-y-auto rounded-xl border border-border/40 bg-card/40 p-4 space-y-4",children:[e.jsxs("section",{children:[e.jsx(te,{index:2,title:"Marca"}),e.jsx(Nt,{brandDNA:_,logoUrl:F,assetsCount:o.length})]}),e.jsx("section",{children:e.jsx(ht,{palette:N.palette,overrides:S,onChange:k,projectId:a||void 0,bgImageOptions:n})}),e.jsxs("section",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(te,{index:3,title:"Brief",inline:!0}),e.jsxs(G,{type:"button",variant:"outline",size:"sm",onClick:w,disabled:g.isAiBriefing||!a,className:"h-7 text-[11px]",children:[g.isAiBriefing?e.jsx(ve,{className:"w-3 h-3 mr-1 animate-spin"}):e.jsx(J,{className:"w-3 h-3 mr-1"}),"Generar con Maasy"]})]}),e.jsx(jt,{recipeId:f,value:M,onChange:R,projectId:a||void 0,productOptions:n,logoOptions:s,preferredLogoUrl:F})]}),e.jsxs("section",{className:"space-y-2 pt-3 border-t border-border/40",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{index:4,title:"Formato",inline:!0}),e.jsxs(Me,{value:v,onValueChange:m=>d(m),children:[e.jsx(Re,{className:"flex-1 h-9 text-xs",children:e.jsx(Te,{})}),e.jsx(Be,{children:Oe.map(m=>e.jsxs(Le,{value:m,className:"text-xs",children:[m," · ",qe[m]]},m))})]})]}),e.jsxs(G,{onClick:u,disabled:g.isGenerating||!C,className:"w-full h-11 text-sm font-semibold shadow-lg",size:"lg",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),g.isGenerating?"Encolandoâ¦":`Generar (${P.duration_seconds}s · 10 créditos)`]})]})]}),e.jsxs("section",{className:"lg:col-span-8 xl:col-span-9 space-y-4",children:[e.jsx(_t,{aspectRatio:v,children:e.jsx(Ue,{job:g.currentJob,isGenerating:g.isGenerating,error:g.error})}),g.history.length>0&&e.jsx(wt,{items:g.history.slice(0,6),activeId:((U=g.currentJob)==null?void 0:U.id)||null,onClick:m=>g.setCurrentJobId(m)})]})]})]}),e.jsx(W,{value:"history",className:"mt-6",children:g.history.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/40 p-10 text-center bg-muted/10",children:[e.jsx(me,{className:"w-8 h-8 mx-auto text-muted-foreground
1/50"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3",children:"Aún no hay renders. Genera el primero desde Studio."})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:g.history.map(m=>{var A;return e.jsxs("button",{type:"button",onClick:()=>g.setCurrentJobId(m.id),className:"text-left rounded-xl border border-border/40 overflow-hidden bg-card/40 hover:border-primary/60 transition-colors group",children:[e.jsx("div",{className:"bg-black",style:{aspectRatio:m.aspect_ratio==="9x16"?"9 / 16":m.aspect_ratio==="1x1"?"1 / 1":"16 / 9"},children:m.status==="done"&&m.result_url?e.jsx("video",{src:m.result_url,muted:!0,loop:!0,playsInline:!0,className:"w-full h-full object-cover",onMouseEnter:I=>I.currentTarget.play(),onMouseLeave:I=>{const T=I.currentTarget;T.pause(),T.currentTime=0}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-xs text-muted-foreground",children:m.status==="rendering"?`Renderizando⦠${Math.round((m.progress||0)*100)}%`:m.status==="error"?"Error":"En cola"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"text-xs font-semibold truncate",children:((A=Q[m.recipe_id])==null?void 0:A.title)||m.recipe_id}),e.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5 flex items-center gap-2",children:[e.jsx("span",{children:m.aspect_ratio}),e.jsx("span",{children:"·"}),e.jsx("span",{children:new Date(m.created_at).toLocaleDateString()}),m.result_cost_usd!=null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Ye,{className:"w-2.5 h-2.5"}),m.result_cost_usd.toFixed(3)]})]})]})]})]},m.id)})})})]}):e.jsxs("div",{className:"rounded-xl border border-dashed border-border/40 p-10 text-center bg-muted/10",children:[e.jsx(J,{className:"w-8 h-8 mx-auto text-muted-foreground/50"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-3",children:"Selecciona una marca activa para empezar."}),e.jsx(G,{asChild:!0,variant:"outline",className:"mt-4",children:e.jsx(de,{to:"/brands",children:"Ir a marcas"})})]})]})}function te({index:a,title:t,inline:r=!1}){return e.jsxs("h2",{className:B("text-sm font-semibold flex items-center gap-2",!r&&"mb-2"),children:[e.jsx("span",{className:"w-5 h-5 rounded-full bg-primary/15 text-primary text-[11px] font-bold flex items-center justify-center",children:a}),t]})}function _t({aspectRatio:a,children:t}){const r=a==="9x16"?"Reel · 1080Ã1920":a==="1x1"?"Feed · 1080Ã1080":"Wide · 1920Ã1080";return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/30 overflow-hidden",children:[e.jsx("div",{className:"px-4 py-2 border-b border-border/40 flex items-center justify-between",children:e.jsxs("div",{className:"text-xs font-semibold flex items-center gap-2",children:[e.jsx(Ke,{className:"w-3.5 h-3.5 text-muted-foreground"}),r]})}),e.jsx("div",{className:"p-4",children:t})]})}function wt({items:a,activeId:t,onClick:r}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-[11px] uppercase tracking-wider text-muted-foreground",children:[e.jsx(Fe,{className:"w-3 h-3"}),"Recientes"]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:a.map(l=>{var i;const o=l.id===t;return e.jsx("button",{type:"button",onClick:()=>r(l.id),className:B("flex-shrink-0 w-20 rounded-md overflow-hidden border-2 transition-all bg-black/40",o?"border-primary ring-2 ring-primary/30":"border-border/40 hover:border-border"),style:{aspectRatio:l.aspect_ratio==="9x16"?"9 / 16":l.aspect_ratio==="1x1"?"1 / 1":"16 / 9"},title:(i=Q[l.recipe_id])==null?void 0:i.title,children:l.status==="done"&&l.result_url?e.jsx("video",{src:l.result_url,muted:!0,playsInline:!0,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-[9px] text-muted-foreground px-1 text-center",children:l.status==="rendering"?"...":l.status==="error"?"â":"â³"})},l.id)})})]})}export{Ut as default}; 2//# sourceMappingURL=BeToolMotionAds-2dJGyDjK.js.map
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.