@prodantix/sdk 0.8.0 → 0.9.0-beta.777
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chat.cjs +3 -5
- package/dist/chat.d.cts +6 -6
- package/dist/chat.d.ts +6 -6
- package/dist/chat.js +3 -5
- package/dist/chunk-3S3BR7QH.js +2 -0
- package/dist/{chunk-ODN4ZELX.js → chunk-5WTMO52O.js} +2 -2
- package/dist/{client-vogZuHfD.d.cts → client-C8r0UAth.d.cts} +1 -1
- package/dist/{client-Cz7M6XJC.d.ts → client-DnfOdWQo.d.ts} +1 -1
- package/dist/{config-Bhwwo-uC.d.ts → config-C-Di5fAj.d.ts} +4 -1
- package/dist/{config-C8WD1Pge.d.cts → config-D1TSuSTZ.d.cts} +4 -1
- package/dist/consent.iife.js +45 -14
- package/dist/ctas.iife.js +3 -3
- package/dist/forms.iife.js +2 -2
- package/dist/{http-BCh716Vs.d.cts → http-CAOViYSh.d.cts} +1 -0
- package/dist/{http-BCh716Vs.d.ts → http-CAOViYSh.d.ts} +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/messenger-help.iife.js +1 -1
- package/dist/messenger-tickets.iife.js +1 -1
- package/dist/messenger.cjs +1 -1
- package/dist/messenger.d.cts +2 -2
- package/dist/messenger.d.ts +2 -2
- package/dist/messenger.iife.js +2 -4
- package/dist/messenger.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/pages.iife.js +1 -1
- package/dist/prodantix-push-sw.js +1 -1
- package/dist/{transport-C9C4hqlF.d.cts → transport-BBYpAuVK.d.cts} +4 -2
- package/dist/{transport-C4mkCaix.d.ts → transport-BZDcmleq.d.ts} +4 -2
- package/dist/web.cjs +4 -4
- package/dist/web.d.cts +3 -3
- package/dist/web.d.ts +3 -3
- package/dist/web.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-YHIIKYUP.js +0 -2
package/dist/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var Te=Object.defineProperty;var $e=(n,e,t)=>e in n?Te(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>$e(n,typeof e!="symbol"?e+"":e,t);var g=class extends Error{constructor(t,r,s){super(r,s);o(this,"code");this.code=t,this.name="ProdantixError";}},v=class extends g{constructor(e){super("config",e),this.name="ConfigError";}},y=class extends g{constructor(t,r){super("validation",r);o(this,"field");this.field=t,this.name="ValidationError";}},l=class extends g{constructor(t,r,s){super("transport",t,s);o(this,"status");this.status=r,this.name="TransportError";}};function h(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function d(){let n=globalThis.AbortController;return n?new n:void 0}var Q=n=>new Promise(e=>{setTimeout(e,n);});function p(n){return n.replace(/\/+$/,"")}var b=class{constructor(){o(this,"store",new Map);}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},S=class{constructor(e,t=()=>false){this.real=e;this.passes=t;o(this,"held",new b);o(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};var Y={now:()=>new Date};function x(n){return n.toISOString()}function X(){if(typeof window>"u"||typeof Intl>"u")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Ae(){return globalThis.crypto}function Pe(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function Re(){let n=Ae();if(n?.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return Pe(e)}var Z={uuid:Re};var Me=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ne=/^(?:\$|[a-z])[a-z0-9_.]*$/;function w(n){let e=0;for(let t of n)e+=1;return e}function ee(n){return Me.test(n)}function Oe(n){return Ne.test(n)}function te(n){let e=w(n);if(e<1||e>200)throw new y("distinct_id","distinct_id must be between 1 and 200 characters")}function ne(n){let e=w(n);if(e<1||e>200)throw new y("event_name","event_name must be between 1 and 200 characters");if(!Oe(n))throw new y("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var re="prodantix-js",se="0.8.0";var qe=n=>{};function ie(n){if(!n.apiKey||!ee(n.apiKey))throw new v("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new v("host is required (the ingest base URL)");let e=p(n.host),t=n.defaultProperties,r=n.storage??new b;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??Y,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t??{},describeElement:n.describeElement,flagsHost:n.flagsHost?p(n.flagsHost):e,flushAt:n.flushAt??20,flushIntervalMs:n.flushIntervalMs??1e4,host:e,ids:n.ids??Z,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:L(n.apiKey),onError:n.onError??qe,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??re,sdkVersion:n.sdkVersion??se,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??r,socketFactory:n.socketFactory,storage:r,streamFlags:n.streamFlags??false,transport:n.transport}}function L(n){return n.slice(0,16)}var oe=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},C=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async ctas(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(a.status<200||a.status>=300)throw new l(`ctas request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).ctas}finally{i!==void 0&&clearTimeout(i);}}};function ae(n,e,t){ne(n.eventName),te(n.distinctId);let r={distinct_id:n.distinctId,event_id:n.eventId??t.uuid(),event_name:n.eventName,properties:n.properties??{},schema_version:1,timestamp:x(n.timestamp??e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var m=Symbol("absent");function Ke(n,e){if(n==="distinct_id")return e.distinctId;let t=e.properties??{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=e.attributes??{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:m}function f(n){return n===m?"undefined":String(n)}function le(n){return n===m?Number.NaN:Number(n)}function ce(n){return n!==m&&n!==null&&n!==""}function ue(n,e){if(!Array.isArray(e))return false;let t=f(n);return e.map(r=>String(r)).includes(t)}function de(n,e){let t=Ke(n.attribute,e),r=n.value;switch(n.op){case "is_set":return ce(t);case "is_not_set":return !ce(t);case "eq":return f(t)===f(r===void 0?m:r);case "neq":return f(t)!==f(r===void 0?m:r);case "contains":return f(t).includes(f(r===void 0?m:r));case "in":return ue(t,r);case "not_in":return Array.isArray(r)?!ue(t,r):false;case "gt":return _(t,r,(s,i)=>s>i);case "gte":return _(t,r,(s,i)=>s>=i);case "lt":return _(t,r,(s,i)=>s<i);case "lte":return _(t,r,(s,i)=>s<=i);case "in_cohort":return typeof r=="string"&&r!==""&&(e.cohorts??[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!(e.cohorts??[]).includes(r);default:return false}}function _(n,e,t){let r=le(n),s=e===void 0?Number.NaN:le(e);return Number.isNaN(r)||Number.isNaN(s)?false:t(r,s)}function pe(n,e){let t=`${n}:${e}`,r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619);return (r>>>0)%100}function G(n,e){return n.targeting.length===0||n.targeting.every(t=>de(t,e))}function he(n,e){let t=pe(n.key,e.distinctId),r=n.variations??[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let s=0;for(let i=r.length-1;i>=0;i--)if(s+=r[i].weight,t<s)return r[i].key;return r[0].key}function j(n,e,t,r){for(let s of n.prerequisites??[]){if(r.includes(s.flagKey))return false;let i=e.find(c=>c.key===s.flagKey);if(!i||!i.enabled)return false;r.push(i.key);let a=j(i,e,t,r)&&G(i,t)&&he(i,t)===s.variationKey;if(r.pop(),!a)return false}return true}function E(n,e,t){return n.enabled?j(n,e,t,[n.key])?G(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:pe(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function ge(n,e){let t={};for(let r of n)t[r.key]=E(r,n,e).enabled;return t}function V(n,e,t){let r=n.variations??[],s=r[0];if(!s)return null;if(!n.enabled||!j(n,e,t,[n.key])||!G(n,t))return s;let i=he(n,t);return r.find(a=>a.key===i)??s}function fe(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function me(n){return `40${JSON.stringify(n)}`}function ye(){return "3"}function ve(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let a=U(t);return {kind:"open",pingInterval:typeof a?.pingInterval=="number"?a.pingInterval:25e3,pingTimeout:typeof a?.pingTimeout=="number"?a.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),s=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let a=U(s);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(r!=="2")return {kind:"other"};let i=U(s);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function U(n){try{return JSON.parse(n)}catch{return null}}var De="/socket.io/?EIO=4&transport=websocket",Le=250,I=class{constructor(e){this.options=e;o(this,"socket",null);o(this,"heartbeat",null);o(this,"pending",null);o(this,"lastKey","");o(this,"ready",false);o(this,"closed",false);o(this,"heartbeatWindow",45e3);o(this,"factory");o(this,"setTimer");o(this,"clearTimer");this.factory=e.socketFactory??Ge,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${De}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e?.close();}receive(e){let t=ve(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(me({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(ye());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let r=t.payload?.key;this.lastKey=typeof r=="string"?r:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Le));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Ge(n){let e=globalThis.WebSocket;if(!e)throw new l("no WebSocket");return new e(n)}var F=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`flags request failed with status ${a.status}`,a.status);let c=JSON.parse(await a.text());return {flags:c.flags??{},variants:c.variants??{}}}finally{i!==void 0&&clearTimeout(i);}}async snapshot(){let e=this.fetch;if(!e)throw new l("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`flag snapshot request failed with status ${i.status}`,i.status);let a=JSON.parse(await i.text()),c={flags:a.flags??[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(c.socketUrl=a.socketUrl),c}finally{s!==void 0&&clearTimeout(s);}}async memberships(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`memberships request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).cohorts??[]}finally{i!==void 0&&clearTimeout(i);}}};var B=class extends Error{constructor(t,r,s){super(s);o(this,"fields");o(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},T=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async request(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(a["content-type"]="application/json");let c=await r(`${this.host}${e}`,{body:t.body,headers:a,method:t.method,signal:s?.signal});return {status:c.status,text:await c.text()}}finally{i!==void 0&&clearTimeout(i);}}async form(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new l(`form request failed with status ${r}`,r);return JSON.parse(s)}async submit(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(s).afterSubmit;let i=[],a=`form submission failed with status ${r}`;try{let c=JSON.parse(s);i=c.error?.fields??[],a=c.error?.message??a;}catch{i=[];}throw new B(r,i,a)}};var be="$survey_shown",Se="$survey_dismissed",ke="$survey_sent",$=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async surveys(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`surveys request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).surveys??[]}finally{i!==void 0&&clearTimeout(i);}}};function A(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,s]of Object.entries(e))t[`$survey_response_${r}`]=s;return t}var P=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async guides(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`guides request failed with status ${i.status}`,i.status);return JSON.parse(await i.text()).guides??[]}finally{s!==void 0&&clearTimeout(s);}}};function xe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function H(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function J(n,e){return `pdx.${n}.${e}`}var z="consent",je=["identityLink","analytics","marketing","functional"];function k(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let s of je){let i=t[s];typeof i=="boolean"&&(r[s]=i);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(s=>typeof s=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch{return null}}var we=n=>n.endsWith(`.${z}`);function M(n,e){return k(n.getItem(J(e,z)))}function Ve(n,e,t){let r=J(e,z),s=k(JSON.stringify(t)),i=s===null?null:k(JSON.stringify({...M(n,e)??{},...s}));if(i===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(i));}var R=class{constructor(e,t,r,s){this.storage=e;this.shared=t;this.ids=r;this.namespace=s;o(this,"anonymousId");o(this,"distinctId");o(this,"identified");this.refresh();}refresh(){let e=H(this.shared.getItem(this.key("anonymous_id"))),t=H(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=H(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return M(this.shared,this.namespace)}setConsent(e){Ve(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),s=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!s||this.consent()?.identityLink===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return J(this.namespace,e)}};var N=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async inbox(e){let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,s=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!s.ok)throw new l(`inbox request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).messages??[]}async markRead(e,t){let r=this.requireFetch(),s=`${this.host}/v1/messages/read`,i=await this.request(r,s,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!i.ok)throw new l(`mark-read request failed with status ${i.status}`,i.status)}requireFetch(){if(!this.fetch)throw new l("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}};var O=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;o(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);this.onOverflow?.({dropped:e});}};var Ue={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Be(n){return `pdx.${n}.session`}var q=class{constructor(e,t,r,s,i=Ue){this.storage=e;this.ids=t;this.clock=r;this.namespace=s;this.options=i;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),s=r!==void 0&&r.id!==t.id?r:t;return this.write({...s,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch{return}}key(){return Be(this.namespace)}};var u={createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",set:"$set"};function Ce(n){return n>=400&&n<500&&n!==429}var K=class{constructor(e={}){o(this,"fetch");o(this,"maxRetries");o(this,"requestTimeoutMs");o(this,"baseDelayMs");o(this,"maxDelayMs");o(this,"sleep");o(this,"random");this.fetch=h(e.fetch),this.maxRetries=e.maxRetries??3,this.requestTimeoutMs=e.requestTimeoutMs??1e4,this.baseDelayMs=e.baseDelayMs??500,this.maxDelayMs=e.maxDelayMs??3e4,this.sleep=e.sleep??Q,this.random=e.random??Math.random;}async send(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),s;for(let i=0;i<=this.maxRetries;i+=1){try{let a=await this.attempt(t,e,r);if(a.ok)return;if(Ce(a.status))throw new l(`ingest rejected batch with status ${a.status}`,a.status);s=new l(`ingest transient status ${a.status}`,a.status);}catch(a){if(a instanceof l&&a.status!==void 0&&Ce(a.status))throw a;s=a;}i<this.maxRetries&&await this.sleep(this.backoff(i));}throw new l("ingest delivery failed after retries",void 0,{cause:s})}async attempt(e,t,r){let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var He="queue",Je=1e3,_e=3e4,W=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},D=class{constructor(e){o(this,"config");o(this,"identity");o(this,"session");o(this,"queue");o(this,"transport");o(this,"flagsClient");o(this,"messagesClient");o(this,"surveysClient");o(this,"guidesClient");o(this,"captureListeners",new Set);o(this,"formsClient");o(this,"ctasClient");o(this,"context");o(this,"flushTimer");o(this,"flushing",false);o(this,"cachedFlags");o(this,"cachedSnapshot");o(this,"membershipCache");o(this,"stream");o(this,"shutDown",false);o(this,"exposures",new Set);o(this,"gates");o(this,"cookielessId");o(this,"storageListeners",new Set);let t=ie(e),r=M(t.sharedStorage,t.namespace)??t.consent??null;if(this.gates=[new S(t.storage),new S(t.sharedStorage,we)],t.consentMode!=="banner"||r?.analytics===true)for(let a of this.gates)a.open();let[s,i]=this.gates;this.config={...t,sharedStorage:i,storage:s},this.identity=new R(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new q(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new O(this.config.maxQueueSize,({dropped:a})=>{this.config.onError(new g("queue_overflow",`event queue overflow: dropped ${a.length} oldest event(s)`));}),this.transport=this.config.transport??new K({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new F({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new $({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new P({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new T({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new C({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){return this.session?.current()}get sessionStartedAt(){return this.session?.startedAt()}capture(e,t={}){try{this.identity.refresh();let r={...this.config.defaultProperties(),...t.element===void 0?{}:this.config.describeElement?.(t.element)??{},...t.properties??{}},s=ae({context:this.context,distinctId:t.distinctId??this.identity.getDistinctId(),eventName:e,properties:r,sessionId:t.sessionId??this.session?.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(s);}catch(r){this.config.onError(r);}for(let r of this.captureListeners)try{r(e);}catch(s){this.config.onError(s);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),s={};r.anonymousToLink!==void 0&&(s.$anon_distinct_id=r.anonymousToLink);let i=X(),a={...i===null?{}:{$timezone:i},...W(t.traits??{}),...t.set??{}};Object.keys(a).length>0&&(s.$set=a),this.capture(u.identify,{properties:s});}link(e,t,r){if(this.isCookieless())return;let s={$anon_distinct_id:t},i=W(r??{});Object.keys(i).length>0&&(s.$set=i),this.capture(u.identify,{distinctId:e,properties:s});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(u.createAlias,{properties:{alias:e}});}group(e,t,r){let s={$group_key:t,$group_type:e};r&&(s.$set=r),this.capture(u.group,{properties:s});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(u.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=W(e);Object.keys(t).length!==0&&this.capture(u.set,{properties:{$set:t}});}async getAllFlags(){let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:t.variants??{}},t.flags}async isFeatureEnabled(e){let r=(await this.getAllFlags())[e]??false;return this.recordExposure(e,this.cachedFlags?.variants[e]?.key??String(r)),r}async getVariant(e){let t=await this.getAllFlags(),r=this.cachedFlags?.variants[e]??null;return this.recordExposure(e,r?.key??String(t[e]??false)),r}async getVariantLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(Fe=>Fe.key===e),i=await this.localContext(t,r.flags),a=s?V(s,r.flags,i):null,c=s?E(s,r.flags,i).enabled:false;return this.recordExposure(e,a?.key??String(c)),a?{key:a.key,value:a.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(u.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(c=>c.key===e),i=await this.localContext(t,r.flags),a=s?E(s,r.flags,i).enabled:false;return this.recordExposure(e,(s?V(s,r.flags,i)?.key:void 0)??String(a)),a}async localContext(e,t){let r=this.identity.getDistinctId(),s=e.cohorts;if(s===void 0&&fe(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&i-this.membershipCache.fetchedAt<_e?s=this.membershipCache.cohorts:(s=await this.flagsClient.memberships(r),this.membershipCache={cohorts:s,distinctId:r,fetchedAt:i});}return {attributes:e.attributes,cohorts:s,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<_e)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new I({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e??this.config.locale)}captureSurveyShown(e){this.capture(be,{properties:A(e,{})});}captureSurveyDismissed(e){this.capture(Se,{properties:A(e,{})});}captureSurveySent(e,t){this.capture(ke,{properties:A(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:xe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,s){let{$page_id:i,$page_variant:a}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window>"u"?"":window.location.href,solution:s,...typeof i=="string"&&typeof a=="string"?{pageId:i,pageVariant:a}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:oe(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Je);try{await this.transport.send({body:{events:e,sent_at:x(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){this.session?.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){this.shutDown=true,this.stopTimer(),this.stream?.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${He}`}};var ze=200;function Ee(){return globalThis.process}function We(n){Ee()?.on("beforeExit",()=>{n.flush();});}function Nn(n){let e=Ee(),t={...n,os:n.os??(e?.platform?e.platform.slice(0,50):void 0),streamFlags:n.streamFlags??true},r=new D(t);return We(r),r}function On(n,e){let t=L(e),r=Qe(n,`pdx_${t}`);if(r===void 0)return null;let s=Ye(r);if(s===void 0)return null;let i=Ie(s[`pdx.${t}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:k(s[`pdx.${t}.consent`]),sessionId:Xe(s[`pdx.${t}.session`])}}function Qe(n,e){let t=`${e}=`;for(let r of n.split(";")){let s=r.trim();if(s.startsWith(t))return s.slice(t.length)}}function Ye(n){try{let e=JSON.parse(decodeURIComponent(n));return e===null||typeof e!="object"||Array.isArray(e)?void 0:e}catch{return}}function Ie(n){if(typeof n!="string")return;let e=w(n);return e>=1&&e<=ze?n:void 0}function Xe(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);return e===null||typeof e!="object"||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"?null:Ie(e.id)??null}catch{return null}}exports.createNodeClient=Nn;exports.readSharedIdentity=On;//# sourceMappingURL=node.cjs.map
|
|
1
|
+
'use strict';var $e=Object.defineProperty;var Ae=(n,e,t)=>e in n?$e(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>Ae(n,typeof e!="symbol"?e+"":e,t);var f=class extends Error{constructor(t,r,s){super(r,s);o(this,"code");this.code=t,this.name="ProdantixError";}},b=class extends f{constructor(e){super("config",e),this.name="ConfigError";}},v=class extends f{constructor(t,r){super("validation",r);o(this,"field");this.field=t,this.name="ValidationError";}},l=class extends f{constructor(t,r,s){super("transport",t,s);o(this,"status");this.status=r,this.name="TransportError";}};function g(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function d(){let n=globalThis.AbortController;return n?new n:void 0}var Y=n=>new Promise(e=>{setTimeout(e,n);});function p(n){return n.replace(/\/+$/,"")}var S=class{constructor(){o(this,"store",new Map);}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},k=class{constructor(e,t=()=>false){this.real=e;this.passes=t;o(this,"held",new S);o(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};var X={now:()=>new Date};function w(n){return n.toISOString()}function Z(){if(typeof window>"u"||typeof Intl>"u")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Pe(){return globalThis.crypto}function Re(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function Me(){let n=Pe();if(n?.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return Re(e)}var ee={uuid:Me};var Ne=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Oe=/^(?:\$|[a-z])[a-z0-9_.]*$/;function C(n){let e=0;for(let t of n)e+=1;return e}function te(n){return Ne.test(n)}function qe(n){return Oe.test(n)}function ne(n){let e=C(n);if(e<1||e>200)throw new v("distinct_id","distinct_id must be between 1 and 200 characters")}function re(n){let e=C(n);if(e<1||e>200)throw new v("event_name","event_name must be between 1 and 200 characters");if(!qe(n))throw new v("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var se="prodantix-js",ie="0.9.0";var Ke=n=>{};function oe(n){if(!n.apiKey||!te(n.apiKey))throw new b("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new b("host is required (the ingest base URL)");let e=p(n.host),t=n.defaultProperties,r=n.storage??new S;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??X,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t??{},describeElement:n.describeElement,flagsHost:n.flagsHost?p(n.flagsHost):e,flushAt:n.flushAt??20,flushIntervalMs:n.flushIntervalMs??1e4,host:e,ids:n.ids??ee,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:G(n.apiKey),onError:n.onError??Ke,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??se,sdkVersion:n.sdkVersion??ie,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??r,socketFactory:n.socketFactory,storage:r,streamFlags:n.streamFlags??false,transport:n.transport}}function G(n){return n.slice(0,16)}var ae=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},_=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async ctas(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(a.status<200||a.status>=300)throw new l(`ctas request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).ctas}finally{i!==void 0&&clearTimeout(i);}}};function le(n,e,t){re(n.eventName),ne(n.distinctId);let r={distinct_id:n.distinctId,event_id:n.eventId??t.uuid(),event_name:n.eventName,properties:n.properties??{},schema_version:1,timestamp:w(n.timestamp??e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var y=Symbol("absent");function De(n,e){if(n==="distinct_id")return e.distinctId;let t=e.properties??{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=e.attributes??{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:y}function m(n){return n===y?"undefined":String(n)}function ce(n){return n===y?Number.NaN:Number(n)}function ue(n){return n!==y&&n!==null&&n!==""}function de(n,e){if(!Array.isArray(e))return false;let t=m(n);return e.map(r=>String(r)).includes(t)}function pe(n,e){let t=De(n.attribute,e),r=n.value;switch(n.op){case "is_set":return ue(t);case "is_not_set":return !ue(t);case "eq":return m(t)===m(r===void 0?y:r);case "neq":return m(t)!==m(r===void 0?y:r);case "contains":return m(t).includes(m(r===void 0?y:r));case "in":return de(t,r);case "not_in":return Array.isArray(r)?!de(t,r):false;case "gt":return E(t,r,(s,i)=>s>i);case "gte":return E(t,r,(s,i)=>s>=i);case "lt":return E(t,r,(s,i)=>s<i);case "lte":return E(t,r,(s,i)=>s<=i);case "in_cohort":return typeof r=="string"&&r!==""&&(e.cohorts??[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!(e.cohorts??[]).includes(r);default:return false}}function E(n,e,t){let r=ce(n),s=e===void 0?Number.NaN:ce(e);return Number.isNaN(r)||Number.isNaN(s)?false:t(r,s)}function he(n,e){let t=`${n}:${e}`,r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619);return (r>>>0)%100}function j(n,e){return n.targeting.length===0||n.targeting.every(t=>pe(t,e))}function ge(n,e){let t=he(n.key,e.distinctId),r=n.variations??[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let s=0;for(let i=r.length-1;i>=0;i--)if(s+=r[i].weight,t<s)return r[i].key;return r[0].key}function V(n,e,t,r){for(let s of n.prerequisites??[]){if(r.includes(s.flagKey))return false;let i=e.find(c=>c.key===s.flagKey);if(!i||!i.enabled)return false;r.push(i.key);let a=V(i,e,t,r)&&j(i,t)&&ge(i,t)===s.variationKey;if(r.pop(),!a)return false}return true}function I(n,e,t){return n.enabled?V(n,e,t,[n.key])?j(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:he(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function fe(n,e){let t={};for(let r of n)t[r.key]=I(r,n,e).enabled;return t}function U(n,e,t){let r=n.variations??[],s=r[0];if(!s)return null;if(!n.enabled||!V(n,e,t,[n.key])||!j(n,t))return s;let i=ge(n,t);return r.find(a=>a.key===i)??s}function me(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function ye(n){return `40${JSON.stringify(n)}`}function ve(){return "3"}function be(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let a=B(t);return {kind:"open",pingInterval:typeof a?.pingInterval=="number"?a.pingInterval:25e3,pingTimeout:typeof a?.pingTimeout=="number"?a.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),s=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let a=B(s);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(r!=="2")return {kind:"other"};let i=B(s);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function B(n){try{return JSON.parse(n)}catch{return null}}var Le="/socket.io/?EIO=4&transport=websocket",Ge=250,F=class{constructor(e){this.options=e;o(this,"socket",null);o(this,"heartbeat",null);o(this,"pending",null);o(this,"lastKey","");o(this,"ready",false);o(this,"closed",false);o(this,"heartbeatWindow",45e3);o(this,"factory");o(this,"setTimer");o(this,"clearTimer");this.factory=e.socketFactory??je,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Le}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e?.close();}receive(e){let t=be(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(ye({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(ve());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let r=t.payload?.key;this.lastKey=typeof r=="string"?r:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Ge));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function je(n){let e=globalThis.WebSocket;if(!e)throw new l("no WebSocket");return new e(n)}var T=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`flags request failed with status ${a.status}`,a.status);let c=JSON.parse(await a.text());return {flags:c.flags??{},variants:c.variants??{}}}finally{i!==void 0&&clearTimeout(i);}}async snapshot(){let e=this.fetch;if(!e)throw new l("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`flag snapshot request failed with status ${i.status}`,i.status);let a=JSON.parse(await i.text()),c={flags:a.flags??[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(c.socketUrl=a.socketUrl),c}finally{s!==void 0&&clearTimeout(s);}}async memberships(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`memberships request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).cohorts??[]}finally{i!==void 0&&clearTimeout(i);}}};var H=class extends Error{constructor(t,r,s){super(s);o(this,"fields");o(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},$=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async request(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(a["content-type"]="application/json");let c=await r(`${this.host}${e}`,{body:t.body,headers:a,method:t.method,signal:s?.signal});return {status:c.status,text:await c.text()}}finally{i!==void 0&&clearTimeout(i);}}async form(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new l(`form request failed with status ${r}`,r);return JSON.parse(s)}async submit(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(s).afterSubmit;let i=[],a=`form submission failed with status ${r}`;try{let c=JSON.parse(s);i=c.error?.fields??[],a=c.error?.message??a;}catch{i=[];}throw new H(r,i,a)}};var Se="$survey_shown",ke="$survey_dismissed",xe="$survey_sent",A=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async surveys(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`surveys request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).surveys??[]}finally{i!==void 0&&clearTimeout(i);}}};function P(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,s]of Object.entries(e))t[`$survey_response_${r}`]=s;return t}var R=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async guides(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`guides request failed with status ${i.status}`,i.status);return JSON.parse(await i.text()).guides??[]}finally{s!==void 0&&clearTimeout(s);}}};function we(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function J(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function z(n,e){return `pdx.${n}.${e}`}var W="consent",Ve=["identityLink","analytics","marketing","functional"];function x(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let s of Ve){let i=t[s];typeof i=="boolean"&&(r[s]=i);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(s=>typeof s=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch{return null}}var Ce=n=>n.endsWith(`.${W}`);function N(n,e){return x(n.getItem(z(e,W)))}function Ue(n,e,t){let r=z(e,W),s=x(JSON.stringify(t)),i=s===null?null:x(JSON.stringify({...N(n,e)??{},...s}));if(i===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(i));}var M=class{constructor(e,t,r,s){this.storage=e;this.shared=t;this.ids=r;this.namespace=s;o(this,"anonymousId");o(this,"distinctId");o(this,"identified");this.refresh();}refresh(){let e=J(this.shared.getItem(this.key("anonymous_id"))),t=J(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=J(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return N(this.shared,this.namespace)}setConsent(e){Ue(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),s=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!s||this.consent()?.identityLink===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return z(this.namespace,e)}};var O=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=g(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async inbox(e){let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,s=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!s.ok)throw new l(`inbox request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).messages??[]}async markRead(e,t){let r=this.requireFetch(),s=`${this.host}/v1/messages/read`,i=await this.request(r,s,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!i.ok)throw new l(`mark-read request failed with status ${i.status}`,i.status)}requireFetch(){if(!this.fetch)throw new l("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}};var q=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;o(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);this.onOverflow?.({dropped:e});}};var Be={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function He(n){return `pdx.${n}.session`}var K=class{constructor(e,t,r,s,i=Be){this.storage=e;this.ids=t;this.clock=r;this.namespace=s;this.options=i;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),s=r!==void 0&&r.id!==t.id?r:t;return this.write({...s,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch{return}}key(){return He(this.namespace)}};var u={createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",set:"$set"};var _e=6e4;function Je(n){return n.length*3<=_e||new TextEncoder().encode(n).length<=_e}function Ee(n){return n>=400&&n<500&&n!==429}var D=class{constructor(e={}){o(this,"fetch");o(this,"maxRetries");o(this,"requestTimeoutMs");o(this,"baseDelayMs");o(this,"maxDelayMs");o(this,"sleep");o(this,"random");this.fetch=g(e.fetch),this.maxRetries=e.maxRetries??3,this.requestTimeoutMs=e.requestTimeoutMs??1e4,this.baseDelayMs=e.baseDelayMs??500,this.maxDelayMs=e.maxDelayMs??3e4,this.sleep=e.sleep??Y,this.random=e.random??Math.random;}async send(e,t={}){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=JSON.stringify(e.body),i=t.keepalive===true&&Je(s),a;for(let c=0;c<=this.maxRetries;c+=1){try{let h=await this.attempt(r,e,s,i);if(h.ok)return;if(Ee(h.status))throw new l(`ingest rejected batch with status ${h.status}`,h.status);a=new l(`ingest transient status ${h.status}`,h.status);}catch(h){if(h instanceof l&&h.status!==void 0&&Ee(h.status))throw h;a=h;}c<this.maxRetries&&await this.sleep(this.backoff(c));}throw new l("ingest delivery failed after retries",void 0,{cause:a})}async attempt(e,t,r,s){let i=d(),a=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},...s?{keepalive:!0}:{},method:"POST",signal:i?.signal})}finally{a!==void 0&&clearTimeout(a);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var ze="queue",We=1e3,Ie=3e4,Q=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},L=class{constructor(e){o(this,"config");o(this,"identity");o(this,"session");o(this,"queue");o(this,"transport");o(this,"flagsClient");o(this,"messagesClient");o(this,"surveysClient");o(this,"guidesClient");o(this,"captureListeners",new Set);o(this,"formsClient");o(this,"ctasClient");o(this,"context");o(this,"flushTimer");o(this,"flushing",false);o(this,"cachedFlags");o(this,"cachedSnapshot");o(this,"membershipCache");o(this,"stream");o(this,"shutDown",false);o(this,"exposures",new Set);o(this,"gates");o(this,"cookielessId");o(this,"storageListeners",new Set);let t=oe(e),r=N(t.sharedStorage,t.namespace)??t.consent??null;if(this.gates=[new k(t.storage),new k(t.sharedStorage,Ce)],t.consentMode!=="banner"||r?.analytics===true)for(let a of this.gates)a.open();let[s,i]=this.gates;this.config={...t,sharedStorage:i,storage:s},this.identity=new M(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new K(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new q(this.config.maxQueueSize,({dropped:a})=>{this.config.onError(new f("queue_overflow",`event queue overflow: dropped ${a.length} oldest event(s)`));}),this.transport=this.config.transport??new D({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new T({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new O({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new A({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new R({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new $({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new _({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){return this.session?.current()}get sessionStartedAt(){return this.session?.startedAt()}capture(e,t={}){try{this.identity.refresh();let r={...this.config.defaultProperties(),...t.element===void 0?{}:this.config.describeElement?.(t.element)??{},...t.properties??{}},s=le({context:this.context,distinctId:t.distinctId??this.identity.getDistinctId(),eventName:e,properties:r,sessionId:t.sessionId??this.session?.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(s);}catch(r){this.config.onError(r);}for(let r of this.captureListeners)try{r(e);}catch(s){this.config.onError(s);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),s={};r.anonymousToLink!==void 0&&(s.$anon_distinct_id=r.anonymousToLink);let i=Z(),a={...i===null?{}:{$timezone:i},...Q(t.traits??{}),...t.set??{}};Object.keys(a).length>0&&(s.$set=a),this.capture(u.identify,{properties:s});}link(e,t,r){if(this.isCookieless())return;let s={$anon_distinct_id:t},i=Q(r??{});Object.keys(i).length>0&&(s.$set=i),this.capture(u.identify,{distinctId:e,properties:s});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(u.createAlias,{properties:{alias:e}});}group(e,t,r){let s={$group_key:t,$group_type:e};r&&(s.$set=r),this.capture(u.group,{properties:s});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(u.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=Q(e);Object.keys(t).length!==0&&this.capture(u.set,{properties:{$set:t}});}async getAllFlags(){let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:t.variants??{}},t.flags}async isFeatureEnabled(e){let r=(await this.getAllFlags())[e]??false;return this.recordExposure(e,this.cachedFlags?.variants[e]?.key??String(r)),r}async getVariant(e){let t=await this.getAllFlags(),r=this.cachedFlags?.variants[e]??null;return this.recordExposure(e,r?.key??String(t[e]??false)),r}async getVariantLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(h=>h.key===e),i=await this.localContext(t,r.flags),a=s?U(s,r.flags,i):null,c=s?I(s,r.flags,i).enabled:false;return this.recordExposure(e,a?.key??String(c)),a?{key:a.key,value:a.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(u.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return fe(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(c=>c.key===e),i=await this.localContext(t,r.flags),a=s?I(s,r.flags,i).enabled:false;return this.recordExposure(e,(s?U(s,r.flags,i)?.key:void 0)??String(a)),a}async localContext(e,t){let r=this.identity.getDistinctId(),s=e.cohorts;if(s===void 0&&me(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&i-this.membershipCache.fetchedAt<Ie?s=this.membershipCache.cohorts:(s=await this.flagsClient.memberships(r),this.membershipCache={cohorts:s,distinctId:r,fetchedAt:i});}return {attributes:e.attributes,cohorts:s,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<Ie)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new F({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e??this.config.locale)}captureSurveyShown(e){this.capture(Se,{properties:P(e,{})});}captureSurveyDismissed(e){this.capture(ke,{properties:P(e,{})});}captureSurveySent(e,t){this.capture(xe,{properties:P(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:we(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,s){let{$page_id:i,$page_variant:a}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window>"u"?"":window.location.href,solution:s,...typeof i=="string"&&typeof a=="string"?{pageId:i,pageVariant:a}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:ae(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(We);try{await this.transport.send({body:{events:e,sent_at:w(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){this.session?.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){this.shutDown=true,this.stopTimer(),this.stream?.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${ze}`}};var Qe=200;function Fe(){return globalThis.process}function Ye(n){Fe()?.on("beforeExit",()=>{n.flush();});}function qn(n){let e=Fe(),t={...n,os:n.os??(e?.platform?e.platform.slice(0,50):void 0),streamFlags:n.streamFlags??true},r=new L(t);return Ye(r),r}function Kn(n,e){let t=G(e),r=Xe(n,`pdx_${t}`);if(r===void 0)return null;let s=Ze(r);if(s===void 0)return null;let i=Te(s[`pdx.${t}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:x(s[`pdx.${t}.consent`]),sessionId:et(s[`pdx.${t}.session`])}}function Xe(n,e){let t=`${e}=`;for(let r of n.split(";")){let s=r.trim();if(s.startsWith(t))return s.slice(t.length)}}function Ze(n){try{let e=JSON.parse(decodeURIComponent(n));return e===null||typeof e!="object"||Array.isArray(e)?void 0:e}catch{return}}function Te(n){if(typeof n!="string")return;let e=C(n);return e>=1&&e<=Qe?n:void 0}function et(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);return e===null||typeof e!="object"||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"?null:Te(e.id)??null}catch{return null}}exports.createNodeClient=qn;exports.readSharedIdentity=Kn;//# sourceMappingURL=node.cjs.map
|
|
2
2
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProdantixClient } from './client-
|
|
1
|
+
import { P as ProdantixClient } from './client-C8r0UAth.cjs';
|
|
2
2
|
import { b as Consent, P as ProdantixConfig } from './types-BUXFV_aE.cjs';
|
|
3
|
-
import './http-
|
|
3
|
+
import './http-CAOViYSh.cjs';
|
|
4
4
|
|
|
5
5
|
/** What the web SDK's cookie says about the visitor on this request: the
|
|
6
6
|
* anonymous id every subdomain of the site shares, the session it is in, and
|
package/dist/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as ProdantixClient } from './client-
|
|
1
|
+
import { P as ProdantixClient } from './client-DnfOdWQo.js';
|
|
2
2
|
import { b as Consent, P as ProdantixConfig } from './types-BUXFV_aE.js';
|
|
3
|
-
import './http-
|
|
3
|
+
import './http-CAOViYSh.js';
|
|
4
4
|
|
|
5
5
|
/** What the web SDK's cookie says about the visitor on this request: the
|
|
6
6
|
* anonymous id every subdomain of the site shares, the session it is in, and
|
package/dist/node.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {_,h as h$1,R,e}from'./chunk-
|
|
1
|
+
import {_,h as h$1,R,e}from'./chunk-3S3BR7QH.js';import'./chunk-V77KYPOF.js';import'./chunk-5WTMO52O.js';import'./chunk-5XGN7UAV.js';var a=200;function f(){return globalThis.process}function p(t){f()?.on("beforeExit",()=>{t.flush();});}function h(t){let n=f(),e={...t,os:t.os??(n?.platform?n.platform.slice(0,50):void 0),streamFlags:t.streamFlags??true},r=new _(e);return p(r),r}function w(t,n){let e=h$1(n),r=m(t,`pdx_${e}`);if(r===void 0)return null;let o=g(r);if(o===void 0)return null;let i=l(o[`pdx.${e}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:R(o[`pdx.${e}.consent`]),sessionId:y(o[`pdx.${e}.session`])}}function m(t,n){let e=`${n}=`;for(let r of t.split(";")){let o=r.trim();if(o.startsWith(e))return o.slice(e.length)}}function g(t){try{let n=JSON.parse(decodeURIComponent(t));return n===null||typeof n!="object"||Array.isArray(n)?void 0:n}catch{return}}function l(t){if(typeof t!="string")return;let n=e(t);return n>=1&&n<=a?t:void 0}function y(t){if(typeof t!="string")return null;try{let n=JSON.parse(t);return n===null||typeof n!="object"||typeof n.startedAt!="number"||typeof n.lastActivityAt!="number"?null:l(n.id)??null}catch{return null}}export{h as createNodeClient,w as readSharedIdentity};//# sourceMappingURL=node.js.map
|
|
2
2
|
//# sourceMappingURL=node.js.map
|
package/dist/pages.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){'use strict';var wt=Object.defineProperty;var Tt=(n,e,t)=>e in n?wt(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var c=(n,e,t)=>Tt(n,typeof e!="symbol"?e+"":e,t);var b=class extends Error{constructor(t,r,i){super(r,i);c(this,"code");this.code=t,this.name="ProdantixError";}},F=class extends b{constructor(e){super("config",e),this.name="ConfigError";}},T=class extends b{constructor(t,r){super("validation",r);c(this,"field");this.field=t,this.name="ValidationError";}},p=class extends b{constructor(t,r,i){super("transport",t,i);c(this,"status");this.status=r,this.name="TransportError";}};function y(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function h(){let n=globalThis.AbortController;return n?new n:void 0}var xe=n=>new Promise(e=>{setTimeout(e,n);});function g(n){return n.replace(/\/+$/,"")}var E=class{constructor(){c(this,"store",new Map);}getItem(e){var t;return (t=this.store.get(e))!=null?t:null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},A=class{constructor(e,t=()=>false){this.real=e;this.passes=t;c(this,"held",new E);c(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};function we(){try{let n=globalThis.localStorage;if(n){let e="__pdx_probe__";return n.setItem(e,"1"),n.removeItem(e),n}}catch(n){return new E}return new E}var Te={now:()=>new Date};function L(n){return n.toISOString()}function Ce(){if(typeof window=="undefined"||typeof Intl=="undefined")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Ct(){return globalThis.crypto}function _t(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function te(){let n=Ct();if(n!=null&&n.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n!=null&&n.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return _t(e)}var _e={uuid:te};var It=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ft=/^(?:\$|[a-z])[a-z0-9_.]*$/;function Ie(n){let e=0;for(let t of n)e+=1;return e}function Fe(n){return It.test(n)}function At(n){return Ft.test(n)}function Ae(n){let e=Ie(n);if(e<1||e>200)throw new T("distinct_id","distinct_id must be between 1 and 200 characters")}function $e(n){let e=Ie(n);if(e<1||e>200)throw new T("event_name","event_name must be between 1 and 200 characters");if(!At(n))throw new T("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var Pe="prodantix-js",Me="0.8.0";var $t=n=>{};function Oe(n){var i,o,s,a,l,u,d,f,v,k,_,I,O,ke,Ee;if(!n.apiKey||!Fe(n.apiKey))throw new F("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new F("host is required (the ingest base URL)");let e=g(n.host),t=n.defaultProperties,r=(i=n.storage)!=null?i:new E;return {apiKey:n.apiKey,autocapture:(o=n.autocapture)!=null?o:false,clock:(s=n.clock)!=null?s:Te,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t!=null?t:{},describeElement:n.describeElement,flagsHost:n.flagsHost?g(n.flagsHost):e,flushAt:(a=n.flushAt)!=null?a:20,flushIntervalMs:(l=n.flushIntervalMs)!=null?l:1e4,host:e,ids:(u=n.ids)!=null?u:_e,locale:n.locale,maxQueueSize:(d=n.maxQueueSize)!=null?d:1e3,maxRetries:(f=n.maxRetries)!=null?f:3,namespace:ne(n.apiKey),onError:(v=n.onError)!=null?v:$t,os:n.os,requestTimeoutMs:(k=n.requestTimeoutMs)!=null?k:1e4,sdkName:(_=n.sdkName)!=null?_:Pe,sdkVersion:(I=n.sdkVersion)!=null?I:Me,sessionTracking:(O=n.sessionTracking)!=null?O:false,sharedStorage:(ke=n.sharedStorage)!=null?ke:r,socketFactory:n.socketFactory,storage:r,streamFlags:(Ee=n.streamFlags)!=null?Ee:false,transport:n.transport}}function ne(n){return n.slice(0,16)}var Le=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},N=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async ctas(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(s.status<200||s.status>=300)throw new p(`ctas request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).ctas}finally{o!==void 0&&clearTimeout(o);}}};function Ne(n,e,t){var i,o,s;$e(n.eventName),Ae(n.distinctId);let r={distinct_id:n.distinctId,event_id:(i=n.eventId)!=null?i:t.uuid(),event_name:n.eventName,properties:(o=n.properties)!=null?o:{},schema_version:1,timestamp:L((s=n.timestamp)!=null?s:e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var w=Symbol("absent");function Pt(n,e){var i,o;if(n==="distinct_id")return e.distinctId;let t=(i=e.properties)!=null?i:{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=(o=e.attributes)!=null?o:{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:w}function x(n){return n===w?"undefined":String(n)}function Re(n){return n===w?Number.NaN:Number(n)}function De(n){return n!==w&&n!==null&&n!==""}function qe(n,e){if(!Array.isArray(e))return false;let t=x(n);return e.map(r=>String(r)).includes(t)}function Ke(n,e){var i,o;let t=Pt(n.attribute,e),r=n.value;switch(n.op){case "is_set":return De(t);case "is_not_set":return !De(t);case "eq":return x(t)===x(r===void 0?w:r);case "neq":return x(t)!==x(r===void 0?w:r);case "contains":return x(t).includes(x(r===void 0?w:r));case "in":return qe(t,r);case "not_in":return Array.isArray(r)?!qe(t,r):false;case "gt":return R(t,r,(s,a)=>s>a);case "gte":return R(t,r,(s,a)=>s>=a);case "lt":return R(t,r,(s,a)=>s<a);case "lte":return R(t,r,(s,a)=>s<=a);case "in_cohort":return typeof r=="string"&&r!==""&&((i=e.cohorts)!=null?i:[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!((o=e.cohorts)!=null?o:[]).includes(r);default:return false}}function R(n,e,t){let r=Re(n),i=e===void 0?Number.NaN:Re(e);return Number.isNaN(r)||Number.isNaN(i)?false:t(r,i)}function Ve(n,e){let t=`${n}:${e}`,r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%100}function re(n,e){return n.targeting.length===0||n.targeting.every(t=>Ke(t,e))}function je(n,e){var o;let t=Ve(n.key,e.distinctId),r=(o=n.variations)!=null?o:[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let i=0;for(let s=r.length-1;s>=0;s--)if(i+=r[s].weight,t<i)return r[s].key;return r[0].key}function ie(n,e,t,r){var i;for(let o of (i=n.prerequisites)!=null?i:[]){if(r.includes(o.flagKey))return false;let s=e.find(l=>l.key===o.flagKey);if(!s||!s.enabled)return false;r.push(s.key);let a=ie(s,e,t,r)&&re(s,t)&&je(s,t)===o.variationKey;if(r.pop(),!a)return false}return true}function D(n,e,t){return n.enabled?ie(n,e,t,[n.key])?re(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:Ve(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function Ge(n,e){let t={};for(let r of n)t[r.key]=D(r,n,e).enabled;return t}function se(n,e,t){var s,a;let r=(s=n.variations)!=null?s:[],i=r[0];if(!i)return null;if(!n.enabled||!ie(n,e,t,[n.key])||!re(n,t))return i;let o=je(n,t);return (a=r.find(l=>l.key===o))!=null?a:i}function Be(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function Ue(n){return `40${JSON.stringify(n)}`}function He(){return "3"}function Je(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let s=oe(t);return {kind:"open",pingInterval:typeof(s==null?void 0:s.pingInterval)=="number"?s.pingInterval:25e3,pingTimeout:typeof(s==null?void 0:s.pingTimeout)=="number"?s.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let s=oe(i);return {kind:"connectError",message:typeof(s==null?void 0:s.message)=="string"?s.message:"refused"}}if(r!=="2")return {kind:"other"};let o=oe(i);return !Array.isArray(o)||typeof o[0]!="string"?{kind:"other"}:{kind:"event",name:o[0],payload:o[1]}}function oe(n){try{return JSON.parse(n)}catch(e){return null}}var Mt="/socket.io/?EIO=4&transport=websocket",Ot=250,q=class{constructor(e){this.options=e;c(this,"socket",null);c(this,"heartbeat",null);c(this,"pending",null);c(this,"lastKey","");c(this,"ready",false);c(this,"closed",false);c(this,"heartbeatWindow",45e3);c(this,"factory");c(this,"setTimer");c(this,"clearTimer");var t,r,i;this.factory=(t=e.socketFactory)!=null?t:Lt,this.setTimer=(r=e.setTimer)!=null?r:((o,s)=>setTimeout(o,s)),this.clearTimer=(i=e.clearTimer)!=null?i:(o=>clearTimeout(o));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Mt}`,t;try{t=this.factory(e);}catch(r){this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e==null||e.close();}receive(e){var r,i,o,s;let t=Je(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),(r=this.socket)==null||r.send(Ue({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),(i=this.socket)==null||i.send(He());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),(o=this.socket)==null||o.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let a=(s=t.payload)==null?void 0:s.key;this.lastKey=typeof a=="string"?a:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Ot));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>{var t;return (t=this.socket)==null?void 0:t.close()},this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Lt(n){let e=globalThis.WebSocket;if(!e)throw new p("no WebSocket");return new e(n)}var K=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){var s,a;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let l=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!l.ok)throw new p(`flags request failed with status ${l.status}`,l.status);let u=JSON.parse(await l.text());return {flags:(s=u.flags)!=null?s:{},variants:(a=u.variants)!=null?a:{}}}finally{o!==void 0&&clearTimeout(o);}}async snapshot(){var o;let e=this.fetch;if(!e)throw new p("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`flag snapshot request failed with status ${s.status}`,s.status);let a=JSON.parse(await s.text()),l={flags:(o=a.flags)!=null?o:[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(l.socketUrl=a.socketUrl),l}finally{i!==void 0&&clearTimeout(i);}}async memberships(e){var s;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`memberships request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).cohorts)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};var ae=class extends Error{constructor(t,r,i){super(i);c(this,"fields");c(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},V=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async request(e,t){let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(s["content-type"]="application/json");let a=await r(`${this.host}${e}`,{body:t.body,headers:s,method:t.method,signal:i==null?void 0:i.signal});return {status:a.status,text:await a.text()}}finally{o!==void 0&&clearTimeout(o);}}async form(e,t){let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new p(`form request failed with status ${r}`,r);return JSON.parse(i)}async submit(e,t){var a,l,u,d;let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(i).afterSubmit;let o=[],s=`form submission failed with status ${r}`;try{let f=JSON.parse(i);o=(l=(a=f.error)==null?void 0:a.fields)!=null?l:[],s=(d=(u=f.error)==null?void 0:u.message)!=null?d:s;}catch(f){o=[];}throw new ae(r,o,s)}};var We="$survey_shown",ze="$survey_dismissed",Ye="$survey_sent",j=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async surveys(e,t){var s;let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`surveys request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).surveys)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};function G(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,i]of Object.entries(e))t[`$survey_response_${r}`]=i;return t}var B=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async guides(e){var o;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`guides request failed with status ${s.status}`,s.status);return (o=JSON.parse(await s.text()).guides)!=null?o:[]}finally{i!==void 0&&clearTimeout(i);}}};function Qe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function ce(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function ue(n,e){return `pdx.${n}.${e}`}var de="consent",Nt=["identityLink","analytics","marketing","functional"];function le(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let i of Nt){let o=t[i];typeof o=="boolean"&&(r[i]=o);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(i=>typeof i=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch(e){return null}}var Xe=n=>n.endsWith(`.${de}`);function H(n,e){return le(n.getItem(ue(e,de)))}function Rt(n,e,t){var s;let r=ue(e,de),i=le(JSON.stringify(t)),o=i===null?null:le(JSON.stringify({...(s=H(n,e))!=null?s:{},...i}));if(o===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(o));}var U=class{constructor(e,t,r,i){this.storage=e;this.shared=t;this.ids=r;this.namespace=i;c(this,"anonymousId");c(this,"distinctId");c(this,"identified");this.refresh();}refresh(){let e=ce(this.shared.getItem(this.key("anonymous_id"))),t=ce(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=ce(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return H(this.shared,this.namespace)}setConsent(e){Rt(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){var o;let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),i=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!i||((o=this.consent())==null?void 0:o.identityLink)===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return ue(this.namespace,e)}};var J=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async inbox(e){var s;let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,i=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!i.ok)throw new p(`inbox request failed with status ${i.status}`,i.status);return (s=JSON.parse(await i.text()).messages)!=null?s:[]}async markRead(e,t){let r=this.requireFetch(),i=`${this.host}/v1/messages/read`,o=await this.request(r,i,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!o.ok)throw new p(`mark-read request failed with status ${o.status}`,o.status)}requireFetch(){if(!this.fetch)throw new p("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}};var W=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;c(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){var t;if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);(t=this.onOverflow)==null||t.call(this,{dropped:e});}};var Dt={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function qt(n){return `pdx.${n}.session`}var z=class{constructor(e,t,r,i,o=Dt){this.storage=e;this.ids=t;this.clock=r;this.namespace=i;this.options=o;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),i=r!==void 0&&r.id!==t.id?r:t;return this.write({...i,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch(t){return}}key(){return qt(this.namespace)}};var m={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageleave:"$pageleave",pageview:"$pageview",set:"$set",webVitals:"$web_vitals"};function Ze(n){return n>=400&&n<500&&n!==429}var C=class{constructor(e={}){c(this,"fetch");c(this,"maxRetries");c(this,"requestTimeoutMs");c(this,"baseDelayMs");c(this,"maxDelayMs");c(this,"sleep");c(this,"random");var t,r,i,o,s,a;this.fetch=y(e.fetch),this.maxRetries=(t=e.maxRetries)!=null?t:3,this.requestTimeoutMs=(r=e.requestTimeoutMs)!=null?r:1e4,this.baseDelayMs=(i=e.baseDelayMs)!=null?i:500,this.maxDelayMs=(o=e.maxDelayMs)!=null?o:3e4,this.sleep=(s=e.sleep)!=null?s:xe,this.random=(a=e.random)!=null?a:Math.random;}async send(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),i;for(let o=0;o<=this.maxRetries;o+=1){try{let s=await this.attempt(t,e,r);if(s.ok)return;if(Ze(s.status))throw new p(`ingest rejected batch with status ${s.status}`,s.status);i=new p(`ingest transient status ${s.status}`,s.status);}catch(s){if(s instanceof p&&s.status!==void 0&&Ze(s.status))throw s;i=s;}o<this.maxRetries&&await this.sleep(this.backoff(o));}throw new p("ingest delivery failed after retries",void 0,{cause:i})}async attempt(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var Kt="queue",Vt=1e3,et=3e4,pe=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},Y=class{constructor(e){c(this,"config");c(this,"identity");c(this,"session");c(this,"queue");c(this,"transport");c(this,"flagsClient");c(this,"messagesClient");c(this,"surveysClient");c(this,"guidesClient");c(this,"captureListeners",new Set);c(this,"formsClient");c(this,"ctasClient");c(this,"context");c(this,"flushTimer");c(this,"flushing",false);c(this,"cachedFlags");c(this,"cachedSnapshot");c(this,"membershipCache");c(this,"stream");c(this,"shutDown",false);c(this,"exposures",new Set);c(this,"gates");c(this,"cookielessId");c(this,"storageListeners",new Set);var s,a,l;let t=Oe(e),r=(a=(s=H(t.sharedStorage,t.namespace))!=null?s:t.consent)!=null?a:null;if(this.gates=[new A(t.storage),new A(t.sharedStorage,Xe)],t.consentMode!=="banner"||(r==null?void 0:r.analytics)===true)for(let u of this.gates)u.open();let[i,o]=this.gates;this.config={...t,sharedStorage:o,storage:i},this.identity=new U(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new z(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new W(this.config.maxQueueSize,({dropped:u})=>{this.config.onError(new b("queue_overflow",`event queue overflow: dropped ${u.length} oldest event(s)`));}),this.transport=(l=this.config.transport)!=null?l:new C({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new K({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new J({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new j({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new B({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new V({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){var e;return (e=this.session)==null?void 0:e.current()}get sessionStartedAt(){var e;return (e=this.session)==null?void 0:e.startedAt()}capture(e,t={}){var r,i,o,s,a,l,u;try{this.identity.refresh();let d={...this.config.defaultProperties(),...t.element===void 0?{}:(o=(i=(r=this.config).describeElement)==null?void 0:i.call(r,t.element))!=null?o:{},...(s=t.properties)!=null?s:{}},f=Ne({context:this.context,distinctId:(a=t.distinctId)!=null?a:this.identity.getDistinctId(),eventName:e,properties:d,sessionId:(u=t.sessionId)!=null?u:(l=this.session)==null?void 0:l.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(f);}catch(d){this.config.onError(d);}for(let d of this.captureListeners)try{d(e);}catch(f){this.config.onError(f);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){var a,l;if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),i={};r.anonymousToLink!==void 0&&(i.$anon_distinct_id=r.anonymousToLink);let o=Ce(),s={...o===null?{}:{$timezone:o},...pe((a=t.traits)!=null?a:{}),...(l=t.set)!=null?l:{}};Object.keys(s).length>0&&(i.$set=s),this.capture(m.identify,{properties:i});}link(e,t,r){if(this.isCookieless())return;let i={$anon_distinct_id:t},o=pe(r!=null?r:{});Object.keys(o).length>0&&(i.$set=o),this.capture(m.identify,{distinctId:e,properties:i});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(m.createAlias,{properties:{alias:e}});}group(e,t,r){let i={$group_key:t,$group_type:e};r&&(i.$set=r),this.capture(m.group,{properties:i});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(m.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=pe(e);Object.keys(t).length!==0&&this.capture(m.set,{properties:{$set:t}});}async getAllFlags(){var r;let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:(r=t.variants)!=null?r:{}},t.flags}async isFeatureEnabled(e){var i,o,s,a;let r=(i=(await this.getAllFlags())[e])!=null?i:false;return this.recordExposure(e,(a=(s=(o=this.cachedFlags)==null?void 0:o.variants[e])==null?void 0:s.key)!=null?a:String(r)),r}async getVariant(e){var i,o,s,a;let t=await this.getAllFlags(),r=(o=(i=this.cachedFlags)==null?void 0:i.variants[e])!=null?o:null;return this.recordExposure(e,(a=r==null?void 0:r.key)!=null?a:String((s=t[e])!=null?s:false)),r}async getVariantLocal(e,t={}){var l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?se(i,r.flags,o):null,a=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=s==null?void 0:s.key)!=null?l:String(a)),s?{key:s.key,value:s.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(m.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return Ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){var a,l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=i?(a=se(i,r.flags,o))==null?void 0:a.key:void 0)!=null?l:String(s)),s}async localContext(e,t){let r=this.identity.getDistinctId(),i=e.cohorts;if(i===void 0&&Be(t)){let o=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&o-this.membershipCache.fetchedAt<et?i=this.membershipCache.cohorts:(i=await this.flagsClient.memberships(r),this.membershipCache={cohorts:i,distinctId:r,fetchedAt:o});}return {attributes:e.attributes,cohorts:i,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<et)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new q({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e!=null?e:this.config.locale)}captureSurveyShown(e){this.capture(We,{properties:G(e,{})});}captureSurveyDismissed(e){this.capture(ze,{properties:G(e,{})});}captureSurveySent(e,t){this.capture(Ye,{properties:G(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:Qe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,i){let{$page_id:o,$page_variant:s}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window=="undefined"?"":window.location.href,solution:i,...typeof o=="string"&&typeof s=="string"?{pageId:o,pageVariant:s}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:Le(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Vt);try{await this.transport.send({body:{events:e,sent_at:L(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){var e;(e=this.session)==null||e.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){var e;this.shutDown=true,this.stopTimer(),(e=this.stream)==null||e.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${Kt}`}};var jt="data-prodantix",Gt="data-prodantix-action",Bt="data-prodantix-ignore",$=300,fe="data-pdx-no-capture",me="pdx-no-capture",Ut=new Set(["a","button","input","label","option","select","summary","textarea"]),Ht=new Set(["button","checkbox","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","switch","tab","treeitem"]);function Jt(n){var e;return Ut.has(n.tagName.toLowerCase())||Ht.has(((e=n.getAttribute("role"))!=null?e:"").trim().toLowerCase())}function nt(n){for(let e=n;e!==null;e=e.parentElement)if(Jt(e))return e;return n}function rt(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(Bt)!==null)return true;return false}function it(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(fe)!==null||typeof e.className=="string"&&e.className.split(/\s+/).includes(me))return true;return false}function st(n){let e=new Set;return t=>{e.has(t.message)||(e.add(t.message),n(t));}}function tt(n,e,t){let r=n.getAttribute(e);if(r===null)return;let i=r.trim();if(i!==""){if(i.length>$){t(new b("validation",`${e} on a <${n.tagName.toLowerCase()}> is ${i.length} characters, over the ${$}-character limit, so it was ignored: "${i.slice(0,40)}\u2026"`));return}return i}}function ot(n,e){let t={},r=tt(n,jt,e);r!==void 0&&(t.$el_description=r,t.$el_description_source="annotation");let i=tt(n,Gt,e);return i!==void 0&&(t.$el_action=i),t}var Wt="$form_submitted",zt=new Set(["button","file","hidden","image","password","reset","submit"]),at=/(card|cc-?num|cvc|cvv|iban|security.?code)/i,Yt=n=>{var t;return ((t=n.getAttribute("autocomplete"))!=null?t:"").startsWith("cc-")||at.test(n.name)||at.test(n.id)},Qt=n=>{let e=n.name.toLowerCase();return n instanceof HTMLInputElement&&n.type==="email"||e==="email"||n.getAttribute("autocomplete")==="email"?"$email":e==="name"||e==="full_name"||e==="fullname"||n.getAttribute("autocomplete")==="name"?"$name":null},Xt=(n,e)=>{var i,o;if(n.closest("[data-prodantix-ignore]")||n.hasAttribute("data-prodantix-form"))return null;let t={},r={};for(let s of Array.from(n.elements)){if(!(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)||!s.name||s.closest("[data-prodantix-ignore]")||Yt(s)||s instanceof HTMLInputElement&&(zt.has(s.type)||(s.type==="checkbox"||s.type==="radio")&&!s.checked))continue;let a=s.value.trim();if(a==="")continue;t[s.name]=a;let l=Qt(s);l&&(r[l]=a);}return {$answers:t,$form_id:n.id||`${e}#${Array.from(n.ownerDocument.forms).indexOf(n)}`,$page_url:(o=(i=n.ownerDocument.location)==null?void 0:i.href)!=null?o:"",$set:r,collected:true}},ct=(n,e=document)=>{let t=r=>{var i,o;if(r.target instanceof HTMLFormElement){let s=Xt(r.target,(o=(i=e.location)==null?void 0:i.pathname)!=null?o:"");s&&n.capture(Wt,{properties:s});}};return e.addEventListener("submit",t,true),()=>e.removeEventListener("submit",t,true)};var Zt=1e3,en=5e3,tn=50,he=class{constructor(){c(this,"fcp");c(this,"lcp");c(this,"cls");c(this,"window",{end:0,start:0,sum:0});c(this,"interactions",new Map);}add(e){var t,r;if(e.entryType==="paint"&&e.name==="first-contentful-paint"&&(this.fcp=e.startTime),e.entryType==="largest-contentful-paint"&&(this.lcp=e.startTime),e.entryType==="layout-shift"&&!e.hadRecentInput&&e.value!==void 0){let i=this.window.sum>0&&e.startTime-this.window.end<Zt&&e.startTime-this.window.start<en;this.window=i?{end:e.startTime,start:this.window.start,sum:this.window.sum+e.value}:{end:e.startTime,start:e.startTime,sum:e.value},this.cls=Math.max((t=this.cls)!=null?t:0,this.window.sum);}e.entryType==="event"&&e.interactionId!==void 0&&e.interactionId>0&&this.interactions.set(e.interactionId,Math.max((r=this.interactions.get(e.interactionId))!=null?r:0,e.duration));}properties(e){var r;let t={};if(this.lcp!==void 0&&(t.$lcp_ms=Math.round(this.lcp)),this.fcp!==void 0&&(t.$fcp_ms=Math.round(this.fcp)),this.cls!==void 0&&(t.$cls=Math.round(this.cls*1e4)/1e4),this.interactions.size>0){let i=[...this.interactions.values()].sort((o,s)=>s-o);t.$inp_ms=Math.round((r=i[Math.min(i.length-1,Math.floor(i.length/tn))])!=null?r:0);}return e!==void 0&&(t.$ttfb_ms=Math.round(e)),t}},nn=[{type:"paint"},{type:"largest-contentful-paint"},{type:"layout-shift"},{durationThreshold:40,type:"event"}];function lt(n,e){let t=new he,r=[];for(let s of nn){let a=e.observer(l=>{for(let u of l)t.add(u);});if(a!==void 0)try{a.observe({...s,buffered:!0}),r.push(a);}catch(l){a.disconnect();}}let i=false,o=()=>{if(i)return;let s=t.properties(e.firstByte());if(Object.keys(s).length===0)return;i=true;let a=e.path();n.capture(m.webVitals,{properties:a===void 0?s:{...s,$pathname:a}});};return e.addEventListener("visibilitychange",()=>{e.isHidden()&&o();}),e.addEventListener("pagehide",o),()=>{for(let s of r)s.disconnect();}}function ut(){if(!(typeof window=="undefined"||typeof document=="undefined"||typeof PerformanceObserver=="undefined"))return {addEventListener:(n,e)=>(n==="pagehide"?window:document).addEventListener(n,e),firstByte:()=>{let n=performance.getEntriesByType("navigation")[0];return n instanceof PerformanceNavigationTiming&&n.responseStart>0?n.responseStart:void 0},isHidden:()=>document.visibilityState==="hidden",observer:n=>{try{return new PerformanceObserver(e=>n(e.getEntries()))}catch(e){return}},path:()=>{var n;return (n=window.location)==null?void 0:n.pathname}}}var rn=new Set(["input","select","textarea"]),sn=new Set(["email","password","tel"]);function X(){return globalThis.location}function dt(){return globalThis.document}function on(){let n=globalThis.window;return n!=null?n:globalThis}function an(n){return typeof n=="object"&&n!==null&&typeof n.tagName=="string"}function Q(n,e){let t;try{t=new URL(n,e);}catch(r){return}return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:t.protocol}function pt(){let n=X(),e=dt(),t={};if(n){let r=Q(n.href);r&&(t.$current_url=r),t.$pathname=n.pathname,t.$host=n.host;}if(e){e.title&&(t.$title=e.title);let r=e.referrer?Q(e.referrer):void 0;r&&(t.$referrer=r);}return t}function cn(n){return typeof n.className=="string"?n.className:""}function ln(n){var e;return rn.has(n.tagName.toLowerCase())||sn.has(((e=n.getAttribute("type"))!=null?e:"").toLowerCase())}function un(n,e,t){var l,u;let r={$el_tag:n.tagName.toLowerCase(),$event_type:"click"};if(e)return r;let i=t?(l=n.textContent)==null?void 0:l.trim():void 0;i&&(r.$el_text=i.slice(0,255)),n.id&&(r.$el_id=n.id);let o=cn(n);o&&(r.$el_classes=o);let s=n.getAttribute("href"),a=s?Q(s,(u=X())==null?void 0:u.href):void 0;return a&&(r.$el_href=a),r}function ge(n){return (n!=null?n:"").replace(/\s+/g," ").trim()}function P(n,e){return {$el_description:n,$el_description_source:e}}function dn(n,e,t){var s;if(!e&&t){let a=ge(n.getAttribute("aria-label"));if(a!==""&&a.length<=$)return P(a,"aria_label");let l=ge(n.textContent);if(l!==""&&l.length<=$)return P(l,"text")}let r=e?null:n.getAttribute("href"),i=r?Q(r,(s=X())==null?void 0:s.href):void 0;if(i)return P(i,"href");let o=ge(n.getAttribute("role")).toLowerCase();return o===""?P(n.tagName.toLowerCase(),"tag"):P(o,"role")}function pn(n,e){let t=new Set,r=(u,d)=>{if(t.has(u))return false;try{return d()}catch(f){return t.add(u),e(new b("config",`autocapture maskSelectors entry "${u}" is not a valid selector`,{cause:f})),false}},i=(u,d)=>u.matches?r(d,()=>{var f;return ((f=u.matches)==null?void 0:f.call(u,d))===!0}):false,o=u=>{var f;let d=(f=u.querySelector)==null?void 0:f.bind(u);return d?d(`[${fe}], .${me}`)!==null||n.some(v=>r(v,()=>d(v)!==null)):false},s=u=>{for(let d=u;d;d=d.parentElement){let f=d;if(n.some(v=>i(f,v)))return true}return false},a=u=>{for(let d=u;d;d=d.parentElement)if(ln(d))return true;return false},l=u=>it(u)||s(u);return {holdsMasked:o,isMasked:u=>l(u)||a(u),isOptedOut:l}}function fn(n){let e=globalThis.history,t=on(),r="",i=()=>{let a=X(),l=a?`${a.pathname}${a.search}`:"";l!==r&&(r=l,n.capture(m.pageview,{properties:pt()}));};if(i(),!e||!t)return ()=>{};let o=e.pushState.bind(e),s=e.replaceState.bind(e);return e.pushState=(...a)=>{o(...a),i();},e.replaceState=(...a)=>{s(...a),i();},t.addEventListener("popstate",i),()=>{e.pushState=o,e.replaceState=s,t.removeEventListener("popstate",i);}}function mn(n,e){var l,u,d;let t=dt();if(!t)return ()=>{};let r=(l=e.onError)!=null?l:(()=>{}),i=pn((u=e.maskSelectors)!=null?u:[],r),o=st(r),s=(d=e.captureElementText)!=null?d:false,a=f=>{let v=f.target;if(!an(v)||rt(v))return;let k=nt(v),_=i.isMasked(v)||i.holdsMasked(k),I=i.isOptedOut(v)?{}:ot(k,o),O=I.$el_description===void 0?dn(k,_,s):{};n.capture(m.autocapture,{properties:{...pt(),...un(k,_,s),...O,...I}});};return t.addEventListener("click",a,true),()=>t.removeEventListener("click",a,true)}function ft(n,e={}){var i,o;let t=[];((i=e.pageviews)==null||i)&&t.push(fn(n)),((o=e.clicks)==null||o)&&t.push(mn(n,e)),e.collectForms===true&&typeof document!="undefined"&&t.push(ct(n));let r=e.webVitals===false?void 0:ut();return r!==void 0&&t.push(lt(n,r)),()=>{for(let s of t)s();}}function hn(){let n=globalThis.document;return (n==null?void 0:n.visibilityState)==="hidden"}function gn(n){let e=globalThis.navigator,t=globalThis.Blob;if(!(e!=null&&e.sendBeacon)||!t)return false;let r=JSON.stringify({...n.body,api_key:n.projectKey});try{let i=new t([r],{type:"application/json"});return e.sendBeacon(n.url,i)}catch(i){return false}}var Z=class{constructor(e={}){c(this,"fetchTransport");this.fetchTransport=new C(e);}async send(e){hn()&&gn(e)||await this.fetchTransport.send(e);}};var ye="prodantix:consent-ready",ve="prodantix:consent",mt="__prodantixConsent";var ht=(n,e)=>{n.takeCookielessId(e.anonymousId),e.consent!==null?n.setConsent(e.consent):e.rule==="notice"&&n.allowStorage();},gt=(n,e)=>{let t=e[mt];t&&ht(n,t);let r=o=>{let s=o.detail;s&&ht(n,s);},i=o=>{let s=o.detail;s&&n.setConsent(s);};return e.addEventListener(ye,r),e.addEventListener(ve,i),()=>{e.removeEventListener(ye,r),e.removeEventListener(ve,i);}};var yn=/^\d{1,3}(\.\d{1,3}){3}$/,vn=/^[a-z0-9.-]+$/i;function yt(){return Math.random().toString(36).slice(2,12)}function ee(n,e){let t=`${e}=`,r=[];for(let i of n.cookie.split(";")){let o=i.trim();o.startsWith(t)&&r.push(o.slice(t.length));}return r}function M(n,e,t){let r=["Path=/",`Max-Age=${e}`,"SameSite=Lax"];return n&&r.push(`Domain=${n}`),t&&r.push("Secure"),r.join("; ")}function vt(n,e,t,r){try{let i=`pdx_probe_${r()}`,o=r();n.cookie=`${i}=${o}; ${M(e,60,t)}`;let s=ee(n,i).includes(o);n.cookie=`${i}=; ${M(e,0,t)}`;let a=ee(n,i).includes(o);return s&&!a}catch(i){return false}}function bn(n){let e=n.replace(/^\[|\]$/g,"").toLowerCase();if(e.includes(":")||yn.test(e)||!e.includes("."))return [];let t=e.split("."),r=[];for(let i=t.length-2;i>=0;i-=1)r.push(t.slice(i).join("."));return r}function Sn(n,e,t,r=yt){for(let i of bn(n))if(vt(e,i,t,r))return i}function kn(n){let e=new Map,t=JSON.parse(decodeURIComponent(n));if(t===null||typeof t!="object"||Array.isArray(t))return e;for(let[r,i]of Object.entries(t))typeof i=="string"&&e.set(r,i);return e}var be=class{constructor(e,t,r,i){this.jar=e;this.name=t;this.domain=r;this.secure=i;}getItem(e){var t;return (t=this.read().get(e))!=null?t:null}setItem(e,t){let r=this.read();r.set(e,t),this.write(r);}removeItem(e){let t=this.read();t.delete(e)&&this.write(t);}read(){try{let e=ee(this.jar,this.name);e.length>1&&this.domain&&(this.jar.cookie=`${this.name}=; ${M(void 0,0,this.secure)}`,e=ee(this.jar,this.name));let t=e[0];return t?kn(t):new Map}catch(e){return new Map}}write(e){try{if(e.size===0){this.jar.cookie=`${this.name}=; ${M(this.domain,0,this.secure)}`;return}let t=encodeURIComponent(JSON.stringify(Object.fromEntries(e)));this.jar.cookie=`${this.name}=${t}; ${M(this.domain,31536e3,this.secure)}`;}catch(t){return}}};function En(){return globalThis.document}function xn(){var n,e;return (e=(n=globalThis.location)==null?void 0:n.hostname)!=null?e:""}function wn(){var n;return ((n=globalThis.location)==null?void 0:n.protocol)==="https:"}function Tn(n){if(n===void 0)return;let e=n.startsWith(".")?n.slice(1):n;return vn.test(e)?e.toLowerCase():void 0}function bt(n){var s,a,l,u,d;let e="jar"in n?n.jar:En();if(!e||((s=globalThis.navigator)==null?void 0:s.cookieEnabled)===false)return null;let r=(a=n.random)!=null?a:yt,i=(l=n.secure)!=null?l:wn(),o=(u=n.hostname)!=null?u:xn();try{let f=(d=Tn(n.domain))!=null?d:Sn(o,e,i,r);return vt(e,f,i,r)?new be(e,n.name,f,i):null}catch(f){return null}}var St=(n,e,t,r=Date.now)=>{let i=0,o=e.visibilityState==="visible"?r():void 0,s=()=>{o!==void 0&&(i+=r()-o,o=void 0,n(Math.round(i/1e3)));},a=()=>{e.visibilityState==="visible"?o!=null||(o=r()):s();};return e.addEventListener("visibilitychange",a),t.addEventListener("pagehide",s),()=>{e.removeEventListener("visibilitychange",a),t.removeEventListener("pagehide",s);}};var kt=(n,e)=>({...n.page?{$page_id:n.page}:{},...n.page&&e?{$page_view_id:e}:{},...n.variant?{$page_variant:n.variant}:{}});var Cn=(n,e)=>{var t;try{return (t=bt({name:`pdx_${ne(n)}`}))!=null?t:e}catch(r){return e}},S=document.currentScript,Se=S==null?void 0:S.dataset.key,Et,xt;if(S&&Se){let n=new URL(S.src,window.location.href).origin,e=we(),t=S.dataset.consent==="banner",r=new Y({apiKey:Se,...t?{consentMode:"banner"}:{},defaultProperties:kt(S.dataset,te()),flagsHost:(Et=S.dataset.edge)!=null?Et:n,host:(xt=S.dataset.host)!=null?xt:n,sharedStorage:Cn(Se,e),storage:e,transport:new Z({})});t&>(r,window),ft(r,{clicks:true,collectForms:false,pageviews:true}),St(i=>{r.capture(m.pageleave,{properties:{$engaged_seconds:i}}),r.flush();},document,window);}})();//# sourceMappingURL=pages.iife.js.map
|
|
1
|
+
(function(){'use strict';var Tt=Object.defineProperty;var Ct=(n,e,t)=>e in n?Tt(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var c=(n,e,t)=>Ct(n,typeof e!="symbol"?e+"":e,t);var b=class extends Error{constructor(t,r,i){super(r,i);c(this,"code");this.code=t,this.name="ProdantixError";}},A=class extends b{constructor(e){super("config",e),this.name="ConfigError";}},T=class extends b{constructor(t,r){super("validation",r);c(this,"field");this.field=t,this.name="ValidationError";}},p=class extends b{constructor(t,r,i){super("transport",t,i);c(this,"status");this.status=r,this.name="TransportError";}};function y(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function h(){let n=globalThis.AbortController;return n?new n:void 0}var xe=n=>new Promise(e=>{setTimeout(e,n);});function g(n){return n.replace(/\/+$/,"")}var E=class{constructor(){c(this,"store",new Map);}getItem(e){var t;return (t=this.store.get(e))!=null?t:null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},F=class{constructor(e,t=()=>false){this.real=e;this.passes=t;c(this,"held",new E);c(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};function we(){try{let n=globalThis.localStorage;if(n){let e="__pdx_probe__";return n.setItem(e,"1"),n.removeItem(e),n}}catch(n){return new E}return new E}var Te={now:()=>new Date};function O(n){return n.toISOString()}function Ce(){if(typeof window=="undefined"||typeof Intl=="undefined")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function _t(){return globalThis.crypto}function It(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function te(){let n=_t();if(n!=null&&n.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n!=null&&n.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return It(e)}var _e={uuid:te};var At=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ft=/^(?:\$|[a-z])[a-z0-9_.]*$/;function Ie(n){let e=0;for(let t of n)e+=1;return e}function Ae(n){return At.test(n)}function $t(n){return Ft.test(n)}function Fe(n){let e=Ie(n);if(e<1||e>200)throw new T("distinct_id","distinct_id must be between 1 and 200 characters")}function $e(n){let e=Ie(n);if(e<1||e>200)throw new T("event_name","event_name must be between 1 and 200 characters");if(!$t(n))throw new T("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var Pe="prodantix-js",Me="0.9.0";var Pt=n=>{};function Le(n){var i,o,s,a,l,u,d,m,v,k,_,I,L,ke,Ee;if(!n.apiKey||!Ae(n.apiKey))throw new A("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new A("host is required (the ingest base URL)");let e=g(n.host),t=n.defaultProperties,r=(i=n.storage)!=null?i:new E;return {apiKey:n.apiKey,autocapture:(o=n.autocapture)!=null?o:false,clock:(s=n.clock)!=null?s:Te,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t!=null?t:{},describeElement:n.describeElement,flagsHost:n.flagsHost?g(n.flagsHost):e,flushAt:(a=n.flushAt)!=null?a:20,flushIntervalMs:(l=n.flushIntervalMs)!=null?l:1e4,host:e,ids:(u=n.ids)!=null?u:_e,locale:n.locale,maxQueueSize:(d=n.maxQueueSize)!=null?d:1e3,maxRetries:(m=n.maxRetries)!=null?m:3,namespace:ne(n.apiKey),onError:(v=n.onError)!=null?v:Pt,os:n.os,requestTimeoutMs:(k=n.requestTimeoutMs)!=null?k:1e4,sdkName:(_=n.sdkName)!=null?_:Pe,sdkVersion:(I=n.sdkVersion)!=null?I:Me,sessionTracking:(L=n.sessionTracking)!=null?L:false,sharedStorage:(ke=n.sharedStorage)!=null?ke:r,socketFactory:n.socketFactory,storage:r,streamFlags:(Ee=n.streamFlags)!=null?Ee:false,transport:n.transport}}function ne(n){return n.slice(0,16)}var Oe=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},N=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async ctas(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(s.status<200||s.status>=300)throw new p(`ctas request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).ctas}finally{o!==void 0&&clearTimeout(o);}}};function Ne(n,e,t){var i,o,s;$e(n.eventName),Fe(n.distinctId);let r={distinct_id:n.distinctId,event_id:(i=n.eventId)!=null?i:t.uuid(),event_name:n.eventName,properties:(o=n.properties)!=null?o:{},schema_version:1,timestamp:O((s=n.timestamp)!=null?s:e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var w=Symbol("absent");function Mt(n,e){var i,o;if(n==="distinct_id")return e.distinctId;let t=(i=e.properties)!=null?i:{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=(o=e.attributes)!=null?o:{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:w}function x(n){return n===w?"undefined":String(n)}function Re(n){return n===w?Number.NaN:Number(n)}function De(n){return n!==w&&n!==null&&n!==""}function qe(n,e){if(!Array.isArray(e))return false;let t=x(n);return e.map(r=>String(r)).includes(t)}function Ke(n,e){var i,o;let t=Mt(n.attribute,e),r=n.value;switch(n.op){case "is_set":return De(t);case "is_not_set":return !De(t);case "eq":return x(t)===x(r===void 0?w:r);case "neq":return x(t)!==x(r===void 0?w:r);case "contains":return x(t).includes(x(r===void 0?w:r));case "in":return qe(t,r);case "not_in":return Array.isArray(r)?!qe(t,r):false;case "gt":return R(t,r,(s,a)=>s>a);case "gte":return R(t,r,(s,a)=>s>=a);case "lt":return R(t,r,(s,a)=>s<a);case "lte":return R(t,r,(s,a)=>s<=a);case "in_cohort":return typeof r=="string"&&r!==""&&((i=e.cohorts)!=null?i:[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!((o=e.cohorts)!=null?o:[]).includes(r);default:return false}}function R(n,e,t){let r=Re(n),i=e===void 0?Number.NaN:Re(e);return Number.isNaN(r)||Number.isNaN(i)?false:t(r,i)}function Ve(n,e){let t=`${n}:${e}`,r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%100}function re(n,e){return n.targeting.length===0||n.targeting.every(t=>Ke(t,e))}function je(n,e){var o;let t=Ve(n.key,e.distinctId),r=(o=n.variations)!=null?o:[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let i=0;for(let s=r.length-1;s>=0;s--)if(i+=r[s].weight,t<i)return r[s].key;return r[0].key}function ie(n,e,t,r){var i;for(let o of (i=n.prerequisites)!=null?i:[]){if(r.includes(o.flagKey))return false;let s=e.find(l=>l.key===o.flagKey);if(!s||!s.enabled)return false;r.push(s.key);let a=ie(s,e,t,r)&&re(s,t)&&je(s,t)===o.variationKey;if(r.pop(),!a)return false}return true}function D(n,e,t){return n.enabled?ie(n,e,t,[n.key])?re(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:Ve(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function Ge(n,e){let t={};for(let r of n)t[r.key]=D(r,n,e).enabled;return t}function se(n,e,t){var s,a;let r=(s=n.variations)!=null?s:[],i=r[0];if(!i)return null;if(!n.enabled||!ie(n,e,t,[n.key])||!re(n,t))return i;let o=je(n,t);return (a=r.find(l=>l.key===o))!=null?a:i}function Ue(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function He(n){return `40${JSON.stringify(n)}`}function Be(){return "3"}function Je(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let s=oe(t);return {kind:"open",pingInterval:typeof(s==null?void 0:s.pingInterval)=="number"?s.pingInterval:25e3,pingTimeout:typeof(s==null?void 0:s.pingTimeout)=="number"?s.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let s=oe(i);return {kind:"connectError",message:typeof(s==null?void 0:s.message)=="string"?s.message:"refused"}}if(r!=="2")return {kind:"other"};let o=oe(i);return !Array.isArray(o)||typeof o[0]!="string"?{kind:"other"}:{kind:"event",name:o[0],payload:o[1]}}function oe(n){try{return JSON.parse(n)}catch(e){return null}}var Lt="/socket.io/?EIO=4&transport=websocket",Ot=250,q=class{constructor(e){this.options=e;c(this,"socket",null);c(this,"heartbeat",null);c(this,"pending",null);c(this,"lastKey","");c(this,"ready",false);c(this,"closed",false);c(this,"heartbeatWindow",45e3);c(this,"factory");c(this,"setTimer");c(this,"clearTimer");var t,r,i;this.factory=(t=e.socketFactory)!=null?t:Nt,this.setTimer=(r=e.setTimer)!=null?r:((o,s)=>setTimeout(o,s)),this.clearTimer=(i=e.clearTimer)!=null?i:(o=>clearTimeout(o));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Lt}`,t;try{t=this.factory(e);}catch(r){this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e==null||e.close();}receive(e){var r,i,o,s;let t=Je(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),(r=this.socket)==null||r.send(He({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),(i=this.socket)==null||i.send(Be());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),(o=this.socket)==null||o.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let a=(s=t.payload)==null?void 0:s.key;this.lastKey=typeof a=="string"?a:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Ot));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>{var t;return (t=this.socket)==null?void 0:t.close()},this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Nt(n){let e=globalThis.WebSocket;if(!e)throw new p("no WebSocket");return new e(n)}var K=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){var s,a;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let l=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!l.ok)throw new p(`flags request failed with status ${l.status}`,l.status);let u=JSON.parse(await l.text());return {flags:(s=u.flags)!=null?s:{},variants:(a=u.variants)!=null?a:{}}}finally{o!==void 0&&clearTimeout(o);}}async snapshot(){var o;let e=this.fetch;if(!e)throw new p("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`flag snapshot request failed with status ${s.status}`,s.status);let a=JSON.parse(await s.text()),l={flags:(o=a.flags)!=null?o:[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(l.socketUrl=a.socketUrl),l}finally{i!==void 0&&clearTimeout(i);}}async memberships(e){var s;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`memberships request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).cohorts)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};var ae=class extends Error{constructor(t,r,i){super(i);c(this,"fields");c(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},V=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async request(e,t){let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(s["content-type"]="application/json");let a=await r(`${this.host}${e}`,{body:t.body,headers:s,method:t.method,signal:i==null?void 0:i.signal});return {status:a.status,text:await a.text()}}finally{o!==void 0&&clearTimeout(o);}}async form(e,t){let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new p(`form request failed with status ${r}`,r);return JSON.parse(i)}async submit(e,t){var a,l,u,d;let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(i).afterSubmit;let o=[],s=`form submission failed with status ${r}`;try{let m=JSON.parse(i);o=(l=(a=m.error)==null?void 0:a.fields)!=null?l:[],s=(d=(u=m.error)==null?void 0:u.message)!=null?d:s;}catch(m){o=[];}throw new ae(r,o,s)}};var We="$survey_shown",ze="$survey_dismissed",Ye="$survey_sent",j=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async surveys(e,t){var s;let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`surveys request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).surveys)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};function G(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,i]of Object.entries(e))t[`$survey_response_${r}`]=i;return t}var U=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async guides(e){var o;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`guides request failed with status ${s.status}`,s.status);return (o=JSON.parse(await s.text()).guides)!=null?o:[]}finally{i!==void 0&&clearTimeout(i);}}};function Qe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function ce(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function ue(n,e){return `pdx.${n}.${e}`}var de="consent",Rt=["identityLink","analytics","marketing","functional"];function le(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let i of Rt){let o=t[i];typeof o=="boolean"&&(r[i]=o);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(i=>typeof i=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch(e){return null}}var Xe=n=>n.endsWith(`.${de}`);function B(n,e){return le(n.getItem(ue(e,de)))}function Dt(n,e,t){var s;let r=ue(e,de),i=le(JSON.stringify(t)),o=i===null?null:le(JSON.stringify({...(s=B(n,e))!=null?s:{},...i}));if(o===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(o));}var H=class{constructor(e,t,r,i){this.storage=e;this.shared=t;this.ids=r;this.namespace=i;c(this,"anonymousId");c(this,"distinctId");c(this,"identified");this.refresh();}refresh(){let e=ce(this.shared.getItem(this.key("anonymous_id"))),t=ce(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=ce(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return B(this.shared,this.namespace)}setConsent(e){Dt(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){var o;let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),i=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!i||((o=this.consent())==null?void 0:o.identityLink)===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return ue(this.namespace,e)}};var J=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async inbox(e){var s;let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,i=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!i.ok)throw new p(`inbox request failed with status ${i.status}`,i.status);return (s=JSON.parse(await i.text()).messages)!=null?s:[]}async markRead(e,t){let r=this.requireFetch(),i=`${this.host}/v1/messages/read`,o=await this.request(r,i,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!o.ok)throw new p(`mark-read request failed with status ${o.status}`,o.status)}requireFetch(){if(!this.fetch)throw new p("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}};var W=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;c(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){var t;if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);(t=this.onOverflow)==null||t.call(this,{dropped:e});}};var qt={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Kt(n){return `pdx.${n}.session`}var z=class{constructor(e,t,r,i,o=qt){this.storage=e;this.ids=t;this.clock=r;this.namespace=i;this.options=o;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),i=r!==void 0&&r.id!==t.id?r:t;return this.write({...i,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch(t){return}}key(){return Kt(this.namespace)}};var f={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageleave:"$pageleave",pageview:"$pageview",set:"$set",webVitals:"$web_vitals"};var Ze=6e4;function Vt(n){return n.length*3<=Ze||new TextEncoder().encode(n).length<=Ze}function et(n){return n>=400&&n<500&&n!==429}var C=class{constructor(e={}){c(this,"fetch");c(this,"maxRetries");c(this,"requestTimeoutMs");c(this,"baseDelayMs");c(this,"maxDelayMs");c(this,"sleep");c(this,"random");var t,r,i,o,s,a;this.fetch=y(e.fetch),this.maxRetries=(t=e.maxRetries)!=null?t:3,this.requestTimeoutMs=(r=e.requestTimeoutMs)!=null?r:1e4,this.baseDelayMs=(i=e.baseDelayMs)!=null?i:500,this.maxDelayMs=(o=e.maxDelayMs)!=null?o:3e4,this.sleep=(s=e.sleep)!=null?s:xe,this.random=(a=e.random)!=null?a:Math.random;}async send(e,t={}){let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=JSON.stringify(e.body),o=t.keepalive===true&&Vt(i),s;for(let a=0;a<=this.maxRetries;a+=1){try{let l=await this.attempt(r,e,i,o);if(l.ok)return;if(et(l.status))throw new p(`ingest rejected batch with status ${l.status}`,l.status);s=new p(`ingest transient status ${l.status}`,l.status);}catch(l){if(l instanceof p&&l.status!==void 0&&et(l.status))throw l;s=l;}a<this.maxRetries&&await this.sleep(this.backoff(a));}throw new p("ingest delivery failed after retries",void 0,{cause:s})}async attempt(e,t,r,i){let o=h(),s=o?setTimeout(()=>o.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},...i?{keepalive:!0}:{},method:"POST",signal:o==null?void 0:o.signal})}finally{s!==void 0&&clearTimeout(s);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var jt="queue",Gt=1e3,tt=3e4,pe=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},Y=class{constructor(e){c(this,"config");c(this,"identity");c(this,"session");c(this,"queue");c(this,"transport");c(this,"flagsClient");c(this,"messagesClient");c(this,"surveysClient");c(this,"guidesClient");c(this,"captureListeners",new Set);c(this,"formsClient");c(this,"ctasClient");c(this,"context");c(this,"flushTimer");c(this,"flushing",false);c(this,"cachedFlags");c(this,"cachedSnapshot");c(this,"membershipCache");c(this,"stream");c(this,"shutDown",false);c(this,"exposures",new Set);c(this,"gates");c(this,"cookielessId");c(this,"storageListeners",new Set);var s,a,l;let t=Le(e),r=(a=(s=B(t.sharedStorage,t.namespace))!=null?s:t.consent)!=null?a:null;if(this.gates=[new F(t.storage),new F(t.sharedStorage,Xe)],t.consentMode!=="banner"||(r==null?void 0:r.analytics)===true)for(let u of this.gates)u.open();let[i,o]=this.gates;this.config={...t,sharedStorage:o,storage:i},this.identity=new H(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new z(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new W(this.config.maxQueueSize,({dropped:u})=>{this.config.onError(new b("queue_overflow",`event queue overflow: dropped ${u.length} oldest event(s)`));}),this.transport=(l=this.config.transport)!=null?l:new C({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new K({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new J({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new j({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new U({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new V({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){var e;return (e=this.session)==null?void 0:e.current()}get sessionStartedAt(){var e;return (e=this.session)==null?void 0:e.startedAt()}capture(e,t={}){var r,i,o,s,a,l,u;try{this.identity.refresh();let d={...this.config.defaultProperties(),...t.element===void 0?{}:(o=(i=(r=this.config).describeElement)==null?void 0:i.call(r,t.element))!=null?o:{},...(s=t.properties)!=null?s:{}},m=Ne({context:this.context,distinctId:(a=t.distinctId)!=null?a:this.identity.getDistinctId(),eventName:e,properties:d,sessionId:(u=t.sessionId)!=null?u:(l=this.session)==null?void 0:l.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(m);}catch(d){this.config.onError(d);}for(let d of this.captureListeners)try{d(e);}catch(m){this.config.onError(m);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){var a,l;if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),i={};r.anonymousToLink!==void 0&&(i.$anon_distinct_id=r.anonymousToLink);let o=Ce(),s={...o===null?{}:{$timezone:o},...pe((a=t.traits)!=null?a:{}),...(l=t.set)!=null?l:{}};Object.keys(s).length>0&&(i.$set=s),this.capture(f.identify,{properties:i});}link(e,t,r){if(this.isCookieless())return;let i={$anon_distinct_id:t},o=pe(r!=null?r:{});Object.keys(o).length>0&&(i.$set=o),this.capture(f.identify,{distinctId:e,properties:i});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(f.createAlias,{properties:{alias:e}});}group(e,t,r){let i={$group_key:t,$group_type:e};r&&(i.$set=r),this.capture(f.group,{properties:i});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(f.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=pe(e);Object.keys(t).length!==0&&this.capture(f.set,{properties:{$set:t}});}async getAllFlags(){var r;let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:(r=t.variants)!=null?r:{}},t.flags}async isFeatureEnabled(e){var i,o,s,a;let r=(i=(await this.getAllFlags())[e])!=null?i:false;return this.recordExposure(e,(a=(s=(o=this.cachedFlags)==null?void 0:o.variants[e])==null?void 0:s.key)!=null?a:String(r)),r}async getVariant(e){var i,o,s,a;let t=await this.getAllFlags(),r=(o=(i=this.cachedFlags)==null?void 0:i.variants[e])!=null?o:null;return this.recordExposure(e,(a=r==null?void 0:r.key)!=null?a:String((s=t[e])!=null?s:false)),r}async getVariantLocal(e,t={}){var l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?se(i,r.flags,o):null,a=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=s==null?void 0:s.key)!=null?l:String(a)),s?{key:s.key,value:s.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(f.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return Ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){var a,l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=i?(a=se(i,r.flags,o))==null?void 0:a.key:void 0)!=null?l:String(s)),s}async localContext(e,t){let r=this.identity.getDistinctId(),i=e.cohorts;if(i===void 0&&Ue(t)){let o=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&o-this.membershipCache.fetchedAt<tt?i=this.membershipCache.cohorts:(i=await this.flagsClient.memberships(r),this.membershipCache={cohorts:i,distinctId:r,fetchedAt:o});}return {attributes:e.attributes,cohorts:i,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<tt)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new q({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e!=null?e:this.config.locale)}captureSurveyShown(e){this.capture(We,{properties:G(e,{})});}captureSurveyDismissed(e){this.capture(ze,{properties:G(e,{})});}captureSurveySent(e,t){this.capture(Ye,{properties:G(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:Qe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,i){let{$page_id:o,$page_variant:s}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window=="undefined"?"":window.location.href,solution:i,...typeof o=="string"&&typeof s=="string"?{pageId:o,pageVariant:s}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:Oe(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Gt);try{await this.transport.send({body:{events:e,sent_at:O(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){var e;(e=this.session)==null||e.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){var e;this.shutDown=true,this.stopTimer(),(e=this.stream)==null||e.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${jt}`}};var Ut="data-prodantix",Ht="data-prodantix-action",Bt="data-prodantix-ignore",$=300,me="data-pdx-no-capture",fe="pdx-no-capture",Jt=new Set(["a","button","input","label","option","select","summary","textarea"]),Wt=new Set(["button","checkbox","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","switch","tab","treeitem"]);function zt(n){var e;return Jt.has(n.tagName.toLowerCase())||Wt.has(((e=n.getAttribute("role"))!=null?e:"").trim().toLowerCase())}function rt(n){for(let e=n;e!==null;e=e.parentElement)if(zt(e))return e;return n}function it(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(Bt)!==null)return true;return false}function st(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(me)!==null||typeof e.className=="string"&&e.className.split(/\s+/).includes(fe))return true;return false}function ot(n){let e=new Set;return t=>{e.has(t.message)||(e.add(t.message),n(t));}}function nt(n,e,t){let r=n.getAttribute(e);if(r===null)return;let i=r.trim();if(i!==""){if(i.length>$){t(new b("validation",`${e} on a <${n.tagName.toLowerCase()}> is ${i.length} characters, over the ${$}-character limit, so it was ignored: "${i.slice(0,40)}\u2026"`));return}return i}}function at(n,e){let t={},r=nt(n,Ut,e);r!==void 0&&(t.$el_description=r,t.$el_description_source="annotation");let i=nt(n,Ht,e);return i!==void 0&&(t.$el_action=i),t}var Yt="$form_submitted",Qt=new Set(["button","file","hidden","image","password","reset","submit"]),ct=/(card|cc-?num|cvc|cvv|iban|security.?code)/i,Xt=n=>{var t;return ((t=n.getAttribute("autocomplete"))!=null?t:"").startsWith("cc-")||ct.test(n.name)||ct.test(n.id)},Zt=n=>{let e=n.name.toLowerCase();return n instanceof HTMLInputElement&&n.type==="email"||e==="email"||n.getAttribute("autocomplete")==="email"?"$email":e==="name"||e==="full_name"||e==="fullname"||n.getAttribute("autocomplete")==="name"?"$name":null},en=(n,e)=>{var i,o;if(n.closest("[data-prodantix-ignore]")||n.hasAttribute("data-prodantix-form"))return null;let t={},r={};for(let s of Array.from(n.elements)){if(!(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)||!s.name||s.closest("[data-prodantix-ignore]")||Xt(s)||s instanceof HTMLInputElement&&(Qt.has(s.type)||(s.type==="checkbox"||s.type==="radio")&&!s.checked))continue;let a=s.value.trim();if(a==="")continue;t[s.name]=a;let l=Zt(s);l&&(r[l]=a);}return {$answers:t,$form_id:n.id||`${e}#${Array.from(n.ownerDocument.forms).indexOf(n)}`,$page_url:(o=(i=n.ownerDocument.location)==null?void 0:i.href)!=null?o:"",$set:r,collected:true}},lt=(n,e=document)=>{let t=r=>{var i,o;if(r.target instanceof HTMLFormElement){let s=en(r.target,(o=(i=e.location)==null?void 0:i.pathname)!=null?o:"");s&&n.capture(Yt,{properties:s});}};return e.addEventListener("submit",t,true),()=>e.removeEventListener("submit",t,true)};var tn=1e3,nn=5e3,rn=50,he=class{constructor(){c(this,"fcp");c(this,"lcp");c(this,"cls");c(this,"window",{end:0,start:0,sum:0});c(this,"interactions",new Map);}add(e){var t,r;if(e.entryType==="paint"&&e.name==="first-contentful-paint"&&(this.fcp=e.startTime),e.entryType==="largest-contentful-paint"&&(this.lcp=e.startTime),e.entryType==="layout-shift"&&!e.hadRecentInput&&e.value!==void 0){let i=this.window.sum>0&&e.startTime-this.window.end<tn&&e.startTime-this.window.start<nn;this.window=i?{end:e.startTime,start:this.window.start,sum:this.window.sum+e.value}:{end:e.startTime,start:e.startTime,sum:e.value},this.cls=Math.max((t=this.cls)!=null?t:0,this.window.sum);}e.entryType==="event"&&e.interactionId!==void 0&&e.interactionId>0&&this.interactions.set(e.interactionId,Math.max((r=this.interactions.get(e.interactionId))!=null?r:0,e.duration));}properties(e){var r;let t={};if(this.lcp!==void 0&&(t.$lcp_ms=Math.round(this.lcp)),this.fcp!==void 0&&(t.$fcp_ms=Math.round(this.fcp)),this.cls!==void 0&&(t.$cls=Math.round(this.cls*1e4)/1e4),this.interactions.size>0){let i=[...this.interactions.values()].sort((o,s)=>s-o);t.$inp_ms=Math.round((r=i[Math.min(i.length-1,Math.floor(i.length/rn))])!=null?r:0);}return e!==void 0&&(t.$ttfb_ms=Math.round(e)),t}},sn=[{type:"paint"},{type:"largest-contentful-paint"},{type:"layout-shift"},{durationThreshold:40,type:"event"}];function ut(n,e){let t=new he,r=[];for(let s of sn){let a=e.observer(l=>{for(let u of l)t.add(u);});if(a!==void 0)try{a.observe({...s,buffered:!0}),r.push(a);}catch(l){a.disconnect();}}let i=false,o=()=>{if(i)return;let s=t.properties(e.firstByte());if(Object.keys(s).length===0)return;i=true;let a=e.path();n.capture(f.webVitals,{properties:a===void 0?s:{...s,$pathname:a}});};return e.addEventListener("visibilitychange",()=>{e.isHidden()&&o();}),e.addEventListener("pagehide",o),()=>{for(let s of r)s.disconnect();}}function dt(){if(!(typeof window=="undefined"||typeof document=="undefined"||typeof PerformanceObserver=="undefined"))return {addEventListener:(n,e)=>(n==="pagehide"?window:document).addEventListener(n,e),firstByte:()=>{let n=performance.getEntriesByType("navigation")[0];return n instanceof PerformanceNavigationTiming&&n.responseStart>0?n.responseStart:void 0},isHidden:()=>document.visibilityState==="hidden",observer:n=>{try{return new PerformanceObserver(e=>n(e.getEntries()))}catch(e){return}},path:()=>{var n;return (n=window.location)==null?void 0:n.pathname}}}var on=new Set(["input","select","textarea"]),an=new Set(["email","password","tel"]);function X(){return globalThis.location}function pt(){return globalThis.document}function cn(){let n=globalThis.window;return n!=null?n:globalThis}function ln(n){return typeof n=="object"&&n!==null&&typeof n.tagName=="string"}function Q(n,e){let t;try{t=new URL(n,e);}catch(r){return}return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:t.protocol}function mt(){let n=X(),e=pt(),t={};if(n){let r=Q(n.href);r&&(t.$current_url=r),t.$pathname=n.pathname,t.$host=n.host;}if(e){e.title&&(t.$title=e.title);let r=e.referrer?Q(e.referrer):void 0;r&&(t.$referrer=r);}return t}function un(n){return typeof n.className=="string"?n.className:""}function dn(n){var e;return on.has(n.tagName.toLowerCase())||an.has(((e=n.getAttribute("type"))!=null?e:"").toLowerCase())}function pn(n,e,t){var l,u;let r={$el_tag:n.tagName.toLowerCase(),$event_type:"click"};if(e)return r;let i=t?(l=n.textContent)==null?void 0:l.trim():void 0;i&&(r.$el_text=i.slice(0,255)),n.id&&(r.$el_id=n.id);let o=un(n);o&&(r.$el_classes=o);let s=n.getAttribute("href"),a=s?Q(s,(u=X())==null?void 0:u.href):void 0;return a&&(r.$el_href=a),r}function ge(n){return (n!=null?n:"").replace(/\s+/g," ").trim()}function P(n,e){return {$el_description:n,$el_description_source:e}}function mn(n,e,t){var s;if(!e&&t){let a=ge(n.getAttribute("aria-label"));if(a!==""&&a.length<=$)return P(a,"aria_label");let l=ge(n.textContent);if(l!==""&&l.length<=$)return P(l,"text")}let r=e?null:n.getAttribute("href"),i=r?Q(r,(s=X())==null?void 0:s.href):void 0;if(i)return P(i,"href");let o=ge(n.getAttribute("role")).toLowerCase();return o===""?P(n.tagName.toLowerCase(),"tag"):P(o,"role")}function fn(n,e){let t=new Set,r=(u,d)=>{if(t.has(u))return false;try{return d()}catch(m){return t.add(u),e(new b("config",`autocapture maskSelectors entry "${u}" is not a valid selector`,{cause:m})),false}},i=(u,d)=>u.matches?r(d,()=>{var m;return ((m=u.matches)==null?void 0:m.call(u,d))===!0}):false,o=u=>{var m;let d=(m=u.querySelector)==null?void 0:m.bind(u);return d?d(`[${me}], .${fe}`)!==null||n.some(v=>r(v,()=>d(v)!==null)):false},s=u=>{for(let d=u;d;d=d.parentElement){let m=d;if(n.some(v=>i(m,v)))return true}return false},a=u=>{for(let d=u;d;d=d.parentElement)if(dn(d))return true;return false},l=u=>st(u)||s(u);return {holdsMasked:o,isMasked:u=>l(u)||a(u),isOptedOut:l}}function hn(n){let e=globalThis.history,t=cn(),r="",i=()=>{let a=X(),l=a?`${a.pathname}${a.search}`:"";l!==r&&(r=l,n.capture(f.pageview,{properties:mt()}));};if(i(),!e||!t)return ()=>{};let o=e.pushState.bind(e),s=e.replaceState.bind(e);return e.pushState=(...a)=>{o(...a),i();},e.replaceState=(...a)=>{s(...a),i();},t.addEventListener("popstate",i),()=>{e.pushState=o,e.replaceState=s,t.removeEventListener("popstate",i);}}function gn(n,e){var l,u,d;let t=pt();if(!t)return ()=>{};let r=(l=e.onError)!=null?l:(()=>{}),i=fn((u=e.maskSelectors)!=null?u:[],r),o=ot(r),s=(d=e.captureElementText)!=null?d:false,a=m=>{let v=m.target;if(!ln(v)||it(v))return;let k=rt(v),_=i.isMasked(v)||i.holdsMasked(k),I=i.isOptedOut(v)?{}:at(k,o),L=I.$el_description===void 0?mn(k,_,s):{};n.capture(f.autocapture,{properties:{...mt(),...pn(k,_,s),...L,...I}});};return t.addEventListener("click",a,true),()=>t.removeEventListener("click",a,true)}function ft(n,e={}){var i,o;let t=[];((i=e.pageviews)==null||i)&&t.push(hn(n)),((o=e.clicks)==null||o)&&t.push(gn(n,e)),e.collectForms===true&&typeof document!="undefined"&&t.push(lt(n));let r=e.webVitals===false?void 0:dt();return r!==void 0&&t.push(ut(n,r)),()=>{for(let s of t)s();}}function yn(){let n=globalThis.document;return (n==null?void 0:n.visibilityState)==="hidden"}var Z=class{constructor(e={}){c(this,"fetchTransport");this.fetchTransport=new C(e);}async send(e){await this.fetchTransport.send(e,{keepalive:yn()});}};var ye="prodantix:consent-ready",ve="prodantix:consent",ht="__prodantixConsent";var gt=(n,e)=>{n.takeCookielessId(e.anonymousId),e.consent!==null?n.setConsent(e.consent):e.rule==="notice"&&n.allowStorage();},yt=(n,e)=>{let t=e[ht];t&>(n,t);let r=o=>{let s=o.detail;s&>(n,s);},i=o=>{let s=o.detail;s&&n.setConsent(s);};return e.addEventListener(ye,r),e.addEventListener(ve,i),()=>{e.removeEventListener(ye,r),e.removeEventListener(ve,i);}};var vn=/^\d{1,3}(\.\d{1,3}){3}$/,bn=/^[a-z0-9.-]+$/i;function vt(){return Math.random().toString(36).slice(2,12)}function ee(n,e){let t=`${e}=`,r=[];for(let i of n.cookie.split(";")){let o=i.trim();o.startsWith(t)&&r.push(o.slice(t.length));}return r}function M(n,e,t){let r=["Path=/",`Max-Age=${e}`,"SameSite=Lax"];return n&&r.push(`Domain=${n}`),t&&r.push("Secure"),r.join("; ")}function bt(n,e,t,r){try{let i=`pdx_probe_${r()}`,o=r();n.cookie=`${i}=${o}; ${M(e,60,t)}`;let s=ee(n,i).includes(o);n.cookie=`${i}=; ${M(e,0,t)}`;let a=ee(n,i).includes(o);return s&&!a}catch(i){return false}}function Sn(n){let e=n.replace(/^\[|\]$/g,"").toLowerCase();if(e.includes(":")||vn.test(e)||!e.includes("."))return [];let t=e.split("."),r=[];for(let i=t.length-2;i>=0;i-=1)r.push(t.slice(i).join("."));return r}function kn(n,e,t,r=vt){for(let i of Sn(n))if(bt(e,i,t,r))return i}function En(n){let e=new Map,t=JSON.parse(decodeURIComponent(n));if(t===null||typeof t!="object"||Array.isArray(t))return e;for(let[r,i]of Object.entries(t))typeof i=="string"&&e.set(r,i);return e}var be=class{constructor(e,t,r,i){this.jar=e;this.name=t;this.domain=r;this.secure=i;}getItem(e){var t;return (t=this.read().get(e))!=null?t:null}setItem(e,t){let r=this.read();r.set(e,t),this.write(r);}removeItem(e){let t=this.read();t.delete(e)&&this.write(t);}read(){try{let e=ee(this.jar,this.name);e.length>1&&this.domain&&(this.jar.cookie=`${this.name}=; ${M(void 0,0,this.secure)}`,e=ee(this.jar,this.name));let t=e[0];return t?En(t):new Map}catch(e){return new Map}}write(e){try{if(e.size===0){this.jar.cookie=`${this.name}=; ${M(this.domain,0,this.secure)}`;return}let t=encodeURIComponent(JSON.stringify(Object.fromEntries(e)));this.jar.cookie=`${this.name}=${t}; ${M(this.domain,31536e3,this.secure)}`;}catch(t){return}}};function xn(){return globalThis.document}function wn(){var n,e;return (e=(n=globalThis.location)==null?void 0:n.hostname)!=null?e:""}function Tn(){var n;return ((n=globalThis.location)==null?void 0:n.protocol)==="https:"}function Cn(n){if(n===void 0)return;let e=n.startsWith(".")?n.slice(1):n;return bn.test(e)?e.toLowerCase():void 0}function St(n){var s,a,l,u,d;let e="jar"in n?n.jar:xn();if(!e||((s=globalThis.navigator)==null?void 0:s.cookieEnabled)===false)return null;let r=(a=n.random)!=null?a:vt,i=(l=n.secure)!=null?l:Tn(),o=(u=n.hostname)!=null?u:wn();try{let m=(d=Cn(n.domain))!=null?d:kn(o,e,i,r);return bt(e,m,i,r)?new be(e,n.name,m,i):null}catch(m){return null}}var kt=(n,e,t,r=Date.now)=>{let i=0,o=e.visibilityState==="visible"?r():void 0,s=()=>{o!==void 0&&(i+=r()-o,o=void 0,n(Math.round(i/1e3)));},a=()=>{e.visibilityState==="visible"?o!=null||(o=r()):s();};return e.addEventListener("visibilitychange",a),t.addEventListener("pagehide",s),()=>{e.removeEventListener("visibilitychange",a),t.removeEventListener("pagehide",s);}};var Et=(n,e)=>({...n.page?{$page_id:n.page}:{},...n.page&&e?{$page_view_id:e}:{},...n.variant?{$page_variant:n.variant}:{}});var _n=(n,e)=>{var t;try{return (t=St({name:`pdx_${ne(n)}`}))!=null?t:e}catch(r){return e}},S=document.currentScript,Se=S==null?void 0:S.dataset.key,xt,wt;if(S&&Se){let n=new URL(S.src,window.location.href).origin,e=we(),t=S.dataset.consent==="banner",r=new Y({apiKey:Se,...t?{consentMode:"banner"}:{},defaultProperties:Et(S.dataset,te()),flagsHost:(xt=S.dataset.edge)!=null?xt:n,host:(wt=S.dataset.host)!=null?wt:n,sharedStorage:_n(Se,e),storage:e,transport:new Z({})});t&&yt(r,window),ft(r,{clicks:true,collectForms:false,pageviews:true}),kt(i=>{r.capture(f.pageleave,{properties:{$engaged_seconds:i}}),r.flush();},document,window);}})();//# sourceMappingURL=pages.iife.js.map
|
|
2
2
|
//# sourceMappingURL=pages.iife.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(){'use strict';var w=Object.defineProperty;var k=(e,r,t)=>r in e?w(e,r,{enumerable:true,configurable:true,writable:true,value:t}):e[r]=t;var a=(e,r,t)=>k(e,typeof r!="symbol"?r+"":r,t);var g=class extends Error{constructor(t,i,o){super(i,o);a(this,"code");this.code=t,this.name="ProdantixError";}};var d=class extends g{constructor(t,i,o){super("transport",t,o);a(this,"status");this.status=i,this.name="TransportError";}};function m(e){if(e)return e;let r=globalThis.fetch;if(typeof r=="function")return r.bind(globalThis)}function y(){let e=globalThis.AbortController;return e?new e:void 0}function P(e){return e.replace(/\/+$/,"")}var f=class{constructor(r){a(this,"fetch");a(this,"host");a(this,"projectKey");a(this,"requestTimeoutMs");var t;this.fetch=m(r.fetch),this.host=P(r.host),this.projectKey=r.projectKey,this.requestTimeoutMs=(t=r.requestTimeoutMs)!=null?t:1e4;}async request(r,t){let i=this.fetch;if(!i)throw new d("no fetch implementation available in this runtime");let o=y(),
|
|
1
|
+
(function(){'use strict';var w=Object.defineProperty;var k=(e,r,t)=>r in e?w(e,r,{enumerable:true,configurable:true,writable:true,value:t}):e[r]=t;var a=(e,r,t)=>k(e,typeof r!="symbol"?r+"":r,t);var g=class extends Error{constructor(t,i,o){super(i,o);a(this,"code");this.code=t,this.name="ProdantixError";}};var d=class extends g{constructor(t,i,o){super("transport",t,o);a(this,"status");this.status=i,this.name="TransportError";}};function m(e){if(e)return e;let r=globalThis.fetch;if(typeof r=="function")return r.bind(globalThis)}function y(){let e=globalThis.AbortController;return e?new e:void 0}function P(e){return e.replace(/\/+$/,"")}var f=class{constructor(r){a(this,"fetch");a(this,"host");a(this,"projectKey");a(this,"requestTimeoutMs");var t;this.fetch=m(r.fetch),this.host=P(r.host),this.projectKey=r.projectKey,this.requestTimeoutMs=(t=r.requestTimeoutMs)!=null?t:1e4;}async request(r,t){let i=this.fetch;if(!i)throw new d("no fetch implementation available in this runtime");let o=y(),l=o?setTimeout(()=>o.abort(),this.requestTimeoutMs):void 0;try{let u={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(u["content-type"]="application/json");let n=await i(`${this.host}${r}`,{body:t.body,headers:u,method:t.method,signal:o==null?void 0:o.signal});return {status:n.status,text:await n.text()}}finally{l!==void 0&&clearTimeout(l);}}async vapidKey(r){let{status:t,text:i}=await this.request(`/v1/push/vapid?appId=${encodeURIComponent(r)}`,{method:"GET"});if(t<200||t>=300)throw new d(`push key request failed with status ${t}`,t);return JSON.parse(i).publicKey}async register(r){let{status:t,text:i}=await this.request("/v1/push/devices",{body:JSON.stringify(r),method:"POST"});if(t<200||t>=300)throw new d(`push registration failed with status ${t}`,t);return JSON.parse(i).id}async opened(r){let{status:t}=await this.request("/v1/push/opens",{body:JSON.stringify({sendId:r}),method:"POST"});if(t<200||t>=300)throw new d(`push open report failed with status ${t}`,t)}};var x=e=>{if(e===null||typeof e!="object")return {};let r=e,t=i=>{let o=r[i];return typeof o=="string"?o:void 0};return {body:t("body"),image:t("image"),send:t("send"),title:t("title"),url:t("url")}},v=e=>e!==void 0&&(e.startsWith("https://")||e.startsWith("/")&&!e.startsWith("//")),b=e=>{var l,u;let r=new URLSearchParams(e.location.search),t=(l=r.get("host"))!=null?l:"",i=(u=r.get("key"))!=null?u:"",o=t===""||i===""?null:new f({host:t,projectKey:i});e.addEventListener("push",n=>{var c,p,h;let s=x((p=(c=n.data)==null?void 0:c.json())!=null?p:null);n.waitUntil(e.registration.showNotification((h=s.title)!=null?h:"",{body:s.body,data:s,image:s.image}));}),e.addEventListener("notificationclick",n=>{var p;n.notification.close();let s=(p=n.notification.data)!=null?p:{},c=[];o!==null&&s.send!==void 0&&c.push(o.opened(s.send).catch(h=>console.error("[prodantix] the push open could not be recorded",h))),v(s.url)&&c.push(e.clients.openWindow(s.url)),n.waitUntil(Promise.all(c));});};b(self);
|
|
2
2
|
})();//# sourceMappingURL=prodantix-push-sw.js.map
|
|
3
3
|
//# sourceMappingURL=prodantix-push-sw.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchLike } from './http-
|
|
1
|
+
import { F as FetchLike } from './http-CAOViYSh.cjs';
|
|
2
2
|
import { T as Transport, i as TransportRequest } from './types-BUXFV_aE.cjs';
|
|
3
3
|
|
|
4
4
|
interface FetchTransportOptions {
|
|
@@ -19,7 +19,9 @@ declare class FetchTransport implements Transport {
|
|
|
19
19
|
private readonly sleep;
|
|
20
20
|
private readonly random;
|
|
21
21
|
constructor(options?: FetchTransportOptions);
|
|
22
|
-
send(request: TransportRequest
|
|
22
|
+
send(request: TransportRequest, options?: {
|
|
23
|
+
keepalive?: boolean;
|
|
24
|
+
}): Promise<void>;
|
|
23
25
|
private attempt;
|
|
24
26
|
private backoff;
|
|
25
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FetchLike } from './http-
|
|
1
|
+
import { F as FetchLike } from './http-CAOViYSh.js';
|
|
2
2
|
import { T as Transport, i as TransportRequest } from './types-BUXFV_aE.js';
|
|
3
3
|
|
|
4
4
|
interface FetchTransportOptions {
|
|
@@ -19,7 +19,9 @@ declare class FetchTransport implements Transport {
|
|
|
19
19
|
private readonly sleep;
|
|
20
20
|
private readonly random;
|
|
21
21
|
constructor(options?: FetchTransportOptions);
|
|
22
|
-
send(request: TransportRequest
|
|
22
|
+
send(request: TransportRequest, options?: {
|
|
23
|
+
keepalive?: boolean;
|
|
24
|
+
}): Promise<void>;
|
|
23
25
|
private attempt;
|
|
24
26
|
private backoff;
|
|
25
27
|
}
|