1import{E as M}from"./jspdf.es.min-Cf87GPVe.js";import{autoTable as G}from"./jspdf.plugin.autotable-B0IxatYY.js";import{g as E,c as U}from"./plans-BDbKdIvJ.js";import"./index-D1idcEUO.js";import"./browser-C_pOKF9d.js";import"./validator-DQvzLbga.js";function N(r,o){if(!r)return o;const a=r.trim().replace(/^#/,""),t=a.length===3?a.split("").map(i=>i+i).join(""):a;return t.length!==6||/[^0-9a-fA-F]/.test(t)?o:[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}function W(r,o,a){return[Math.round(r[0]+(o[0]-r[0])*a),Math.round(r[1]+(o[1]-r[1])*a),Math.round(r[2]+(o[2]-r[2])*a)]}function k(r){const[o,a,t]=r.map(g=>g/255);return .2126*o+.7152*a+.0722*t>.6?[17,24,39]:[255,255,255]}async function Y(r){try{const o=await fetch(r);if(!o.ok)return null;const a=await o.blob(),t=await new Promise((d,u)=>{const s=new FileReader;s.onload=()=>d(s.result),s.onerror=u,s.readAsDataURL(a)}),i=await new Promise((d,u)=>{const s=new Image;s.onload=()=>d({width:s.naturalWidth,height:s.naturalHeight}),s.onerror=u,s.src=t}),g=a.type.includes("png")?"PNG":a.type.includes("webp")?"WEBP":"JPEG";return{dataUrl:t,...i,format:g}}catch{return null}}const f=210,w=297,l=16,h=f-l*2;async function V(r,o,a){const t=new M({unit:"mm",format:"a4"}),i=N(a.primaryColor,[249,115,22]),g=W(i,[0,0,0],.35),d=[17,24,39],u=[107,114,128],s=[229,231,235],x=k(i),m=o.recommendedPlan?E(o.recommendedPlan):void 0,p=o.alternatePlan?E(o.alternatePlan):void 0,F=a.logoUrl?await Y(a.logoUrl):null;let e=0;if(t.setFillColor(...i),t.rect(0,0,f,62,"F"),t.setFillColor(...g),t.rect(0,58,f,4,"F"),F){const c=Math.min(45,F.width/F.height*12);try{t.addImage(F.dataUrl,F.format,l,12,c,12,void 0,"FAST")}catch{}}else t.setFont("helvetica","bold"),t.setFontSize(13),t.setTextColor(...x),t.text(a.name,l,20);t.setFont("helvetica","normal"),t.setFontSize(9),t.setTextColor(...x),t.text("GROWTH PROPOSAL",l,36),t.setFont("helvetica","bold"),t.setFontSize(22),t.setTextColor(...x);const A=o.headline?.trim()||`A plan built to grow ${r}`,O=t.splitTextToSize(A,h).slice(0,3);t.text(O,l,46),e=74,t.setFontSize(9),t.setTextColor(...u);const H=new Date().toLocaleDateString(void 0,{year:"numeric",month:"long",day:"numeric"});t.text(`Prepared for ${r}`,l,e),t.text(H,f-l,e,{align:"right"}),e+=4,t.setDrawColor(...s),t.setLineWidth(.3),t.line(l,e,f-l,e),e+=8;const T=n=>{e=$(t,e,16),t.setFillColor(...i),t.rect(l,e-3.5,3,5,"F"),t.setFont("helvetica","bold"),t.setFontSize(13),t.setTextColor(...d),t.text(n,l+6,e),e+=7},C=(n,c=u)=>{t.setFont("helvetica","normal"),t.setFontSize(10),t.setTextColor(...c);const y=t.splitTextToSize(n,h);e=$(t,e,y.length*5),t.text(y,l,e),e+=y.length*5+2};if(o.summary?.trim()&&(C(o.summary.trim(),d),e+=2),m){e=$(t,e,40);const n=l,c=`$${m.price.toLocaleString()}/mo${m.setup>0?` + $${m.setup.toLocaleString()} ${m.setupLabel??"setup"}`:""}`,D=26+m.features.map(S=>t.splitTextToSize(S,h-16).length).reduce((S,P)=>S+P,0)*5+4;t.setFillColor(...W(i,[255,255,255],.9)),t.setDrawColor(...i),t.setLineWidth(.6),t.roundedRect(n,e,h,D,3,3,"FD"),t.setFillColor(...i),t.roundedRect(n+h-52,e-3,52,8,2,2,"F"),t.setFont("helvetica","bold"),t.setFontSize(7.5),t.setTextColor(...x),t.text("RECOMMENDED FOR YOU",n+h-26,e+2.4,{align:"center"}),t.setFont("helvetica","bold"),t.setFontSize(15),t.setTextColor(...d),t.text(`${m.name} â ${m.tagline}`,n+8,e+11),t.setFont("helvetica","bold"),t.setFontSize(13),t.setTextColor(...g),t.text(c,n+8,e+19);let v=e+27;t.setFontSize(9.5),m.features.forEach(S=>{t.setFont("helvetica","bold"),t.setTextColor(...i),t.text("â",n+8,v),t.setFont("helvetica","normal"),t.setTextColor(...d);const P=t.splitTextToSize(S,h-16);t.text(P,n+13,v),v+=P.length*5}),e+=D+8}const b=o.addons??[];b.length>0&&(T("Recommended add-ons"),b.forEach(n=>{const c=U[n];c&&C(`⢠${c.name} â ${c.description}`,d)}),e+=2),o.whyThisPlan?.trim()&&(T("Why this is the right fit"),C(o.whyThisPlan.trim()));const z=o.challengesSolved??[];z.length>0&&(T("Challenges we'll solve for you"),G(t,{startY:e,margin:{left:l,right:l},theme:"grid",head:[["Challenge","How we solve it"]],body:z.map(n=>[n.challenge,n.solution]),headStyles:{fillColor:i,textColor:x,fontStyle:"bold",fontSize:9},bodyStyles:{fontSize:9,textColor:d,valign:"top"},alternateRowStyles:{fillColor:[249,250,251]},columnStyles:{0:{cellWidth:60,fontStyle:"bold"}}}),e=_(t)+8);const R=o.promisedOutcomes??[];if(R.length>0&&(T("What you can expect"),R.forEach(n=>{const c=t.splitTextToSize(n,h-6);e=$(t,e,c.length*5+1),t.setFont("helvetica","bold"),t.setFontSize(10),t.setTextColor(...i),t.text("â",l,e),t.setFont("helvetica","normal"),t.setTextColor(...d),t.text(c,l+5,e),e+=c.length*5+1}),e+=4),o.proposalCopy?.trim()&&(T("A note from our team"),C(o.proposalCopy.trim(),d)),p){const n=p.price!=null?` at $${p.price}/mo`:"";C(`Prefer a different starting point? We also suggested ${p.name} â ${p.tagline}${n}. Just ask and we'll walk you through it.`)}const L=t.getNumberOfPages();for(let n=1;n<=L;
1n++)t.setPage(n),t.setDrawColor(...s),t.setLineWidth(.3),t.line(l,w-12,f-l,w-12),t.setFont("helvetica","normal"),t.setFontSize(8),t.setTextColor(...u),t.text(`${a.name} â Proposal for ${r}`,l,w-7),t.text(`Page ${n} of ${L}`,f-l,w-7,{align:"right"});const I=r.replace(/[^a-z0-9]+/gi,"-").replace(/^-+|-+$/g,"").toLowerCase();t.save(`proposal-${I||"prospect"}.pdf`)}function _(r){return r.lastAutoTable?.finalY??l}function $(r,o,a){return o+a>w-18?(r.addPage(),l+4):o}export{V as generateProposalPdf};
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.