1import{r as v,a as q,j as e,C as k,b as G,n as O,e as F,d as z,T as I,Y as Q,a4 as W,ba as _,bb as X,s as $,bC as Z,aK as ee,bc as se,B as P,w as K,v as ae,l as te,bo as re,cs as ne,bk as M,b6 as ie,S as le,ab as S,aF as B,$ as oe,a0 as ce,a1 as de,a2 as me,a3 as he,ap as xe,p as ge}from"./index-CuSEeJFb.js";import{P as H}from"./progress-B2eMqtVV.js";import{A as T}from"./ai-assist-button-YA_IMV7l.js";import{C as U}from"./circle-check-DSSdNCFx.js";import"./wand-sparkles-Cnc6tXs_.js";import"./copy-Ctw93tQ7.js";function fe({avatar:l,offerContext:r,className:y,onFieldUpdate:A}){const[f,a]=v.useState(0),[b,p]=v.useState(0),[w,D]=v.useState({}),u=["Analyzing avatar profile and preferences...","Identifying key pain points and motivations...","Generating targeted offer recommendations...","Creating field-specific content suggestions...","Finalizing personalized coaching guidance..."],h=t=>{D(c=>({...c,[t]:!c[t]}))},{data:o,isLoading:d,error:N}=q({queryKey:["/api/marketing-coach/avatar-coaching",l.id],queryFn:async()=>{const t=await fetch("/api/marketing-coach/avatar-coaching",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({avatarId:l.id,offerContext:r})});if(!t.ok){const m=await t.text();throw console.error("Coaching API error:",t.status,m),new Error(`Failed to fetch coaching recommendations: ${t.status} ${m}`)}return await t.json()},enabled:!!l.id,staleTime:10*60*1e3,refetchOnWindowFocus:!1,refetchOnMount:!1});v.useEffect(()=>{if(d){a(0),p(0);const t=Date.now(),c=3e3,m=setInterval(()=>{p(s=>{const i=Date.now()-t,n=Math.min(i/c*100,95),x=Math.min(s+3,n),g=Math.floor(x/20);return g!==f&&g<u.length&&a(g),x})},150);return()=>clearInterval(m)}else b<100&&(p(100),setTimeout(()=>{a(0),p(0)},500))},[d,f,u.length,b]);const C=(o==null?void 0:o.recommendations)||[],L=t=>{switch(t){case"beginner":return"bg-green-100 text-green-800";case"intermediate":return"bg-yellow-100 text-yellow-800";case"advanced":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};return d?e.jsxs(k,{className:`${y} animate-pulse`,children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-gray-200 rounded-lg",children:e.jsx(O,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-48"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-64 mt-2"})]})]})}),e.jsx(F,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(t=>e.jsxs("div",{className:"p-4 border rounded-lg",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4 mb-2"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-full mb-3"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 bg-gray-200 rounded w-5/6"}),e.jsx("div",{className:"h-3 bg-gray-200 rounded w-4/6"})]})]},t))})})]}):N||C.length===0?e.jsx(k,{className:y,children:e.jsxs(F,{className:"p-6 text-center",children:[e.jsx(O,{className:"h-8 w-8 text-gray-400 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-600",children:N?"Unable to load coaching recommendations":"No coaching recommendations available yet"})]})}):e.jsxs(k,{className:y,children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"p-2 bg-orange-100 rounded-lg flex-shrink-0",children:e.jsx(O,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(z,{className:"text-lg flex items-center gap-2",children:[e.jsx(I,{className:"h-4 w-4 text-orange-600"}),"Offer Coaching"]}),e.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Personalized guidance for creating offers that appeal to ",e.jsx("span",{className:"font-medium text-orange-700",children:l.name})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(Q,{className:"h-3 w-3 text-gray-500"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[l.age?`${l.age}-year-old`:""," ",l.location?`from ${l.location}`:""]})]})]})]})}),e.jsxs(F,{className:"space-y-4",children:[d?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"relative overflow-hidden bg-gradient-to-br from-orange-50 via-orange-25 to-yellow-50 rounded-xl border border-orange-200 shadow-sm",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-pulse"}),e.jsx("div",{className:"relative p-6",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-12 h-12 bg-orange-100 rounded-full flex items-center justify-center",children:e.jsx(O,{className:"h-6 w-6 text-orange-600"})}),e.jsx(W,{className:"absolute -top-1 -right-1 h-4 w-4 text-orange-500 animate-spin"})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("h3",{className:"text-lg font-semibold text-orange-900 mb-1",children:["Creating AI Coaching for ",l.name]}),e.jsxs("p",{className:"text-sm text-orange-700 mb-4 flex items-center gap-2",children:[e.jsx("span",{className:"animate-pulse",children:"â"}),u[f]]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"text-orange-800 font-medium",children:"Progress"}),e.jsxs("span",{className:"text-orange-600 tabular-nums",children:[Math.round(b),"%"]})]}),e.jsx(H,{value:b,className:"h-3 bg-orange-100"}),e.jsxs("div",{className:"flex justify-between items-center text-xs text-orange-600",children:[e.jsxs("span",{children:["Step ",f+1," of ",u.length]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{className:"h-3 w-3"}),f," completed"]})]})]})]})]})})]})}):N?e.jsx("div",{className:"p-6 bg-red-50 border border-red-200 rounded-xl",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-red-100 rounded-full flex items-center justify-center",children:e.jsx(I,{className:"h-5 w-5 text-red-600"})}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-red-900 mb-1",children:"Coaching Unavailable"}),e.jsx("p",{className:"text-sm text-red-700",children:"Unable to generate coaching recommendations. Please try again."})]})]})}):C.map((t,c)=>e.jsx("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden",children:e.jsxs(_,{open:w[c],onOpenChange:()=>h(c),children:[e.jsx(X,{asChild:!0,children:e.jsxs("div",{className:"flex items-start justify-between p-4 cursor-pointer hover:bg-gray-50 transition-colors duration-200",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx("div",{className:"w-8 h-8 bg-orange-100 rounded-lg flex items-center justify-center",children:e.jsx(I,{className:"h-4 w-4 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-semibold text-gray-900 text-lg text-left",children:t.title}),e.jsx($,{className:`text-xs mt-1 ${L(t.difficulty)}`,children:t.difficulty}),e.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed text-left",children:t.description})]})]}),e.jsx("div",{className:"ml-3 flex-shrink-0",children:w[c]?e.jsx(Z,{className:"w-5 h-5 text-gray-400"}):e.jsx(ee,{className:"w-5 h-5 text-gray-400"})})]})}),e.jsx(se,{children:e.jsxs("div",{className:"px-4 pb-4 border-t border-gray-100",children:[t.steps.length>0&&e.jsxs("div",{className:"mt-4 pl-11",children:[e.jsxs("h5",{className:"text-sm font-semibold text-gray-900 mb-3 flex items-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 bg-green-100 rounded-full flex items-center justify-center",children:e.jsx(U,{className:"h-3 w-3 text-green-600"})}),"Click to Use These Suggestions:"]}),e.jsx("div",{className:"space-y-2",children:t.steps.map((m,s)=>{if(m.startsWith("FIELD:")&&A){const[,n]=m.split("FIELD:"),[x,g]=n.split("|");return e.jsx(P,{variant:"outline",size:"sm",className:"text-left justify-start w-full h-auto p-3 text-sm border-orange-200 hover:border-orange-300 hover:bg-orange-50 transition-all group",onClick:()=>A(x,g),children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-2 sm:gap-3 w-full",children:[e.jsx("span",{className:"text-orange-600 font-semibold bg-orange-100 px-2 py-1 rounded text-xs uppercase tracking-wide flex-shrink-0 self-start",children:x}),e.jsx("span",{className:"text-gray-700 group-hover:text-gray-900 leading-relaxed break-words text-left",children:g})]})},s)}else return e.jsxs("div",{className:"text-sm text-gray-600 flex items-start gap-2 p-2",children:[e.jsx(K,{className:"h-3 w-3 text-gray-400 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:m})]},s)})})]}),t.timeframe&&e.jsxs("div",{className:"flex items-center gap-2 mt-4 pt-4 border-t border-gray-100 pl-11",children:[e.jsx("div",{className:"w-4 h-4 bg-blue-100 rounded-full flex items-center justify-center",children:e.jsx(ae,{className:"h-3 w-3 text-blue-600"})}),e.jsxs("span",{className:"text-xs text-gray-500 font-medium",children:["Timeframe: ",t.timeframe]})]})]})})]})},c)),!d&&!N&&C.length>0&&e.jsx("div",{className:"mt-6 p-4 bg-gradient-to-r from-orange-50 to-yellow-50 rounded-lg border border-orange-100",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(te,{className:"h-5 w-5 text-orange-600 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium text-orange-900 mb-1",children:"Pro Tip"}),e.jsxs("p",{className:"text-sm text-orange-800 leading-relaxed",children:["These recommendations are specifically tailored for ",e.jsx("strong",{children:l.name})," based on their pain points, goals, and industry context. Use this guid
1ance to create an offer that resonates deeply with this specific avatar."]})]})]})})]})]})}const pe=["Discount Offer","Bundle Package","Free Trial","Buy One Get One","Limited Time Bonus","Early Bird Special","Seasonal Promotion","Loyalty Reward"];function we(){const[,l]=re(),{offerData:r,updateOfferData:y,markStepComplete:A,progress:f}=ne(),[a,b]=v.useState({name:r.name||"",headline:r.headline||"",subheadline:r.subheadline||"",description:r.description||"",type:r.type||""}),[p,w]=v.useState(!1),{data:D=[]}=q({queryKey:["/api/client-avatars"],queryFn:async()=>{const s=await fetch("/api/client-avatars");if(!s.ok)throw new Error("Failed to fetch avatars");return s.json()}}),u=r.targetAvatarId?D.find(s=>s.id===r.targetAvatarId):{id:1,name:r.selectedService?`${r.selectedService} Customer`:"Target Customer",demographic:"Small Business Owner",industry:r.selectedService||"Service Industry",painPoints:["Limited time for marketing","Need more leads","Struggling with conversions"],goals:["Grow business","Increase revenue","Save time"],challenges:["Resource constraints","Marketing expertise","Competition"]},h=(s,i)=>{const n={...a,[s]:i};b(n),y(n)},o=(s,i)=>{let n=i.trim();n=n.replace(/^#{1,6}\s*/,""),n=n.replace(/\*\*(.*?)\*\*/g,"$1"),n=n.replace(/\*(.*?)\*/g,"$1"),n=n.replace(/^[â¢\-\*]\s*/,""),h(s,n)},d=async s=>{try{const i=await fetch("/api/ai-assist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:s})});if(!i.ok)throw new Error("Failed to generate content");return(await i.json()).suggestion||""}catch(i){return console.error("AI generation error:",i),""}},N=async()=>{w(!0);try{console.log("Generating offer name...");const s=`Create an offer name for a ${r.offerTier} tier ${r.selectedService} offer`,i=await d(s);i&&(o("name",i),await new Promise(j=>setTimeout(j,500))),console.log("Generating offer type...");const n=`Suggest the best offer type for a ${r.offerTier} tier ${r.selectedService} service`,x=await d(n);x&&(o("type",x),await new Promise(j=>setTimeout(j,500))),console.log("Generating headline...");const g=`Create a compelling headline for a ${i||a.name||x} offer for ${r.selectedService}`,E=await d(g);E&&(o("headline",E),await new Promise(j=>setTimeout(j,500))),console.log("Generating subheadline...");const J=`Create a supporting subheadline that complements: "${E||a.headline}"`,R=await d(J);R&&(o("subheadline",R),await new Promise(j=>setTimeout(j,500))),console.log("Generating description...");const Y=`Write a detailed description for ${i||a.name||"this offer"} that explains what customers get`,V=await d(Y);V&&o("description",V),console.log("All fields generated successfully!")}catch(s){console.error("Error generating all fields:",s)}finally{w(!1)}},C=()=>{A(2),l("/offer-guide-value-proposition")},L=a.name&&a.headline&&a.description&&a.type,t=[a.name,a.headline,a.subheadline,a.description,a.type].filter(Boolean).length,c=5,m=t/c*100;return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("header",{className:"bg-white shadow-sm",children:e.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:e.jsxs("nav",{className:"flex items-center justify-between h-16",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(P,{variant:"ghost",size:"sm",className:"gap-2",onClick:()=>l("/offer-guide-interactive"),children:[e.jsx(M,{className:"h-4 w-4"}),"Back to Foundation"]}),e.jsx(K,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Core Offer"})]}),e.jsxs($,{variant:"secondary",children:["Step 2 of ",f.totalSteps]})]})})}),e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Core Offer Details"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t," of ",c," completed"]})]}),e.jsx(H,{value:m,className:"mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Define the basic details of your offer including name, headline, and type."})]}),e.jsxs(k,{className:"mb-6 bg-orange-50 border-orange-200",children:[e.jsx(G,{children:e.jsxs(z,{className:"flex items-center gap-2 text-orange-700",children:[e.jsx(ie,{className:"w-5 h-5"}),"Foundation Summary"]})}),e.jsx(F,{children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-orange-600 font-medium",children:"Selected Service:"}),e.jsx($,{variant:"outline",className:"border-orange-300",children:r.selectedService})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-orange-600 font-medium",children:"Offer Tier:"}),e.jsx($,{variant:"outline",className:"border-orange-300",children:r.offerTier})]})]})})]}),u&&e.jsx("div",{className:"mb-6",children:e.jsx(fe,{avatar:u,offerContext:{name:a.name||"New Offer",tier:r.offerTier||void 0,value:a.description||void 0},className:"border-blue-200 bg-blue-50/30 dark:bg-blue-950/20",onFieldU
1pdate:(s,i)=>{h(s,i)}})}),e.jsx("div",{className:"grid grid-cols-1 gap-6",children:e.jsxs(k,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(z,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-blue-600"}),"Basic Information"]}),e.jsx(P,{onClick:N,disabled:p,variant:"outline",className:"gap-2 bg-gradient-to-r from-orange-50 to-yellow-50 border-orange-200 hover:from-orange-100 hover:to-yellow-100 text-orange-700 hover:text-orange-800","data-testid":"button-generate-all",children:p?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"w-4 h-4 animate-spin"}),"Generating All..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4"}),"AI Generate All"]})})]})}),e.jsxs(F,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{htmlFor:"name",children:"Offer Name *"}),e.jsx(T,{label:"AI Fill",prompt:`Create an offer name for a ${r.offerTier} tier ${r.selectedService} offer`,onGenerate:s=>o("name",s),currentValue:a.name,fieldName:"name",size:"sm"})]}),e.jsx(B,{id:"name",placeholder:"Enter a compelling offer name...",value:a.name,onChange:s=>h("name",s.target.value),"data-testid":"input-offer-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{htmlFor:"type",children:"Offer Type *"}),e.jsx(T,{label:"AI Fill",prompt:`Suggest the best offer type for a ${r.offerTier} tier ${r.selectedService} service`,onGenerate:s=>o("type",s),currentValue:a.type,fieldName:"type",size:"sm"})]}),e.jsxs(oe,{value:a.type,onValueChange:s=>h("type",s),children:[e.jsx(ce,{"data-testid":"select-offer-type",children:e.jsx(de,{placeholder:"Select offer type"})}),e.jsx(me,{children:pe.map(s=>e.jsx(he,{value:s,children:s},s))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{htmlFor:"headline",children:"Main Headline *"}),e.jsx(T,{label:"AI Fill",prompt:`Create a compelling headline for a ${a.name||a.type} offer for ${r.selectedService}`,onGenerate:s=>o("headline",s),currentValue:a.headline,fieldName:"headline",size:"sm"})]}),e.jsx(B,{id:"headline",placeholder:"Create a compelling main headline...",value:a.headline,onChange:s=>h("headline",s.target.value),"data-testid":"input-headline"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{htmlFor:"subheadline",children:"Subheadline"}),e.jsx(T,{label:"AI Fill",prompt:`Create a supporting subheadline that complements: "${a.headline}"`,onGenerate:s=>o("subheadline",s),currentValue:a.subheadline,fieldName:"subheadline",size:"sm"})]}),e.jsx(B,{id:"subheadline",placeholder:"Add supporting text to reinforce your headline...",value:a.subheadline,onChange:s=>h("subheadline",s.target.value),"data-testid":"input-subheadline"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(S,{htmlFor:"description",children:"Offer Description *"}),e.jsx(T,{label:"AI Fill",prompt:`Write a detailed description for ${a.name||"this offer"} that explains what customers get`,onGenerate:s=>o("description",s),currentValue:a.description,fieldName:"description",size:"sm"})]}),e.jsx(xe,{id:"description",placeholder:"Describe what customers will receive with this offer...",value:a.description,onChange:s=>h("description",s.target.value),className:"min-h-[120px]","data-testid":"textarea-description"})]})]})]})}),e.jsxs("div",{className:"flex justify-between items-center mt-8 pt-6 border-t",children:[e.jsxs(P,{variant:"outline",className:"gap-2",onClick:()=>l("/offer-guide-interactive"),children:[e.jsx(M,{className:"w-4 h-4"}),"Previous Step"]}),e.jsxs(P,{onClick:C,disabled:!L,className:"gap-2 bg-orange-600 hover:bg-orange-700","data-testid":"button-continue",children:["Continue to Value Proposition",e.jsx(ge,{className:"w-4 h-4"})]})]})]})]})}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.