PageSourceSearch

https://www.instagem.ai/assets/AdCreatorResultPage-BmdC29x3.js

js instagem.ai collected 2026-10-05 12:05:18 UTC 11,268 bytes, 1 lines download raw bytes

1import{b as M,E as P,aM as B,r as w,j as e,S as H,I as S,C as f,l as N,af as R,c as x,o as $,W as z,aG as F,a as K,am as D,cu as G,ak as q,H as W}from"./main-DX7XzkoU.js";import{B as I}from"./badge-BOGaWzi1.js";import{D as J}from"./DashboardLoading-DZLzzgDQ.js";import{A as O}from"./AnimatedLoader-plV4dLae.js";import{u as Q,I as U,d as V}from"./usePost-Bb_nm_K-.js";import{M as T}from"./megaphone-B0K-HV7w.js";import{A}from"./arrow-left-Cf41rOjY.js";import{D as X}from"./download-DFu9GkQ8.js";import{C as Y}from"./copy-CZIwHXLK.js";import"./gem-DGeoeC5P.js";import"./brain-CtAcgEyq.js";import"./palette-OTKsHiwO.js";import"./wand-sparkles-CwRAYUwy.js";import"./camera-D4Am3_jY.js";import"./proxy-BFtvzxWL.js";import"./index-CSlo_wNj.js";import"./lightbulb-UJa6zn96.js";import"./chevron-left-B_lb0x5L.js";import"./chevron-right-D27HfhtL.js";import"./referral-code-CAIXjQN4.js";import"./sheet-D4yLKOxB.js";import"./share-2-DpYr0PID.js";import"./external-link-Bhm5X9sQ.js";import"./circle-help-CV3y08qY.js";const Z=({postId:b,ad:m,onGenerating:a})=>{const{t:i}=M(),{toast:l}=P(),{openPricingModal:_}=B(),h=m.image_concepts||[],[v,k]=w.useState(m.art_cta||""),[p,y]=w.useState(h.map(t=>({headline:t.headline||"",subheadline:t.subheadline||""}))),[C,u]=w.useState(!1),o=(t,n,c)=>{y(d=>d.map((s,r)=>r===t?{...s,[n]:c}:s))},L=p.length>0&&p.every(t=>t.headline.trim().length>0),g=async()=>{u(!0);try{const t=h.map((s,r)=>{var j,E;return{...s,headline:((j=p[r])==null?void 0:j.headline)??s.headline,subheadline:((E=p[r])==null?void 0:E.subheadline)??s.subheadline}}),{error:n}=await z.from("posts").update({post_data:{ad:{...m,art_cta:v.trim(),image_concepts:t}}}).eq("id",b);if(n)throw new Error(n.message);const{data:c,error:d}=await z.functions.invoke("generate-ad-creatives",{body:{postId:b,phase:"art"}});if(d)throw d;if((c==null?void 0:c.error)==="LIMIT_REACHED"){u(!1),_();return}a()}catch(t){l({title:i("common.error"),description:t instanceof Error?t.message:i("errors.generic"),variant:"destructive"}),u(!1)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-1",children:[e.jsx(H,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium text-primary",children:i("adCreator.approveBadge")})]}),e.jsx("h3",{className:"text-lg font-semibold",children:i("adCreator.approveTitle")}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-lg mx-auto",children:i("adCreator.approveSubtitle")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-semibold",children:i("adCreator.artCtaLabel")}),e.jsx(S,{value:v,onChange:t=>k(t.target.value),placeholder:i("adCreator.artCtaPlaceholder"),maxLength:30,className:"h-11"})]}),e.jsx("div",{className:"space-y-4",children:p.map((t,n)=>{var c;return e.jsx(f,{children:e.jsxs(N,{className:"p-4 space-y-3",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:((c=h[n])==null?void 0:c.short_label)||i("adCreator.conceptLabel",{index:n+1})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:i("adCreator.conceptHeadlineLabel")}),e.jsx(S,{value:t.headline,onChange:d=>o(n,"headline",d.target.value),maxLength:60,"aria-invalid":t.headline.trim().length===0,className:"h-11 font-medium"}),t.headline.trim().length===0&&e.jsx("p",{className:"text-xs text-destructive",children:i("adCreator.headlineRequired")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:i("adCreator.conceptSubheadlineLabel")}),e.jsx(R,{value:t.subheadline,onChange:d=>o(n,"subheadline",d.target.value),maxLength:120,className:"min-h-[60
1px] resize-none"})]})]})},n)})}),e.jsx(x,{onClick:g,disabled:C||!L,size:"lg",className:"w-full h-12 text-base rounded-xl font-semibold bg-gradient-to-r from-primary to-purple-600 border-0",children:C?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-5 h-5 mr-2 animate-spin"}),i("adCreator.generating")]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"w-5 h-5 mr-2"}),i("adCreator.generateArtsButton",{count:p.length})]})})]})},we=()=>{var t,n,c,d;const{postId:b}=F(),m=K(),{t:a}=M(),{toast:i}=P(),{post:l,isLoading:_,isPending:h,error:v,refetch:k}=Q(b),[p,y]=w.useState(null),C=async(s,r)=>{try{await navigator.clipboard.writeText(s),y(r),setTimeout(()=>y(j=>j===r?null:j),1500)}catch{i({title:a("common.error"),description:a("adCreator.copyError"),variant:"destructive"})}},u=async(s,r)=>{try{await V(s,`ad-${r+1}.png`)}catch{i({title:a("common.error"),description:a("errors.generic"),variant:"destructive"})}};if(_&&!l)return e.jsx(J,{});if(v||!l)return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center p-4 text-center",children:[e.jsx(D,{className:"w-12 h-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("adCreator.notFoundTitle")}),e.jsx(x,{onClick:()=>m("/dashboard/ad-creator"),className:"mt-4",children:a("adCreator.backToCreator")})]});if(h||l.status==="creating"){const s=[a("adCreator.step_analyzing"),a("adCreator.step_copy"),a("adCreator.step_concepts"),a("adCreator.step_arts"),a("adCreator.step_finalizing")];return e.jsxs("div",{className:"min-h-screen bg-background flex flex-col",children:[e.jsxs("div",{className:"flex items-center h-12 px-2 sm:px-4",children:[e.jsx(x,{variant:"ghost",size:"icon",onClick:()=>m("/dashboard/ad-creator"),children:e.jsx(A,{className:"w-5 h-5"})}),e.jsx("span",{className:"ml-2 font-semibold",children:a("adCreator.generating")})]}),e.jsx("div",{className:"flex-1 flex items-center justify-center p-4 bg-muted/10",children:e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(O,{title:a("adCreator.generating"),steps:s})})})]})}if(l.status==="error")return e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center p-4 text-center",children:[e.jsx(D,{className:"w-12 h-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:a("adCreator.errorTitle")}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-4",children:l.errorMessage||a("errors.generic")}),e.jsx(x,{onClick:()=>m("/dashboard/ad-creator"),children:a("adCreator.tryAgain")})]});if(l.status==="strategy_review"){const s=((t=l.postData)==null?void 0:t.ad)||{};return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-6 md:py-8 space-y-6",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-0 top-0",children:e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>m("/dashboard/ad-creator"),className:"gap-2 pl-2 pr-4 text-muted-foreground hover:text-foreground",children:[e.jsx(A,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("common.back")})]})}),e.jsx("div",{className:"text-center pt-8 md:pt-0",children:e.jsxs(I,{variant:"secondary",className:"px-3 py-1 gap-1.5 bg-primary/10 text-primary border-0",children:[e.jsx(T,{className:"w-3.5 h-3.5"})," ",a("adCreator.badge")]})})]}),e.jsx(Z,{postId:l.id,ad:s,onGenerating:k})]})})}const o=((n=l.postData)==null?void 0:n.ad)||{},L=(o.image_concepts||[]).filter(s=>!!s.image_url),g=({text:s,copyKey:r})=>e.jsx(x,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>C(s,r),"aria-label":a("adCreator.copy"),children:p===r?e.jsx(W,{className:"w-4 h-4 text-green-600"}):e.jsx(Y,{className:"w-4 h-4"})});return e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 py-6 md:py-8 space-y-8",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-0 top-0",children:e.jsxs(x,{variant:"ghost",size:"sm",onClick:()=>m("/dashboard/ad-creator"),className:"gap-2 pl-2 pr-4 text-muted-foreground hover:text-foreground",children:[e.jsx(A,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden md:inline",children:a("common.back")})]})}),e.jsxs("div",{className:"text-center space-y-2 pt-8 md:pt-0",children:[e.jsx("div",{className:"flex items-center justify-center gap-2 mb-2",children:e.jsxs(I,{variant:"secondary",className:"px-3 py-1 gap-1.5 bg-primary/10 text-primary border-0",children:[e.jsx(T,{className:"w-3.5 h-3.5"})," ",a("adCreator.badge")]})}),e.jsx("h2",{className:"text-2xl md:text-3xl font-bold tracking-tight",children:a("adCreator.resultTitle")})]})]}),e.jsxs("section",{className:"space-y-3",children:[e.jsx("h3",{className:"text-lg font-semibold",children:a("adCreator.artsHeading")}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:L.map((s,r)=>e.jsxs(f,{className:"overflow-hidden group",children:[e.jsxs("div",{className:"relative bg-muted",children:[e.jsx("img",{src:s.image_url,alt:s.short_label||a("adCreator.artAlt",{index:r+1}),className:"w-full h-auto"}),e.jsx("div",{className:"absolute inset-x-0 bottom-0 p-3 bg-gradient-to-t from-black/60 to-transparent opacity-100 md:opacity-0 md:group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity",children:e.jsxs(x,{size:"sm",variant:"secondary",className:"gap-2",onClick:()=>u(s.image_url,r),children:[e.jsx(X,{className:"w-4 h-4"}),G()?a("image_actions.save_gallery"):a("adCreator.download")]})})]}),s.short_label&&e.jsx(N,{className:"p-3",children:e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:s.short_label})})]},s.image_url))})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsx("h3",{className:"text-lg font-semibold",children:a("adCreator.copyHeading")}),!!((c=o.primary_texts)!=null&&c.length)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:a("adCreator.primaryTextsLabel")}),o.primary_texts.map((s,r)=>e.jsx(f,{children:e.jsxs(N,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-sm whitespace-pre-line flex-1",children:s}),e.jsx(g,{text:s,copyKey:`pt-${r}`})]})},`pt-${r}`))]}),!!((d=o.headlines)!=null&&d.length)&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:a("adCreator.headlinesLabel")}),o.headlines.map((s,r)=>e.jsx(f,{children:e.jsxs(N,{className:"p-4 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-sm font-medium flex-1",children:s}),e.jsx(g,{text:s,copyKey:`hl-${r}`})]})},`hl-${r}`))]}),o.description&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:a("adCreator.descriptionLabel")}),e.jsx(f,{children:e.jsxs(N,{className:"p-4 flex items-start justify-between gap-3",children:[e.jsx("p",{className:"text-sm flex-1",children:o.description}),e.jsx(g,{text:o.description,copyKey:"desc"})]})})]})]}),e.jsx("section",{className:"max-w-2xl mx-auto",children:e.jsx(U,{postId:l.id,subject:"ad"})}),e.jsx("div",{className:"flex justify-center pt-2 pb-8",children:e.jsxs(x,{onClick:()=>m("/dashboard/ad-creator"),variant:"outline",className:"gap-2",children:[e.jsx(q,{className:"w-4 h-4"}),a("adCreator.generateAgain")]})})]})})};export{we 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.