1import{r as j,a as X,j as e,C as y,e as w,n as M,b as z,d as D,T as U,Y as se,a4 as ae,ba as te,bb as re,s as Y,bC as ne,aK as ie,bc as le,B as u,w as Z,v as oe,l as ce,bo as de,cs as me,bk as _,S as xe,ab as A,ap as H,D as he,aF as q,aD as R,ar as W,i as J,p as ue}from"./index-CuSEeJFb.js";import{P as ee}from"./progress-B2eMqtVV.js";import{A as T}from"./ai-assist-button-YA_IMV7l.js";import{C as Q}from"./circle-check-DSSdNCFx.js";import"./wand-sparkles-Cnc6tXs_.js";import"./copy-Ctw93tQ7.js";function fe({avatar:o,offerContext:t,valueContext:E,className:B,onFieldUpdate:I}){const[b,a]=j.useState(0),[C,f]=j.useState(0),[$,k]=j.useState({}),N=["Analyzing avatar profile and value preferences...","Identifying key transformation opportunities...","Generating targeted value proposition recommendations...","Creating field-specific content suggestions...","Finalizing personalized value coaching guidance..."],S=r=>{k(c=>({...c,[r]:!c[r]}))},{data:P,isLoading:i,error:v}=X({queryKey:["/api/marketing-coach/value-coaching",o.id],queryFn:async()=>{const r=await fetch("/api/marketing-coach/value-coaching",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({avatarId:o.id,offerContext:t,valueContext:E})});if(!r.ok){const d=await r.text();throw console.error("Value coaching API error:",r.status,d),new Error(`Failed to fetch value coaching recommendations: ${r.status} ${d}`)}return await r.json()},enabled:!!o.id,staleTime:10*60*1e3,refetchOnWindowFocus:!1,refetchOnMount:!1});j.useEffect(()=>{if(i){a(0),f(0);const r=Date.now(),c=3e3,d=setInterval(()=>{f(m=>{const G=Date.now()-r,F=Math.min(G/c*100,95),x=Math.min(m+3,F),h=Math.floor(x/20);return h!==b&&h<N.length&&a(h),x})},150);return()=>clearInterval(d)}else C<100&&(f(100),setTimeout(()=>{a(0),f(0)},500))},[i,b,N.length,C]);const O=r=>{switch(r){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"}},V=(P==null?void 0:P.recommendations)||[];return i?e.jsx(y,{className:B,children:e.jsx(w,{className:"p-6",children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(r=>e.jsx("div",{className:"bg-gray-100 rounded-lg p-4 animate-pulse",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gray-200 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"}),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"})]})]})},r))})})}):v||V.length===0?e.jsx(y,{className:B,children:e.jsxs(w,{className:"p-6 text-center",children:[e.jsx(M,{className:"h-8 w-8 text-gray-400 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-600",children:v?"Unable to load value proposition coaching recommendations":"No value proposition coaching recommendations available yet"})]})}):e.jsxs(y,{className:B,children:[e.jsx(z,{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(M,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(D,{className:"text-lg flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-orange-600"}),"Value Proposition Coaching"]}),e.jsxs("p",{className:"text-sm text-gray-600 mt-1",children:["Personalized guidance for creating value propositions that appeal to ",e.jsx("span",{className:"font-medium text-orange-700",children:o.name})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(se,{className:"h-3 w-3 text-gray-500"}),e.jsxs("span",{className:"text-xs text-gray-500",children:[o.age?`${o.age}-year-old`:""," ",o.location?`from ${o.location}`:""]})]})]})]})}),e.jsxs(w,{className:"space-y-4",children:[i?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(M,{className:"h-6 w-6 text-orange-600"})}),e.jsx(ae,{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 Value Proposition Coaching for ",o.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:"â"}),N[b]]}),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(C),"%"]})]}),e.jsx(ee,{value:C,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 ",b+1," of ",N.length]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"h-3 w-3"}),b," completed"]})]})]})]})]})})]})}):v?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(U,{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 value proposition coaching recommendations. Please try again."})]})]})}):V.map((r,c)=>e.jsx("div",{className:"bg-white border border-gray-200 rounded-xl overflow-hidden",children:e.jsxs(te,{open:$[c],onOpenChange:()=>S(c),children:[e.jsx(re,{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(U,{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:r.title}),e.jsx(Y,{className:`text-xs mt-1 ${O(r.difficulty)}`,children:r.difficulty}),e.jsx("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed text-left",children:r.description})]})]}),e.jsx("div",{className:"ml-3 flex-shrink-0",children:$[c]?e.jsx(ne,{className:"w-5 h-5 text-gray-400"}):e.jsx(ie,{className:"w-5 h-5 text-gray-400"})})]})}),e.jsx(le,{children:e.jsxs("div",{className:"px-4 pb-4 border-t border-gray-100",children:[r.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(Q,{className:"h-3 w-3 text-green-600"})}),"Click to Use These Suggestions:"]}),e.jsx("div",{className:"space-y-2",children:r.steps.map((d,m)=>{if(d.startsWith("FIELD:")&&I){const[,F]=d.split("FIELD:"),[x,h]=F.split("|"),L=()=>
1{if(x==="benefits"||x==="features"){const K=h.split(",").map(s=>s.trim()).filter(s=>s);I(x,K)}else I(x,h)};return e.jsx(u,{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:L,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:h})]})},m)}else return e.jsxs("div",{className:"text-sm text-gray-600 flex items-start gap-2 p-2",children:[e.jsx(Z,{className:"h-3 w-3 text-gray-400 mt-0.5 flex-shrink-0"}),e.jsx("span",{children:d})]},m)})})]}),r.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(oe,{className:"h-3 w-3 text-blue-600"})}),e.jsxs("span",{className:"text-xs text-gray-500 font-medium",children:["Timeframe: ",r.timeframe]})]})]})})]})},c)),!i&&!v&&V.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(ce,{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 value proposition recommendations are specifically tailored for ",e.jsx("strong",{children:o.name})," based on their pain points, goals, and transformation desires. Use this guidance to create a compelling value proposition that resonates deeply with this specific avatar."]})]})]})})]})]})}function ye(){const[,o]=de(),{offerData:t,updateOfferData:E,markStepComplete:B,progress:I}=me(),{data:b=[]}=X({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()}}),[a,C]=j.useState({coreValue:t.coreValue||"",transformation:t.transformation||"",benefits:t.benefits||[],features:t.features||[],bonuses:t.bonuses||[]}),[f,$]=j.useState(""),[k,N]=j.useState(""),[S,P]=j.useState(""),i=(s,n)=>{const l={...a,[s]:n};C(l),E(l)},v=()=>{if(f.trim()){const s=[...a.benefits,f.trim()];i("benefits",s),$("")}},O=s=>
1{const n=a.benefits.filter((l,g)=>g!==s);i("benefits",n)},V=()=>{if(k.trim()){const s=[...a.features,k.trim()];i("features",s),N("")}},r=s=>{const n=a.features.filter((l,g)=>g!==s);i("features",n)},c=()=>{if(S.trim()){const s=[...a.bonuses,S.trim()];i("bonuses",s),P("")}},d=s=>{const n=a.bonuses.filter((l,g)=>g!==s);i("bonuses",n)},m=(s,n)=>{if(s==="benefits"||s==="features"||s==="bonuses"){const l=n.split(/[,\n]/).map(g=>{let p=g.trim();return p=p.replace(/^#{1,6}\s*/,""),p=p.replace(/^[â¢\-\*]\s*/,""),p=p.replace(/\*\*(.*?)\*\*/g,"$1"),p=p.replace(/\*(.*?)\*/g,"$1"),p}).filter(g=>g);i(s,l)}else{let l=n.trim();l=l.replace(/^#{1,6}\s*/,""),l=l.replace(/\*\*(.*?)\*\*/g,"$1"),l=l.replace(/\*(.*?)\*/g,"$1"),i(s,l)}},G=()=>{B(3),o("/offer-guide-pricing")},F=t.targetAvatarId?b.find(s=>s.id===t.targetAvatarId):{id:1,name:t.selectedService?`${t.selectedService} Customer`:"Target Customer",demographic:"Small Business Owner",industry:t.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"]},x=a.coreValue&&a.transformation&&a.benefits.length>0&&a.features.length>0,h=[a.coreValue,a.transformation,a.benefits.length>0,a.features.length>0].filter(Boolean).length,L=4,K=h/L*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(u,{variant:"ghost",size:"sm",className:"gap-2",onClick:()=>o("/offer-guide-core-offer"),children:[e.jsx(_,{className:"h-4 w-4"}),"Back to Core Offer"]}),e.jsx(Z,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-sm font-medium text-gray-900",children:"Value Proposition"})]}),e.jsxs(Y,{variant:"secondary",children:["Step 3 of ",I.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:"Value Proposition"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[h," of ",L," completed"]})]}),e.jsx(ee,{value:K,className:"mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Define the core value, transformation, benefits, and features of your offer."})]}),F&&e.jsx("div",{className:"mb-6",children:e.jsx(fe,{avatar:F,offerContext:{name:t.name||"New Offer",type:t.type||void 0,headline:t.headline||void 0,description:t.description||void 0},valueContext:a,className:"border-blue-200 bg-blue-50/30 dark:bg-blue-950/20",onFieldUpdate:(s,n)=>{i(s,n)}})}),e.jsxs("div",{className:"grid grid-cols-1 gap-6",children:[e.jsxs(y,{children:[e.jsx(z,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"w-5 h-5 text-purple-600"}),"Core Value & Transformation"]})}),e.jsxs(w,{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(A,{htmlFor:"coreValue",children:"Core Value Proposition *"}),e.jsx(T,{label:"AI Fill",prompt:`Create a core value proposition for ${t.name||"this offer"} in the ${t.selectedService} industry`,onGenerate:s=>m("coreValue",s),currentValue:a.coreValue,fieldName:"coreValue",size:"sm"})]}),e.jsx(H,{id:"coreValue",placeholder:"What's the main value customers get from this offer?",value:a.coreValue,onChange:s=>i("coreValue",s.target.value),className:"min-h-[80px]","data-testid":"textarea-core-value"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(A,{htmlFor:"transformation",children:"Transformation Promise *"}),e.jsx(T,{label:"AI Fill",prompt:`Describe the transformation customers will experience with ${t.name||"this offer"}`,onGenerate:s=>m("transformation",s),currentValue:a.transformation,fieldName:"transformation",size:"sm"})]}),e.jsx(H,{id:"transformation",placeholder:"How will customers be different after using this offer?",value:a.transformation,onChange:s=>i("transformation",s.target.value),className:"min-h-[80px]","data-testid":"textarea-transformation"})]})]})]}),e.jsxs(y,{children:[e.jsx(z,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"w-5 h-5 text-yellow-600"}),"Key Benefits"]})}),e.jsx(w,{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(A,{children:"Customer Benefits *"}),e.jsx(T,{label:"AI Generate",prompt:`Generate a list of key benefits for ${t.name||"this offer"} in ${t.selectedService}`,onGenerate:s=>m("benefits",s),currentValue:a.benefits.join(", "),fieldName:"benefits",size:"sm"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{placeholder:"Add a benefit...",value:f,onChange:s=>$(s.target.value),onKeyPress:s=>s.key==="Enter"&&v(),"data-testid":"input-new-benefit"}),e.jsx(u,{type:"button",onClick:v,disabled:!f.trim(),size:"sm","data-testid":"button-add-benefit",children:e.jsx(R,{className:"w-4 h-4"})})]}),a.benefits.length>
10&&e.jsx("div",{className:"space-y-2 mt-3",children:a.benefits.map((s,n)=>e.jsxs("div",{className:"flex items-center justify-between bg-yellow-50 p-2 rounded-md",children:[e.jsx("span",{className:"text-sm",children:s}),e.jsx(u,{type:"button",variant:"ghost",size:"sm",onClick:()=>O(n),"data-testid":`button-remove-benefit-${n}`,children:e.jsx(W,{className:"w-4 h-4"})})]},n))})]})})]}),e.jsxs(y,{children:[e.jsx(z,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-5 h-5 text-green-600"}),"Features & What's Included"]})}),e.jsx(w,{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(A,{children:"Features & Inclusions *"}),e.jsx(T,{label:"AI Generate",prompt:`List specific features and what's included in ${t.name||"this offer"} for ${t.selectedService}`,onGenerate:s=>m("features",s),currentValue:a.features.join(", "),fieldName:"features",size:"sm"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{placeholder:"Add a feature...",value:k,onChange:s=>N(s.target.value),onKeyPress:s=>s.key==="Enter"&&V(),"data-testid":"input-new-feature"}),e.jsx(u,{type:"button",onClick:V,disabled:!k.trim(),size:"sm","data-testid":"button-add-feature",children:e.jsx(R,{className:"w-4 h-4"})})]}),a.features.length>0&&e.jsx("div",{className:"space-y-2 mt-3",children:a.features.map((s,n)=>e.jsxs("div",{className:"flex items-center justify-between bg-green-50 p-2 rounded-md",children:[e.jsx("span",{className:"text-sm",children:s}),e.jsx(u,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(n),"data-testid":`button-remove-feature-${n}`,children:e.jsx(W,{className:"w-4 h-4"})})]},n))})]})})]}),e.jsxs(y,{children:[e.jsx(z,{children:e.jsxs(D,{className:"flex items-center gap-2",children:[e.jsx(J,{className:"w-5 h-5 text-blue-600"}),"Bonuses & Extras"]})}),e.jsx(w,{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(A,{children:"Additional Bonuses"}),e.jsx(T,{label:"AI Generate",prompt:`Suggest valuable bonuses to add to ${t.name||"this offer"} for ${t.selectedService}`,onGenerate:s=>m("bonuses",s),currentValue:a.bonuses.join(", "),fieldName:"bonuses",size:"sm"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(q,{placeholder:"Add a bonus...",value:S,onChange:s=>P(s.target.value),onKeyPress:s=>s.key==="Enter"&&c(),"data-testid":"input-new-bonus"}),e.jsx(u,{type:"button",onClick:c,disabled:!S.trim(),size:"sm","data-testid":"button-add-bonus",children:e.jsx(R,{className:"w-4 h-4"})})]}),a.bonuses.length>0&&e.jsx("div",{className:"space-y-2 mt-3",children:a.bonuses.map((s,n)=>e.jsxs("div",{className:"flex items-center justify-between bg-blue-50 p-2 rounded-md",children:[e.jsx("span",{className:"text-sm",children:s}),e.jsx(u,{type:"button",variant:"ghost",size:"sm",onClick:()=>d(n),"data-testid":`button-remove-bonus-${n}`,children:e.jsx(W,{className:"w-4 h-4"})})]},n))})]})})]})]}),e.jsxs("div",{className:"flex justify-between items-center mt-8 pt-6 border-t",children:[e.jsxs(u,{variant:"outline",className:"gap-2",onClick:()=>o("/offer-guide-core-offer"),children:[e.jsx(_,{className:"w-4 h-4"}),"Previous Step"]}),e.jsxs(u,{onClick:G,disabled:!x,className:"gap-2 bg-orange-600 hover:bg-orange-700","data-testid":"button-continue",children:["Continue to Pricing",e.jsx(ue,{className:"w-4 h-4"})]})]})]})]})}export{ye 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.