// WebMCP — progressive enhancement. Silent no-op in all browsers until navigator.modelContext ships.
(function () {
  if (!navigator.modelContext) return;

  navigator.modelContext.registerTools([
    {
      name: "request_pilot",
      description: "Submit a Signal pilot interest form for a DMEPOS supplier or billing company.",
      parameters: {
        type: "object",
        properties: {
          name:    { type: "string", description: "Full name of the contact" },
          email:   { type: "string", description: "Work email address" },
          company: { type: "string", description: "Organization name" },
          role:    { type: "string", description: "Role, e.g. Billing Manager, Owner, RCM Director" }
        },
        required: ["name", "email", "company", "role"]
      },
      execute: async function ({ name, email, company, role }) {
        const res = await fetch("https://n8n.sttilsolutions.com/webhook/signal-cgm-lead", {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({ name, email, company, role })
        });
        if (!res.ok) throw new Error("Submission failed");
        return { success: true, message: "Pilot request submitted. STTIL Solutions will respond within 2 business days." };
      }
    }
  ]);
})();
