/**
 * Shared visitor registration with sleep-outage handling.
 */
(function (w) {
  "use strict";

  w.sciiRegisterVisitor = function (payload) {
    return fetch("/api/register-visitor", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify(payload),
    })
      .then(function (r) {
        return r.json();
      })
      .then(function (d) {
        if (typeof w.sciiHandleRegisterResponse === "function") {
          w.sciiHandleRegisterResponse(d);
        }
        return d;
      })
      .catch(function () {});
  };
})(window);
