/**
 * Canonical Caseman product URLs (hosted at caseman.cnpsolutions.co.bw).
 * ERP marketing pages link out — do not duplicate the Caseman site here.
 */
(function (global) {
  'use strict';

  const CASEMAN_URL = 'https://caseman.cnpsolutions.co.bw/';
  const CASEMAN_DEMO_URL = 'https://caseman.cnpsolutions.co.bw/#contact';
  const CASEMAN_WA_TEXT = 'Hello CNP Solutions, I need help with Caseman.';

  const CASEMAN_LINKS = {
    landing: CASEMAN_URL,
    features: CASEMAN_URL + '#features',
    getStarted: CASEMAN_URL + '#get-started',
    contact: CASEMAN_DEMO_URL,
    demo: CASEMAN_DEMO_URL,
    whatsapp: 'https://wa.me/26777122880?text=' + encodeURIComponent(CASEMAN_WA_TEXT),
    salesEmail: 'mailto:sales@cnpsolutions.co.bw?subject=Caseman%20demo%20request',
  };

  const CASEMAN_ATTR = 'noopener noreferrer';

  function applyCasemanLinks() {
    document.querySelectorAll('[data-caseman-link]').forEach(function (el) {
      const key = el.getAttribute('data-caseman-link');
      if (!CASEMAN_LINKS[key]) return;
      el.setAttribute('href', CASEMAN_LINKS[key]);
      if (!el.getAttribute('target')) {
        el.setAttribute('target', '_blank');
        el.setAttribute('rel', CASEMAN_ATTR);
      }
    });
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', applyCasemanLinks);
  } else {
    applyCasemanLinks();
  }

  global.CASEMAN_URL = CASEMAN_URL;
  global.CASEMAN_DEMO_URL = CASEMAN_DEMO_URL;
  global.CASEMAN_LINKS = CASEMAN_LINKS;
})(typeof window !== 'undefined' ? window : globalThis);
