@prodantix/sdk 0.7.0-beta.437 → 0.7.0-beta.440

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.
Files changed (43) hide show
  1. package/dist/chat.cjs +5 -103
  2. package/dist/chat.d.cts +93 -8
  3. package/dist/chat.d.ts +93 -8
  4. package/dist/chat.js +5 -103
  5. package/dist/chunk-L4P6GMBC.js +2 -0
  6. package/dist/client-Cz7M6XJC.d.ts +477 -0
  7. package/dist/client-vogZuHfD.d.cts +477 -0
  8. package/dist/{config-6ulvfBFp.d.ts → config-Dmk59mPh.d.ts} +41 -2
  9. package/dist/{config-g14Jiv1t.d.cts → config-Dxf1vAMu.d.cts} +41 -2
  10. package/dist/consent.iife.js +20 -0
  11. package/dist/ctas.iife.js +37 -0
  12. package/dist/forms.iife.js +16 -0
  13. package/dist/guides.iife.js +3 -0
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.cts +5 -4
  16. package/dist/index.d.ts +5 -4
  17. package/dist/index.js +1 -1
  18. package/dist/messenger-help.iife.js +1 -1
  19. package/dist/messenger-tickets.iife.js +3 -0
  20. package/dist/messenger.cjs +1 -1
  21. package/dist/messenger.d.cts +1 -1
  22. package/dist/messenger.d.ts +1 -1
  23. package/dist/messenger.iife.js +5 -103
  24. package/dist/messenger.js +1 -1
  25. package/dist/node.cjs +1 -1
  26. package/dist/node.d.cts +3 -2
  27. package/dist/node.d.ts +3 -2
  28. package/dist/node.js +1 -1
  29. package/dist/pages.iife.js +2 -0
  30. package/dist/prodantix-push-sw.js +3 -0
  31. package/dist/surveys.iife.js +2 -0
  32. package/dist/{transport-DKFvkfX4.d.ts → transport-C4mkCaix.d.ts} +1 -1
  33. package/dist/{transport-DN9pXyrX.d.cts → transport-C9C4hqlF.d.cts} +1 -1
  34. package/dist/{types-Q2VNlJbG.d.cts → types-BUXFV_aE.d.cts} +11 -0
  35. package/dist/{types-Q2VNlJbG.d.ts → types-BUXFV_aE.d.ts} +11 -0
  36. package/dist/web.cjs +36 -1
  37. package/dist/web.d.cts +185 -4
  38. package/dist/web.d.ts +185 -4
  39. package/dist/web.js +36 -1
  40. package/package.json +1 -1
  41. package/dist/chunk-D6PMLUYA.js +0 -2
  42. package/dist/client-CL6Xvhay.d.cts +0 -135
  43. package/dist/client-QyKW0LFW.d.ts +0 -135
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var ue=Object.defineProperty;var pe=(n,e,t)=>e in n?ue(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>pe(n,typeof e!="symbol"?e+"":e,t);var u=class extends Error{constructor(t,s,r){super(s,r);o(this,"code");this.code=t,this.name="ProdantixError";}},y=class extends u{constructor(e){super("config",e),this.name="ConfigError";}},h=class extends u{constructor(t,s){super("validation",s);o(this,"field");this.field=t,this.name="ValidationError";}},l=class extends u{constructor(t,s,r){super("transport",t,r);o(this,"status");this.status=s,this.name="TransportError";}};function v(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function p(){let n=globalThis.AbortController;return n?new n:void 0}var G=n=>new Promise(e=>{setTimeout(e,n);});function f(n){return n.replace(/\/+$/,"")}var k=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);}};var J={now:()=>new Date};function F(n){return n.toISOString()}function he(){return globalThis.crypto}function fe(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 ge(){let n=he();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 fe(e)}var H={uuid:ge};var me=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var ye=/^(?:\$|[a-z])[a-z0-9_.]*$/;function U(n){let e=0;for(let t of n)e+=1;return e}function B(n){return me.test(n)}function ve(n){return ye.test(n)}function z(n){let e=U(n);if(e<1||e>200)throw new h("distinct_id","distinct_id must be between 1 and 200 characters")}function Q(n){let e=U(n);if(e<1||e>200)throw new h("event_name","event_name must be between 1 and 200 characters");if(!ve(n))throw new h("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var P="prodantix-js",N="0.7.0";var ke=n=>{};function Y(n){if(!n.apiKey||!B(n.apiKey))throw new y("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new y("host is required (the ingest base URL)");let e=f(n.host),t=n.defaultProperties,s=n.storage??new k;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??J,consent:n.consent,defaultProperties:typeof t=="function"?t:()=>t??{},describeElement:n.describeElement,flagsHost:n.flagsHost?f(n.flagsHost):e,flushAt:n.flushAt??20,flushIntervalMs:n.flushIntervalMs??1e4,host:e,ids:n.ids??H,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:be(n.apiKey),onError:n.onError??ke,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??P,sdkVersion:n.sdkVersion??N,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??s,socketFactory:n.socketFactory,storage:s,streamFlags:n.streamFlags??false,transport:n.transport}}function be(n){return n.slice(0,16)}function W(n,e,t){Q(n.eventName),z(n.distinctId);let s={distinct_id:n.distinctId,event_id:n.eventId??t.uuid(),event_name:n.eventName,properties:n.properties??{},schema_version:1,timestamp:F(n.timestamp??e.now())};return n.context&&(s.context=n.context),n.sessionId&&(s.session_id=n.sessionId),s}var m=Symbol("absent");function Ee(n,e){if(n==="distinct_id")return e.distinctId;let t=e.properties??{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let s=e.attributes??{};return Object.prototype.hasOwnProperty.call(s,n)?s[n]:m}function g(n){return n===m?"undefined":String(n)}function X(n){return n===m?Number.NaN:Number(n)}function Z(n){return n!==m&&n!==null&&n!==""}function ee(n,e){if(!Array.isArray(e))return false;let t=g(n);return e.map(s=>String(s)).includes(t)}function R(n,e){let t=Ee(n.attribute,e),s=n.value;switch(n.op){case "is_set":return Z(t);case "is_not_set":return !Z(t);case "eq":return g(t)===g(s===void 0?m:s);case "neq":return g(t)!==g(s===void 0?m:s);case "contains":return g(t).includes(g(s===void 0?m:s));case "in":return ee(t,s);case "not_in":return Array.isArray(s)?!ee(t,s):false;case "gt":return C(t,s,(r,i)=>r>i);case "gte":return C(t,s,(r,i)=>r>=i);case "lt":return C(t,s,(r,i)=>r<i);case "lte":return C(t,s,(r,i)=>r<=i);case "in_cohort":return typeof s=="string"&&s!==""&&(e.cohorts??[]).includes(s);case "not_in_cohort":return typeof s=="string"&&s!==""&&!(e.cohorts??[]).includes(s);default:return false}}function C(n,e,t){let s=X(n),r=e===void 0?Number.NaN:X(e);return Number.isNaN(s)||Number.isNaN(r)?false:t(s,r)}function M(n,e){let t=`${n}:${e}`,s=2166136261;for(let r=0;r<t.length;r++)s^=t.charCodeAt(r),s=Math.imul(s,16777619);return (s>>>0)%100}function O(n,e){return n.targeting.length===0||n.targeting.every(t=>R(t,e))}function te(n,e){let t=M(n.key,e.distinctId),s=n.variations??[];if(s.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let r=0;for(let i=s.length-1;i>=0;i--)if(r+=s[i].weight,t<r)return s[i].key;return s[0].key}function q(n,e,t,s){for(let r of n.prerequisites??[]){if(s.includes(r.flagKey))return false;let i=e.find(d=>d.key===r.flagKey);if(!i||!i.enabled)return false;s.push(i.key);let a=q(i,e,t,s)&&O(i,t)&&te(i,t)===r.variationKey;if(s.pop(),!a)return false}return true}function b(n,e,t){return n.enabled?q(n,e,t,[n.key])?O(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:M(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 xe(n,e){return b(n,[],e)}function K(n,e){let t={};for(let s of n)t[s.key]=b(s,n,e).enabled;return t}function E(n,e,t){let s=n.variations??[],r=s[0];if(!r)return null;if(!n.enabled||!q(n,e,t,[n.key])||!O(n,t))return r;let i=te(n,t);return s.find(a=>a.key===i)??r}function Se(n,e){return E(n,[],e)}function Ie(n,e,t){let s=n.find(r=>r.key===e);return s?E(s,n,t)?.value??null:null}function ne(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function se(n){return `40${JSON.stringify(n)}`}function re(){return "3"}function ie(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=L(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 s=t.charAt(0),r=t.slice(1);if(s==="0")return {kind:"connected"};if(s==="1")return {kind:"disconnect"};if(s==="4"){let a=L(r);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(s!=="2")return {kind:"other"};let i=L(r);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function L(n){try{return JSON.parse(n)}catch{return null}}var Fe="/socket.io/?EIO=4&transport=websocket",Ce=250,T=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??Te,this.setTimer=e.setTimer??((t,s)=>setTimeout(t,s)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Fe}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=s=>this.receive(String(s.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=ie(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(se({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(re());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 s=t.payload?.key;this.lastKey=typeof s=="string"?s:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Ce));}}}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 Te(n){let e=globalThis.WebSocket;if(!e)throw new l("no WebSocket");return new e(n)}var x=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=v(e.fetch),this.host=f(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 s=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,r=p(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let a=await t(s,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!a.ok)throw new l(`flags request failed with status ${a.status}`,a.status);let d=JSON.parse(await a.text());return {flags:d.flags??{},variants:d.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`,s=p(),r=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let i=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!i.ok)throw new l(`flag snapshot request failed with status ${i.status}`,i.status);let a=JSON.parse(await i.text()),d={flags:a.flags??[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(d.socketUrl=a.socketUrl),d}finally{r!==void 0&&clearTimeout(r);}}async memberships(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let s=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,r=p(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let a=await t(s,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.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);}}};function D(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function V(n,e){return `pdx.${n}.${e}`}var oe="consent";function we(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.identityLink;return typeof t=="boolean"?{identityLink:t}:null}catch{return null}}function _e(n,e){return we(n.getItem(V(e,oe)))}function Ae(n,e,t){let s=V(e,oe);if(typeof t.identityLink!="boolean"){n.removeItem(s);return}n.setItem(s,JSON.stringify({identityLink:t.identityLink}));}var w=class{constructor(e,t,s,r){this.storage=e;this.shared=t;this.ids=s;this.namespace=r;o(this,"anonymousId");o(this,"distinctId");o(this,"identified");this.refresh();}refresh(){let e=D(this.shared.getItem(this.key("anonymous_id"))),t=D(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 s=D(this.storage.getItem(this.key("distinct_id")));s?(this.distinctId=s,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 _e(this.shared,this.namespace)}setConsent(e){Ae(this.shared,this.namespace,e);}identify(e){let t=!this.identified||this.distinctId!==e,s=this.storage.getItem(this.key("linked_anonymous_id")),r=t||s!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!r||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 V(this.namespace,e)}};var S=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=v(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async inbox(e){let t=this.requireFetch(),s=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,r=await this.request(t,s,{headers:this.authHeaders(),method:"GET"});if(!r.ok)throw new l(`inbox request failed with status ${r.status}`,r.status);return JSON.parse(await r.text()).messages??[]}async markRead(e,t){let s=this.requireFetch(),r=`${this.host}/v1/messages/read`,i=await this.request(s,r,{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,s){let r=p(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...s,signal:r?.signal})}finally{i!==void 0&&clearTimeout(i);}}};var _=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 $e={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Pe(n){return `pdx.${n}.session`}var A=class{constructor(e,t,s,r,i=$e){this.storage=e;this.ids=t;this.clock=s;this.namespace=r;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 s=this.live(this.read(),e),r=s!==void 0&&s.id!==t.id?s:t;return this.write({...r,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 Pe(this.namespace)}};var c={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageview:"$pageview",screen:"$screen",set:"$set"},ae=[{emittedBy:"web",meaning:"A click anywhere on the page, with the element that was clicked. The web SDK sends it by default; autocapture: false or autocaptureOptions.clicks: false turns it off.",name:c.autocapture,properties:["$event_type","$el_description","$el_description_source","$el_action","$el_tag","$el_text","$el_id","$el_classes","$el_href","$current_url","$pathname","$host","$title","$referrer"]},{emittedBy:"web",meaning:"A page shown, including every client-side navigation the History API makes: one per distinct path and query.",name:c.pageview,properties:["$current_url","$pathname","$host","$title","$referrer"]},{emittedBy:"flutter",meaning:"A named route pushed or replaced in a Flutter app, the mobile counterpart of $pageview.",name:c.screen,properties:["screen"]},{emittedBy:"every",meaning:"A person becomes known by a distinct id. The anonymous trail before it is joined to them, and any traits ride along under $set.",name:c.identify,properties:["$anon_distinct_id","$set"]},{emittedBy:"every",meaning:"A second id for the same person, so events sent under either resolve to one profile.",name:c.createAlias,properties:["alias"]},{emittedBy:"every",meaning:"The person is placed in a group such as a company or a team; group properties ride along under $set.",name:c.group,properties:["$group_type","$group_key","$set"]},{emittedBy:"every",meaning:"Person properties written without an identify: $set overwrites, $set_once fills only what is still empty.",name:c.set,properties:["$set","$set_once"]},{emittedBy:"every",meaning:"A flag was evaluated for this person, sent once per distinct answer. Experiments attribute exposure from it.",name:c.featureFlagCalled,properties:["$feature_flag","$feature_flag_response"]}],Ne=n=>n.startsWith("$"),Re=n=>ae.find(e=>e.name===n);function le(n){return n>=400&&n<500&&n!==429}var I=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=v(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??G,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 s=JSON.stringify(e.body),r;for(let i=0;i<=this.maxRetries;i+=1){try{let a=await this.attempt(t,e,s);if(a.ok)return;if(le(a.status))throw new l(`ingest rejected batch with status ${a.status}`,a.status);r=new l(`ingest transient status ${a.status}`,a.status);}catch(a){if(a instanceof l&&a.status!==void 0&&le(a.status))throw a;r=a;}i<this.maxRetries&&await this.sleep(this.backoff(i));}throw new l("ingest delivery failed after retries",void 0,{cause:r})}async attempt(e,t,s){let r=p(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:s,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:r?.signal})}finally{i!==void 0&&clearTimeout(i);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var Me="queue",Oe=1e3,ce=3e4,j=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},$=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,"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);this.config=Y(e),this.identity=new w(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 A(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new _(this.config.maxQueueSize,({dropped:t})=>{this.config.onError(new u("queue_overflow",`event queue overflow: dropped ${t.length} oldest event(s)`));}),this.transport=this.config.transport??new I({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new x({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new S({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 s={...this.config.defaultProperties(),...t.element===void 0?{}:this.config.describeElement?.(t.element)??{},...t.properties??{}},r=W({context:this.context,distinctId:t.distinctId??this.identity.getDistinctId(),eventName:e,properties:s,sessionId:t.sessionId??this.session?.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(r);}catch(s){this.config.onError(s);}}identify(e,t={}){this.identity.refresh();let s=this.identity.identify(e),r={};s.anonymousToLink!==void 0&&(r.$anon_distinct_id=s.anonymousToLink);let i={...j(t.traits??{}),...t.set??{}};Object.keys(i).length>0&&(r.$set=i),this.capture(c.identify,{properties:r});}link(e,t,s){let r={$anon_distinct_id:t},i=j(s??{});Object.keys(i).length>0&&(r.$set=i),this.capture(c.identify,{distinctId:e,properties:r});}setConsent(e){this.identity.setConsent(e);}consent(){return this.identity.consent()}alias(e){this.capture(c.createAlias,{properties:{alias:e}});}group(e,t,s){let r={$group_key:t,$group_type:e};s&&(r.$set=s),this.capture(c.group,{properties:r});}setPersonProperties(e,t){let s={};e&&(s.$set=e),t&&(s.$set_once=t),this.capture(c.set,{properties:s});}setPersonTraits(e){let t=j(e);Object.keys(t).length!==0&&this.capture(c.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 s=(await this.getAllFlags())[e]??false;return this.recordExposure(e,this.cachedFlags?.variants[e]?.key??String(s)),s}async getVariant(e){let t=await this.getAllFlags(),s=this.cachedFlags?.variants[e]??null;return this.recordExposure(e,s?.key??String(t[e]??false)),s}async getVariantLocal(e,t={}){let s=await this.flagSnapshot(),r=s.flags.find(de=>de.key===e),i=await this.localContext(t,s.flags),a=r?E(r,s.flags,i):null,d=r?b(r,s.flags,i).enabled:false;return this.recordExposure(e,a?.key??String(d)),a?{key:a.key,value:a.value}:null}recordExposure(e,t){let s=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(s)||(this.exposures.add(s),this.capture(c.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 K(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){let s=await this.flagSnapshot(),r=s.flags.find(d=>d.key===e),i=await this.localContext(t,s.flags),a=r?b(r,s.flags,i).enabled:false;return this.recordExposure(e,(r?E(r,s.flags,i)?.key:void 0)??String(a)),a}async localContext(e,t){let s=this.identity.getDistinctId(),r=e.cohorts;if(r===void 0&&ne(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===s&&i-this.membershipCache.fetchedAt<ce?r=this.membershipCache.cohorts:(r=await this.flagsClient.memberships(s),this.membershipCache={cohorts:r,distinctId:s,fetchedAt:i});}return {attributes:e.attributes,cohorts:r,distinctId:s,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<ce)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 T({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(s=>this.config.onError(s));},onClosed:s=>{this.stream=void 0,s&&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 flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Oe);try{await this.transport.send({body:{events:e,sent_at:F(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}.${Me}`}};function qe(n){return new $(n)}exports.ConfigError=y;exports.FetchTransport=I;exports.FlagsClient=x;exports.MemoryStorage=k;exports.MessagesClient=S;exports.ProdantixClient=$;exports.ProdantixError=u;exports.SDK_NAME=P;exports.SDK_VERSION=N;exports.SYSTEM_EVENT=c;exports.SYSTEM_EVENTS=ae;exports.TransportError=l;exports.ValidationError=h;exports.assignVariant=Se;exports.bucket=M;exports.createClient=qe;exports.evaluateAll=K;exports.evaluateFlag=xe;exports.getVariant=Ie;exports.isSystemEventName=Ne;exports.matches=R;exports.systemEvent=Re;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var Ae=Object.defineProperty;var Pe=(n,e,t)=>e in n?Ae(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>Pe(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";}},m=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 ie=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);}},b=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 oe={now:()=>new Date};function T(n){return n.toISOString()}function ae(){if(typeof window>"u"||typeof Intl>"u")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Re(){return globalThis.crypto}function Me(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 Ne(){let n=Re();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 Me(e)}var le={uuid:Ne};var Oe=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ke=/^(?:\$|[a-z])[a-z0-9_.]*$/;function ce(n){let e=0;for(let t of n)e+=1;return e}function ue(n){return Oe.test(n)}function qe(n){return Ke.test(n)}function de(n){let e=ce(n);if(e<1||e>200)throw new m("distinct_id","distinct_id must be between 1 and 200 characters")}function pe(n){let e=ce(n);if(e<1||e>200)throw new m("event_name","event_name must be between 1 and 200 characters");if(!qe(n))throw new m("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var L="prodantix-js",G="0.7.0";var De=n=>{};function he(n){if(!n.apiKey||!ue(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 S;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??oe,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??le,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:Le(n.apiKey),onError:n.onError??De,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??L,sdkVersion:n.sdkVersion??G,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??r,socketFactory:n.socketFactory,storage:r,streamFlags:n.streamFlags??false,transport:n.transport}}function Le(n){return n.slice(0,16)}var ge=(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=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 me(n,e,t){pe(n.eventName),de(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:T(n.timestamp??e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var y=Symbol("absent");function Ge(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 f(n){return n===y?"undefined":String(n)}function fe(n){return n===y?Number.NaN:Number(n)}function ye(n){return n!==y&&n!==null&&n!==""}function ve(n,e){if(!Array.isArray(e))return false;let t=f(n);return e.map(r=>String(r)).includes(t)}function V(n,e){let t=Ge(n.attribute,e),r=n.value;switch(n.op){case "is_set":return ye(t);case "is_not_set":return !ye(t);case "eq":return f(t)===f(r===void 0?y:r);case "neq":return f(t)!==f(r===void 0?y:r);case "contains":return f(t).includes(f(r===void 0?y:r));case "in":return ve(t,r);case "not_in":return Array.isArray(r)?!ve(t,r):false;case "gt":return A(t,r,(s,i)=>s>i);case "gte":return A(t,r,(s,i)=>s>=i);case "lt":return A(t,r,(s,i)=>s<i);case "lte":return A(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 A(n,e,t){let r=fe(n),s=e===void 0?Number.NaN:fe(e);return Number.isNaN(r)||Number.isNaN(s)?false:t(r,s)}function j(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 U(n,e){return n.targeting.length===0||n.targeting.every(t=>V(t,e))}function Se(n,e){let t=j(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 B(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=B(i,e,t,r)&&U(i,t)&&Se(i,t)===s.variationKey;if(r.pop(),!a)return false}return true}function k(n,e,t){return n.enabled?B(n,e,t,[n.key])?U(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:j(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 Ve(n,e){return k(n,[],e)}function H(n,e){let t={};for(let r of n)t[r.key]=k(r,n,e).enabled;return t}function x(n,e,t){let r=n.variations??[],s=r[0];if(!s)return null;if(!n.enabled||!B(n,e,t,[n.key])||!U(n,t))return s;let i=Se(n,t);return r.find(a=>a.key===i)??s}function je(n,e){return x(n,[],e)}function Ue(n,e,t){let r=n.find(s=>s.key===e);return r?x(r,n,t)?.value??null:null}function be(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function ke(n){return `40${JSON.stringify(n)}`}function xe(){return "3"}function Ee(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=J(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=J(s);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(r!=="2")return {kind:"other"};let i=J(s);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function J(n){try{return JSON.parse(n)}catch{return null}}var Be="/socket.io/?EIO=4&transport=websocket",He=250,P=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(/\/+$/,"")}${Be}`,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=Ee(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(ke({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(xe());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);},He));}}}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 E=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 z=class extends Error{constructor(t,r,s){super(s);o(this,"fields");o(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},R=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 z(r,i,a)}};var Q="$survey_shown",W="$survey_dismissed",Y="$survey_sent",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 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);}}},ze=864e5,Ce=n=>`${n.id}:${n.iteration}`;function M(n,e){return n.length===0?true:n.some(t=>{switch(t.matches){case "exact":return e===t.value;case "starts_with":return e.startsWith(t.value);default:return e.includes(t.value)}})}function Qe(n,e,t,r,s){return n.kind!=="popover"||e.settled.includes(Ce(n))||n.showOnce&&e.settled.some(i=>i.startsWith(`${n.id}:`))||n.waitDays>0&&e.lastShownAt!==void 0&&r-e.lastShownAt<n.waitDays*ze||n.event&&n.event!==s?false:M(n.urls,t)}function We(n,e,t){return n>=(e.minScore??0)&&n<=(e.maxScore??t)}function Ye(n,e,t){let r=e.kind==="nps"?10:e.scale??5,s=e.branches.find(a=>a.choice!=null?t===a.choice:typeof t=="number"&&We(t,a,r));if(s)return s.next??null;let i=n.questions.findIndex(a=>a.id===e.id);return n.questions[i+1]?.id??null}function _(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 Xe="$guide_shown",Ze="$guide_step_viewed",et="$guide_step_missed",tt="$guide_completed",nt="$guide_dismissed",rt="$checklist_task_done",w=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);}}},st=864e5,X=n=>`${n.id}:${n.iteration}`,_e=(n,e)=>`${X(n)}:${e}`;function it(n,e,t,r,s){return e.settled.includes(X(n))||n.showOnce&&e.settled.some(i=>i.startsWith(`${n.id}:`))||n.kind!=="checklist"&&n.waitDays>0&&e.lastShownAt!==void 0&&r-e.lastShownAt<n.waitDays*st||n.event&&n.event!==s?false:M(n.urls,t)}var ot=(n,e)=>n.steps.filter(t=>e.done.includes(_e(n,t.id))).map(t=>t.id),at=(n,e)=>n.kind==="checklist"?n.steps.find(t=>t.event===e):void 0;function Z(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 ee(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function ne(n,e){return `pdx.${n}.${e}`}var re="consent",lt=["identityLink","analytics","marketing","functional"];function te(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 lt){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(`.${re}`);function O(n,e){return te(n.getItem(ne(e,re)))}function ct(n,e,t){let r=ne(e,re),s=te(JSON.stringify(t)),i=s===null?null:te(JSON.stringify({...O(n,e)??{},...s}));if(i===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(i));}var N=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=ee(this.shared.getItem(this.key("anonymous_id"))),t=ee(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=ee(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 O(this.shared,this.namespace)}setConsent(e){ct(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 ne(this.namespace,e)}};var I=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 K=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 ut={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function dt(n){return `pdx.${n}.session`}var q=class{constructor(e,t,r,s,i=ut){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 dt(this.namespace)}};var u={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageleave:"$pageleave",pageview:"$pageview",screen:"$screen",set:"$set"},Ie=[{emittedBy:"web",meaning:"A click anywhere on the page, with the element that was clicked. The web SDK sends it by default; autocapture: false or autocaptureOptions.clicks: false turns it off.",name:u.autocapture,properties:["$event_type","$el_description","$el_description_source","$el_action","$el_tag","$el_text","$el_id","$el_classes","$el_href","$current_url","$pathname","$host","$title","$referrer"]},{emittedBy:"web",meaning:"A page shown, including every client-side navigation the History API makes: one per distinct path and query.",name:u.pageview,properties:["$current_url","$pathname","$host","$title","$referrer"]},{emittedBy:"web",meaning:"A landing page left the visitor's sight, by a tab switch, a closed tab or a navigation away, with the seconds it was in front of them so far. A page returned to and left again sends it again with the larger total.",name:u.pageleave,properties:["$engaged_seconds","$page_id","$page_view_id","$page_variant"]},{emittedBy:"flutter",meaning:"A named route pushed or replaced in a Flutter app, the mobile counterpart of $pageview.",name:u.screen,properties:["screen"]},{emittedBy:"every",meaning:"A person becomes known by a distinct id. The anonymous trail before it is joined to them, and any traits ride along under $set.",name:u.identify,properties:["$anon_distinct_id","$set"]},{emittedBy:"every",meaning:"A second id for the same person, so events sent under either resolve to one profile.",name:u.createAlias,properties:["alias"]},{emittedBy:"every",meaning:"The person is placed in a group such as a company or a team; group properties ride along under $set.",name:u.group,properties:["$group_type","$group_key","$set"]},{emittedBy:"every",meaning:"Person properties written without an identify: $set overwrites, $set_once fills only what is still empty.",name:u.set,properties:["$set","$set_once"]},{emittedBy:"every",meaning:"A flag was evaluated for this person, sent once per distinct answer. Experiments attribute exposure from it.",name:u.featureFlagCalled,properties:["$feature_flag","$feature_flag_response"]}],pt=n=>n.startsWith("$"),ht=n=>Ie.find(e=>e.name===n);function Fe(n){return n>=400&&n<500&&n!==429}var F=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??ie,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(Fe(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&&Fe(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 gt="queue",mt=1e3,Te=3e4,se=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=he(e),r=O(t.sharedStorage,t.namespace)??t.consent??null;if(this.gates=[new b(t.storage),new b(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 N(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 K(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 F({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new E({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new I({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new C({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new w({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new R({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=me({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=ae(),a={...i===null?{}:{$timezone:i},...se(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=se(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=se(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($e=>$e.key===e),i=await this.localContext(t,r.flags),a=s?x(s,r.flags,i):null,c=s?k(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 H(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?k(s,r.flags,i).enabled:false;return this.recordExposure(e,(s?x(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&&be(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&i-this.membershipCache.fetchedAt<Te?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<Te)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 P({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(Q,{properties:_(e,{})});}captureSurveyDismissed(e){this.capture(W,{properties:_(e,{})});}captureSurveySent(e,t){this.capture(Y,{properties:_(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:Z(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:ge(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(mt);try{await this.transport.send({body:{events:e,sent_at:T(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}.${gt}`}};function ft(n){return new D(n)}exports.CHECKLIST_TASK_DONE=rt;exports.ConfigError=v;exports.FetchTransport=F;exports.FlagsClient=E;exports.GUIDE_COMPLETED=tt;exports.GUIDE_DISMISSED=nt;exports.GUIDE_SHOWN=Xe;exports.GUIDE_STEP_MISSED=et;exports.GUIDE_STEP_VIEWED=Ze;exports.GuidesClient=w;exports.MemoryStorage=S;exports.MessagesClient=I;exports.ProdantixClient=D;exports.ProdantixError=g;exports.SDK_NAME=L;exports.SDK_VERSION=G;exports.SURVEY_DISMISSED=W;exports.SURVEY_SENT=Y;exports.SURVEY_SHOWN=Q;exports.SYSTEM_EVENT=u;exports.SYSTEM_EVENTS=Ie;exports.SurveysClient=C;exports.TransportError=l;exports.ValidationError=m;exports.assignVariant=je;exports.bucket=j;exports.createClient=ft;exports.evaluateAll=H;exports.evaluateFlag=Ve;exports.getVariant=Ue;exports.guideKey=X;exports.guideProperties=Z;exports.isDue=Qe;exports.isGuideDue=it;exports.isSystemEventName=pt;exports.matches=V;exports.nextQuestion=Ye;exports.responseProperties=_;exports.settledKey=Ce;exports.systemEvent=ht;exports.taskFor=at;exports.taskKey=_e;exports.tasksDone=ot;exports.urlMatches=M;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- export { C as CaptureOptions, I as IdentifyOptions, L as LocalFlagContext, P as ProdantixClient, c as createClient } from './client-CL6Xvhay.cjs';
2
- import { J as JsonValue, F as FlagsResponse, I as InboxMessage, a as StorageAdapter } from './types-Q2VNlJbG.cjs';
3
- export { C as Clock, b as Consent, E as EventBatch, c as EventContext, d as EventEnvelope, e as EventProperties, f as FlagVariant, g as IdFactory, h as InboxResponse, P as ProdantixConfig, T as Transport, i as TransportRequest } from './types-Q2VNlJbG.cjs';
1
+ export { C as CHECKLIST_TASK_DONE, a as CaptureOptions, G as GUIDE_COMPLETED, b as GUIDE_DISMISSED, c as GUIDE_SHOWN, d as GUIDE_STEP_MISSED, e as GUIDE_STEP_VIEWED, f as Guide, g as GuideAppearance, h as GuideKind, i as GuideMemory, j as GuideStep, k as GuideStepPlacement, l as GuidesClient, I as IdentifyOptions, L as LocalFlagContext, P as ProdantixClient, S as SURVEY_DISMISSED, m as SURVEY_SENT, n as SURVEY_SHOWN, o as Survey, p as SurveyAnswer, q as SurveyAppearance, r as SurveyBranch, s as SurveyMemory, t as SurveyQuestion, u as SurveyQuestionKind, v as SurveyUrlRule, w as SurveysClient, x as createClient, y as guideKey, z as guideProperties, A as isDue, B as isGuideDue, D as nextQuestion, E as responseProperties, F as settledKey, H as taskFor, J as taskKey, K as tasksDone, M as urlMatches } from './client-vogZuHfD.cjs';
2
+ import { J as JsonValue, F as FlagsResponse, I as InboxMessage, a as StorageAdapter } from './types-BUXFV_aE.cjs';
3
+ export { C as Clock, b as Consent, E as EventBatch, c as EventContext, d as EventEnvelope, e as EventProperties, f as FlagVariant, g as IdFactory, h as InboxResponse, P as ProdantixConfig, T as Transport, i as TransportRequest } from './types-BUXFV_aE.cjs';
4
4
  import { F as FetchLike } from './http-BCh716Vs.cjs';
5
- export { F as FetchTransport } from './transport-DN9pXyrX.cjs';
5
+ export { F as FetchTransport } from './transport-C9C4hqlF.cjs';
6
6
 
7
7
  type ProdantixErrorCode = 'config' | 'queue_overflow' | 'transport' | 'validation';
8
8
  declare class ProdantixError extends Error {
@@ -131,6 +131,7 @@ declare const SYSTEM_EVENT: {
131
131
  readonly featureFlagCalled: "$feature_flag_called";
132
132
  readonly group: "$group";
133
133
  readonly identify: "$identify";
134
+ readonly pageleave: "$pageleave";
134
135
  readonly pageview: "$pageview";
135
136
  readonly screen: "$screen";
136
137
  readonly set: "$set";
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { C as CaptureOptions, I as IdentifyOptions, L as LocalFlagContext, P as ProdantixClient, c as createClient } from './client-QyKW0LFW.js';
2
- import { J as JsonValue, F as FlagsResponse, I as InboxMessage, a as StorageAdapter } from './types-Q2VNlJbG.js';
3
- export { C as Clock, b as Consent, E as EventBatch, c as EventContext, d as EventEnvelope, e as EventProperties, f as FlagVariant, g as IdFactory, h as InboxResponse, P as ProdantixConfig, T as Transport, i as TransportRequest } from './types-Q2VNlJbG.js';
1
+ export { C as CHECKLIST_TASK_DONE, a as CaptureOptions, G as GUIDE_COMPLETED, b as GUIDE_DISMISSED, c as GUIDE_SHOWN, d as GUIDE_STEP_MISSED, e as GUIDE_STEP_VIEWED, f as Guide, g as GuideAppearance, h as GuideKind, i as GuideMemory, j as GuideStep, k as GuideStepPlacement, l as GuidesClient, I as IdentifyOptions, L as LocalFlagContext, P as ProdantixClient, S as SURVEY_DISMISSED, m as SURVEY_SENT, n as SURVEY_SHOWN, o as Survey, p as SurveyAnswer, q as SurveyAppearance, r as SurveyBranch, s as SurveyMemory, t as SurveyQuestion, u as SurveyQuestionKind, v as SurveyUrlRule, w as SurveysClient, x as createClient, y as guideKey, z as guideProperties, A as isDue, B as isGuideDue, D as nextQuestion, E as responseProperties, F as settledKey, H as taskFor, J as taskKey, K as tasksDone, M as urlMatches } from './client-Cz7M6XJC.js';
2
+ import { J as JsonValue, F as FlagsResponse, I as InboxMessage, a as StorageAdapter } from './types-BUXFV_aE.js';
3
+ export { C as Clock, b as Consent, E as EventBatch, c as EventContext, d as EventEnvelope, e as EventProperties, f as FlagVariant, g as IdFactory, h as InboxResponse, P as ProdantixConfig, T as Transport, i as TransportRequest } from './types-BUXFV_aE.js';
4
4
  import { F as FetchLike } from './http-BCh716Vs.js';
5
- export { F as FetchTransport } from './transport-DKFvkfX4.js';
5
+ export { F as FetchTransport } from './transport-C4mkCaix.js';
6
6
 
7
7
  type ProdantixErrorCode = 'config' | 'queue_overflow' | 'transport' | 'validation';
8
8
  declare class ProdantixError extends Error {
@@ -131,6 +131,7 @@ declare const SYSTEM_EVENT: {
131
131
  readonly featureFlagCalled: "$feature_flag_called";
132
132
  readonly group: "$group";
133
133
  readonly identify: "$identify";
134
+ readonly pageleave: "$pageleave";
134
135
  readonly pageview: "$pageview";
135
136
  readonly screen: "$screen";
136
137
  readonly set: "$set";
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{x as FetchTransport,o as FlagsClient,a as MemoryStorage,r as MessagesClient,y as ProdantixClient,f as SDK_NAME,g as SDK_VERSION,t as SYSTEM_EVENT,u as SYSTEM_EVENTS,m as assignVariant,j as bucket,z as createClient,l as evaluateAll,k as evaluateFlag,n as getVariant,v as isSystemEventName,i as matches,w as systemEvent}from'./chunk-D6PMLUYA.js';import'./chunk-V77KYPOF.js';export{b as ConfigError,a as ProdantixError,d as TransportError,c as ValidationError}from'./chunk-ODN4ZELX.js';import'./chunk-5XGN7UAV.js';//# sourceMappingURL=index.js.map
1
+ export{J as CHECKLIST_TASK_DONE,Z as FetchTransport,r as FlagsClient,H as GUIDE_COMPLETED,I as GUIDE_DISMISSED,E as GUIDE_SHOWN,G as GUIDE_STEP_MISSED,F as GUIDE_STEP_VIEWED,K as GuidesClient,a as MemoryStorage,T as MessagesClient,_ as ProdantixClient,f as SDK_NAME,g as SDK_VERSION,w as SURVEY_DISMISSED,x as SURVEY_SENT,v as SURVEY_SHOWN,V as SYSTEM_EVENT,W as SYSTEM_EVENTS,y as SurveysClient,p as assignVariant,m as bucket,$ as createClient,o as evaluateAll,n as evaluateFlag,q as getVariant,L as guideKey,Q as guideProperties,B as isDue,N as isGuideDue,X as isSystemEventName,l as matches,C as nextQuestion,D as responseProperties,z as settledKey,Y as systemEvent,P as taskFor,M as taskKey,O as tasksDone,A as urlMatches}from'./chunk-L4P6GMBC.js';import'./chunk-V77KYPOF.js';export{b as ConfigError,a as ProdantixError,d as TransportError,c as ValidationError}from'./chunk-ODN4ZELX.js';import'./chunk-5XGN7UAV.js';//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- (function(){'use strict';var Y=Object.defineProperty;var W=(e,n)=>{for(var t in n)Y(e,t,{get:n[t],enumerable:true});};var M={};W(M,{HELP_CSS:()=>X,SEARCH_PAUSE_MS:()=>q,SUGGESTED:()=>I,TYPED_MINIMUM:()=>D,articleRows:()=>g,collectionRows:()=>R,emptyRows:()=>w,firstView:()=>te,frameAddress:()=>G,helpReads:()=>V,helpTab:()=>ne,helpTabs:()=>N,hostOf:()=>Z,isReadable:()=>H,paused:()=>k,reader:()=>U,searchBox:()=>L,setHelping:()=>A,showArticle:()=>y,suggestions:()=>_,whileTyping:()=>oe});var q=300,D=3,I=3,f=e=>`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${e}"/></svg>`,O=f("M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"),B=f("M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"),$=f("M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"),j=f("M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"),K=f("M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"),F=f("M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"),J=f("M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"),Q=f("M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0"),X='[hidden]{display:none!important}.hsearch{display:flex;align-items:center;gap:8px;height:40px;padding:0 12px;color:var(--ink-3);border:1px solid var(--hairline);border-radius:10px}.hsearch:focus-within{border-color:var(--a);box-shadow:0 0 0 3px color-mix(in srgb,var(--a) 20%,transparent)}.hsearch input{flex:1;min-width:0;height:100%;padding:0;border:0;outline:0;background:none;font:inherit;font-size:14px;color:var(--ink)}.hsearch input::placeholder{color:var(--ink-3)}.hsearch svg,.hrow svg{display:block;flex:none;width:16px;height:16px;fill:currentColor}.hlabel{margin:6px 0 0;font-size:12px;font-weight:600;color:var(--ink-3)}.hrows{display:flex;flex-direction:column}.hrow{display:flex;align-items:center;gap:10px;width:100%;padding:10px 2px;font:inherit;font-size:14px;color:var(--ink);text-align:left;background:none;border:0;border-bottom:1px solid var(--hairline);cursor:pointer}.hrow span{flex:1;min-width:0}.hrow small{font-size:12px;color:var(--ink-3)}.hrow svg{color:var(--ink-3)}.hrow:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hnone{margin:0;padding:10px 2px;font-size:13.5px;color:var(--ink-2)}.hview{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:16px}.htabs{display:grid;grid-template-columns:1fr 1fr;border-top:1px solid var(--hairline)}.htab{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 0 10px;font:inherit;font-size:11.5px;font-weight:550;color:var(--ink-3);background:none;border:0;cursor:pointer}.htab[aria-selected="true"]{color:var(--a)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hsugg{margin:0 10px 8px;padding:10px 12px 4px;border:1px solid var(--hairline);border-radius:10px}.hsugg p{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--ink-3)}.hsugg .hrow{padding:8px 0;font-size:13.5px}.hsugg .hrow:last-child{border-bottom:0}.hreader{flex:1;min-height:0;display:flex;flex-direction:column}.hbar{flex:none;display:flex;align-items:center;gap:6px;height:52px;padding:0 8px;border-bottom:1px solid var(--hairline)}.hbar b{flex:1;min-width:0;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hbtn{display:grid;place-items:center;flex:none;width:32px;height:32px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink);cursor:pointer}.hbtn svg{display:block;width:20px;height:20px;fill:currentColor}.hbtn:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.hbtn:focus-visible{outline:2px solid var(--a)}.hreader iframe{flex:1;min-height:0;width:100%;border:0}.hblocked{flex:1;display:flex;flex-direction:column;gap:8px;padding:20px 18px}.hblocked h3{margin:0;font-size:18px;font-weight:640;letter-spacing:-.015em}.hblocked a{font-size:14px;color:var(--ink);text-decoration:underline}.hmore{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;margin:6px 18px 16px;padding:12px 14px;font-size:13.5px;background:var(--fill);border-radius:10px}.hmore button{padding:7px 14px;font:inherit;font-size:13px;font-weight:600;color:#fff;white-space:nowrap;background:var(--a);border:0;border-radius:8px;cursor:pointer}.hmore button:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.hrow,.htab,.hmore,.hlabel,.hnone,.hsugg p{line-height:1.45}';function L(e,n){let t=document.createElement("label");t.className="hsearch",t.innerHTML=O;let o=document.createElement("input");o.type="search",o.placeholder=e.searchPlaceholder,o.setAttribute("aria-label",e.searchPlaceholder);let i=k(n);return o.addEventListener("input",()=>i(o.value.trim())),t.append(o),t}function k(e){let n;return t=>{clearTimeout(n),n=setTimeout(()=>e(t),300);}}var P=/^https?:\/\//i,H=e=>P.test(e.url)&&P.test(e.embedUrl);function g(e,n,t,o){e.replaceChildren();let i=n.filter(H);if(i.length===0&&t!==null){let r=document.createElement("p");r.className="hnone",r.textContent=t,e.append(r);}for(let r of i){let c=document.createElement("button");c.type="button",c.className="hrow",c.innerHTML=$;let l=document.createElement("span");l.textContent=r.title,c.append(l),c.addEventListener("click",()=>o(r)),e.append(c);}return e}function R(e,n,t){e.replaceChildren();for(let o of n){let i=document.createElement("button");i.type="button",i.className="hrow";let r=document.createElement("span");r.textContent=o.title;let c=document.createElement("small");c.textContent=String(o.articles),i.append(r,c),i.insertAdjacentHTML("beforeend",B),i.addEventListener("click",()=>t(o)),e.append(i);}return e}function w(){let e=document.createElement("div");return e.className="hrows",e}function N(e,n){let t=document.createElement("div");t.className="htabs",t.setAttribute("role","tablist");let o=(i,r,c)=>{let l=document.createElement("button");return l.type="button",l.className="htab",l.setAttribute("role","tab"),l.setAttribute("aria-selected",String(!c)),l.innerHTML=r,l.append(i),l.addEventListener("click",()=>n(c)),l};return t.append(o(e.messagesTab,j,false),o(e.helpTab,K,true)),t}function _(e,n,t){let o=document.createElement("div");o.className="hsugg";let i=document.createElement("p");return i.textContent=e.mightHelp,o.append(i,...g(w(),n.filter(H).slice(0,3),null,t).children),o}function G(e,n){return `${e}${e.includes("?")?"&":"?"}scheme=${n}`}function U(e,n,t,o,i){var C;let r=document.createElement("section");r.className="hreader";let c=document.createElement("div");c.className="hbar";let l=(E,S,b)=>{let h=document.createElement("button");return h.type="button",h.className="hbtn",h.setAttribute("aria-label",E),h.title=E,h.innerHTML=S,h.addEventListener("click",b),h},u=document.createElement("b");u.textContent=(C=e.trail.at(-1))!=null?C:e.title;let s=document.createElement("a");s.className="hbtn",s.href=e.url,s.target="_blank",s.rel="noopener noreferrer",s.setAttribute("aria-label",n.openOnSite),s.title=n.openOnSite,s.innerHTML=J,c.append(l(n.back,F,i.back),u,s,l(t,Q,i.close));let d=document.createElement("iframe");d.title=e.title,d.setAttribute("sandbox","allow-popups allow-popups-to-escape-sandbox"),d.setAttribute("referrerpolicy","no-referrer"),d.setAttribute("src",G(e.embedUrl,o));let x=document.createElement("div");x.className="hmore";let a=document.createElement("span");a.textContent=n.stillNeedHelp;let p=document.createElement("button");p.type="button",p.textContent=n.messageUs,p.addEventListener("click",i.messageUs),x.append(a,p),r.append(c,d,x);let m=new URL(e.embedUrl).origin,T=E=>{var z;if(!r.isConnected){document.removeEventListener("securitypolicyviolation",T);return}if(!((z=E.blockedURI)!=null?z:"").startsWith(m)||!d.isConnected)return;let b=document.createElement("div");b.className="hblocked";let h=document.createElement("h3");h.textContent=e.title;let v=document.createElement("a");v.href=e.url,v.target="_blank",v.rel="noopener noreferrer",v.textContent=n.readOnSite,b.append(h,v),d.replaceWith(b);};return document.addEventListener("securitypolicyviolation",T),r}function V(e){let n=async(t,o="")=>{var i,r;return (r=(i=await e(o,t))==null?void 0:i.articles)!=null?r:[]};return {articles:t=>n({q:t}),collectionArticles:t=>n({collection:t}),collections:async()=>{var t,o;return (o=(t=await e("/collections",{}))==null?void 0:t.collections)!=null?o:[]},popularArticles:()=>n({},"/popular")}}function Z(e,n){let t=e.helpCentre?V(e.helpCentre.bind(e)):e;return t.articles&&t.popularArticles?{...n,source:t}:null}var ee=e=>{var n;return e==="dark"||e==="light"?e:(n=globalThis.matchMedia)!=null&&n.call(globalThis,"(prefers-color-scheme: dark)").matches?"dark":"light"};function A(e,n){e.classList.toggle("helping",n);for(let t of e.children)!(t instanceof HTMLElement)||t.matches(".header, .away, .htabs, .hreader")||(t.hidden=t.classList.contains("hview")?!n:n);e.querySelectorAll(".htab").forEach((t,o)=>t.setAttribute("aria-selected",String(o===1?n:!n)));}function y(e,n){var c;let{panel:t}=e,o=[...t.children].filter(l=>l instanceof HTMLElement&&!l.hidden),i=()=>{r.remove();for(let l of o)l.hidden=false;},r=U(n,e.words,e.closeLabel,ee(e.scheme),{back:i,close:e.close,messageUs:()=>{var l;i(),t.querySelector(".htabs")&&A(t,false),(l=t.querySelector('.composer input:not([type="file"])'))==null||l.focus();}});for(let l of o)l.hidden=true;t.append(r),(c=r.querySelector("button"))==null||c.focus();}function te(e,n){let t=w(),o=r=>y(e,r),i=async()=>{var r,c,l;g(t,((l=await((c=(r=e.source).popularArticles)==null?void 0:c.call(r)))!=null?l:[]).filter(H).slice(0,3),null,o);};n.append(L(e.words,async r=>{var c,l,u;if(!r)return i();g(t,(u=await((l=(c=e.source).articles)==null?void 0:l.call(c,r)))!=null?u:[],e.words.noMatches,o);}),t),i();}function ne(e){let{panel:n,source:t,words:o}=e,i=document.createElement("div");i.className="hview",i.hidden=true;let r=document.createElement("p");r.className="hlabel";let c=w(),l=a=>y(e,a),u=async a=>{var p,m;r.textContent=a.title,g(c,(m=await((p=t.collectionArticles)==null?void 0:p.call(t,a.title)))!=null?m:[],o.noMatches,l);},s=async()=>{var a,p;r.hidden=false,r.textContent=o.collections,R(c,(p=await((a=t.collections)==null?void 0:a.call(t)))!=null?p:[],m=>void u(m));};i.append(L(o,async a=>{var p,m;if(!a)return s();r.hidden=true,g(c,(m=await((p=t.articles)==null?void 0:p.call(t,a)))!=null?m:[],o.noMatches,l);}),r,c);let d=false,x=N(o,a=>{A(n,a),a&&!d&&(d=true,s());});n.append(i,x);}function oe(e,n,t){let o=k(async i=>{var c,l,u,s,d;if((c=e.panel.querySelector(".hsugg"))==null||c.remove(),i.length<3)return;let r=((s=await((u=(l=e.source).articles)==null?void 0:u.call(l,i)))!=null?s:[]).filter(H);n.value.trim()!==i||r.length===0||((d=e.panel.querySelector(".hsugg"))==null||d.remove(),t.before(_(e.words,r,x=>y(e,x))));});n.addEventListener("input",()=>o(n.value.trim()));}window.prodantixMessengerHelp=M;
1
+ (function(){'use strict';var O=Object.defineProperty;var q=(e,n)=>{for(var t in n)O(e,t,{get:n[t],enumerable:true});};var M={};q(M,{HELP_CSS:()=>re,REACTIONS:()=>N,SEARCH_PAUSE_MS:()=>B,SUGGESTED:()=>$,TYPED_MINIMUM:()=>D,articleRows:()=>v,collectionRows:()=>U,emptyRows:()=>A,faces:()=>I,feedbackOf:()=>W,firstView:()=>le,frameAddress:()=>F,helpReads:()=>V,helpTab:()=>ae,helpTabs:()=>_,hostOf:()=>oe,isReadable:()=>E,paused:()=>L,reader:()=>Y,searchBox:()=>y,setHelping:()=>C,showArticle:()=>w,suggestions:()=>G,whileTyping:()=>ce});var B=300,D=3,$=3,g=e=>`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${e}"/></svg>`,j=g("M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"),K=g("M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"),J=g("M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"),Q=g("M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"),X=g("M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"),Z=g("M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"),ee=g("M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"),k=e=>`<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" aria-hidden="true"><circle cx="8" cy="8" r="6.4"/><circle cx="6" cy="6.6" r=".7" fill="currentColor" stroke="none"/><circle cx="10" cy="6.6" r=".7" fill="currentColor" stroke="none"/><path d="${e}"/></svg>`,te={disappointed:k("M5.6 11.4c.7-1 1.5-1.4 2.4-1.4s1.7.4 2.4 1.4"),neutral:k("M5.6 10.6h4.8"),smiley:k("M5.6 9.8c.7 1 1.5 1.4 2.4 1.4s1.7-.4 2.4-1.4")},N=["disappointed","neutral","smiley"],ne=g("M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0"),re='[hidden]{display:none!important}.hsearch{display:flex;align-items:center;gap:8px;height:40px;padding:0 12px;color:var(--ink-3);border:1px solid var(--hairline);border-radius:10px}.hsearch:focus-within{border-color:var(--a);box-shadow:0 0 0 3px color-mix(in srgb,var(--a) 20%,transparent)}.hsearch input{flex:1;min-width:0;height:100%;padding:0;border:0;outline:0;background:none;font:inherit;font-size:14px;color:var(--ink)}.hsearch input::placeholder{color:var(--ink-3)}.hsearch svg,.hrow svg{display:block;flex:none;width:16px;height:16px;fill:currentColor}.hlabel{margin:6px 0 0;font-size:12px;font-weight:600;color:var(--ink-3)}.hrows{display:flex;flex-direction:column}.hrow{display:flex;align-items:center;gap:10px;width:100%;padding:10px 2px;font:inherit;font-size:14px;color:var(--ink);text-align:left;background:none;border:0;border-bottom:1px solid var(--hairline);cursor:pointer}.hrow span{flex:1;min-width:0}.hrow small{font-size:12px;color:var(--ink-3)}.hrow svg{color:var(--ink-3)}.hrow:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hnone{margin:0;padding:10px 2px;font-size:13.5px;color:var(--ink-2)}.hview{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:16px}.htabs{display:grid;grid-template-columns:1fr 1fr;border-top:1px solid var(--hairline)}.htab{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 0 10px;font:inherit;font-size:11.5px;font-weight:550;color:var(--ink-3);background:none;border:0;cursor:pointer}.htab[aria-selected="true"]{color:var(--a)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hsugg{margin:0 10px 8px;padding:10px 12px 4px;border:1px solid var(--hairline);border-radius:10px}.hsugg p{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--ink-3)}.hsugg .hrow{padding:8px 0;font-size:13.5px}.hsugg .hrow:last-child{border-bottom:0}.hreader{flex:1;min-height:0;display:flex;flex-direction:column}.hbar{flex:none;display:flex;align-items:center;gap:6px;height:52px;padding:0 8px;border-bottom:1px solid var(--hairline)}.hbar b{flex:1;min-width:0;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hbtn{display:grid;place-items:center;flex:none;width:32px;height:32px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink);cursor:pointer}.hbtn svg{display:block;width:20px;height:20px;fill:currentColor}.hbtn:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.hbtn:focus-visible{outline:2px solid var(--a)}.hreader iframe{flex:1;min-height:0;width:100%;border:0}.hblocked{flex:1;display:flex;flex-direction:column;gap:8px;padding:20px 18px}.hblocked h3{margin:0;font-size:18px;font-weight:640;letter-spacing:-.015em}.hblocked a{font-size:14px;color:var(--ink);text-decoration:underline}.hmore{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;margin:6px 18px 16px;padding:12px 14px;font-size:13.5px;background:var(--fill);border-radius:10px}.hmore button{padding:7px 14px;font:inherit;font-size:13px;font-weight:600;color:#fff;white-space:nowrap;background:var(--a);border:0;border-radius:8px;cursor:pointer}.hmore button:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.hreact{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;margin:10px 18px 0}.hask{font-size:13.5px;line-height:1.45;color:var(--ink-2)}.hfaces{display:flex;gap:6px}.hface{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:10px;background:none;color:var(--ink-3);cursor:pointer}.hface svg{width:24px;height:24px}.hface:hover{color:var(--ink);background:color-mix(in srgb,currentColor 10%,transparent)}.hface[aria-pressed="true"]{color:var(--a);background:color-mix(in srgb,var(--a) 14%,transparent)}.hface:focus-visible{outline:2px solid var(--a);outline-offset:2px}.hrow,.htab,.hmore,.hlabel,.hnone,.hsugg p{line-height:1.45}';function y(e,n){let t=document.createElement("label");t.className="hsearch",t.innerHTML=j;let o=document.createElement("input");o.type="search",o.placeholder=e.searchPlaceholder,o.setAttribute("aria-label",e.searchPlaceholder);let r=L(n);return o.addEventListener("input",()=>r(o.value.trim())),t.append(o),t}function L(e){let n;return t=>{clearTimeout(n),n=setTimeout(()=>e(t),300);}}var z=/^https?:\/\//i,E=e=>z.test(e.url)&&z.test(e.embedUrl);function v(e,n,t,o){e.replaceChildren();let r=n.filter(E);if(r.length===0&&t!==null){let i=document.createElement("p");i.className="hnone",i.textContent=t,e.append(i);}for(let i of r){let l=document.createElement("button");l.type="button",l.className="hrow",l.innerHTML=J;let a=document.createElement("span");a.textContent=i.title,l.append(a),l.addEventListener("click",()=>o(i)),e.append(l);}return e}function U(e,n,t){e.replaceChildren();for(let o of n){let r=document.createElement("button");r.type="button",r.className="hrow";let i=document.createElement("span");i.textContent=o.title;let l=document.createElement("small");l.textContent=String(o.articles),r.append(i,l),r.insertAdjacentHTML("beforeend",K),r.addEventListener("click",()=>t(o)),e.append(r);}return e}function A(){let e=document.createElement("div");return e.className="hrows",e}function _(e,n){let t=document.createElement("div");t.className="htabs",t.setAttribute("role","tablist");let o=(r,i,l)=>{let a=document.createElement("button");return a.type="button",a.className="htab",a.setAttribute("role","tab"),a.setAttribute("aria-selected",String(!l)),a.innerHTML=i,a.append(r),a.addEventListener("click",()=>n(l)),a};return t.append(o(e.messagesTab,Q,false),o(e.helpTab,X,true)),t}function G(e,n,t){let o=document.createElement("div");o.className="hsugg";let r=document.createElement("p");return r.textContent=e.mightHelp,o.append(r,...v(A(),n.filter(E).slice(0,3),null,t).children),o}function I(e,n){let t=document.createElement("div");t.className="hreact",t.setAttribute("role","group"),t.setAttribute("aria-label",e.rateArticle);let o=document.createElement("span");o.className="hask",o.setAttribute("aria-live","polite"),o.textContent=e.wasItHelpful;let r=document.createElement("span");r.className="hfaces";let i=N.map(c=>{let s=document.createElement("button");return s.type="button",s.className="hface",s.dataset.face=c,s.setAttribute("aria-label",e[c]),s.setAttribute("aria-pressed","false"),s.title=e[c],s.innerHTML=te[c],s}),l=c=>{for(let s of i)s.setAttribute("aria-pressed",String(s.dataset.face===c));o.textContent=c===null?e.wasItHelpful:e.thanks;},a=null;for(let c of i){let s=c.dataset.face;c.addEventListener("click",async()=>{let d=a;a=s,l(s),!await n(s)&&(a=d,l(d));});}return r.append(...i),t.append(o,r),t}function F(e,n){return `${e}${e.includes("?")?"&":"?"}scheme=${n}`}function Y(e,n,t,o,r){var P;let i=document.createElement("section");i.className="hreader";let l=document.createElement("div");l.className="hbar";let a=(m,H,f)=>{let b=document.createElement("button");return b.type="button",b.className="hbtn",b.setAttribute("aria-label",m),b.title=m,b.innerHTML=H,b.addEventListener("click",f),b},c=document.createElement("b");c.textContent=(P=e.trail.at(-1))!=null?P:e.title;let s=document.createElement("a");s.className="hbtn",s.href=e.url,s.target="_blank",s.rel="noopener noreferrer",s.setAttribute("aria-label",n.openOnSite),s.title=n.openOnSite,s.innerHTML=ee,l.append(a(n.back,Z,r.back),c,s,a(t,ne,r.close));let d=document.createElement("iframe");d.title=e.title,d.setAttribute("sandbox","allow-popups allow-popups-to-escape-sandbox"),d.setAttribute("referrerpolicy","no-referrer");let x=document.createElement("div");x.className="hmore";let p=document.createElement("span");p.textContent=n.stillNeedHelp;let u=document.createElement("button");u.type="button",u.textContent=n.messageUs,u.addEventListener("click",r.messageUs),x.append(p,u),r.react?i.append(l,d,I(n,r.react),x):i.append(l,d,x);let h=new URL(e.embedUrl).origin,T=()=>{let m=document.createElement("div");m.className="hblocked";let H=document.createElement("h3");H.textContent=e.title;let f=document.createElement("a");f.href=e.url,f.target="_blank",f.rel="noopener noreferrer",f.textContent=n.readOnSite,m.append(H,f),d.replaceWith(m);},R=m=>{var f;if(!i.isConnected){document.removeEventListener("securitypolicyviolation",R);return}((f=m.blockedURI)!=null?f:"").startsWith(h)&&d.isConnected&&T();};document.addEventListener("securitypolicyviolation",R);let S=m=>{m&&URL.canParse(m)&&new URL(m).origin===h?d.setAttribute("src",F(m,o)):T();};return typeof r.address=="string"?S(r.address):r.address.then(S),i}function V(e){let n=async(t,o="")=>{var r,i;return (i=(r=await e(o,t))==null?void 0:r.articles)!=null?i:[]};return {articleFrame:async t=>{var o,r;return (r=(o=await e(`/${encodeURIComponent(t.pageId)}/frame`,{}))==null?void 0:o.url)!=null?r:null},articles:t=>n({q:t}),collectionArticles:t=>n({collection:t}),collections:async()=>{var t,o;return (o=(t=await e("/collections",{}))==null?void 0:t.collections)!=null?o:[]},popularArticles:()=>n({},"/popular")}}var W=e=>{let{cameFrom:n,helpCentre:t}=e;if(!n||!t)return;let o=async(r,i,l)=>await t.call(e,`/${encodeURIComponent(r.pageId)}/${i}`,{},{...l,language:r.language})!==null;return {cameFrom:n.bind(e),opened:r=>o(r,"opened",{}),react:(r,i)=>o(r,"reaction",{reaction:i})}};function oe(e,n){let t=e.helpCentre?V(e.helpCentre.bind(e)):e;return t.articles&&t.popularArticles?{...n,feedback:W(e),source:t}:null}var ie=e=>{var n;return e==="dark"||e==="light"?e:(n=globalThis.matchMedia)!=null&&n.call(globalThis,"(prefers-color-scheme: dark)").matches?"dark":"light"};function C(e,n){e.classList.toggle("helping",n);for(let t of e.children)!(t instanceof HTMLElement)||t.matches(".header, .away, .htabs, .hreader")||(t.hidden=t.classList.contains("hview")?!n:n||t.classList.contains("tview"));e.querySelectorAll(".htab").forEach((t,o)=>t.setAttribute("aria-selected",String(o===1?n:o===0&&!n)));}function w(e,n){var a;let{panel:t}=e,o=[...t.children].filter(c=>c instanceof HTMLElement&&!c.hidden),r=()=>{l.remove();for(let c of o)c.hidden=false;},{feedback:i}=e,l=Y(n,e.words,e.closeLabel,ie(e.scheme),{address:e.source.articleFrame?e.source.articleFrame(n):n.embedUrl,back:r,close:e.close,messageUs:()=>{var c;i==null||i.cameFrom(n),r(),t.querySelector(".htabs")&&C(t,false),(c=t.querySelector('.composer input:not([type="file"])'))==null||c.focus();},react:i?c=>i.react(n,c):void 0});for(let c of o)c.hidden=true;t.append(l),i==null||i.opened(n),(a=l.querySelector("button"))==null||a.focus();}function le(e,n){let t=A(),o=i=>w(e,i),r=async()=>{var i,l,a;v(t,((a=await((l=(i=e.source).popularArticles)==null?void 0:l.call(i)))!=null?a:[]).filter(E).slice(0,3),null,o);};n.append(y(e.words,async i=>{var l,a,c;if(!i)return r();v(t,(c=await((a=(l=e.source).articles)==null?void 0:a.call(l,i)))!=null?c:[],e.words.noMatches,o);}),t),r();}function ae(e){let{panel:n,source:t,words:o}=e,r=document.createElement("div");r.className="hview",r.hidden=true;let i=document.createElement("p");i.className="hlabel";let l=A(),a=p=>w(e,p),c=async p=>{var u,h;i.textContent=p.title,v(l,(h=await((u=t.collectionArticles)==null?void 0:u.call(t,p.title)))!=null?h:[],o.noMatches,a);},s=async()=>{var p,u;i.hidden=false,i.textContent=o.collections,U(l,(u=await((p=t.collections)==null?void 0:p.call(t)))!=null?u:[],h=>void c(h));};r.append(y(o,async p=>{var u,h;if(!p)return s();i.hidden=true,v(l,(h=await((u=t.articles)==null?void 0:u.call(t,p)))!=null?h:[],o.noMatches,a);}),i,l);let d=false,x=_(o,p=>{C(n,p),p&&!d&&(d=true,s());});n.append(r,x);}function ce(e,n,t){let o=L(async r=>{var l,a,c,s,d;if((l=e.panel.querySelector(".hsugg"))==null||l.remove(),r.length<3)return;let i=((s=await((c=(a=e.source).articles)==null?void 0:c.call(a,r)))!=null?s:[]).filter(E);n.value.trim()!==r||i.length===0||((d=e.panel.querySelector(".hsugg"))==null||d.remove(),t.before(G(e.words,i,x=>w(e,x))));});n.addEventListener("input",()=>o(n.value.trim()));}window.prodantixMessengerHelp=M;
2
2
  })();//# sourceMappingURL=messenger-help.iife.js.map
3
3
  //# sourceMappingURL=messenger-help.iife.js.map
@@ -0,0 +1,3 @@
1
+ (function(){'use strict';var _=Object.defineProperty;var $=(t,r)=>{for(var n in r)_(t,n,{get:r[n],enumerable:true});};var H={};$(H,{POLL_MS:()=>P,TICKETS_CSS:()=>w,control:()=>z,conversation:()=>C,form:()=>F,list:()=>k,ticketsTab:()=>V,updatedAgo:()=>S,valuesOf:()=>A});var P=15e3,T=(t,r)=>{let n=document.createElement("option");return n.value=r,n.textContent=t,n},E=t=>`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${t}"/></svg>`,q=E("M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"),R=E("M22 10V6c0-1.11-.9-2-2-2H4c-1.1 0-1.99.89-1.99 2v4c1.1 0 1.99.9 1.99 2s-.89 2-2 2v4c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-4c-1.1 0-2-.9-2-2s.9-2 2-2zm-9 7.5h-2v-2h2v2zm0-4.5h-2v-2h2v2zm0-4.5h-2v-2h2v2z"),O=E("M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"),w='[hidden]{display:none!important}.htabs{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;grid-template-columns:none;border-top:1px solid var(--hairline)}.htab{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 0 10px;font:inherit;font-size:11.5px;font-weight:550;line-height:1.45;color:var(--ink-3);background:none;border:0;cursor:pointer}.htab[aria-selected="true"]{color:var(--a)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.tview{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:16px}.tview h3{margin:0;font-size:16px;font-weight:640}.tbar{display:flex;align-items:center;gap:6px}.tbar h3{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tback{display:grid;place-items:center;flex:none;width:44px;height:44px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink);cursor:pointer}.tback svg{width:20px;height:20px;fill:currentColor}.tback:focus-visible{outline:2px solid var(--a)}.trow{display:flex;flex-direction:column;gap:2px;width:100%;min-height:44px;padding:10px 2px;font:inherit;font-size:14px;line-height:1.45;color:var(--ink);text-align:left;background:none;border:0;border-bottom:1px solid var(--hairline);cursor:pointer}.trow small{font-size:12px;color:var(--ink-3)}.trow:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.tnote{margin:0;font-size:13.5px;line-height:1.45;color:var(--ink-2)}.tform{display:flex;flex-direction:column;gap:10px}.tform label{display:flex;flex-direction:column;gap:4px;font-size:12.5px;font-weight:600;color:var(--ink-2)}.tform label.tcheck{flex-direction:row;align-items:center;gap:8px}.tform input,.tform select,.tform textarea{min-height:44px;padding:8px 12px;font:inherit;font-size:14px;font-weight:400;color:var(--ink);background:var(--fill);border:1px solid var(--hairline);border-radius:8px}.tform textarea{min-height:88px;resize:vertical}.tform input[type="checkbox"]{min-height:0;width:20px;height:20px}.tform :focus-visible{outline:2px solid var(--a);outline-offset:1px}.tsend{align-self:flex-start;min-height:44px;padding:0 18px;font:inherit;font-size:14px;font-weight:600;color:#fff;background:var(--a);border:0;border-radius:8px;cursor:pointer}.tsend:disabled{opacity:.6;cursor:default}.tsend:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.tfail{margin:0;padding:10px 12px;font-size:13.5px;color:#b91c1c;background:color-mix(in srgb,#dc2626 12%,transparent);border-radius:8px}.tlog{display:flex;flex-direction:column;gap:8px}';function V(t,r,n){var u;let{edge:e,visitor:a}=r;if(!e||!a)return;let o=e.bind(r),c=t.getRootNode();if(c instanceof ShadowRoot&&!c.querySelector("style[data-tickets]")){let b=document.createElement("style");b.dataset.tickets="",b.textContent=w,c.append(b);}let s=document.createElement("div");s.className="tview",s.hidden=true;let i=t.querySelector(".htabs"),l=i!=null?i:document.createElement("div");i||(l.className="htabs",l.setAttribute("role","tablist"),l.append(I(n.messagesTab,q,true)),t.append(l));let p=I(n.ticketsTab,R,false);l.append(p),l.before(s);let f=b=>{for(let d of t.children)!(d instanceof HTMLElement)||d.matches(".header, .away, .htabs, .hreader")||(d.hidden=d===s?!b:b||d.classList.contains("hview"));l.querySelectorAll(".htab").forEach(d=>d.setAttribute("aria-selected",String(b?d===p:d===l.firstElementChild)));};p.addEventListener("click",()=>{f(true),k(s,o,a,n);}),i||(u=l.firstElementChild)==null||u.addEventListener("click",()=>f(false));}function I(t,r,n){let e=document.createElement("button");return e.type="button",e.className="htab",e.setAttribute("role","tab"),e.setAttribute("aria-selected",String(n)),e.innerHTML=r,e.append(t),e}var W=t=>({user_hash:t.userHash,user_id:t.userId});function L(t,r,n){let e=document.createElement("div");if(e.className="tbar",r){let o=document.createElement("button");o.type="button",o.className="tback",o.setAttribute("aria-label",n!=null?n:""),o.innerHTML=O,o.addEventListener("click",r),e.append(o);}let a=document.createElement("h3");return a.textContent=t,e.append(a),e}function y(t,r="tnote"){let n=document.createElement("p");return n.className=r,n.textContent=t,n}function N(t){let r=document.createElement("button");return r.type="submit",r.className="tsend",r.textContent=t.send,r}function S(t,r,n){var s;let e=Math.round((Date.parse(t)-r)/1e3),a=[["day",86400],["hour",3600],["minute",60]],[o,c]=(s=a.find(([,i])=>Math.abs(e)>=i))!=null?s:["second",1];return new Intl.RelativeTimeFormat(n,{numeric:"auto"}).format(Math.round(e/c),o)}async function k(t,r,n,e){var s;let a=await r(`/v1/tickets?${new URLSearchParams(W(n))}`),o=document.createElement("button");o.type="button",o.className="tsend",o.textContent=e.openTicket,o.addEventListener("click",()=>void F(t,r,n,e));let c=(s=a==null?void 0:a.tickets)!=null?s:[];t.replaceChildren(L(e.yourTickets),...a?[]:[y(e.failed,"tfail")],...a&&c.length===0?[y(e.noTickets)]:[],...c.map(i=>{let l=document.createElement("button");l.type="button",l.className="trow";let p=document.createElement("span");p.textContent=`#${i.number} ${i.title}`;let f=document.createElement("small");return f.textContent=`${i.stateLabel} \xB7 ${S(i.updatedAt,Date.now())}`,l.append(p,f),l.disabled=i.conversationId===null,l.addEventListener("click",async()=>{let u=await r(`/v1/tickets/${i.number}/conversation`,{userHash:n.userHash,userId:n.userId});u&&C(t,r,n,e,`#${i.number} ${i.title}`,u);}),l}),o);}function z(t,r){var a;let n=document.createElement("label");if(n.append(t.label),t.attributeType==="boolean"){n.className="tcheck";let o=document.createElement("input");return o.type="checkbox",o.name=t.key,n.prepend(o),n}if(t.attributeType==="enum"||t.attributeType==="multi_enum"){let o=document.createElement("select");o.name=t.key,o.required=t.required,o.multiple=t.attributeType==="multi_enum",o.multiple||o.append(T(r.choose,""));for(let c of t.options)o.append(T(c.label,c.value));return n.append(o),n}let e=document.createElement(t.attributeType==="long_text"?"textarea":"input");return e.name=t.key,e.required=t.required,e instanceof HTMLInputElement&&(e.type=(a={date:"date",number:"number",phone:"tel",url:"url"}[t.attributeType])!=null?a:"text",t.attributeType==="number"&&(e.step="any"),t.attributeType==="phone"&&(e.pattern="\\+[1-9][0-9]{1,14}"),t.attributeType==="url"&&(e.pattern="https?://\\S+"),t.attributeType==="currency"&&(e.pattern="[0-9]+([.,][0-9]+)? *[A-Za-z]{3}",e.placeholder="12.50 EUR")),n.append(e),n}function A(t,r){var e;let n={};for(let a of r){let o=t.elements.namedItem(a.key);if(o instanceof HTMLSelectElement&&o.multiple){let s=[...o.selectedOptions].map(i=>i.value);s.length>0&&(n[a.key]=s);continue}if(o instanceof HTMLInputElement&&o.type==="checkbox"){n[a.key]=o.checked;continue}if(!(o instanceof HTMLInputElement||o instanceof HTMLSelectElement||o instanceof HTMLTextAreaElement))continue;let c=o.value.trim();if(c!=="")if(a.attributeType==="number")n[a.key]=Number(c);else if(a.attributeType==="currency"){let[,s="",i=""]=(e=/^([0-9]+(?:[.,][0-9]+)?) *([A-Za-z]{3})$/.exec(c))!=null?e:[];n[a.key]={amount:Number(s.replace(",",".")),currency:i.toUpperCase()};}else n[a.key]=c;}return n}async function F(t,r,n,e){var M;let a=()=>void k(t,r,n,e),o=await r("/v1/tickets/forms"),c=(M=o==null?void 0:o.forms)!=null?M:[],s=document.createElement("form");s.className="tform";let i=document.createElement("select");i.name="typeId",i.required=true;for(let x of c)i.append(T(x.name,x.typeId));let l=document.createElement("label");l.append(e.whatYouNeed,i);let p=document.createElement("input");p.name="title",p.required=true,p.maxLength=200;let f=document.createElement("label");f.append(e.subject,p);let u=document.createElement("div");u.className="tform";let b=()=>c.find(x=>x.typeId===i.value),d=()=>{var x,g;u.replaceChildren(...((g=(x=b())==null?void 0:x.fields)!=null?g:[]).map(v=>z(v,e)));};i.addEventListener("change",d),d();let m=N(e),h=y(e.failed,"tfail");h.hidden=true,h.setAttribute("role","alert"),s.append(l,f,u,y(e.repliesHere),h,m),s.addEventListener("submit",async x=>{x.preventDefault(),m.disabled=true,h.hidden=true;let g=b(),v=g?await r("/v1/tickets",{attributes:A(s,g.fields),distinctId:n.distinctId,title:p.value.trim(),typeId:g.typeId,userHash:n.userHash,userId:n.userId}):null;if(m.disabled=false,!v){h.hidden=false;return}C(t,r,n,e,`#${v.number} ${p.value.trim()}`,v.conversation);}),t.replaceChildren(L(e.openTicket,a,e.back),...o?[s]:[y(e.failed,"tfail")]),i.focus();}async function C(t,r,n,e,a,o){let c=`/v1/conversations/${encodeURIComponent(o.conversationId)}`,s=document.createElement("div");s.className="tlog",s.setAttribute("role","log"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-label",a);let i=new Set,l=d=>{if(i.has(d.id))return;i.add(d.id);let m=document.createElement("div");m.className=`turn ${d.authorKind}`,m.textContent=d.body,s.append(m);},p=async()=>{var d,m;for(let h of (m=(d=await r(c,void 0,o.token))==null?void 0:d.turns)!=null?m:[])l(h);},f=document.createElement("form");f.className="composer";let u=document.createElement("input");u.type="text",u.required=true,u.placeholder=e.reply,u.setAttribute("aria-label",e.reply),f.append(u,N(e)),f.addEventListener("submit",async d=>{d.preventDefault();let m=u.value.trim();if(!m)return;u.value="";let h=await r(`${c}/turns`,{body:m},o.token);h?l(h.turn):u.value=m;}),t.replaceChildren(L(a,()=>void k(t,r,n,e),e.back),s,f),await p();let b=setInterval(()=>{if(!t.isConnected||!s.isConnected){clearInterval(b);return}p();},15e3);u.focus();}window.prodantixMessengerTickets=H;
2
+ })();//# sourceMappingURL=messenger-tickets.iife.js.map
3
+ //# sourceMappingURL=messenger-tickets.iife.js.map
@@ -1,2 +1,2 @@
1
- 'use strict';var f=Object.defineProperty;var d=(e,t,r)=>t in e?f(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var c=(e,t,r)=>d(e,typeof t!="symbol"?t+"":t,r);var l=class extends Error{constructor(r,n,o){super(n,o);c(this,"code");this.code=r,this.name="ProdantixError";}};var i=class extends l{constructor(r,n,o){super("transport",r,o);c(this,"status");this.status=n,this.name="TransportError";}};function g(e){if(e)return e;let t=globalThis.fetch;if(typeof t=="function")return t.bind(globalThis)}function p(e){return e.replace(/\/+$/,"")}var h="prodantix.messenger.config",E=e=>{let t=e.navigator?.languages;return Array.isArray(t)&&t.length>0?t.join(","):e.navigator?.language||e.document?.documentElement?.lang||void 0},u=(e,t)=>`${h}:${e}:${t??""}`;function k(e,t,r){let n=e?.get(u(t,r));if(!n)return null;try{let o=JSON.parse(n);return o?.apiKey===t?o.config:null}catch{return null}}async function v(e){let t=g(e.fetchImpl);if(!t)return e.onError?.(new i("no fetch available for the prodantix messenger")),null;let r=p(e.host),n=u(e.apiKey,e.locale),o=e.locale?`?locale=${encodeURIComponent(e.locale)}`:"";try{let s=await t(`${r}/v1/messenger/config${o}`,{headers:{authorization:`Bearer ${e.apiKey}`},method:"GET"});if(!s.ok)return e.onError?.(new i(`prodantix messenger config: ${s.status}`,s.status)),null;let a=JSON.parse(await s.text());return a.enabled?(e.storage?.set(n,JSON.stringify({apiKey:e.apiKey,config:a})),a):(e.storage?.remove(n),a)}catch(s){return e.onError?.(s),null}}exports.MESSENGER_CACHE_KEY=h;exports.cacheKeyFor=u;exports.cachedMessengerConfig=k;exports.fetchMessengerConfig=v;exports.localeCandidates=E;//# sourceMappingURL=messenger.cjs.map
1
+ 'use strict';var u=Object.defineProperty;var f=(e,t,r)=>t in e?u(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var c=(e,t,r)=>f(e,typeof t!="symbol"?t+"":t,r);var g=class extends Error{constructor(r,n,s){super(n,s);c(this,"code");this.code=r,this.name="ProdantixError";}};var o=class extends g{constructor(r,n,s){super("transport",r,s);c(this,"status");this.status=n,this.name="TransportError";}};function l(e){if(e)return e;let t=globalThis.fetch;if(typeof t=="function")return t.bind(globalThis)}function p(e){return e.replace(/\/+$/,"")}var h="prodantix.messenger.config",S=e=>{let t=e.navigator?.languages;return Array.isArray(t)&&t.length>0?t.join(","):e.navigator?.language||e.document?.documentElement?.lang||void 0},d=(e,t)=>`${h}:${e}:${t??""}`;function E(e,t,r){let n=e?.get(d(t,r));if(!n)return null;try{let s=JSON.parse(n);return s?.apiKey===t?s.config:null}catch{return null}}async function T(e){let t=l(e.fetchImpl);if(!t)return e.onError?.(new o("no fetch available for the prodantix messenger")),null;let r=p(e.host),n=d(e.apiKey,e.locale),s=e.locale?`?locale=${encodeURIComponent(e.locale)}`:"";try{let i=await t(`${r}/v1/messenger/config${s}`,{headers:{authorization:`Bearer ${e.apiKey}`},method:"GET"});if(!i.ok)return e.onError?.(new o(`prodantix messenger config: ${i.status}`,i.status)),null;let a=JSON.parse(await i.text());return a.enabled?(e.storage?.set(n,JSON.stringify({apiKey:e.apiKey,config:a})),a):(e.storage?.remove(n),a)}catch(i){return e.onError?.(i),null}}exports.MESSENGER_CACHE_KEY=h;exports.cacheKeyFor=d;exports.cachedMessengerConfig=E;exports.fetchMessengerConfig=T;exports.localeCandidates=S;//# sourceMappingURL=messenger.cjs.map
2
2
  //# sourceMappingURL=messenger.cjs.map
@@ -1,2 +1,2 @@
1
- export { H as HelpWords, t as MESSENGER_CACHE_KEY, M as MessengerAttachments, e as MessengerConfig, u as MessengerConfigOptions, v as MessengerHelp, w as StarterPrompt, x as cacheKeyFor, y as cachedMessengerConfig, z as fetchMessengerConfig, E as localeCandidates } from './config-g14Jiv1t.cjs';
1
+ export { H as HelpWords, v as MESSENGER_CACHE_KEY, M as MessengerAttachments, h as MessengerConfig, w as MessengerConfigOptions, x as MessengerHelp, y as MessengerTickets, z as StarterPrompt, T as TicketWords, E as cacheKeyFor, G as cachedMessengerConfig, I as fetchMessengerConfig, J as localeCandidates } from './config-Dxf1vAMu.cjs';
2
2
  import './http-BCh716Vs.cjs';
@@ -1,2 +1,2 @@
1
- export { H as HelpWords, t as MESSENGER_CACHE_KEY, M as MessengerAttachments, e as MessengerConfig, u as MessengerConfigOptions, v as MessengerHelp, w as StarterPrompt, x as cacheKeyFor, y as cachedMessengerConfig, z as fetchMessengerConfig, E as localeCandidates } from './config-6ulvfBFp.js';
1
+ export { H as HelpWords, v as MESSENGER_CACHE_KEY, M as MessengerAttachments, h as MessengerConfig, w as MessengerConfigOptions, x as MessengerHelp, y as MessengerTickets, z as StarterPrompt, T as TicketWords, E as cacheKeyFor, G as cachedMessengerConfig, I as fetchMessengerConfig, J as localeCandidates } from './config-Dmk59mPh.js';
2
2
  import './http-BCh716Vs.js';