/**
 * Landing Page Generator
 * Generates beautiful, TCPA-compliant HTML pages from templates using Handlebars
 * Ported from a2p-autopilot
 */

import Handlebars from 'handlebars';

// --- Types ---

export interface LandingPageConfig {
  businessName: string;
  businessSlug: string;
  useCase: string;
  messageFrequency: string;
  contactEmail: string;
  contactPhone: string;
  brandColor: string;
  logoUrl?: string;
}

export interface GeneratedPages {
  optIn: string;
  privacyPolicy: string;
  terms: string;
}

// --- Helpers ---

export function generateSlug(businessName: string): string {
  return businessName
    .toLowerCase()
    .replace(/[^a-z0-9]+/g, '-')
    .replace(/^-+|-+$/g, '')
    .substring(0, 50);
}

function getBusinessInitial(businessName: string): string {
  return businessName.charAt(0).toUpperCase();
}

function getCurrentDate(): string {
  return new Date().toLocaleDateString('en-US', {
    month: 'long',
    day: 'numeric',
    year: 'numeric',
  });
}

function getCurrentYear(): number {
  return new Date().getFullYear();
}

// --- Template Data ---

function buildTemplateData(config: LandingPageConfig) {
  const slug = config.businessSlug || generateSlug(config.businessName);
  return {
    businessName: config.businessName,
    businessSlug: slug,
    useCase: config.useCase,
    useCaseDescription: config.useCase,
    messageFrequency: config.messageFrequency,
    contactEmail: config.contactEmail,
    contactPhone: config.contactPhone,
    brandColor: config.brandColor || '#3B82F6',
    logoUrl: config.logoUrl || null,
    businessInitial: getBusinessInitial(config.businessName),
    currentDate: getCurrentDate(),
    currentYear: getCurrentYear(),
    privacyPolicyUrl: './privacy-policy.html',
    termsUrl: './terms.html',
  };
}

// --- Opt-In Template ---

const optInTemplate = `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>SMS Opt-In - {{businessName}}</title>
  <script src="https://cdn.tailwindcss.com"><\/script>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <style>
    body { font-family: 'Inter', sans-serif; }
    .gradient-bg {
      background: linear-gradient(135deg, {{brandColor}}15 0%, {{brandColor}}05 100%);
    }
    .brand-accent { color: {{brandColor}}; }
    .brand-border { border-color: {{brandColor}}; }
    .brand-bg { background-color: {{brandColor}}; }
  </style>
</head>
<body class="bg-gray-50 min-h-screen gradient-bg">
  <div class="max-w-2xl mx-auto px-4 py-12 sm:px-6 lg:px-8">

    <!-- Header -->
    <div class="text-center mb-8">
      {{#if logoUrl}}
      <img src="{{logoUrl}}" alt="{{businessName}}" class="h-16 mx-auto mb-4">
      {{else}}
      <div class="h-16 w-16 mx-auto mb-4 brand-bg rounded-full flex items-center justify-center">
        <span class="text-white text-2xl font-bold">{{businessInitial}}</span>
      </div>
      {{/if}}
      <h1 class="text-4xl font-bold text-gray-900 mb-2">{{businessName}}</h1>
      <p class="text-xl text-gray-600">SMS Notifications</p>
    </div>

    <!-- Main Card -->
    <div class="bg-white rounded-2xl shadow-xl overflow-hidden">
      <div class="p-8 sm:p-12">

        <!-- Intro -->
        <div class="mb-8">
          <h2 class="text-2xl font-semibold text-gray-900 mb-4">Stay Connected</h2>
          <p class="text-gray-700 leading-relaxed">
            {{useCaseDescription}}
          </p>
        </div>

        <!-- Form -->
        <form id="optInForm" class="space-y-6">

          <!-- Phone Input -->
          <div>
            <label for="phone" class="block text-sm font-medium text-gray-700 mb-2">
              Mobile Phone Number
            </label>
            <input
              type="tel"
              id="phone"
              name="phone"
              required
              placeholder="(555) 123-4567"
              class="w-full px-4 py-3 border-2 border-gray-300 rounded-lg focus:ring-2 focus:border-transparent transition-all text-lg"
            >
          </div>

          <!-- Consent Checkbox -->
          <div class="bg-blue-50 border-2 border-blue-200 rounded-lg p-6">
            <div class="flex items-start">
              <input
                type="checkbox"
                id="consent"
                name="consent"
                required
                class="mt-1 h-5 w-5 brand-accent rounded focus:ring-2 focus:ring-offset-2"
              >
              <label for="consent" class="ml-3 text-sm text-gray-800 leading-relaxed">
                <strong class="font-semibold">I consent to receive SMS text messages</strong> from {{businessName}}
                at the phone number provided above. I understand that:
                <ul class="mt-3 space-y-2 text-gray-700">
                  <li>&bull; Message frequency: {{messageFrequency}}</li>
                  <li>&bull; Message and data rates may apply</li>
                  <li>&bull; Consent is not a condition of purchase</li>
                  <li>&bull; Reply <strong>STOP</strong> to opt out at any time</li>
                  <li>&bull; Reply <strong>HELP</strong> for assistance</li>
                </ul>
              </label>
            </div>
          </div>

          <!-- Submit Button -->
          <button
            type="submit"
            class="w-full brand-bg text-white font-semibold py-4 px-6 rounded-lg hover:opacity-90 transform hover:scale-[1.02] transition-all shadow-lg text-lg"
          >
            Subscribe to SMS Notifications
          </button>

        </form>

        <!-- Legal Links -->
        <div class="mt-8 pt-8 border-t border-gray-200 text-center space-x-4">
          <a href="{{privacyPolicyUrl}}" class="text-sm brand-accent hover:underline font-medium">Privacy Policy</a>
          <span class="text-gray-300">|</span>
          <a href="{{termsUrl}}" class="text-sm brand-accent hover:underline font-medium">Terms of Service</a>
        </div>

      </div>

      <!-- Carrier Disclosure -->
      <div class="bg-gray-50 px-8 py-6 sm:px-12 border-t border-gray-200">
        <p class="text-xs text-gray-600 leading-relaxed">
          <strong class="font-semibold">Supported Carriers:</strong> AT&amp;T, T-Mobile, Verizon, Sprint, Boost, Cricket,
          Metro PCS, U.S. Cellular, Virgin Mobile, and other major carriers. Carrier message and data rates may apply.
        </p>
        <p class="text-xs text-gray-600 mt-3">
          For support, contact us at <a href="mailto:{{contactEmail}}" class="brand-accent hover:underline">{{contactEmail}}</a>
          or call <a href="tel:{{contactPhone}}" class="brand-accent hover:underline">{{contactPhone}}</a>.
        </p>
      </div>
    </div>

    <!-- Footer -->
    <div class="text-center mt-8 text-sm text-gray-500">
      <p>&copy; {{currentYear}} {{businessName}}. All rights reserved.</p>
      <p class="mt-2">This service complies with TCPA and CTIA messaging guidelines.</p>
    </div>

  </div>

  <script>
    document.getElementById('optInForm').addEventListener('submit', function(e) {
      e.preventDefault();
      var consent = document.getElementById('consent').checked;
      if (!consent) { alert('Please check the consent box to continue.'); return; }
      alert('Thank you for subscribing! You will receive a confirmation message shortly.');
      this.reset();
    });
    var phoneInput = document.getElementById('phone');
    phoneInput.addEventListener('input', function(e) {
      var value = e.target.value.replace(/\\D/g, '');
      if (value.length > 10) value = value.slice(0, 10);
      if (value.length >= 6) {
        value = '(' + value.slice(0,3) + ') ' + value.slice(3,6) + '-' + value.slice(6);
      } else if (value.length >= 3) {
        value = '(' + value.slice(0,3) + ') ' + value.slice(3);
      }
      e.target.value = value;
    });
  <\/script>
</body>
</html>`;

// --- Privacy Policy Template ---

const privacyPolicyTemplate = `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Privacy Policy - {{businessName}}</title>
  <script src="https://cdn.tailwindcss.com"><\/script>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <style>
    body { font-family: 'Inter', sans-serif; }
    .gradient-bg { background: linear-gradient(135deg, {{brandColor}}15 0%, {{brandColor}}05 100%); }
    .brand-accent { color: {{brandColor}}; }
  </style>
</head>
<body class="bg-gray-50 min-h-screen gradient-bg">
  <div class="max-w-4xl mx-auto px-4 py-12 sm:px-6 lg:px-8">

    <div class="mb-8">
      <a href="./" class="inline-flex items-center text-sm brand-accent hover:underline mb-4">&larr; Back to Opt-In</a>
      <h1 class="text-4xl font-bold text-gray-900 mb-2">Privacy Policy</h1>
      <p class="text-gray-600">{{businessName}} SMS Messaging Program</p>
      <p class="text-sm text-gray-500 mt-2">Last Updated: {{currentDate}}</p>
    </div>

    <div class="bg-white rounded-2xl shadow-xl p-8 sm:p-12 space-y-8">

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">1. Overview</h2>
        <p class="text-gray-700 leading-relaxed">
          This Privacy Policy describes how {{businessName}} (&ldquo;we,&rdquo; &ldquo;us,&rdquo; or &ldquo;our&rdquo;) collects, uses, and protects
          your personal information when you participate in our SMS messaging program. We are committed to protecting
          your privacy and complying with applicable laws, including the Telephone Consumer Protection Act (TCPA)
          and CTIA Messaging Principles and Best Practices.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">2. Information We Collect</h2>
        <p class="text-gray-700 leading-relaxed mb-4">When you opt in to our SMS program, we collect:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li><strong>Mobile phone number:</strong> Used to send you SMS messages</li>
          <li><strong>Opt-in timestamp:</strong> Records when you consented to receive messages</li>
          <li><strong>Message interaction data:</strong> Delivery status, opt-out requests, and responses to HELP/STOP commands</li>
          <li><strong>Device and carrier information:</strong> Automatically collected for message delivery</li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">3. How We Use Your Information</h2>
        <p class="text-gray-700 leading-relaxed mb-4">We use your information solely for the following purposes:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li>Send you SMS messages for {{useCase}}</li>
          <li>Process your opt-in consent and opt-out requests</li>
          <li>Provide customer support through the HELP command</li>
          <li>Maintain compliance records as required by law</li>
          <li>Improve our messaging service quality</li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">4. Information Sharing</h2>
        <p class="text-gray-700 leading-relaxed">
          <strong>We do not sell, rent, or share your personal information with third parties for marketing purposes.</strong>
          We may share your information only with:
        </p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4 mt-4">
          <li><strong>Service providers:</strong> SMS platform providers (e.g., Twilio) who help us deliver messages</li>
          <li><strong>Legal compliance:</strong> When required by law or to protect our legal rights</li>
          <li><strong>Business transfers:</strong> In the event of a merger, acquisition, or sale of assets</li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">5. Data Security</h2>
        <p class="text-gray-700 leading-relaxed">
          We implement industry-standard security measures to protect your personal information from unauthorized
          access, disclosure, alteration, or destruction. Your data is encrypted in transit and at rest. However,
          no method of electronic transmission or storage is 100% secure.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">6. Your Rights and Choices</h2>
        <p class="text-gray-700 leading-relaxed mb-4">You have the following rights regarding your personal information:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li><strong>Opt-out:</strong> Reply <strong>STOP</strong> to any message to unsubscribe immediately</li>
          <li><strong>Help:</strong> Reply <strong>HELP</strong> for assistance or contact information</li>
          <li><strong>Access:</strong> Request a copy of your data by contacting us</li>
          <li><strong>Deletion:</strong> Request deletion of your data</li>
          <li><strong>Correction:</strong> Request correction of inaccurate information</li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">7. Data Retention</h2>
        <p class="text-gray-700 leading-relaxed">
          We retain your mobile phone number and consent records for as long as you remain subscribed to our SMS program.
          After you opt out, we retain minimal records for compliance purposes (proof of opt-out) for up to 4 years
          as required by TCPA regulations.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">8. Compliance</h2>
        <p class="text-gray-700 leading-relaxed">Our SMS program complies with:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4 mt-4">
          <li>Telephone Consumer Protection Act (TCPA)</li>
          <li>CTIA Messaging Principles and Best Practices</li>
          <li>CAN-SPAM Act</li>
          <li>Mobile Marketing Association (MMA) Consumer Best Practices</li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">9. Changes to This Policy</h2>
        <p class="text-gray-700 leading-relaxed">
          We may update this Privacy Policy from time to time. The &ldquo;Last Updated&rdquo; date at the top will reflect any changes.
          Continued participation in our SMS program after changes constitutes acceptance of the updated policy.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">10. Contact Us</h2>
        <p class="text-gray-700 leading-relaxed">If you have questions about this Privacy Policy or our SMS program, please contact us:</p>
        <div class="mt-4 p-6 bg-gray-50 rounded-lg">
          <p class="text-gray-800"><strong>{{businessName}}</strong></p>
          <p class="text-gray-700 mt-2">Email: <a href="mailto:{{contactEmail}}" class="brand-accent hover:underline">{{contactEmail}}</a></p>
          <p class="text-gray-700">Phone: <a href="tel:{{contactPhone}}" class="brand-accent hover:underline">{{contactPhone}}</a></p>
        </div>
      </section>

    </div>

    <div class="text-center mt-8 text-sm text-gray-500">
      <p>&copy; {{currentYear}} {{businessName}}. All rights reserved.</p>
    </div>

  </div>
</body>
</html>`;

// --- Terms Template ---

const termsTemplate = `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Terms of Service - {{businessName}}</title>
  <script src="https://cdn.tailwindcss.com"><\/script>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  <style>
    body { font-family: 'Inter', sans-serif; }
    .gradient-bg { background: linear-gradient(135deg, {{brandColor}}15 0%, {{brandColor}}05 100%); }
    .brand-accent { color: {{brandColor}}; }
  </style>
</head>
<body class="bg-gray-50 min-h-screen gradient-bg">
  <div class="max-w-4xl mx-auto px-4 py-12 sm:px-6 lg:px-8">

    <div class="mb-8">
      <a href="./" class="inline-flex items-center text-sm brand-accent hover:underline mb-4">&larr; Back to Opt-In</a>
      <h1 class="text-4xl font-bold text-gray-900 mb-2">Terms of Service</h1>
      <p class="text-gray-600">{{businessName}} SMS Messaging Program</p>
      <p class="text-sm text-gray-500 mt-2">Last Updated: {{currentDate}}</p>
    </div>

    <div class="bg-white rounded-2xl shadow-xl p-8 sm:p-12 space-y-8">

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">1. Agreement to Terms</h2>
        <p class="text-gray-700 leading-relaxed">
          By opting in to receive SMS messages from {{businessName}} (&ldquo;we,&rdquo; &ldquo;us,&rdquo; or &ldquo;our&rdquo;), you agree to these
          Terms of Service. If you do not agree, please do not opt in to our program.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">2. SMS Program Description</h2>
        <p class="text-gray-700 leading-relaxed">{{useCaseDescription}}</p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">3. Consent to Receive Messages</h2>
        <p class="text-gray-700 leading-relaxed mb-4">By providing your mobile phone number and checking the consent box, you:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li>Expressly consent to receive SMS text messages from {{businessName}}</li>
          <li>Certify that you are the account holder or have authorization to use the provided phone number</li>
          <li>Understand that consent is not a condition of purchase or service</li>
          <li>Acknowledge that message frequency is: <strong>{{messageFrequency}}</strong></li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">4. Message Frequency</h2>
        <p class="text-gray-700 leading-relaxed">
          You will receive approximately <strong>{{messageFrequency}}</strong>. The actual frequency may vary based on
          your activity and account status. We will never send unsolicited messages or spam.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">5. Message and Data Rates</h2>
        <p class="text-gray-700 leading-relaxed">
          <strong>Message and data rates may apply.</strong> You are responsible for any charges imposed by your mobile
          carrier for SMS messages. {{businessName}} is not responsible for any carrier charges you may incur.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">6. Opt-Out Instructions</h2>
        <p class="text-gray-700 leading-relaxed mb-4">You may opt out at any time by:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li>Replying <strong>STOP</strong>, <strong>END</strong>, <strong>CANCEL</strong>, <strong>UNSUBSCRIBE</strong>, or <strong>QUIT</strong> to any message</li>
          <li>Contacting us at <a href="mailto:{{contactEmail}}" class="brand-accent hover:underline">{{contactEmail}}</a></li>
        </ul>
        <p class="text-gray-700 leading-relaxed mt-4">
          After opting out, you will receive one final confirmation message, and then no further messages will be sent.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">7. Help and Support</h2>
        <p class="text-gray-700 leading-relaxed mb-4">For assistance:</p>
        <ul class="list-disc list-inside text-gray-700 space-y-2 ml-4">
          <li>Reply <strong>HELP</strong> or <strong>INFO</strong> to any message</li>
          <li>Email us at <a href="mailto:{{contactEmail}}" class="brand-accent hover:underline">{{contactEmail}}</a></li>
          <li>Call us at <a href="tel:{{contactPhone}}" class="brand-accent hover:underline">{{contactPhone}}</a></li>
        </ul>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">8. Supported Carriers</h2>
        <p class="text-gray-700 leading-relaxed">
          Our SMS program is supported by major U.S. carriers including AT&amp;T, T-Mobile, Verizon, Sprint, Boost Mobile,
          Cricket Wireless, Metro PCS, U.S. Cellular, Virgin Mobile, and others.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">9. Carrier Liability Disclaimer</h2>
        <p class="text-gray-700 leading-relaxed">
          <strong>Carriers are not liable for delayed or undelivered messages.</strong> Message delivery depends on
          factors outside our control. {{businessName}} is not responsible for messages that are not received due to
          carrier issues, network outages, or device problems.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">10. Eligibility</h2>
        <p class="text-gray-700 leading-relaxed">
          You must be 18 years of age or older to participate in our SMS program.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">11. Privacy</h2>
        <p class="text-gray-700 leading-relaxed">
          Your privacy is important to us. Please review our
          <a href="{{privacyPolicyUrl}}" class="brand-accent hover:underline font-medium">Privacy Policy</a>
          to understand how we collect, use, and protect your personal information.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">12. Program Changes</h2>
        <p class="text-gray-700 leading-relaxed">
          We reserve the right to modify, suspend, or terminate our SMS program at any time. Continued participation
          after changes constitutes acceptance of the modified terms.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">13. Limitation of Liability</h2>
        <p class="text-gray-700 leading-relaxed">
          {{businessName}} and its service providers shall not be liable for any indirect, incidental, special,
          consequential, or punitive damages arising from the SMS program.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">14. Compliance</h2>
        <p class="text-gray-700 leading-relaxed">
          Our SMS program complies with the Telephone Consumer Protection Act (TCPA), CAN-SPAM Act, CTIA Messaging
          Principles and Best Practices, and all applicable federal and state laws governing SMS communications.
        </p>
      </section>

      <section>
        <h2 class="text-2xl font-semibold text-gray-900 mb-4">15. Contact Information</h2>
        <p class="text-gray-700 leading-relaxed">If you have questions about these Terms of Service, please contact us:</p>
        <div class="mt-4 p-6 bg-gray-50 rounded-lg">
          <p class="text-gray-800"><strong>{{businessName}}</strong></p>
          <p class="text-gray-700 mt-2">Email: <a href="mailto:{{contactEmail}}" class="brand-accent hover:underline">{{contactEmail}}</a></p>
          <p class="text-gray-700">Phone: <a href="tel:{{contactPhone}}" class="brand-accent hover:underline">{{contactPhone}}</a></p>
        </div>
      </section>

    </div>

    <div class="text-center mt-8 text-sm text-gray-500">
      <p>&copy; {{currentYear}} {{businessName}}. All rights reserved.</p>
    </div>

  </div>
</body>
</html>`;

// --- Generator Functions ---

export function generateOptInPage(config: LandingPageConfig): string {
  const data = buildTemplateData(config);
  const compiled = Handlebars.compile(optInTemplate);
  return compiled(data);
}

export function generatePrivacyPolicy(config: LandingPageConfig): string {
  const data = buildTemplateData(config);
  const compiled = Handlebars.compile(privacyPolicyTemplate);
  return compiled(data);
}

export function generateTermsPage(config: LandingPageConfig): string {
  const data = buildTemplateData(config);
  const compiled = Handlebars.compile(termsTemplate);
  return compiled(data);
}

export function generateAllPages(config: LandingPageConfig): GeneratedPages {
  return {
    optIn: generateOptInPage(config),
    privacyPolicy: generatePrivacyPolicy(config),
    terms: generateTermsPage(config),
  };
}
