!function(e){"use strict";var n="ohz_serenity_sid",t="/api/serenity/events";function r(n){return e.jsvars&&void 0!==e.jsvars[n]?e.jsvars[n]:e.ohz_jsvars&&void 0!==e.ohz_jsvars[n]?e.ohz_jsvars[n]:void 0}function i(){if(!1===r("serenityRequireConsent"))return!0;if(e.RGPDConsent&&"function"==typeof e.RGPDConsent.isAllowed)return e.RGPDConsent.isAllowed("analytics");var n=function(){if(e.consentRegime)return String(e.consentRegime).toLowerCase();var n=r("consentRegime");return n?String(n).toLowerCase():"opt_in"}();return"opt_out"===n||"exempt"===n}var o=function(){try{var t=sessionStorage.getItem(n);if(t&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t))return t}catch(e){}var r=e.jsvars&&e.jsvars.sessionId||e.ohz_jsvars&&e.ohz_jsvars.sessionId;if(r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)){try{sessionStorage.setItem(n,r)}catch(e){}return r}var i=function(){if("undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID)return crypto.randomUUID();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var n=16*Math.random()|0;return("x"===e?n:3&n|8).toString(16)})}();try{sessionStorage.setItem(n,i)}catch(e){}return i}(),s=null,a=null,c=null,u=null,d=0,f=!1,l=!1,v=[];function h(e){v.length>=10&&v.shift(),v.push(e)}function y(e,n){if(!l)if("undefined"==typeof fetch){if(navigator.sendBeacon){var r=new Blob([e],{type:"application/json"});navigator.sendBeacon(t,r)}}else fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:e,keepalive:!0}).then(function(t){if(!t.ok)return 401===t.status||403===t.status||404===t.status?(l=!0,v=[],void p()):void(n&&(t.status>=500||429===t.status)&&h(e))}).catch(function(t){n&&h(e),console.warn("[SerenityBeacon] Network error sending batch:",t)})}function g(){if(!l&&(function(){if(!l&&0!==v.length){var e=v.slice();v=[];for(var n=0;n50?void console.warn("[SerenityBeacon] Timed out waiting for window.Serenity"):void(u=setTimeout(x,100));try{var n=r("serenityMaskInputs"),t=Number(r("serenityMaxDuration")),i=isFinite(t)&&t>0?t:30;(s=new e.Serenity({debounceMs:500,captureScreenshots:!1,captureTextContent:!1,maskInputs:!1!==n,maxEvents:500})).start(),f=!0,a&&clearInterval(a),a=setInterval(g,7e3),c&&clearTimeout(c),c=setTimeout(p,60*i*1e3),e.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&g()}),e.addEventListener("pagehide",g),e.addEventListener("beforeunload",g)}catch(e){console.error("[SerenityBeacon] Failed to start recorder:",e)}}}function p(){u&&(clearTimeout(u),u=null),c&&(clearTimeout(c),c=null),f&&(l||g(),a&&(clearInterval(a),a=null),s&&(s.destroy(),s=null),f=!1)}function m(){i()&&x(),e.addEventListener&&e.addEventListener("ohz:consent:changed",function(e){var n=e&&e.detail;n&&n.analytics?x():n&&!1===n.analytics&&p()})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",m):m(),e.SerenityBeacon={getSessionId:function(){return o},flush:g,isRecording:function(){return f}}}("undefined"!=typeof window?window:this);