var g=Object.defineProperty;var A=(e)=>e;function S(e,t){this[e]=A.bind(null,t)}var R=(e,t)=>{for(var o in t)g(e,o,{get:t[o],enumerable:!0,configurable:!0,set:S.bind(t,o)})};var L=(e,t)=>()=>(e&&(t=e(e=0)),t);import{Logger as h}from"@contractspec/lib.logger";import{createClient as C,Temv1alpha1 as m}from"@scaleway/sdk";var l={email:"noreply@transactional.contractspec.io",name:"ContractSpec"},c={email:"contact@contractspec.io",name:"ContractSpec Team"},w="fr-par",a=null,i=null,r=(e)=>new m.API(e),_=(e)=>{let t=e?.trim().toLowerCase();if(t==="par"||t==="fr-par")return"fr-par";if(t==="ams"||t==="nl-ams")return"nl-ams";if(t==="waw"||t==="pl-waw")return"pl-waw";return w},p=()=>{if(a)return{ok:!0,config:a};let e=process.env.SCALEWAY_ACCESS_KEY||process.env.SCALEWAY_ACCESS_KEY_QUEUE,t=process.env.SCALEWAY_SECRET_KEY||process.env.SCALEWAY_SECRET_KEY_QUEUE,o=process.env.SCALEWAY_PROJECT_ID;if(!e||!t||!o)return{ok:!1,errorMessage:"Email service is not configured. Please contact us directly at contact@contractspec.io."};let n=_(process.env.SCALEWAY_REGION);return a={accessKey:e,secretKey:t,projectId:o,region:n,defaultZone:`${n}-1`,from:{email:process.env.SCALEWAY_EMAIL_FROM_EMAIL??l.email,name:process.env.SCALEWAY_EMAIL_FROM_NAME??l.name},teamInbox:{email:process.env.SCALEWAY_EMAIL_TEAM_EMAIL??c.email,name:process.env.SCALEWAY_EMAIL_TEAM_NAME??c.name}},{ok:!0,config:a}},v=(e)=>{if(i)return i;let t=C({accessKey:e.accessKey,secretKey:e.secretKey,defaultProjectId:e.projectId,defaultRegion:e.region,defaultZone:e.defaultZone});return i=r(t),i},s=async(e,t)=>{try{return await v(e).createEmail({region:e.region,projectId:e.projectId,from:e.from,to:t.to,subject:t.subject,text:t.text,html:t.html||t.text,additionalHeaders:t.replyTo?[{key:"Reply-To",value:t.replyTo}]:void 0}),{success:!0}}catch(o){return new h().error("scaleway_tem_email_send_failed",{context:t.context??"email",error:o instanceof Error?o.message:o}),{success:!1,error:o,errorMessage:"Failed to send email via Scaleway."}}},k={resetCaches(){i=null,a=null,r=(e)=>new m.API(e)},setApiFactory(e){r=e},setClient(e){i=e}};var I=(e)=>e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),u=(e)=>I(e).replaceAll(`
`,"<br />");var x="Waitlist service is not configured. Please try again later.",f="Failed to join waitlist. Please try again later or contact us directly.",O=async(e)=>{let t=(e.get("email")??"").toString().trim();if(!t||!t.includes("@"))return{success:!1,text:"Please enter a valid email address."};let o=p();if(!o.ok||!o.config)return{success:!1,text:o.errorMessage??x};let n=`
You're on the waitlist!

Thanks for joining the ContractSpec waitlist. You're now in line for early access to:

• Stabilize your AI-generated code with ContractSpec
• Multi-surface consistency (API, DB, UI, events)
• Safe regeneration without breaking changes
• AI governance and contract enforcement

We'll notify you as soon as early access is available. In the meantime, you can:

• Check out our docs: https://contractspec.io/docs
• Follow our progress on GitHub
• Book a demo call to see ContractSpec in action

We're excited to have you on board!

---
ContractSpec Team
https://contractspec.io

To remove yourself from the waitlist, reply to this email with "remove"
  `.trim(),d=`
    <div style="font-family: sans-serif; max-width: 640px; margin: 0 auto;">
      <h1 style="color: #8b5cf6;">You're on the waitlist!</h1>
      <p>Thanks for joining the ContractSpec waitlist. You're now in line for early access to:</p>
      <ul style="line-height: 1.8;">
        <li>Stabilize your AI-generated code with ContractSpec</li>
        <li>Multi-surface consistency (API, DB, UI, events)</li>
        <li>Safe regeneration without breaking changes</li>
        <li>AI governance and contract enforcement</li>
      </ul>
      <p>We'll notify you as soon as early access is available. In the meantime, you can:</p>
      <ul style="line-height: 1.8;">
        <li>Check out our <a href="https://contractspec.io/docs" style="color: #8b5cf6;">docs</a></li>
        <li>Follow our progress on GitHub</li>
        <li>Book a demo call to see ContractSpec in action</li>
      </ul>
      <p>We're excited to have you on board!</p>
      <hr style="margin: 30px 0; border: none; border-top: 1px solid #e5e7eb;" />
      <p style="color: #6b7280; font-size: 14px;">
        ContractSpec Team<br />
        <a href="https://contractspec.io" style="color: #8b5cf6;">contractspec.io</a>
      </p>
      <p style="color: #9ca3af; font-size: 12px;">
        To remove yourself from the waitlist, reply to this email with "remove"
      </p>
    </div>
  `;if(!(await s(o.config,{to:[{email:t}],subject:"You're on the ContractSpec waitlist!",text:n,html:d,context:"waitlist-welcome"})).success)return{success:!1,text:f};let E=`New waitlist signup from: ${t}`,y=`
    <div style="font-family: sans-serif; max-width: 640px; margin: 0 auto;">
      <p style="margin: 0 0 8px;">New waitlist signup</p>
      <p style="margin: 0;"><strong>Email:</strong> ${u(t)}</p>
    </div>
  `;if(!(await s(o.config,{to:[o.config.teamInbox],subject:`New Waitlist Signup: ${t}`,text:E,html:y,context:"waitlist-team-notification"})).success)return{success:!1,text:f};return{success:!0,text:"Successfully joined waitlist!"}};export{O as joinWaitlist};
