1var SignalStream=function(t){"use strict";function e(t){const e="[SignalStream]";return t?{debug:(...t)=>console.debug(e,...t),info:(...t)=>console.info(e,...t),warn:(...t)=>console.warn(e,...t),error:(...t)=>console.error(e,...t)}:{debug:()=>{},info:()=>{},warn:(...t)=>console.warn(e,...t),error:(...t)=>console.error(e,...t)}}class n extends Error{constructor(t,e){super(e),this.name="TransportHttpError",this.status=t}}function i(t){return t instanceof n&&408!==t.status&&429!==t.status}class o{constructor(t){this.options=t}async send(t){const e=`${this.options.endpoint}/collect`;let i=null;for(let r=0;r<=this.options.maxRetries;r++)try{this.options.logger.debug(`Sending event (attempt ${r+1})`,t.event_id);const o=await this.fetchWithTimeout(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0});if(o.ok)return void this.options.logger.debug("Event sent successfully",t.event_id);if(o.status>=400&&o.status<500){const t=await o.text();throw new n(o.status,`Client error ${o.status}: ${t||o.statusText}`)}i=new Error(`Server error ${o.status}: ${o.statusText}`)}catch(o){if(i=o,this.options.logger.warn(`Send attempt ${r+1} failed:`,o),o instanceof TypeError&&(o.message.includes("Failed to fetch")||o.message.includes("NetworkError")));else if(o instanceof n)throw o;if(r<this.options.maxRetries){const t=this.options.retryDelay*Math.pow(2,r);await this.sleep(t)}}throw new Error(`Failed to send event after ${this.options.maxRetries+1} attempts: ${i?.message}`)}async sendBatch(t){if(0===t.length)return;this.options.logger.debug(`Sending batch of ${t.length} events`);const e=t.map(t=>this.send(t));try{await Promise.all(e),this.options.logger.debug(`Batch of ${t.length} events sent successfully`)}catch(n){throw this.options.logger.error("Batch send failed:",n),n}}sendBeacon(t){if("undefined"==typeof navigator||!navigator.sendBeacon)return this.options.logger.warn("Beacon API not available"),!1;const e=`${this.options.endpoint}/collect`,n=new Blob([JSON.stringify(t)],{type:"application/json"});try{const i=navigator.sendBeacon(e,n);return i?this.options.logger.debug("Event sent via beacon",t.event_id):this.options.logger.warn("Beacon send failed",t.event_id),i}catch(i){return this.options.logger.error("Beacon send error:",i),!1}}async fetchWithTimeout(t,e){const n=new AbortController,i=setTimeout(()=>n.abort(),this.options.timeout);try{return await fetch(t,{...e,signal:n.signal})}finally{clearTimeout(i)}}sleep(t){return new Promise(e=>setTimeout(e,t))}}
1class r{constructor(t){this.queue=[],this.options=t,this.storageAvailable=this.checkStorageAvailable(),this.loadFromStorage(),this.cleanupOldEvents()}add(t){this.queue.length>=this.options.maxSize&&(this.options.logger.warn("Queue is full, dropping oldest event"),this.queue.shift());const e={event:t,attempts:0,timestamp:Date.now()};this.queue.push(e),this.saveToStorage(),this.options.logger.debug(`Event queued: ${t.event_id} (queue size: ${this.queue.length})`)}getAll(){return[...this.queue]}remove(t){const e=this.queue.length;this.queue=this.queue.filter(e=>e.event.event_id!==t),this.queue.length<e&&(this.saveToStorage(),this.options.logger.debug(`Event removed from queue: ${t}`))}incrementAttempts(t){const e=this.queue.find(e=>e.event.event_id===t);e&&(e.attempts++,this.saveToStorage())}size(){return this.queue.length}isEmpty(){return 0===this.queue.length}clear(){this.queue=[],this.saveToStorage(),this.options.logger.debug("Queue cleared")}cleanupOldEvents(){const t=Date.now(),e=this.queue.length;this.queue=this.queue.filter(e=>t-e.timestamp<this.options.maxAge);const n=e-this.queue.length;n>0&&(this.options.logger.debug(`Removed ${n} expired events from queue`),this.saveToStorage())}saveToStorage(){if(this.storageAvailable)try{const t=JSON.stringify(this.queue);localStorage.setItem(this.options.storageKey,t)}catch(t){this.options.logger.error("Failed to save queue to localStorage:",t)}}loadFromStorage(){if(this.storageAvailable)try{const t=localStorage.getItem(this.options.storageKey);t&&(this.queue=JSON.parse(t),this.options.logger.debug(`Loaded ${this.queue.length} events from storage`))}catch(t){this.options.logger.error("Failed to load queue from localStorage:",t),this.queue=[]}}checkStorageAvailable(){try{const t="__signalstream_test__";return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch(t){return this.options.logger.warn("localStorage not available, queue will not persist"),!1}}}class s{constructor(){this.callbacks=[],this.initialized=!1,this.cachedConsent=null,this.init()}init(){const t=c();t&&(this.initialized=!0,this.cachedConsent=t),this.setupWindowEventListeners(),this.isAvailable()?this.initialized=!0:this.waitForCookieFirst()}setupWindowEventListeners(){"undefined"!=typeof window&&(window.addEventListener("cf_init",()=>{if(this.initialized=!0,!this.cachedConsent){const t=this.getConsent();t&&(this.cachedConsent=t,this.notifyCallbacks(t))}}),window.addEventListener("cf_consent_loaded",t=>{if(t.detail){this.initialized=!0;const e=this.mapCookieFirstConsent(t.detail);this.cachedConsent=e,this.notifyCallbacks(e)}}),window.addEventListener("cf_consent",t=>{if(t.detail){const e=this.mapCookieFirstConsent(t.detail);this.cachedConsent=e,this.notifyCallbacks(e)}}))}waitForCookieFirst(){const t=setInterval(()=>{if(this.isAvailable()&&(this.initialized=!0,clearInterval(t),!this.cachedConsent)){const t=this.getConsent();t&&(this.cachedConsent=t,this.notifyCallbacks(t))}},100);setTimeout(()=>clearInterval(t),3e3)}mapCookieFirstConsent(t){return{marketing:!0===t.advertising,analytics:!0===t.performance,preferences:!0===t.functional,functional:!0===t.functional,necessary:!1!==t.necessary,decided:!0}}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(n){console.error("CookieFirst consent callback error:",n)}})}getConsent(){if(this.isAvailable()&&window.CookieFirst?.consent)return this.mapCookieFirstConsent(window.CookieFirst.consent);if(this.cachedConsent)return this.cachedConsent;return c()||{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}}onChange(t){if(this.callbacks.push(t),this.initialized)try{t(this.getConsent())}catch(e){console.error("CookieFirst consent callback error:",e)}}isAvailable(){return"undefined"!=typeof window&&void 0!==window.CookieFirst&&void 0!==window.CookieFirst.consent}}function c(){if("undefined"==typeof window||"undefined"==typeof localStorage)return null;try{const t=localStorage.getItem("cookiefirst-consent");if(!t)return null;const e=JSON.parse(t);if("object"!=typeof e||null===e)return null;const n=Object.prototype.hasOwnProperty;return n.call(e,"__proto__")||n.call(e,"constructor")||n.call(e,"prototype")?null:{marketing:!0===e.advertising,analytics:!0===e.performance,preferences:!0===e.functional,functional:!0===e.functional,necessary:!1!==e.necessary,decided:!0}}catch(t){return null}}function a(t){const e=t.purposes||{};return{necessary:!1!==e[1],functional:!0===e[2],preferences:!0===e[3],analytics:!0===e[4],marketing:!0===e[5],timestamp:t.timestamp?new Date(t.timestamp).getTime():Date.now(),decided:!0,...t.timestamp?{decision_time:new Date(t.timestamp).getTime()}:{}}}class u{constructor(){this.callbacks=[],this.initialized=!1,this.lastConsentSnapshot=null,this.pollTimer=null,this.init()}init(){this.isAvailable()?(this.initialized=!0,this.setupEventListener()):this.waitForIubenda()}waitForIubenda(){const t=setInterval(()=>{if(this.isAvailable()){this.initialized=!0,this.setupEventListener(),clearInterval(t);const e=this.getConsent();this.callbacks.forEach(t=>t(e))}},100);setTimeout(()=>clearInterval(t),1e4)}
1setupEventListener(){if("undefined"==typeof window)return;window._iub&&!window._iub.csConfiguration&&(window._iub.csConfiguration={}),window._iub&&window._iub.csConfiguration&&!window._iub.csConfiguration.callback&&(window._iub.csConfiguration.callback={});const t=window._iub?.csConfiguration?.callback?.onConsentGiven,e=window._iub?.csConfiguration?.callback?.onConsentRejected,n=window._iub?.csConfiguration?.callback?.onPreferenceExpressed;window._iub&&window._iub.csConfiguration&&window._iub.csConfiguration.callback&&(window._iub.csConfiguration.callback.onConsentGiven=()=>{this.emitConsent(),t&&t()},window._iub.csConfiguration.callback.onConsentRejected=()=>{this.emitConsent(),e&&e()},window._iub.csConfiguration.callback.onPreferenceExpressed=t=>{this.emitConsent(),n&&n(t)}),this.lastConsentSnapshot=JSON.stringify(this.getConsent()),this.startConsentPolling()}emitConsent(){const t=this.getConsent();this.lastConsentSnapshot=JSON.stringify(t),this.notifyCallbacks(t)}emitIfChanged(){const t=this.getConsent(),e=JSON.stringify(t);e!==this.lastConsentSnapshot&&(this.lastConsentSnapshot=e,this.notifyCallbacks(t))}startConsentPolling(){null===this.pollTimer&&"undefined"!=typeof window&&(this.pollTimer=setInterval(()=>this.emitIfChanged(),1e3))}destroy(){null!==this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null),this.callbacks=[]}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(n){console.error("iubenda consent callback error:",n)}})}getConsent(){return this.isAvailable()&&window._iub?.cs?.consent?a(window._iub.cs.consent):{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}}onChange(t){if(this.callbacks.push(t),this.initialized){const n=this.getConsent();try{t(n)}catch(e){console.error("iubenda consent callback error:",e)}}}isAvailable(){return"undefined"!=typeof window&&void 0!==window._iub&&void 0!==window._iub.cs&&void 0!==window._iub.cs.consent}}class l{constructor(){this.callbacks=[],this.cachedConsent=null,this.ready=!1,this.init()}init(){this.isAvailable()&&window.__tcfapi("addEventListener",2,(t,e)=>{if(!e||!t)return;if("tcloaded"!==t.eventStatus&&"useractioncomplete"!==t.eventStatus)return;const n=function(t){const e=t.purpose?.consents??{},n=t=>!0===e[t];return{marketing:n(1)&&n(3)&&n(4),analytics:n(1)&&n(8),functional:n(1),preferences:!1,necessary:!0,decided:!0}}(t);this.cachedConsent=n,this.ready=!0,this.notifyCallbacks(n)})}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(n){console.error("TCF consent callback error:",n)}})}getConsent(){return this.cachedConsent??{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}}onChange(t){if(this.callbacks.push(t),this.ready&&this.cachedConsent)try{t(this.cachedConsent)}catch(e){console.error("TCF consent callback error:",e)}}isAvailable(){return"undefined"!=typeof window&&"function"==typeof window.__tcfapi}}class f{constructor(){this.callbacks=[],this.ready=!1,this.init()}init(){if("undefined"==typeof document)return;const t=()=>{this.ready=!0,this.notifyCallbacks(this.getConsent())};document.addEventListener("wp_listen_for_consent_change",t),document.addEventListener("wp_consent_type_defined",t),this.isAvailable()&&(this.ready=!0)}notifyCallbacks(t){this.callbacks.forEach(e=>{try{e(t)}catch(n){console.error("WP Consent API consent callback error:",n)}})}getConsent(){return this.isAvailable()?null===function(){if("undefined"==typeof window)return null;const t=window.wp_consent_type||window.consent_api?.consent_type;return"optin"===t||"optout"===t?t:null}()?{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}:function(t){const e=t("marketing"),n=t("statistics")||t("statistics-anonymous"),i=t("preferences");return{marketing:e,analytics:n,preferences:i,functional:!1,necessary:!0,decided:e||n||i}}(t=>{try{return!0===window.wp_has_consent?.(t)}catch{return!1}}):{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}}onChange(t){if(this.callbacks.push(t),this.ready)try{t(this.getConsent())}catch(e){console.error("WP Consent API consent callback error:",e)}}isAvailable(){return"undefined"!=typeof window&&"function"==typeof window.wp_has_consent}}const d=[{name:"tcf",isAvailable:()=>"undefined"!=typeof window&&"function"==typeof window.__tcfapi,create:()=>new l},{name:"iubenda",isAvailable:()=>"undefined"!=typeof window&&void 0!==window._iub&&void 0!==window._iub.cs&&void 0!==window._iub.cs.consent,create:()=>new u},{name:"cookiefirst",isAvailable:()=>"undefined"!=typeof window&&(void 0!==window.CookieFirst||null!==c()),create:()=>new s}];class h{constructor(t=d){this.delegate=null,this.callbacks=[],this.registry=t,this.bindFirstAvailable()||this.waitForCmp()}bindFirstAvailable(){for(const t of this.registry)if(t.isAvailable())return this.delegate=t.create(),this.callbacks.forEach(t=>this.delegate.onChange(t)),!0;return!1}waitForCmp(){if("undefined"==typeof window)return;const t=setInterval(()=>{this.bindFirstAvailable()&&clearInterval(t)},100);setTimeout(()=>clearInterval(t),1e4)}getConsent(){return this.delegate?this.delegate.getConsent():{marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0,decided:!1}}onChange(t){this.callbacks.push(t),this.delegate&&this.delegate.onChange(t)}
1isAvailable(){return null!==this.delegate&&this.delegate.isAvailable()}}function p(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():function(){if("undefined"!=typeof crypto&&crypto.getRandomValues){const t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;const e=Array.from(t).map(t=>t.toString(16).padStart(2,"0")).join("");return[e.slice(0,8),e.slice(8,12),e.slice(12,16),e.slice(16,20),e.slice(20,32)].join("-")}return console.warn("SignalStream: crypto.getRandomValues not available, using Math.random fallback"),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}()}function w(t){const e={},n=Object.keys(t).sort();for(const i of n){const n=t[i];null===n||"object"!=typeof n||Array.isArray(n)?e[i]=n:e[i]=w(n)}return e}async function y(t,e,n,i){const o=w(t),r=w(e),s=`${JSON.stringify(o)}|${JSON.stringify(r)}|${n}`;try{const t=new TextEncoder,e=t.encode(i),n=await crypto.subtle.importKey("raw",e,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return function(t){const e=new Uint8Array(t);return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}(await crypto.subtle.sign("HMAC",n,t.encode(s)))}catch(c){throw new Error("Failed to generate HMAC signature: cryptographic operation failed")}}function g(){return"undefined"!=typeof crypto&&void 0!==crypto.subtle}function m(t){if("undefined"==typeof document||"string"!=typeof document.cookie)return null;const e=document.cookie.split(";").find(e=>e.trim().startsWith(`${t}=`));if(!e)return null;const n=e.split("=")[1];return n?decodeURIComponent(n.trim()):null}function v(t,e,n){if("undefined"!=typeof document&&"string"==typeof document.cookie)try{const i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),document.cookie=`${t}=${encodeURIComponent(e)}; expires=${i.toUTCString()}; path=/; SameSite=Lax`}catch(i){console.debug("Failed to set cookie:",i)}}function b(t){if(!0!==t||"undefined"==typeof window)return null;try{const t=new URL(window.location.href).searchParams.get("fbclid");if(!t)return null;const e=`fb.1.${Date.now()}.${t}`;return v("_fbc",e,90),e}catch(e){return console.error("Failed to parse fbclid from URL:",e),null}}function _(t){return!0===t?m("_fbc"):null}function S(t){return!0===t?m("_fbp"):null}function k(t){if(!0!==t)return null;const e=S(t);if(e)return e;if("undefined"==typeof document)return null;const n=`fb.1.${Date.now()}.${Math.floor(1e10*Math.random())}`;return v("_fbp",n,90),n}function C(t){let e=_(t);return e||(e=b(t)),{fbc:e,fbp:k(t)}}function $(t){if(!0!==t||"undefined"==typeof window)return null;try{const e=new URL(window.location.href).searchParams.get("ttclid");return e?(I(t,e),e):null}catch(e){return console.error("Failed to parse ttclid from URL:",e),null}}function A(t){return!0===t?function(){if("undefined"==typeof document||"string"!=typeof document.cookie)return null;const t=document.cookie.split(";").find(t=>t.trim().startsWith("_ttclid="));if(!t)return null;const e=t.split("=")[1];return e?decodeURIComponent(e.trim()):null}():null}function I(t,e){!0===t&&function(t,e){if("undefined"!=typeof document&&"string"==typeof document.cookie)try{const t=new Date;t.setTime(t.getTime()+864e5),document.cookie=`_ttclid=${encodeURIComponent(e)}; expires=${t.toUTCString()}; path=/; SameSite=Lax`}catch(n){console.debug("Failed to set cookie:",n)}}(0,e)}function x(t){let e=A(t);return e||(e=$(t)),{ttclid:e}}function F(t){if("undefined"==typeof document||"string"!=typeof document.cookie)return null;const e=document.cookie.split(";").find(e=>e.trim().startsWith(`${t}=`));if(!e)return null;const n=e.split("=")[1];return n?decodeURIComponent(n.trim()):null}function R(t,e,n){if("undefined"!=typeof document&&"string"==typeof document.cookie)try{const i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),document.cookie=`${t}=${encodeURIComponent(e)}; expires=${i.toUTCString()}; path=/; SameSite=Lax`}catch(i){console.debug("Failed to set cookie:",i)}}function P(t){if(!0!==t||"undefined"==typeof window)return null;try{const t=new URL(window.location.href).searchParams.get("gclid");if(!t)return null;return R("_gcl_aw",`GCL.1.${Date.now()}.${t}`,90),t}catch(e){return console.error("Failed to parse gclid from URL:",e),null}}function M(t){if(!0!==t||"undefined"==typeof window)return null;try{const t=new URL(window.location.href).searchParams.get("wbraid");return t?(R("_gcl_gb",t,90),t):null}catch(e){return console.error("Failed to parse wbraid from URL:",e),null}}function T(t){if(!0!==t||"undefined"==typeof window)return null;try{const t=new URL(window.location.href).searchParams.get("gbraid");return t?(R("_gcl_ag",t,90),t):null}catch(e){return console.error("Failed to parse gbraid from URL:",e),null}}function j(t){if(!0!==t)return null;const e=F("_gcl_aw");if(!e)return null;const n=e.split(".");return n.length<4||"GCL"!==n[0]?e:n.slice(3).join(".")}function E(t){return!0===t?F("_gcl_gb"):null}function U(t){return!0===t?F("_gcl_ag"):null}function O(t){let e=j(t);e||(e=P(t));let n=E(t);n||(n=M(t));let i=U(t);
1return i||(i=T(t)),{gclid:e,wbraid:n,gbraid:i}}function L(t){return!0===t?function(){if("undefined"==typeof document||"string"!=typeof document.cookie)return null;const t=document.cookie.split(";").find(t=>t.trim().startsWith("li_fat_id="));if(!t)return null;const e=t.split("=")[1];return e?decodeURIComponent(e.trim()):null}():null}function q(t){if(!0!==t||"undefined"==typeof window)return null;try{const t=new URL(window.location.href).searchParams.get("li_fat_id");return t?(function(t,e){if("undefined"!=typeof document&&"string"==typeof document.cookie)try{const t=new Date;t.setTime(t.getTime()+2592e6),document.cookie=`li_fat_id=${encodeURIComponent(e)}; expires=${t.toUTCString()}; path=/; SameSite=Lax`}catch(n){console.debug("Failed to set cookie:",n)}}(0,t),t):null}catch(e){return console.error("Failed to parse li_fat_id from URL:",e),null}}function D(t){let e=L(t);return e||(e=q(t)),{li_fat_id:e}}const N={purchase:"Purchase",add_to_cart:"AddToCart",view_content:"ViewContent",initiate_checkout:"InitiateCheckout",add_payment_info:"AddPaymentInfo",add_to_wishlist:"AddToWishlist",complete_registration:"CompleteRegistration",lead:"Lead",search:"Search",page_view:"PageView",begin_checkout:"InitiateCheckout",view_item:"ViewContent",generate_lead:"Lead"},G={},z=new Set(["purchase","add_to_cart","view_content","initiate_checkout","add_payment_info","add_to_wishlist","complete_registration","lead","search","page_view"]);for(const[je,Ee]of Object.entries(N))G[Ee]&&!z.has(je)||(G[Ee]=je);const J=new Set;function B(t){J.add(t)}function H(t){return G[t]||t}function V(t,e){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};const n=e?.debounceMs??100,i=e?.trackHashChanges??!0;let o=window.location.href,r=null,s=null;function c(e){window.location.href!==o&&(s=e,null!==r&&clearTimeout(r),r=setTimeout(()=>{setTimeout(()=>{const n=window.location.href,i=o;o=n;const c=window.location;t({url:n,path:c.pathname,title:document.title,referrer:i,search:c.search,hash:c.hash,navigationType:s||e}),s=null,r=null},50)},n))}const a=history.pushState.bind(history),u=history.replaceState.bind(history);function l(){c("popstate")}function f(){c("hashchange")}return history.pushState=function(t,e,n){a(t,e,n),c("pushState")},history.replaceState=function(t,e,n){u(t,e,n),c("replaceState")},window.addEventListener("popstate",l),i&&window.addEventListener("hashchange",f),()=>{null!==r&&(clearTimeout(r),r=null),history.pushState=a,history.replaceState=u,window.removeEventListener("popstate",l),i&&window.removeEventListener("hashchange",f)}}const Z=["dataLayer","google_tag_data","Shopify","wc_add_to_cart_params","__ss_pageData"],K=/^[a-zA-Z_$][a-zA-Z0-9_$.]*$/,W=["__proto__","constructor","prototype"],Q=new Set(["__proto__","constructor","prototype"]);function X(t,e){const n=e.split(".");let i=t;for(const o of n){if(Q.has(o))return;if(null==i||"object"!=typeof i)return;i=i[o]}return i}function Y(t,e,n){switch(t.source){case"static":return t.value;case"page_title":return n.pageTitle;case"element_text":return e?.textContent?.trim()??void 0;case"element_attribute":return e?.getAttribute(t.key)??void 0;case"ancestor_attribute":{const n=e?.closest(t.selector);return n?.getAttribute(t.key)??void 0}case"url_param":try{return new URLSearchParams(new URL(n.pageUrl).search).get(t.key)??void 0}catch{return}case"url_path_segment":try{return new URL(n.pageUrl).pathname.split("/").filter(Boolean)[t.index]??void 0}catch{return}case"css_variable":if(!e)return;try{return getComputedStyle(e).getPropertyValue(t.name).trim()||void 0}catch{return}case"meta_tag":{if("undefined"==typeof document)return;const e=t.name.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),n=document.querySelector(`meta[name="${e}"]`);return n?.getAttribute("content")??void 0}case"datalayer_field":{const e=X(n.dataLayerPayload,t.path);return"array"===t.as?Array.isArray(e)?e:void 0:e}case"js_path":return function(t){if(!K.test(t))return;const e=t.split(".");for(const i of e)if(W.includes(i))return;const n=e[0];return Z.includes(n)&&"undefined"!=typeof window?X(window,t):void 0}(t.path);default:return}}const tt=["_value","_price","_amount","_count"];function et(t,e,n,i){const o={};for(const[r,s]of Object.entries(t??{}))try{let t=Y(s,e,n);if("string"==typeof t&&""!==t&&tt.some(t=>r.endsWith(t))){const e=Number(t);isNaN(e)||(t=e)}void 0!==t&&(o[r]=t)}catch{i.debug("Data extraction failed for key:",r)}return o}const nt=new Map;function it(t){try{return new URL(t).pathname}catch{return t}}function ot(t,e,n){switch(n){case"exact":return it(t)===e;case"starts_with":return it(t).startsWith(e);case"contains":return t.includes(e);case"regex":try{let n=nt.get(e);
1if(!n){if(n=new RegExp(e),nt.size>=50){const t=nt.keys().next().value;void 0!==t&&nt.delete(t)}nt.set(e,n)}return n.test(t)}catch{return!1}default:return!1}}class rt{constructor(t,e,n,i){this.activeRules=new Map,this.fireCounts=new Map,this.scrollThresholdsFired=new Map,this.intersectionObserversFired=new Map,this.sdk=t,this.installers=e,this.logger=n,this.debug=i}applyRules(t){try{const e=("undefined"!=typeof window?window.location.hostname:"").toLowerCase().replace(/^www\./,""),n=t.filter(t=>!t.domain||t.domain.toLowerCase().replace(/^www\./,"")===e),i=new Set(n.map(t=>t.id));for(const[t]of this.activeRules)i.has(t)||this.uninstallRule(t);for(const t of n){const e=this.activeRules.get(t.id);if(e){if(e.version===t.version)continue;this.uninstallRule(t.id)}this.installRule(t)}}catch(e){this.logger.error("applyRules failed:",e)}}destroy(){for(const[t]of this.activeRules)this.uninstallRule(t);this.fireCounts.clear(),this.scrollThresholdsFired.clear(),this.intersectionObserversFired.clear()}onConsentGranted(){try{const t=Array.from(this.activeRules.values()).map(t=>t.rule).filter(t=>"page_view"===t.type&&0===(this.fireCounts.get(t.id)??0));for(const e of t)this.uninstallRule(e.id),this.installRule(e)}catch(t){this.logger.error("onConsentGranted failed:",t)}}getScrollThresholdsFired(t){let e=this.scrollThresholdsFired.get(t);return e||(e=new Set,this.scrollThresholdsFired.set(t,e)),e}getIntersectionObserversFired(t){let e=this.intersectionObserversFired.get(t);return e||(e=new Set,this.intersectionObserversFired.set(t,e)),e}get activeRuleCount(){return this.activeRules.size}installRule(t){const e=this.installers[t.type];if(e)try{const n=e(t,e=>{this.fireRule(t,e)});this.activeRules.set(t.id,{rule:t,version:t.version,cleanup:n}),this.debug&&this.logger.debug("Installed rule:",t.name,`(${t.type})`)}catch(n){this.logger.error("Failed to install rule:",t.name,n)}else this.debug&&this.logger.debug("No installer registered for rule type:",t.type)}uninstallRule(t){const e=this.activeRules.get(t);if(e){try{e.cleanup()}catch(n){this.logger.error("Failed to uninstall rule:",t,n)}this.activeRules.delete(t)}}fireRule(t,e){try{if(t.trigger.page_filter&&(n=t.trigger.page_filter,!ot(e.pageUrl,n.url_pattern,n.url_match_type)))return void(this.debug&&this.logger.debug("Rule page filter mismatch:",t.name));if(!this.hasConsent(t.consent_category))return void(this.debug&&this.logger.debug("Rule blocked by consent:",t.name,t.consent_category));if(null!=t.trigger.max_fires_per_session&&(this.fireCounts.get(t.id)??0)>=t.trigger.max_fires_per_session)return void(this.debug&&this.logger.debug("Rule session throttle reached:",t.name));const i=et(t.event.data,e.element,e,this.logger);if(t.event.items){const n=function(t,e,n){const i=X(e.dataLayerPayload,t.path);if(!Array.isArray(i))return;if(!t.item_map)return i;const o=t.item_map;return i.map(t=>{if(null==t||"object"!=typeof t)return{};const i={...e,dataLayerPayload:t};return et(o,null,i,n)})}(t.event.items,e,this.logger);void 0!==n&&(i.items=n)}this.fireCounts.set(t.id,(this.fireCounts.get(t.id)??0)+1),this.sdk.track(t.event.event_name,i,{rule_id:t.id}).catch(e=>{this.logger.error("Rule track failed:",t.name,e)}),this.debug&&this.logger.debug("Rule fired:",t.name,t.event.event_name,i)}catch(i){this.logger.error("Rule fire error:",t.name,i)}var n}hasConsent(t){const e=this.sdk.getConsent();switch(t){case"necessary":return!0;case"functional":return e.functional;case"analytics":return e.analytics;case"marketing":return e.marketing;default:return!1}}}const st=new Map;let ct=null;function at(t,e){try{return t.matches(e)?t:t.closest(e)}catch{return null}}function ut(t,e){try{const n=`[data-ss-track="${CSS.escape(e)}"]`;
1return t.matches(n)?t:t.closest(n)}catch{let n=t;for(;n;){if(n.getAttribute("data-ss-track")===e)return n;n=n.parentElement}return null}}function lt(){return function(t,e){return st.set(t.id,{rule:t,onFire:e,lastFireMs:0}),null===ct&&(ct=function(t){const e=t.target;if(!(e instanceof Element))return;const n=Date.now(),i=window.location.href,o=document.title;for(const[,r]of st)try{const{rule:t,onFire:s,lastFireMs:c}=r,a=t.trigger;if(n-c<(a.debounce_ms??500))continue;let u=null;if(a.selector&&(u=at(e,a.selector)),!u&&a.fallback_selector&&(u=at(e,a.fallback_selector)),u||(u=ut(e,t.id)),!u)continue;r.lastFireMs=n,s({element:u,pageUrl:i,pageTitle:o})}catch{}},document.addEventListener("click",ct,{capture:!0})),function(){st.delete(t.id),st.size>0||null!==ct&&(document.removeEventListener("click",ct,{capture:!0}),ct=null)}}}const ft=new Map;let dt=null;function ht(t,e){try{return t.matches(e)?t:t.closest(e)}catch{return null}}function pt(t,e){try{const n=`[data-ss-track="${CSS.escape(e)}"]`;return t.matches(n)?t:t.closest(n)}catch{let n=t;for(;n;){if(n.getAttribute("data-ss-track")===e)return n;n=n.parentElement}return null}}function wt(){return function(t,e){return ft.set(t.id,{rule:t,onFire:e,lastFireMs:0}),null===dt&&(dt=function(t){const e=t.target;if(!(e instanceof Element))return;const n=Date.now(),i=window.location.href,o=document.title;for(const[,r]of ft)try{const{rule:t,onFire:s,lastFireMs:c}=r,a=t.trigger;if(n-c<(a.debounce_ms??500))continue;let u=null;if(a.selector&&(u=ht(e,a.selector)),!u&&a.fallback_selector&&(u=ht(e,a.fallback_selector)),u||(u=pt(e,t.id)),!u)continue;r.lastFireMs=n,s({element:u,pageUrl:i,pageTitle:o})}catch{}},document.addEventListener("submit",dt,{capture:!0})),function(){ft.delete(t.id),ft.size>0||null!==dt&&(document.removeEventListener("submit",dt,{capture:!0}),dt=null)}}}function yt(t,e){const n=t.trigger;return!n.url_pattern||ot(e,n.url_pattern,n.url_match_type??"contains")}function gt(){return{element:null,pageUrl:window.location.href,pageTitle:document.title}}const mt=new Map;let vt=null,bt=null;function _t(){const t=function(){const t=document.body.scrollHeight;if(t<=0)return 0;const e=window.scrollY+window.innerHeight;return Math.min(100,e/t*100)}(),e=window.location.href,n=document.title;for(const[,i]of mt)try{const{rule:o,onFire:r,firedThresholds:s}=i,c=o.trigger.thresholds;if(!c||0===c.length)continue;const a=!1!==o.trigger.fire_once;for(const i of c)t<i||a&&s.has(i)||(s.add(i),r({element:null,scrollPercent:i,pageUrl:e,pageTitle:n}))}catch{}}function St(t){return function(e,n){const i=t(e.id);mt.set(e.id,{rule:e,onFire:n,firedThresholds:i}),null===vt&&(vt=function(){null!==bt&&clearTimeout(bt),bt=setTimeout(()=>{bt=null,_t()},100)},window.addEventListener("scroll",vt,{passive:!0}));try{_t()}catch{}return function(){mt.delete(e.id),mt.size>0||null!==vt&&(window.removeEventListener("scroll",vt),vt=null,null!==bt&&(clearTimeout(bt),bt=null))}}}const kt=new Map;let Ct=null;function $t(t,e,n){const i=t.id;return i?`id:${i}`:`${e}:${t.tagName.toLowerCase()}:${n}`}function At(t){try{return Array.from(document.querySelectorAll(t))}catch{return[]}}function It(t,e){try{return t.matches(e)}catch{return!1}}function xt(t,e,n,i){const{observer:o,firedKeys:r,rule:s}=e;if(!1!==s.trigger.fire_once){const e=$t(t,n,i);if(r.has(e))return}o?.observe(t)}function Ft(t,e,n,i){const{rule:o,onFire:r,firedKeys:s}=e,c=!1!==o.trigger.fire_once,a=$t(t,n,i);if(!c||!s.has(a)){c&&s.add(a);try{r({element:t,pageUrl:window.location.href,pageTitle:document.title})}catch{}}}function Rt(t){for(const[,e]of kt){const{rule:n}=e,i=n.trigger.selector;if(i)for(const o of t){if(!(o instanceof Element))continue;if(It(o,i)){const t=At(i).indexOf(o);e.observer?xt(o,e,i,t>=0?t:0):Ft(o,e,i,t>=0?t:0)}const t=(()=>{try{return Array.from(o.querySelectorAll(i))}catch{return[]}})();for(const n of t){const t=At(i).indexOf(n);e.observer?xt(n,e,i,t>=0?t:0):Ft(n,e,i,t>=0?t:0)}}}}function Pt(t){if(null===t)return"null";if(Array.isArray(t))return"array";const e=typeof t;return"string"===e?"string":"number"===e?"number":"boolean"===e?"boolean":"object"===e?"object":"unknown"}const Mt=new Set(["__proto__","constructor","prototype"]);function Tt(t){const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function jt(t,e="",n=0){const i=[];if(n>=5)return i;if(null===t||"object"!=typeof t)return i;for(const o of Object.keys(t)){if(i.length>=500)break;if(Mt.has(o))continue;const r=t[o];if(null==r)continue;const s=e?`${e}.${o}`:o;if(s.length>512)continue;const c=Pt(r);if(i.push({path:s,type:c}),"object"===c&&n+1<5&&Tt(r)){const t=jt(r,s,n+1);for(const e of t){if(i.length>=500)break;i.push(e)}}else if("array"===c&&n+1<5){const t=r;if(t.length>0){const e=t[0];if(null!=e&&"object"==typeof e&&!Array.isArray(e)&&Tt(e)){const t=jt(e,`${s}[]`,n+1);for(const e of t){if(i.length>=500)break;i.push(e)}}}}}return i}let Et=null,Ut=[],Ot=null,Lt=null;function qt(){if(!Et||0===Ut.length)return;const t=Ut;Ut=[];const e=`${Et.endpoint}/discovery/observation`,n=JSON.stringify({observations:t});try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const t=new Blob([n],{type:"application/json"});if(navigator.sendBeacon(e,t))return}"function"==typeof fetch&&fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:n,keepalive:!0}
1).catch(()=>{})}catch{}}function Dt(t,e){if(!Et)return;if("string"!=typeof t||0===t.length)return;if(t.length>255)return;if(Ut.length>=50)return;let n;try{n=jt(e)}catch{return}0!==n.length&&(Ut.push({site_id:Et.siteId,event_name:t,payload_shape:n}),Ut.length>=50&&qt())}const Nt=new Map;let Gt=!1,zt=null;const Jt=new Set;let Bt=0,Ht=null,Vt=!1;function Zt(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&"[object Arguments]"!==Object.prototype.toString.call(t)&&"string"==typeof t.event}function Kt(t,e){const n=t.event;if("string"!=typeof n)return;const i=window.location.href,o=document.title;let r=!1;for(const[,s]of Nt)try{const{rule:c,onFire:a}=s;if(c.trigger.datalayer_event!==n)continue;if(r=!0,e?.onlyRuleIds&&!e.onlyRuleIds.has(c.id))continue;a({element:null,dataLayerPayload:t,pageUrl:i,pageTitle:o})}catch{}if(!r&&!1!==e?.discovery)try{Dt(n,t)}catch{}}function Wt(...t){for(const n of t)try{Zt(n)&&Kt(n)}catch{}const e=zt.apply(this,t);return Array.isArray(window.dataLayer)&&(Bt=window.dataLayer.length),e}function Qt(){Array.isArray(window.dataLayer)||(window.dataLayer=[]);const t=window.dataLayer;if(!Gt)return zt=t.push,t.push=Wt,void(Gt=!0);t.push!==Wt&&(zt=t.push,t.push=Wt)}function Xt(){if(Nt.size>0||Vt)return;if(!Gt)return;const t=window.dataLayer;t&&t.push===Wt&&null!==zt&&(t.push=zt),Gt=!1,zt=null}function Yt(t){const e=Array.isArray(window.dataLayer)?window.dataLayer.length:0;null===Ht&&(Ht={ruleIds:new Set,end:e,discoveryStart:Math.min(Bt,e)},Bt=e,Promise.resolve().then(te)),void 0===t||Jt.has(t)||Ht.ruleIds.add(t)}function te(){const t=Ht;if(Ht=null,null===t)return;if(!Gt)return;const e=window.dataLayer;if(!Array.isArray(e))return;const n=Math.min(t.end,e.length);for(let i=0;i<n;i++)try{const n=e[i];if(!Zt(n))continue;Kt(n,{onlyRuleIds:t.ruleIds,discovery:i>=t.discoveryStart})}catch{}for(const i of t.ruleIds)Nt.has(i)&&Jt.add(i)}const ee={gtm:/^GTM-[A-Z0-9]{6,8}$/,ga4:/^G-[A-Z0-9]{10}$/,meta:/^\d{15,16}$/,tiktok:/^[A-Z0-9]{18,24}$/,pinterest:/^\d{13}$/,snapchat:/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/,linkedin:/^\d{4,10}$/},ne={6:"sourcepoint",7:"didomi",10:"inmobi_choice",28:"onetrust"},ie=[{global:"Cookiebot",vendor:"cookiebot"},{global:"cookieyes",vendor:"cookieyes"},{global:"OneTrust",vendor:"onetrust"},{global:"UC_UI",vendor:"usercentrics"},{global:"complianz",vendor:"complianz"},{global:"_iub",vendor:"iubenda"},{global:"Didomi",vendor:"didomi"},{global:"truste",vendor:"trustarc"},{global:"Osano",vendor:"osano"},{global:"Termly",vendor:"termly"},{global:"axeptio",vendor:"axeptio"},{global:"__cmp",vendor:"consentmanager"},{global:"_sp_",vendor:"sourcepoint"},{global:"CookieInformation",vendor:"cookie_information"},{global:"CookieFirst",vendor:"cookiefirst"},{global:"BorlabsCookie",vendor:"borlabs"},{global:"wp_has_consent",vendor:"wp_consent_api"}];function oe(t){try{if("undefined"==typeof window)return;return window[t]}catch{return}}const re="unknown";function se(t,e){return{vendor:t,external_id:e,loaded_via:re}}function ce(t){return{vendor:t,external_id:null,loaded_via:re}}function ae(t){return Array.isArray(t)?t:null!==t&&"object"==typeof t&&"number"==typeof t.length?Array.from(t):null}function ue(t,e,n,i){const o=ae(t);if(null!==o)for(const r of o){const t=ae(r);if(null===t||t.length<2)continue;if(t[0]!==e)continue;const o=t[1];"string"==typeof o&&n.test(o)&&i.add(o)}}function le(t){return null===t||"object"!=typeof t?[]:Object.keys(t)}const fe=[function(){const t=[];for(const e of le(oe("google_tag_manager")))ee.gtm.test(e)?t.push(se("gtm",e)):ee.ga4.test(e)&&t.push(se("ga4",e));return t},function(){const t=oe("fbq")??oe("_fbq");if(null==t)return[];const e=new Set,n=t.instance,i=null!==n&&"object"==typeof n?n.pixelsByID:void 0;for(const o of le(i))ee.meta.test(o)&&e.add(o);return ue(t.queue,"init",ee.meta,e),[...e].map(t=>se("meta",t))},function(){const t=oe("ttq");if(null===t||"object"!=typeof t)return[];const e=new Set;for(const n of le(t._i))ee.tiktok.test(n)&&e.add(n);return[...e].map(t=>se("tiktok",t))},function(){const t=oe("pintrk");if(null==t)return[];const e=new Set;return ue(t.queue,"load",ee.pinterest,e),[...e].map(t=>se("pinterest",t))},function(){const t=oe("snaptr");if(null==t)return[];const e=new Set;return ue(t.queue,"init",ee.snapchat,e),[...e].map(t=>se("snapchat",t))},function(){const t=new Set,e=ae(oe("_linkedin_data_partner_ids"));if(null!==e)for(const i of e){const e=String(i);ee.linkedin.test(e)&&t.add(e)}const n=oe("_linkedin_partner_id");if(null!=n){const e=String(n);ee.linkedin.test(e)&&t.add(e)}return[...t].map(t=>se("linkedin",t))},function(){return null==oe("uetq")?[]:[se("microsoft",null)]},function(){const t=oe("gaGlobal");return null!==t&&"object"==typeof t?[se("ua",null)]:[]},function(){const t=[];
1for(const e of ie){null!=oe(e.global)&&t.push(ce(e.vendor))}return t},function(){const t=oe("__tcfapi");if("function"!=typeof t)return[];let e=null;return t("ping",2,(t,n)=>{if(n&&null!==t&&"object"==typeof t){const n=t.cmpId;"number"==typeof n&&(e=function(t){return ne[String(t)]??"tcf_generic"}(n))}}),null===e?[]:[ce(e)]}];let de=!1;const he=new Map;let pe,we=!1,ye=!1,ge=null,me=null,ve=0,be=!1;function _e(t){if(null===ge)return;if(t.length<2)return;if("event"!==t[0])return;const e=t[1];if("string"!=typeof e||0===e.length)return;const n=t[2];ge(e,null!=n&&"object"==typeof n?n:{})}function Se(...t){if("function"==typeof pe)try{pe.apply(this,t)}catch{}try{!function(t){if(t.length<2)return;if("event"!==t[0])return;const e=t[1];if("string"!=typeof e||0===e.length)return;const n=t[2];if(null==n||"object"!=typeof n)return;const i=n.event_id;if("string"!=typeof i||0===i.length)return;const o=Date.now();let r=he.get(e);r||(r=[],he.set(e,r)),r.push({event_id:i,recorded_at:o}),r.length>16&&r.shift()}(t)}catch{}try{_e(t)}catch{}}function ke(){return!!we||"undefined"!=typeof window&&"function"==typeof window.gtag&&(pe=window.gtag,window.gtag=Se,we=!0,!0)}function Ce(){ye||null!==ge||we&&("undefined"!=typeof window&&window.gtag===Se&&void 0!==pe&&(window.gtag=pe),we=!1,pe=void 0)}function $e(){null!==me&&(clearInterval(me),me=null)}function Ae(){if(be)return;if(null===ge)return;if(be=!0,"undefined"==typeof window)return;const t=window.dataLayer;if(Array.isArray(t))for(let e=0;e<t.length;e++)try{const n=t[e];if("[object Arguments]"!==Object.prototype.toString.call(n))continue;const i=n;if("event"!==i[0])continue;_e(Array.from(i))}catch{}}function Ie(t){const e=null===t||"object"!=typeof t||Array.isArray(t)?{}:t;return{...e,marketing:!0===e.marketing,analytics:!0===e.analytics,preferences:!0===e.preferences,functional:!0===e.functional,necessary:!0===e.necessary}}class xe{constructor(t){if(this._pageViewUrl=null,this.gtagCaptureConsentCategory=null,this.pendingGtagCaptures=[],this.ruleEngine=null,this.rulesVersion=0,function(t){if(!t.endpoint)throw new Error("SignalStream: endpoint is required");if(!t.siteId)throw new Error("SignalStream: siteId is required");if(!t.signingSecret)throw new Error("SignalStream: signingSecret is required");try{const e=new URL(t.endpoint);if("https:"!==e.protocol&&"http:"!==e.protocol)throw new Error("SignalStream: endpoint must use http or https protocol");if("http:"===e.protocol&&"localhost"!==e.hostname&&"127.0.0.1"!==e.hostname)throw new Error("SignalStream: endpoint must use HTTPS for non-localhost URLs. HMAC signing secrets are exposed over unencrypted connections.")}catch(e){if(e instanceof Error&&e.message.startsWith("SignalStream:"))throw e;throw new Error(`SignalStream: invalid endpoint URL: ${e}`)}if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.siteId))throw new Error("SignalStream: siteId must be a valid UUID");if(t.signingSecret.length<32)throw new Error("SignalStream: signingSecret must be at least 32 characters");if(void 0!==t.batchSize&&(t.batchSize<1||t.batchSize>100))throw new Error("SignalStream: batchSize must be between 1 and 100");if(void 0!==t.flushInterval&&(t.flushInterval<1e3||t.flushInterval>6e4))throw new Error("SignalStream: flushInterval must be between 1000 and 60000 ms");if(void 0!==t.spaDebounceMs&&(t.spaDebounceMs<0||t.spaDebounceMs>5e3))throw new Error("SignalStream: spaDebounceMs must be between 0 and 5000 ms");if(void 0!==t.consentAdapter&&"cookiefirst"!==t.consentAdapter&&"iubenda"!==t.consentAdapter&&"tcf"!==t.consentAdapter&&"auto"!==t.consentAdapter&&"wp-consent-api"!==t.consentAdapter&&"custom"!==t.consentAdapter)throw new Error("SignalStream: consentAdapter must be 'cookiefirst', 'iubenda', 'tcf', 'auto', 'wp-consent-api', or 'custom'");if("custom"===t.consentAdapter&&!t.customConsentProvider)throw new Error('SignalStream: customConsentProvider is required when consentAdapter is "custom"')}(t),this.config=function(t){return{endpoint:t.endpoint,siteId:t.siteId,signingSecret:t.signingSecret,debug:t.debug??false,batchSize:t.batchSize??10,flushInterval:t.flushInterval??5e3,consentAdapter:t.consentAdapter??"cookiefirst",customConsentProvider:t.customConsentProvider??(()=>({marketing:!1,analytics:!1,preferences:!1,functional:!1,necessary:!0})),customConsentListener:t.customConsentListener??(()=>{}),trackPageViewOnConsent:t.trackPageViewOnConsent??true,interceptMetaPixel:t.interceptMetaPixel??false,captureGtag:t.captureGtag??false,trackSPANavigation:t.trackSPANavigation??true,spaDebounceMs:t.spaDebounceMs??100,trackHashChanges:t.trackHashChanges??true,autoPageView:t.autoPageView??true}}(t),this.logger=e(this.config.debug),!g())throw new Error("SignalStream requires Web Crypto API (crypto.subtle)");this.sessionId=this.generateSessionId(),this.consentAdapter=this.initConsentAdapter(),this.currentConsent=Ie(this.consentAdapter.getConsent()),this.transport=new o({endpoint:this.config.endpoint,timeout:1e4,maxRetries:3,retryDelay:1e3,logger:this.logger}),this.queue=new r({maxSize:1e3,maxAge:864e5,storageKey:`signalstream_queue_${this.config.siteId}`,logger:this.logger}),this.setupConsentListener(),this.startFlushTimer(),this.setupUnloadHandler(),this.processQueue(),(this.config.interceptMetaPixel||this.hasFbqOnPage())&&this.setupInterceptor(),this.processPrePatchedEvents(),this.fetchSiteConfig(),this.config.trackSPANavigation&&this.setupSPATracker(),this.config.autoPageView&&this.page().catch(t=>{this.logger.error("Failed to track auto page_view:",t)}),this.logger.info("SignalStream initialized",{siteId:this.config.siteId,endpoint:this.config.endpoint})}async track(t,e,n){this.logger.debug("Track event:",t,e);try{let i=e;const o=function(t){const e=he.get(t);if(!e||0===e.length)return;const n=Date.now()-6e4;for(let i=e.length-1;i>=0;i--){const t=e[i];if(t.recorded_at>=n)return t.event_id}}(t);void 0!==o&&(i={...e??{},client_event_id:o});const r=await this.createEventPayload(t,i,n);await this.sendEvent(r,{fromInterceptor:n?._fromInterceptor})}catch(i){throw this.logger.error("Failed to track event:",i),i}}async page(t,e){const n=e?.url||("undefined"!=typeof window?window.location.href:"");
1if(this._pageViewUrl===n)return void this.logger.debug("PageView dedup: skipping duplicate for",n);this._pageViewUrl=n;const i={name:t,title:e?.title||document.title,url:n,path:e?.path||window.location.pathname,search:e?.search||window.location.search,referrer:e?.referrer||document.referrer,...e};await this.track("page_view",i)}identify(t,e){this.userId=t,this.logger.debug("User identified:",t),e&&this.track("identify",{user_id:t,...e}).catch(()=>{})}async flush(){this.logger.debug("Flushing events..."),await this.processQueue()}getConsent(){return{...this.currentConsent}}destroy(){if(this.flushTimer&&clearInterval(this.flushTimer),this.rulesVersionTimer&&(clearInterval(this.rulesVersionTimer),this.rulesVersionTimer=void 0),this.ruleEngine){try{this.ruleEngine.destroy()}catch{}this.ruleEngine=null}this.cleanupInterceptor&&(this.cleanupInterceptor(),this.cleanupInterceptor=void 0),this.cleanupGtagCapture&&(this.cleanupGtagCapture(),this.cleanupGtagCapture=void 0),this.cleanupSPATracker&&(this.cleanupSPATracker(),this.cleanupSPATracker=void 0),this.flush(),this.logger.info("SignalStream destroyed")}hasFbqOnPage(){return"undefined"!=typeof window&&"function"==typeof window.fbq}setupInterceptor(){this.cleanupInterceptor||(this.cleanupInterceptor=function(t,e){if("undefined"==typeof window)return e.debug("Meta Pixel interceptor: no window, skipping"),()=>{};const n=window;let i=null,o=null,r=!1;function s(){const o=n.fbq;return!(!o||"function"!=typeof o||(i=function(t,e,n,i){const o=t._fbq;if(i.info("Meta Pixel interceptor: installing fbq Proxy wrapper"),e.queue&&Array.isArray(e.queue)){const t=[...e.queue];e.queue.length=0;for(const o of t){if(!Array.isArray(o)||o.length<2){e.queue.push(o);continue}const t=o[0];if("track"===t||"trackCustom"===t){const r=o[1],s=o[2]||{},c=o[3]||{},a=c.eventID;if(a&&J.has(a)){J.delete(a),e.queue.push(o),i.debug("Meta Pixel interceptor: queue pass-through (known ID)",a);continue}const u=a||p(),l=[t,r,s,{...c,eventID:u}];e.queue.push(l),i.debug("Meta Pixel interceptor: queue intercepted",r,u),n(r,{...s},u)}else e.queue.push(o)}}const r=new Proxy(e,{apply(t,e,o){if(o.length<2)return Reflect.apply(t,e,o);const r=o[0];if("track"!==r&&"trackCustom"!==r)return Reflect.apply(t,e,o);const s=o[1],c=o[2]||{},a=o[3]||{},u=a.eventID;if(u&&J.has(u))return J.delete(u),i.debug("Meta Pixel interceptor: pass-through (known ID)",u),Reflect.apply(t,e,o);const l=u||p(),f={...a,eventID:l};Reflect.apply(t,e,[r,s,c,f]),i.debug("Meta Pixel interceptor: intercepted",s,l),n(s,{...c},l)}});return t.fbq=r,o===e&&(t._fbq=r),i.info("Meta Pixel interceptor: installed successfully"),()=>{t.fbq=e,void 0!==o&&(t._fbq=o),i.debug("Meta Pixel interceptor: original fbq restored")}}(n,o,t,e),0))}if(!s()){e.debug("Meta Pixel interceptor: fbq not found, polling until it appears");let t=0;o=setInterval(()=>{if(r)o&&(clearInterval(o),o=null);else{if(t+=16,t>=3e4)return e.debug("Meta Pixel interceptor: gave up waiting for fbq after 30s"),void(o&&(clearInterval(o),o=null));s()&&(e.info(`Meta Pixel interceptor: fbq appeared after ${t}ms, proxy installed`),o&&(clearInterval(o),o=null))}},16)}return()=>{r=!0,o&&(clearInterval(o),o=null),i&&(i(),i=null),J.clear(),e.debug("Meta Pixel interceptor: cleaned up")}}((t,e,n)=>{const i=H(t);this.track(i,e,{eventId:n,_fromInterceptor:!0}).catch(t=>{this.logger.error("Failed to send intercepted Meta event:",t)})},this.logger))}setupGtagCapture(){var t;this.cleanupGtagCapture||(t=(t,e)=>{this.hasGtagCaptureConsent()?this.emitCapturedGtagEvent(t,e):this.bufferWithheldGtagCapture(t,e)},"undefined"!=typeof window&&(ge=t,ke()?Ae():null===me&&(ve=0,me=setInterval(()=>{ve+=16,ke()?(Ae(),$e()):ve>=3e4&&$e()},16))),this.cleanupGtagCapture=()=>(ge=null,$e(),void Ce()))}emitCapturedGtagEvent(t,e){if("page_view"===t){const t="undefined"!=typeof window?window.location.href:"";if(this._pageViewUrl===t)return void this.logger.debug("gtag capture: page_view dedup skip for",t);this._pageViewUrl=t}this.track(t,e).catch(t=>{this.logger.error("Failed to send captured gtag event:",t)})}bufferWithheldGtagCapture(t,e){this.pendingGtagCaptures.push({eventName:t,eventData:e}),this.pendingGtagCaptures.length>50&&this.pendingGtagCaptures.shift(),this.logger.debug("gtag capture: with
1held by consent (buffered for re-offer)",t)}flushPendingGtagCaptures(){if(0===this.pendingGtagCaptures.length)return;if(!this.hasGtagCaptureConsent())return;const t=this.pendingGtagCaptures;this.pendingGtagCaptures=[],this.logger.info("Re-offering consent-withheld gtag captures after grant",t.length);for(const{eventName:e,eventData:n}of t)this.emitCapturedGtagEvent(e,n)}resolveGtagCaptureConsentCategory(){const t=this.gtagCaptureConsentCategory;return"necessary"===t||"functional"===t||"analytics"===t||"marketing"===t?t:"marketing"}hasGtagCaptureConsent(){const t=this.getConsent();switch(this.resolveGtagCaptureConsentCategory()){case"necessary":return!0;case"functional":return t.functional;case"analytics":return t.analytics;case"marketing":return t.marketing;default:return!1}}setupSPATracker(){this.cleanupSPATracker||(this.cleanupSPATracker=V(t=>{this._pageViewUrl=null,this.page(void 0,{title:t.title,url:t.url,path:t.path,referrer:t.referrer,search:t.search,navigationType:t.navigationType}).catch(t=>{this.logger.error("Failed to track SPA navigation:",t)})},{debounceMs:this.config.spaDebounceMs,trackHashChanges:this.config.trackHashChanges}),this.logger.debug("SPA navigation tracker installed"))}processPrePatchedEvents(){if("undefined"==typeof window)return;const t=window,e=t.__ssInterceptedEvents;if(!e||!Array.isArray(e)||0===e.length)return;const n=e.slice(0,50);this.logger.debug("Processing",n.length,"pre-patched intercepted events");const i=/^[a-zA-Z0-9_-]{1,128}$/,o=/^[a-zA-Z][a-zA-Z0-9_]{0,63}$/;for(const r of n){if(!r||"object"!=typeof r)continue;if(!r.n||!r.id)continue;if("string"!=typeof r.id||!i.test(r.id)){this.logger.debug("Skipping intercepted event with invalid id format");continue}if("string"!=typeof r.n||!o.test(r.n)){this.logger.debug("Skipping intercepted event with invalid name format");continue}let t={};if(r.d&&"object"==typeof r.d&&!Array.isArray(r.d)){if(Object.keys(r.d).length>50){this.logger.debug("Skipping intercepted event: data has too many keys");continue}try{if(JSON.stringify(r.d).length>4096){this.logger.debug("Skipping intercepted event: data exceeds size limit");continue}}catch{this.logger.debug("Skipping intercepted event: data not serializable");continue}t=r.d}B(r.id);const e=H(r.n);"page_view"!==e&&"PageView"!==r.n||(this._pageViewUrl="undefined"!=typeof window?window.location.href:null),this.track(e,t,{eventId:r.id,_fromInterceptor:!0}).catch(t=>{this.logger.error("Failed to send pre-patched event:",t)})}delete t.__ssInterceptedEvents}async createEventPayload(t,e,n){const i=n?.eventId||p(),o=Math.floor(Date.now()/1e3),r=C(this.currentConsent.marketing),s=x(this.currentConsent.marketing),c=O(this.currentConsent.marketing),a=D(this.currentConsent.marketing),u={...this.currentConsent,timestamp:1e3*o},l={event_id:i,event_name:t,event_data:e||{},consent_state:u,timestamp:o,site_id:this.config.siteId,session_id:this.sessionId,page_url:"undefined"!=typeof window?window.location.href:void 0,page_title:"undefined"!=typeof document?document.title:void 0,referrer:"undefined"!=typeof document?document.referrer:void 0,user_agent:"undefined"!=typeof navigator?navigator.userAgent:void 0};this.userId&&(l.user_id=this.userId),n?.rule_id&&(l.rule_id=n.rule_id),(r.fbc||r.fbp||s.ttclid||c.gclid||c.wbraid||c.gbraid||a.li_fat_id)&&(l.identifiers={},r.fbc&&(l.identifiers.fbc=r.fbc),r.fbp&&(l.identifiers.fbp=r.fbp),s.ttclid&&(l.identifiers.ttclid=s.ttclid),c.gclid&&(l.identifiers.gclid=c.gclid),c.wbraid&&(l.identifiers.wbraid=c.wbraid),c.gbraid&&(l.identifiers.gbraid=c.gbraid),a.li_fat_id&&(l.identifiers.li_fat_id=a.li_fat_id));const f=await y({...l.event_data},u,o,this.config.signingSecret);return{...l,signature:f}}async sendEvent(t,e){try{if(await this.transport.send(t),this.cleanupInterceptor&&!e?.fromInterceptor){const e=(n=t.event_name,N[n]||n);t.event_name in N&&(B(t.event_id),this.firePixelEvent(e,t.event_data,t.event_id))}}catch(o){if(i(o))return void this.logger.warn("Event refused by gateway, not queuing:",o);this.logger.warn("Event send failed, adding to queue:",o),this.queue.add(t)}var n}firePixelEvent(t,e,n){if("undefined"==typeof window)return;const i=window.fbq;i&&(i("track",t,e||{},{eventID:n}
1),this.logger.debug("Meta Pixel: fired fbq track for SDK event",t,n))}async processQueue(){if(this.queue.isEmpty())return;this.logger.debug(`Processing ${this.queue.size()} queued events`);const t=this.queue.getAll();for(const n of t)if(n.attempts>=3)this.logger.warn("Dropping event after 3 attempts:",n.event.event_id),this.queue.remove(n.event.event_id);else try{await this.transport.send(n.event),this.queue.remove(n.event.event_id)}catch(e){this.logger.debug("Queue event send failed:",e),i(e)?this.queue.remove(n.event.event_id):this.queue.incrementAttempts(n.event.event_id)}}initConsentAdapter(){return"custom"===this.config.consentAdapter&&this.config.customConsentProvider?{getConsent:this.config.customConsentProvider,onChange:this.config.customConsentListener||(()=>{}),isAvailable:()=>!0}:function(t){switch(t){case"tcf":return new l;case"iubenda":return new u;case"auto":return new h;case"wp-consent-api":return new f;default:return new s}}(this.config.consentAdapter)}setupConsentListener(){this.consentAdapter.onChange(t=>{const e=Ie(t),n=this.currentConsent;this.currentConsent=e,this.logger.debug("Consent changed:",e);const i=!n.analytics&&e.analytics,o=!n.marketing&&e.marketing;(i||o)&&(this.logger.info("Consent granted, processing queue"),this.processQueue(),this.config.trackPageViewOnConsent&&(this.logger.info("Tracking page_view after consent grant"),this._pageViewUrl=null,this.page("Consent Granted Page View",{consent_granted:!0,analytics_granted:i,marketing_granted:o}).catch(t=>{this.logger.error("Failed to track page_view on consent:",t)})),this.ruleEngine?.onConsentGranted()),this.flushPendingGtagCaptures()})}startFlushTimer(){this.flushTimer=setInterval(()=>{this.processQueue()},this.config.flushInterval)}setupUnloadHandler(){"undefined"!=typeof window&&window.addEventListener("beforeunload",()=>{this.queue.getAll().forEach(t=>{this.transport.sendBeacon(t.event)})})}generateSessionId(){return p()}fetchSiteConfig(){this.loadCachedRules(),this.loadCachedGtagCapture();const t=`${this.config.endpoint}/site-config?site_id=${encodeURIComponent(this.config.siteId)}`;fetch(t,{method:"GET",cache:"default"}).then(t=>{if(t.ok)return t.json();this.logger.debug("Site config fetch returned",t.status)}).then(t=>{t&&("boolean"==typeof t.interceptMetaPixel&&(this.config.interceptMetaPixel=t.interceptMetaPixel,t.interceptMetaPixel?this.setupInterceptor():this.cleanupInterceptor&&(this.logger.debug("Server disabled interceptMetaPixel, removing interceptor"),this.cleanupInterceptor(),this.cleanupInterceptor=void 0),this.logger.debug("Site config updated from server:",{interceptMetaPixel:t.interceptMetaPixel})),this.handleRulesFromConfig(t),"boolean"==typeof t.discoveryEnabled&&(t.discoveryEnabled?(function(t){if(null===Et||Et.endpoint!==t.endpoint||Et.siteId!==t.siteId){if(null!==Et&&qt(),Et={endpoint:t.endpoint,siteId:t.siteId},null!==Ot&&clearInterval(Ot),"function"==typeof setInterval){Ot=setInterval(()=>qt(),3e4);const t=Ot;"function"==typeof t.unref&&t.unref()}null===Lt&&"undefined"!=typeof window&&"function"==typeof window.addEventListener&&(Lt=()=>qt(),window.addEventListener("pagehide",Lt))}}({endpoint:this.config.endpoint,siteId:this.config.siteId}),Vt=!0,Qt(),Yt()):(qt(),Et=null,null!==Ot&&(clearInterval(Ot),Ot=null),null!==Lt&&"undefined"!=typeof window&&"function"==typeof window.removeEventListener&&(window.removeEventListener("pagehide",Lt),Lt=null),Vt=!1,Xt())),!0===t.tagReportEnabled&&function(t){let e;try{e="undefined"==typeof window||de?null:(de=!0,{sdk_version:"1.0.0",detected:function(t){const e=new Set,n=[];for(const i of t){const t=`${i.vendor}|${i.external_id??""}`;e.has(t)||(e.add(t),n.push(i))}return n}(fe.flatMap(t=>function(t){try{return t()}catch{return[]}}(t)))})}catch{return}if(null===e||0===e.detected.length)return;const n=`${t.endpoint}/tag-report`,i=JSON.stringify({site_id:t.siteId,detected:e.detected,sdk_version:e.sdk_version});try{if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon){const t=new Blob([i],{type:"application/json"});if(navigator.sendBeacon(n,t))return}"function"==typeof fetch&&fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:i,keepalive:!0}
1).catch(()=>{})}catch{}}({endpoint:this.config.endpoint,siteId:this.config.siteId}),"boolean"==typeof t.interceptGtagForDedup&&(t.interceptGtagForDedup?(ye=!0,ke()):(ye=!1,he.clear(),Ce())),null!==t.gtagCaptureConsentCategory&&"string"!=typeof t.gtagCaptureConsentCategory||(this.gtagCaptureConsentCategory=t.gtagCaptureConsentCategory),"boolean"==typeof t.captureGtag&&(this.config.captureGtag=t.captureGtag,t.captureGtag?(this.setupGtagCapture(),this.cacheGtagCaptureConfig(this.gtagCaptureConsentCategory)):(this.clearGtagCaptureCache(),this.cleanupGtagCapture&&(this.logger.debug("Server disabled captureGtag, removing capture"),this.cleanupGtagCapture(),this.cleanupGtagCapture=void 0,this.pendingGtagCaptures=[]))),this.startRulesVersionPolling())}).catch(t=>{this.logger.debug("Site config fetch failed (using static config):",t)})}handleRulesFromConfig(t){try{const e=t.trackingRules,n="number"==typeof t.rulesVersion?t.rulesVersion:0;if(this.rulesVersion=n,!(e&&0!==e.length||this.ruleEngine))return;if(e&&e.length>0&&this.cacheRules(e,n),this.isInspectorMode())return void this.logger.debug("Inspector mode active, skipping rule engine");!this.ruleEngine&&e&&e.length>0&&(this.ruleEngine=this.createRuleEngine()),this.ruleEngine&&(this.ruleEngine.applyRules(e||[]),this.logger.debug("Rules applied:",e?.length??0,"rules, version",n))}catch(e){this.logger.error("Failed to process tracking rules:",e)}}createRuleEngine(){return new rt({track:(t,e,n)=>this.track(t,e,n),getConsent:()=>{const t=this.getConsent();return{marketing:t.marketing,analytics:t.analytics,functional:t.functional,necessary:t.necessary}}},this.createInstallerMap(),{debug:(...t)=>this.logger.debug(...t),error:(...t)=>this.logger.error(...t)},this.config.debug)}createInstallerMap(){return{click:lt(),form_submit:wt(),page_view:function(t,e){const n={rule:t,onFire:e,lastFiredUrl:null,navigationHandler:null};try{const i=window.location.href;if(yt(t,i)){n.lastFiredUrl=i;const t=gt();e(t)}}catch{}const i=function(){try{const i=window.location.href;if(i===n.lastFiredUrl)return;if(yt(t,i)){n.lastFiredUrl=i;const t=gt();e(t)}}catch{}};return n.navigationHandler=i,document.addEventListener("ss:navigation",i),function(){n.navigationHandler&&(document.removeEventListener("ss:navigation",n.navigationHandler),n.navigationHandler=null)}},scroll_depth:St(t=>this.ruleEngine.getScrollThresholdsFired(t)),element_visible:(t=t=>this.ruleEngine.getIntersectionObserversFired(t),function(e,n){const i=t(e.id),o=e.trigger.selector??"",r="undefined"!=typeof IntersectionObserver,s={rule:e,onFire:n,observer:null,firedKeys:i};if(kt.set(e.id,s),o){if(r){const t=function(t,e){const{rule:n,onFire:i,firedKeys:o}=t,r=n.trigger.intersection_threshold??.5,s=!1!==n.trigger.fire_once;return new IntersectionObserver(n=>{const r=window.location.href,c=document.title;for(const a of n){if(!a.isIntersecting)continue;const n=a.target;try{const a=At(e).indexOf(n),u=$t(n,e,a>=0?a:0);if(s){if(o.has(u)){t.observer?.unobserve(n);continue}o.add(u),t.observer?.unobserve(n)}i({element:n,pageUrl:r,pageTitle:c})}catch{}}},{threshold:r})}(s,o);s.observer=t;const e=At(o);for(let n=0;n<e.length;n++)xt(e[n],s,o,n)}else{const t=At(o);for(let e=0;e<t.length;e++)Ft(t[e],s,o,e)}try{!function(){if(null!==Ct)return;Ct=new MutationObserver(t=>{for(const e of t)if(0!==e.addedNodes.length)try{Rt(e.addedNodes)}catch{}});const t=document.body??document.documentElement;Ct.observe(t,{childList:!0,subtree:!0})}()}catch{}}return function(){try{s.observer?.disconnect()}catch{}s.observer=null,kt.delete(e.id),kt.size>0||null!==Ct&&(Ct.disconnect(),Ct=null)}}),datalayer_push:function(t,e){return Nt.set(t.id,{rule:t,onFire:e}),Qt(),Yt(t.id),function(){Nt.delete(t.id),Xt()}}};var t}isInspectorMode(){return"undefined"!=typeof window&&!!window.__SS_INSPECTOR_MODE}cacheRules(t,e){try{if("undefined"==typeof sessionStorage)return;const n=`ss_rules_${this.config.siteId}_${e}`;sessionStorage.setItem(n,JSON.stringify(t))}catch{}}loadCachedRules(){try{if("undefined"==typeof sessionStorage)return;const t=`ss_rules_${this.config.siteId}_`;for(let e=0;e<sessionStorage.length;e++){const n=sessionStorage.key(e);if(n&&n.startsWith(t)){const e=sessionStorage.getItem(n);if(!e)continue;const i=JSON.parse(e);if(!Array.isArray(i)||0===i.length)continue;const o=new Set(["click","form_submit","page_view","scroll_depth","element_visible","datalayer_push"]),r=new Set(["necessary","functional","analytics","marketing"]),s=/^[a-z][a-z0-9_]{0,63}$/;if(!i.every(t=>{if(null==t||"object"!=typeof t)return!1;const e=t;if("string"!=typeof e.id||0===e.id.length)return!1;if("string"!=typeof e.type||!o.has(e.type))return!1;if("string"!=typeof e.consent_category||!r.has(e.consent_category))return!1;if(null==e.event||"object"!=typeof e.event)return!1;const n=e.event;return!("string"!=typeof n.event_name||!s.test(n.event_name))&&null!=e.trigger&&"object"==typeof e.trigger})){this.logger.debug("Cached rules failed structural validation, skipping"),sessionStorage.removeItem(n);continue}const c=i,a=parseInt(n.slice(t.length),10);if(isNaN(a))continue;return this.rulesVersion=a,this.logger.debug("Loaded cached rules:",c.length,"rules, version",a),void(this.isInspectorMode()||(this.ruleEngine=this.createRuleEngine(),this.ruleEngine.applyRules(c)))}}}catch{}}
1gtagCaptureCacheKey(){return`ss_gtagcap_${this.config.siteId}`}cacheGtagCaptureConfig(t){try{if("undefined"==typeof sessionStorage)return;sessionStorage.setItem(this.gtagCaptureCacheKey(),JSON.stringify({enabled:!0,category:t}))}catch{}}clearGtagCaptureCache(){try{if("undefined"==typeof sessionStorage)return;sessionStorage.removeItem(this.gtagCaptureCacheKey())}catch{}}loadCachedGtagCapture(){try{if("undefined"==typeof sessionStorage)return;const t=sessionStorage.getItem(this.gtagCaptureCacheKey());if(!t)return;const e=JSON.parse(t);if(null==e||"object"!=typeof e)return;const n=e;if(!0!==n.enabled)return;const i=n.category;"necessary"!==i&&"functional"!==i&&"analytics"!==i&&"marketing"!==i&&null!==i||(this.gtagCaptureConsentCategory=i),this.config.captureGtag=!0,this.setupGtagCapture(),this.logger.debug("gtag capture attached from sessionStorage fast-path")}catch{}}startRulesVersionPolling(){this.rulesVersionTimer||(this.rulesVersionTimer=setInterval(()=>{this.checkRulesVersion()},3e5))}checkRulesVersion(){const t=`${this.config.endpoint}/rules-version?site_id=${encodeURIComponent(this.config.siteId)}`;fetch(t,{method:"GET",cache:"no-cache"}).then(t=>{if(t.ok)return t.json()}).then(t=>{if(!t)return;const e="number"==typeof t.rulesVersion?t.rulesVersion:0;e!==this.rulesVersion&&(this.logger.debug("Rules version changed:",this.rulesVersion,"â",e),this.refetchRules())}).catch(t=>{this.logger.debug("Rules version check failed:",t)})}refetchRules(){const t=`${this.config.endpoint}/site-config?site_id=${encodeURIComponent(this.config.siteId)}`;fetch(t,{method:"GET",cache:"no-cache"}).then(t=>{if(t.ok)return t.json()}).then(t=>{t&&this.handleRulesFromConfig(t)}).catch(t=>{this.logger.debug("Rules re-fetch failed:",t)})}}const Fe=["track","identify","page","flush","destroy"],Re=/^[A-Za-z][A-Za-z0-9_]{0,63}$/,Pe="SignalStreamQueue:";function Me(t,...e){try{t.warn(...e)}catch{}}function Te(t,e,n){let i,o;try{if(!Array.isArray(e))return void Me(n,Pe,"skipped an unrecognised entry of type",typeof e);const t=e[0];if("string"!=typeof t||(r=t,!Fe.includes(r)))return void Me(n,Pe,"skipped an entry naming an unknown method:",function(t){return"string"!=typeof t?"a "+typeof t:Re.test(t)?'"'+t+'"':"a non-identifier name"}(t));i=t,o=e.slice(1)}catch{return void Me(n,Pe,"skipped an entry that could not be read:",typeof e)}var r,s;try{const e=t[i].apply(t,o);null===(s=e)||"object"!=typeof s&&"function"!=typeof s||"function"!=typeof s.then||e.then(void 0,()=>{Me(n,Pe,"a replayed call failed:",i)})}catch{Me(n,Pe,"a replayed call threw:",i)}}return t.CookieFirstAdapter=s,t.IubendaAdapter=u,t.SignalStream=xe,t.VERSION="1.0.0",t.WpConsentApiAdapter=f,t.default=xe,t.generateEventId=p,t.generateSignature=y,t.getFacebookIdentifiers=C,t.getGoogleIdentifiers=O,t.getLinkedInIdentifiers=D,t.getOrGenerateFbp=k,t.getTikTokIdentifiers=x,t.installPreInitQueue=function(t,n,i=e(!1)){try{const e=n.SignalStreamQueue;if(void 0!==e&&!Array.isArray(e))return void Me(i,Pe,"the global is not an array; queued calls will not be replayed");const o=Array.isArray(e)?e:[];if(!Object.isExtensible(o))return void Me(i,Pe,"the global cannot be modified; queued calls will not be replayed and","later pushes will not be processed");for(n.SignalStreamQueue=o;o.length>0;)Te(t,o.shift(),i);try{o.push=function(...e){for(const n of e)Te(t,n,i);return o.length}}catch{Me(i,Pe,"replayed the queued calls, but push could not be patched;","later pushes will not be processed")}}catch{Me(i,Pe,"the queue could not be installed; queued calls will not be replayed")}},t.installSPATracker=V,t.isCryptoAvailable=g,t.isValidUUID=function(t){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t)},t.parseFbclid=b,t.parseGbraid=T,t.parseGclid=P,t.parseLiFatIdFromUrl=q,t.parseTtclid=$,t.parseWbraid=M,t.readCookieFirstLocalStorage=c,t.readFbcCookie=_,t.readFbpCookie=S,t.readGbraidCookie=U,t.readGclCookie=j,t.readIubendaConsent=function(){if("undefined"==typeof window||!window._iub?.cs)return null;try{const t=window._iub.cs.consent;return t?a(t):null}catch(t){return console.error("Failed to read iubenda consent:",t),null}}
1,t.readLiFatIdCookie=L,t.readTtclidCookie=A,t.readWbraidCookie=E,t.signEventPayload=async function(t,e,n){const i=Math.floor(Date.now()/1e3);return{signature:await y(t,e,i,n),timestamp:i}},t.storeGclidCookie=function(t,e){!0===t&&R("_gcl_aw",`GCL.1.${Date.now()}.${e}`,90)},t.storeTtclidCookie=I,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({}); 2//# sourceMappingURL=signalstream.iife.js.map 3 4 5// Auto-initialization from SignalStreamConfig 6(function() { 7 'use strict'; 8 9 function initSignalStream() { 10 // Check for configuration object 11 var config = window.SignalStreamConfig; 12 if (!config) { 13 console.warn('[SignalStream] No SignalStreamConfig found on window. SDK loaded but not initialized.'); 14 console.warn('[SignalStream] Set window.SignalStreamConfig = { siteId, endpoint, signingSecret, ... } before loading the SDK.'); 15 return; 16 } 17 18 // Validate required fields 19 if (!config.siteId || !config.endpoint || !config.signingSecret) { 20 console.error('[SignalStream] Missing required config: siteId, endpoint, and signingSecret are required.'); 21 return; 22 } 23 24 // Create instance 25 try { 26 window.signalstream = new SignalStream.SignalStream({ 27 siteId: config.siteId, 28 endpoint: config.endpoint, 29 signingSecret: config.signingSecret, 30 consentAdapter: config.cmpType || config.consentAdapter || 'cookiefirst', 31 debug: config.debug || false, 32 trackSPANavigation: config.trackSPANavigation, 33 spaDebounceMs: config.spaDebounceMs, 34 trackHashChanges: config.trackHashChanges, 35 autoPageView: config.autoPageView !== false 36 }); 37 38 // Drain window.SignalStreamQueue and patch its push (ADR-078). Only after a 39 // successful construction â an SDK that never came up consumes nothing. 40 SignalStream.installPreInitQueue(window.signalstream, window); 41 42 console.info('[SignalStream] Initialized successfully', { siteId: config.siteId }); 43 } catch (error) { 44 console.error('[SignalStream] Failed to initialize:', error); 45 } 46 } 47 48 // Initialize when DOM is ready 49 if (document.readyState === 'loading') { 50 document.addEventListener('DOMContentLoaded', initSignalStream); 51 } else { 52 initSignalStream(); 53 } 54})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.