@lucida-analytics/browser 0.1.4 → 0.1.6

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 (85) hide show
  1. package/README.md +52 -1
  2. package/dist/autocapture.d.ts +1 -1
  3. package/dist/autocapture.js +1 -1
  4. package/dist/{banner-2TSKJ4WK.js → banner-7LEREYUH.js} +1 -1
  5. package/dist/{static/v0.1.4/chunk-32K5P5GN.js → chunk-536QABLP.js} +1 -1
  6. package/dist/{static/v0.1.4/chunk-O4W7SZ2X.js → chunk-EFNCQJI3.js} +1 -1
  7. package/dist/{static/v0.1.4/chunk-3FSDKRIG.js → chunk-UPPUYIIH.js} +1 -1
  8. package/dist/{client--prXZN9c.d.ts → client-pxkkaWtR.d.ts} +2 -2
  9. package/dist/consent.d.ts +9 -3
  10. package/dist/consent.js +1 -1
  11. package/dist/core.d.ts +3 -3
  12. package/dist/core.js +3 -3
  13. package/dist/correlate.d.ts +8 -2
  14. package/dist/correlate.js +1 -1
  15. package/dist/early-access.d.ts +1 -1
  16. package/dist/experiments.d.ts +1 -1
  17. package/dist/flags.d.ts +1 -1
  18. package/dist/forms.d.ts +1 -1
  19. package/dist/guides.d.ts +1 -1
  20. package/dist/heatmaps.d.ts +1 -1
  21. package/dist/host-headers.d.ts +1 -1
  22. package/dist/index.d.ts +15 -5
  23. package/dist/index.js +2 -2
  24. package/dist/inspector.d.ts +1 -1
  25. package/dist/lucida.js +3 -3
  26. package/dist/recommendations.d.ts +1 -1
  27. package/dist/{recorder-IDVKI2RP.js → recorder-4WIMQCLR.js} +1 -1
  28. package/dist/replay.d.ts +2 -2
  29. package/dist/replay.js +1 -1
  30. package/dist/static/v0/autocapture.js +1 -1
  31. package/dist/static/v0/{banner-2TSKJ4WK.js → banner-7LEREYUH.js} +1 -1
  32. package/dist/static/v0/{chunk-32K5P5GN.js → chunk-536QABLP.js} +1 -1
  33. package/dist/{chunk-O4W7SZ2X.js → static/v0/chunk-EFNCQJI3.js} +1 -1
  34. package/dist/{chunk-3FSDKRIG.js → static/v0/chunk-UPPUYIIH.js} +1 -1
  35. package/dist/static/v0/consent.js +1 -1
  36. package/dist/static/v0/core.js +3 -3
  37. package/dist/static/v0/correlate.js +1 -1
  38. package/dist/static/v0/index.js +2 -2
  39. package/dist/static/v0/lucida.js +3 -3
  40. package/dist/static/v0/manifest.json +28 -0
  41. package/dist/static/{v0.1.4/recorder-IDVKI2RP.js → v0/recorder-4WIMQCLR.js} +1 -1
  42. package/dist/static/v0/replay.js +1 -1
  43. package/dist/static/v0.1.6/autocapture.js +1 -0
  44. package/dist/static/{v0.1.4/banner-2TSKJ4WK.js → v0.1.6/banner-7LEREYUH.js} +1 -1
  45. package/dist/{chunk-32K5P5GN.js → static/v0.1.6/chunk-536QABLP.js} +1 -1
  46. package/dist/static/{v0/chunk-O4W7SZ2X.js → v0.1.6/chunk-EFNCQJI3.js} +1 -1
  47. package/dist/static/{v0/chunk-3FSDKRIG.js → v0.1.6/chunk-UPPUYIIH.js} +1 -1
  48. package/dist/static/v0.1.6/consent.js +1 -0
  49. package/dist/static/v0.1.6/core.js +3 -0
  50. package/dist/static/v0.1.6/correlate.js +1 -0
  51. package/dist/static/v0.1.6/index.js +3 -0
  52. package/dist/static/v0.1.6/lucida.js +3 -0
  53. package/dist/static/v0.1.6/manifest.json +28 -0
  54. package/dist/static/{v0/recorder-IDVKI2RP.js → v0.1.6/recorder-4WIMQCLR.js} +1 -1
  55. package/dist/static/v0.1.6/replay.js +1 -0
  56. package/dist/toolbar.d.ts +1 -1
  57. package/dist/{types-DKM0hGl2.d.ts → types-QPJGHOv0.d.ts} +20 -3
  58. package/dist/webmcp.d.ts +1 -1
  59. package/lucida-global.d.ts +24 -0
  60. package/package.json +5 -3
  61. package/storage.json +75 -0
  62. package/dist/static/v0.1.4/autocapture.js +0 -1
  63. package/dist/static/v0.1.4/consent.js +0 -1
  64. package/dist/static/v0.1.4/core.js +0 -3
  65. package/dist/static/v0.1.4/correlate.js +0 -1
  66. package/dist/static/v0.1.4/index.js +0 -3
  67. package/dist/static/v0.1.4/integrity.json +0 -30
  68. package/dist/static/v0.1.4/lucida.js +0 -3
  69. package/dist/static/v0.1.4/replay.js +0 -1
  70. /package/dist/static/{v0.1.4 → v0.1.6}/chunk-AWIQCFGN.js +0 -0
  71. /package/dist/static/{v0.1.4 → v0.1.6}/chunk-FUE3SDQU.js +0 -0
  72. /package/dist/static/{v0.1.4 → v0.1.6}/early-access.js +0 -0
  73. /package/dist/static/{v0.1.4 → v0.1.6}/experiments.js +0 -0
  74. /package/dist/static/{v0.1.4 → v0.1.6}/flags.js +0 -0
  75. /package/dist/static/{v0.1.4 → v0.1.6}/forms.js +0 -0
  76. /package/dist/static/{v0.1.4 → v0.1.6}/guides.js +0 -0
  77. /package/dist/static/{v0.1.4 → v0.1.6}/heatmaps.js +0 -0
  78. /package/dist/static/{v0.1.4 → v0.1.6}/host-headers.js +0 -0
  79. /package/dist/static/{v0.1.4 → v0.1.6}/inspector.js +0 -0
  80. /package/dist/static/{v0.1.4 → v0.1.6}/modules-FANMZRDJ.js +0 -0
  81. /package/dist/static/{v0.1.4 → v0.1.6}/persistent-SLVINN5A.js +0 -0
  82. /package/dist/static/{v0.1.4 → v0.1.6}/recommendations.js +0 -0
  83. /package/dist/static/{v0.1.4 → v0.1.6}/toolbar.js +0 -0
  84. /package/dist/static/{v0.1.4 → v0.1.6}/validation-HGJXZ553.js +0 -0
  85. /package/dist/static/{v0.1.4 → v0.1.6}/webmcp.js +0 -0
package/dist/core.js CHANGED
@@ -1,3 +1,3 @@
1
- var K="lc_consent",ue=["analytics","replay","marketing"],j=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let t=this.opens();this.state={analytics:t,replay:t,marketing:t},this.key=e.storageKey||K;let s=e.storage.get(this.key);if(s)try{let r=JSON.parse(s);for(let o of ue)typeof r[o]=="boolean"&&(this.state[o]=r[o]);this.decided=ue.some(o=>typeof r[o]=="boolean")}catch{}this.waiting=!!e.awaitRemote&&!this.decided,this.waiting&&(this.state={analytics:!1,replay:!1,marketing:!1})}o;modeNow;queueBeforeConsent;state;decided=!1;waiting;geoCookieless=!1;key;listeners=[];opens(){return this.modeNow==="opt_out"&&!(this.o.respectDnt&&this.o.dnt)}get mode(){return this.modeNow}get resolving(){return this.waiting}get anonymous(){return this.geoCookieless&&!this.decided}resolve(e){if(!this.waiting)return this.state.analytics;this.waiting=!1,(e==="opt_in"||e==="opt_out")&&(this.modeNow=e),this.geoCookieless=e==="cookieless";let t=!this.geoCookieless&&this.opens();return this.state={analytics:t,replay:t,marketing:t},t}get(){return{...this.state}}has(e){return this.state[e]}status(e="analytics"){return this.decided?this.state[e]?"granted":"denied":"pending"}get pending(){return this.waiting||this.modeNow==="opt_in"&&!this.state.analytics}set(e){let t=this.get();for(let s of ue)e[s]!==void 0&&(this.state[s]=e[s]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let s of this.listeners)s(this.get(),t)}onChange(e){this.listeners.push(e)}},$=class{constructor(e,t){this.inner=e;this.allowed=t}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,t){this.allowed()?this.inner.set(e,t):this.mem.set(e,t)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,t]of this.mem)t===null?this.inner.remove(e):this.inner.set(e,t);this.mem.clear()}discardBuffered(){this.mem.clear()}};var G=0,R=0;function Fe(n){let e=new Uint8Array(n),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let s=0;s<n;s++)e[s]=Math.floor(Math.random()*256);return e}function w(n=Date.now()){if(n>G){G=n;let o=Fe(2);R=((o[0]??0)<<8|(o[1]??0))&1023}else R++,R>4095&&(G++,R=0);let e=Fe(8),t=new Uint8Array(16),s=G;t[0]=Math.floor(s/2**40)&255,t[1]=Math.floor(s/2**32)&255,t[2]=Math.floor(s/2**24)&255,t[3]=Math.floor(s/2**16)&255,t[4]=Math.floor(s/2**8)&255,t[5]=s&255,t[6]=112|R>>8,t[7]=R&255,t[8]=128|(e[0]??0)&63;for(let o=1;o<8;o++)t[8+o]=e[o]??0;let r=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var Ne="lc_identity",Y=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let o=e.get(Ne),a;try{a=o?JSON.parse(o):void 0}catch{a=void 0}if(a?.distinct_id)this.s=a;else if(s)this.s={distinct_id:"",anon_id:"",identified:!1};else{let l=t??w();this.s={distinct_id:l,anon_id:l,identified:r&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(Ne,JSON.stringify(this.s))}get distinctId(){return this.s.distinct_id}get priorAnonId(){return this.s.identified&&this.s.anon_id&&this.s.anon_id!==this.s.distinct_id?this.s.anon_id:void 0}get isIdentified(){return this.s.identified}identify(e){if(!e||e===this.s.distinct_id)return e&&!this.s.identified&&(this.s.identified=!0,this.save()),{event:null};let t=this.s.distinct_id,s=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),s&&t?{event:"$identify",anonDistinctId:t}:{event:"$identify"}}aliasProps(e,t){return{alias:e,distinct_id:t??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let t=e&&this.s.anon_id||w();this.s={distinct_id:t,anon_id:t,identified:!1},this.save()}};function D(n,e={}){let t=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**n);return Math.round(t*(.5+.5*(e.random??Math.random)()))}function Be(n){return n===0||n===408||n===429||n>=500}var J=class{constructor(e){this.o=e;this.flushAt=e.flushAt??20,this.intervalMs=e.flushIntervalMs??5e3,this.maxSize=e.maxQueueSize??1e3,this.maxRetries=e.maxRetries??5,this.batchMax=Math.max(1,Math.min(e.maxBatchSize??1e3,1e3))}o;items=[];timer;attempt=0;inflight;closed=!1;warned404=!1;flushAt;intervalMs;maxSize;maxRetries;batchMax;get size(){return this.items.length}enqueue(e){this.closed||(this.items.push(e),this.items.length>this.maxSize&&this.o.onDrop?.(this.items.splice(0,this.items.length-this.maxSize),"queue_full"),this.items.length>=this.flushAt?this.flush():this.arm(this.intervalMs))}arm(e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},e))}disarm(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}flush(e={}){if(this.disarm(),this.inflight)return this.inflight.then(()=>this.items.length?this.flush(e):void 0);if(!this.items.length)return Promise.resolve();let t=this.items.splice(0,this.batchMax),s=(this.o.clock??Date).now(),r=JSON.stringify({api_key:this.o.apiKey,batch:t,sent_at:new Date(s).toISOString()});this.o.log?.("send batch",t.length);let o=this.o.transport.send(this.o.url,r,e.beacon?{beacon:!0}:{}).then(a=>a,()=>({status:0,retryAfterMs:void 0})).then(a=>this.settle(t,a.status,!!e.beacon,a.retryAfterMs)).finally(()=>{this.inflight=void 0});return this.inflight=o,o}settle(e,t,s,r){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Be(t)||s||this.attempt>=this.maxRetries){t===404&&!this.warned404&&(this.warned404=!0,console.warn(`[lucida] ${this.o.url} returned 404, so events are being dropped. apiHost is probably wrong: use https://capture.lucidace.com (or your own capture host), not the app host.`)),this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let o=Math.max(D(this.attempt++,this.o.backoff),Math.min(r??0,6e4));this.o.log?.("retry in",o,"ms"),this.arm(o)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var pe="lc_session";function qe(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var wt=6e4,Ct=10*36e5,Pt=24*36e5,$t=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function It(n,e){let t=$t.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=Pt}var Q=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Ct,Math.max(wt,t.idleMs??30*6e4)),this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??{now:()=>Date.now()},this.bootstrapId=t.bootstrapId}storage;o;windowId=w();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=qe(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=qe(e.session_max_minutes,5,10080)??this.maxMs),this.o.newOnEvents===void 0&&Array.isArray(e.session_new_on_events)&&(this.newOn=e.session_new_on_events.filter(t=>typeof t=="string"&&t!==""))}read(){try{let e=this.storage.get(pe);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),r=this.read(),o=!!(r?.campaign&&e&&r.campaign!==e),a=t!==void 0&&this.newOn.includes(t),l=!r||Math.abs(s-r.last)>this.idleMs||Math.abs(s-r.start)>this.maxMs||o||a;return(l||!r)&&(r={id:!r&&this.bootstrapId&&It(this.bootstrapId,s)?this.bootstrapId:w(s),start:s,last:s}),this.bootstrapId=void 0,r.last=s,e&&(r.campaign=e),this.storage.set(pe,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:l}}startedAt(){return this.read()?.start}reset(){this.storage.remove(pe)}};function Ue(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var Z=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Ue(e,t)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([t])=>e(t))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[t,s]of Object.entries(e))t in this.p||(this.p[t]=s);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},X=class{constructor(e){this.storage=e;this.g=Ue(e,"lc_groups")??{}}storage;g;set(e,t){this.g[e]=t,this.storage.set("lc_groups",JSON.stringify(this.g))}all(){return Object.keys(this.g).length?{...this.g}:void 0}clear(){this.g={},this.storage.remove("lc_groups")}};function Ot(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var L=class{constructor(e){this.c=e;this.clock=e.clock??{now:()=>Date.now()},this.consent=new j({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new $(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new Y(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new Q(this.gated,{clock:this.clock,...e.session}),this.props=new Z(this.gated,void 0,e.persistProperty),this.groupState=new X(this.gated),this.queue=new J({transport:e.transport,url:`${e.apiHost.replace(/\/+$/,"")}/v1/batch`,apiKey:e.apiKey,clock:this.clock,...e.log?{log:e.log}:{},...e.onDrop?{onDrop:e.onDrop}:{},...e.queue})}c;consent;identity;session;queue;storage;gated;props;groupState;clock;device;pre=[];listeners=[];captureListeners=[];sessionListeners=[];lastSession="";filter;get anonDistinctId(){return this.identity.priorAnonId}get distinctId(){return this.identity.distinctId}get deviceId(){return this.c.cookieless?"":(this.device||(this.device=this.gated.get("lc_device_id")||w(),this.gated.set("lc_device_id",this.device)),this.device)}get groups(){return this.groupState.all()}get sessionId(){return this.touchSession().sessionId}touchSession(e){let t=this.session.touch(this.c.campaignKey?.(),e);if(t.sessionId!==this.lastSession){this.lastSession=t.sessionId;for(let s of this.sessionListeners)s(t.sessionId,t.windowId)}return t}onSessionId(e){return this.sessionListeners.push(e),()=>{this.sessionListeners.splice(this.sessionListeners.indexOf(e),1)}}get sessionStart(){return this.session.startedAt()}getProperty(e){return this.props.all()[e]}setFilter(e){this.filter=e}onChange(e){this.listeners.push(e)}onCaptured(e){this.captureListeners.push(e)}emit(e){for(let t of this.listeners)t(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,t={},s={}){let r=this.consent.has("analytics"),o=!r&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!r&&!o&&!a){this.c.log?.("dropped (no consent)",e);return}if(o&&(e==="$identify"||e==="$create_alias")){this.c.log?.("withheld (declined, anonymous mode)",e);return}let l=this.touchSession(e),p=this.c.enrich?.(e,t),h=this.consent.status()!=="pending",m=o?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=o?{}:{...p?.$set_once,...s.$set_once},C=this.groupState.all(),g=o?"":this.identity.distinctId,v={uuid:w(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Ot(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:l.sessionId,$window_id:l.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...h?{$consent:this.consent.get()}:{}},...Object.keys(m).length?{$set:m}:{},...Object.keys(_).length?{$set_once:_}:{},...!o&&s.$unset?.length?{$unset:s.$unset}:{},...C?{$groups:C}:{}},b=this.filter?this.filter(v):v;if(!b){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,b),this.c.onCapture?.(b);for(let S of this.captureListeners)S(b);return r||o?this.queue.enqueue(b):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(b),b}identify(e,t,s){let r=this.identity.identify(e);(r.event||t||s)&&this.capture("$identify",r.anonDistinctId?{$anon_distinct_id:r.anonDistinctId}:{},{...t?{$set:t}:{},...s?{$set_once:s}:{}}),this.emit("identify")}alias(e,t){this.capture("$create_alias",this.identity.aliasProps(e,t))}reset(e={}){this.identity.reset(e.reuseAnonymousId),e.resetDeviceId&&(this.device=void 0,this.gated.remove("lc_device_id")),this.props.clear(),this.groupState.clear(),this.session.reset(),this.lastSession="",this.emit("reset")}register(e){this.props.register(e)}registerOnce(e){this.props.registerOnce(e)}unregister(e){this.props.unregister(e)}group(e,t,s){this.groupState.set(e,t),this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s??{}}),this.emit("group")}getConsent(){return this.consent.get()}getConsentStatus(e="analytics"){return this.consent.status(e)}hasConsent(e){return this.consent.has(e)}setConsent(e){let t=this.consent.has("analytics"),s=e.analytics??t;if(t&&!s&&(this.capture("$opt_out"),this.queue.flush()),!t&&s&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!t&&s){this.gated.flushBuffered();for(let r of this.pre.splice(0))this.queue.enqueue(r);this.capture("$opt_in")}else t&&!s&&this.queue.clear();s||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e);let t=e.consent_default;this.resolveConsent(t==="opt_in"||t==="opt_out"||t==="cookieless"?t:void 0)}resolveConsent(e){if(!this.consent.resolving)return;let t=this.consent.resolve(e),s=this.pre.splice(0);if(t){this.gated.flushBuffered();for(let r of s)this.queue.enqueue(r)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let r of s){if(r.event==="$identify"||r.event==="$create_alias")continue;let o={...r};delete o.distinct_id,delete o.$set,delete o.$set_once,delete o.$unset,this.queue.enqueue(o)}}else this.consent.queueBeforeConsent&&this.pre.push(...s);this.emit("consent")}optIn(){this.setConsent({analytics:!0,replay:!0,marketing:!0})}optOut(){this.setConsent({analytics:!1,replay:!1,marketing:!1})}flush(e){return this.queue.flush(e)}shutdown(){return this.queue.shutdown()}};function He(n){let e="";return t=>{for(e+=t;;){let s=/\r?\n\r?\n/.exec(e);if(!s)return;let r=e.slice(0,s.index);e=e.slice(s.index+s[0].length);let o="message",a,l=[];for(let p of r.split(/\r?\n/)){if(p.startsWith(":"))continue;let h=p.indexOf(":"),[m,_]=h<0?[p,""]:[p.slice(0,h),p.slice(h+1).replace(/^ /,"")];m==="event"?o=_??"":m==="data"?l.push(_??""):m==="id"&&(a=_)}l.length&&n(a===void 0?{event:o,data:l.join(`
2
- `)}:{event:o,data:l.join(`
3
- `),id:a})}}}var ee=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;cursor=0;gen=0;polling=!1;start(){this.stopped&&(this.stopped=!1,this.loop(++this.gen))}stop(){this.stopped=!0,this.gen++,this.ctl?.abort(),this.timer&&clearTimeout(this.timer)}restart(){let e=!this.stopped;this.stop(),this.cursor=0,e&&this.start()}live(e){return!this.stopped&&e===this.gen}deliver(e){if(e.seq>this.cursor){this.cursor=e.seq;try{this.o.onIntervention(e)}catch(t){this.o.log?.("onIntervention threw",t)}}}url(e){let t=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${t}`}sleep(e){return new Promise(t=>{this.timer=setTimeout(t,e),this.timer.unref?.()})}async loop(e){let t=0;for(;this.live(e);){let s;try{let r=await this.connectOnce(e);if(r==="gone")return this.stop();r==="poll"?(t=0,s=this.o.pollMs??15e3):(r==="streamed"&&(t=0),s=D(t++,this.o.backoff))}catch(r){this.live(e)&&this.o.log?.("intervention stream error",r),s=D(t++,this.o.backoff)}if(!this.live(e))return;await this.sleep(s)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let t={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},s=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:t,signal:this.ctl.signal});if(s.status===404)return"gone";if(!s.ok)return"failed";let r=s.body;if(!r||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let o=He(l=>{if(!(l.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(l.data))}catch{this.o.log?.("bad intervention payload")}}),a=r.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:l,value:p}=await a.read();if(l)return"streamed";o(p)}}async pollOnce(e){this.ctl=new AbortController;let t=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(t.status===404)return"gone";if(!t.ok)return"failed";let s=await t.json();if(this.live(e))for(let r of s.data??[])this.deliver(r);return"poll"}};function fe(n,e){let t=new Set,{whenConsented:s,disabled:r,...o}=e,a=new ee({...o,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),l=!1;return n.onChange(p=>{l&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!l&&!r&&(l=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function ge(n,e,t={}){let s=t.key??"lc_offline",r=t.maxBatches??50,o=t.maxBytes??1e6,a=t.isOnline??(()=>!0),l,p,h=()=>{try{let g=JSON.parse(e.get(s)??"[]");return Array.isArray(g)?g:[]}catch{return[]}},m=g=>{let v=g.reduce((b,S)=>b+S.body.length,0);for(;g.length>r||v>o&&g.length>1;)v-=g.shift().body.length;g.length?e.set(s,JSON.stringify(g)):e.remove(s)},_=g=>{m([...h(),...g]),l??=setTimeout(()=>{l=void 0,C.drain()},t.retryMs??3e4)},C={async send(g,v,b){if(!a())return _([{url:g,body:v}]),{status:200};let S=await n.send(g,v,b);return S.status!==0?S:(_([{url:g,body:v}]),{status:200})},drain(){return p??=(async()=>{let g=h();if(!g.length||!a())return;e.remove(s);let v=[];for(let[b,S]of g.entries())if((await n.send(S.url,S.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return C}function he(n){let e=Object.keys(n);if(e.length===0)return{};let t={};for(let s of e)t[`$feature/${s}`]=n[s];return t.$active_feature_flags=e.filter(s=>n[s]!==!1).sort(),t}function me(n,e,t,s){return{key:n,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...t!==void 0?{payload:t}:{},reason:e===void 0?"not_found":s}}var A={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Et=["resolved","unresolved","escalated","abandoned","error"],Rt=4e3,At=2e3,Ve=["wrong","useless","not helpful","unhelpful","doesn't work","does not work","didn't help","did not help","not what i asked","that's not it","stupid","terrible","awful","frustrating","frustrated","annoying","worst","hate","incorrect","nonsense","confusing","makes no sense","real person","human agent","talk to a human","speak to a human","wtf","ugh"],ze=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],B=n=>Array.from(n),ve=(n,e)=>B(n).slice(0,e).join(""),Tt=0xcbf29ce484222325n,Mt=0x100000001b3n,jt=0xffffffffffffffffn,Dt=new TextEncoder;function Lt(n){let e=Tt;for(let t of Dt.encode(n))e=(e^BigInt(t))*Mt&jt;return e}function Ke(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(r=>B(r).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let r of e){let o=Lt(r);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((o>>BigInt(a)&1n)===1n?1:-1)}let s=0n;for(let r=0;r<64;r++)(t[r]??0)>0&&(s|=1n<<BigInt(r));return s.toString(16).padStart(16,"0")}function Ge(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let o of Ve)t.includes(` ${o} `)&&(s++,t=t.split(` ${o} `).join(" "));let r=ze.filter(o=>t.includes(` ${o} `)).length;return s>r?-1:r>s?1:0}var Ye=n=>B(n).filter(e=>e>="0"&&e<="9").map(Number);function Ft(n){let e=Ye(n);if(e.length<13||e.length>19)return!1;let t=0;return e.reverse().forEach((s,r)=>t+=r%2===1?s>4?s*2-9:s*2:s),t%10===0}var We=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Nt=[[new RegExp(String.raw`(?<!${We})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${We})`,"gu"),Ft],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,()=>!0],[/\+?\p{Nd}[\p{Nd}\s().-]{7,}\p{Nd}/gu,Bt]];function Bt(n){let e=Ye(n).length;return e>=10&&e<=15}var qt=n=>B(n).map(e=>/\s/u.test(e)?e:"*").join("");function be(n){let e=n;for(let[t,s]of Nt)e=e.replace(t,r=>s(r)?qt(r):r);return e===n?void 0:e}function Je(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var Qe=n=>typeof n=="string"&&Et.includes(n)?n:void 0,F=(n,e)=>typeof n=="string"&&n?ve(n,e):void 0;function Ut(n,e,t){let s=ve(e,t),r=be(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function Ze(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let r={$ai_role:n,$ai_message_index:t,$ai_text_length:B(e).length};if(n==="user"){let o=Ke(e);o!==void 0&&(r.$ai_text_hash=o),r.$ai_sentiment=Ge(e)}return s?{...r,...Ut("$ai_text",e,Rt)}:r}function Xe(n,e){let t=n.value;if(n.kind==="thumbs"&&t!==1&&t!==-1||n.kind==="rating"&&!(Number.isInteger(t)&&t>=1&&t<=5)||n.kind!=="thumbs"&&n.kind!=="rating"&&n.kind!=="comment")return;let s={$ai_feedback_kind:n.kind};if(n.kind!=="comment"&&(s.$ai_feedback_value=t),n.comment&&e){let r=ve(n.comment,At);s.$ai_feedback_comment=be(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function ye(n,e){let t=Qe(n),s=F(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function Ht(){let n=globalThis.crypto,e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function et(n={}){let e={$ai_conversation_id:n.conversationId||Ht()},t=(s,r)=>{r!==void 0&&(e[s]=r)};return t("$ai_agent_name",F(n.agentName,128)),t("$ai_agent_version",F(n.agentVersion,64)),t("$ai_topic",F(n.topic,128)),t("$ai_use_case",F(n.useCase,128)),t("$ai_trace_id",Je(n.traceId)),e}var N=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=et(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(A.started,{}),this}message(e,t,s={}){let r=s.index??this.next,o=Ze(e,t,r,this.captureText);return o?(this.next=r+1,this.send(A.message,o),!0):!1}feedback(e){let t=Xe(e,this.captureText);return t?(this.send(A.feedback,t),!0):!1}end(e,t){this.send(A.ended,ye(e,t))}outcome(e,t){let s=ye(e,t);return s.$ai_outcome?(this.send(A.outcome,s),!0):!1}};var Wt=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client","cypress","lightpanda","hubspot","nessus","prerender","deepscan","screaming frog","sitebulb","turnitin","ia_archiver","chatgpt-user","app.hypefactors.com","google favicon","google web preview","-google","googleother","googleweblight","google-read-aloud","google-inspectiontool","google-hoteladsverifier","google-cloudvertexbot"];function tt(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:Wt.some(s=>t.includes(s))&&!/\bcubot\b/.test(t)}var O=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],nt="lc_click_ids";function st(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(nt)??"{}")}catch{return{}}};return()=>{let o=r();if(location.search!==s){s=location.search;let l=new URLSearchParams(s),p=!1;for(let h of O){let m=l.get(h);m&&(o[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(nt,JSON.stringify(o))}let a={};for(let l of O){let p=o[l];p&&t()-p.t<e*864e5&&(a[l]=p.v)}return a}}function Vt(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function zt(n){let e=new Map;for(let s of n.split(";")){let[r,...o]=s.trim().toLowerCase().split(/\s+/);r&&!e.has(r)&&e.set(r,o)}let t=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!t&&!(t.includes("'unsafe-inline'")&&!t.some(s=>s.startsWith("'nonce-")||s.startsWith("'sha")))}function ot(n,e){if(typeof document>"u")return()=>{};!e&&Vt().some(zt)&&n("CSP hint: this page's Content-Security-Policy blocks inline <style>; set the `nonce` option so guides and the experiment veil render (docs/guides/csp.md)");let t=s=>{let r=s;/^style-src/.test(r.effectiveDirective??"")&&r.blockedURI==="inline"&&n(`CSP hint: an inline style was blocked by ${r.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",t),()=>document.removeEventListener("securitypolicyviolation",t)}var Kt=(n,e)=>n.slice(0,e);function rt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return Kt(n,64)}}function it(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,r=o=>{let a=o,l={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:rt(a.blockedURI??""),$csp_source_file:a.sourceFile?rt(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[l.$csp_directive,l.$csp_blocked_uri,l.$csp_source_file,l.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(l).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",r),()=>document.removeEventListener("securitypolicyviolation",r)}var Gt=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],at=()=>typeof location<"u"&&Gt.includes(location.protocol);function Yt(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let r=n.slice(s.length),o=r.search(/[?#]/);return s+t(o<0?r:r.slice(0,o))+(o<0?"":r.slice(o))}function ct(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=o=>Yt(o,t,s);return{transport:{send:(o,a,l)=>n.send(r(o),a,l)},fetch:((o,a)=>e(typeof o=="string"?r(o):o instanceof URL?r(o.href):o,a))}}var Jt="__LUCIDA_DEVTOOLS_HOOK__";function lt(n,e,t){let s=globalThis[Jt];if(!(!s||typeof s.emit!="function"||typeof s.attach!="function")){n.onCapture(r=>{try{s.emit(r)}catch{}});try{s.attach({projectKeyPrefix:n.apiKey.slice(0,8),apiHost:t,distinctId:()=>e.distinctId,loadToolbar:r=>e.loadToolbar(r),startReplay:async()=>n.replay?(await n.replay.start(!0),n.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var q=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Qt(n){let e={},t=new URLSearchParams(location.search);for(let s of[...q,...O,...n]){let r=t.get(s);r&&(e[`$${s}`]=r)}return e}function dt(){let n=new URLSearchParams(location.search),e=q.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function Zt(n){try{return n?new URL(n).hostname:""}catch{return""}}var Xt=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function en(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function ut(n,e,t=[],s=!1){let r={$current_url:Xt(),$host:location.host,$pathname:s?en():location.pathname,$referrer:document.referrer,$title:document.title,$screen_width:screen.width,$screen_height:screen.height,$viewport_width:window.innerWidth,$viewport_height:window.innerHeight,$browser_language:navigator.language,$timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};if(navigator.maxTouchPoints>1&&(r.$touch_points=navigator.maxTouchPoints),n!=="$pageview")return{properties:r};let o=Qt(t);Object.assign(r,o);let a=e.$current_url??location.href,l=e.$referrer??document.referrer,p={$initial_referrer:l||"$direct",$initial_referring_domain:Zt(l)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(o))p[`$initial_${h.slice(1)}`]=m;return{properties:r,$set_once:p}}var pt="_lcid";var tn=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function nn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",r]=n.slice(t+1).split("_",2),o=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&o<=e+5e3&&e-o<=12e4)return r&&/^[\w-]{1,64}$/.test(r)?{distinctId:a,sessionId:r}:{distinctId:a}}function ft(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(pt);if(t!==null){e.searchParams.delete(pt),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!tn(new URL(document.referrer).hostname,n))return}catch{return}return nn(t)}}function gt(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,r=s,o=e();return()=>{let a=e();return r=Math.min(s,r+(a-o)/1e3*t),o=a,r<1?!1:(r-=1,!0)}}var _e="<masked>",sn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],rn=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],ht=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function on(n,e){let t=n,s=[...sn,...e.maskParams??[],...e.maskCampaignParams?[...q,...O]:[]];if(s.length){let r=t.indexOf("#"),o=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);t=o.replace(new RegExp(`([?&])(${s.map(ht).join("|")})=[^&]*`,"gi"),`$1$2=${_e}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function mt(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...q,...O].map(ht).join("|")})$`),t=s=>{let r;if(n.maskCampaignParams)for(let[o,a]of Object.entries(s))typeof a=="string"&&e.test(o)?(r??={...s})[o]=_e:o==="$click_ids"&&a&&typeof a=="object"&&((r??={...s})[o]=Object.fromEntries(Object.keys(a).map(l=>[l,_e])));for(let o of rn){let a=(r??s)[o];if(typeof a!="string")continue;let l=on(a,n);l!==a&&((r??={...s})[o]=l)}return r??s};return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}function an(n,e,t){let s=e;for(let r of n)try{let o=r(s);if(o==null)return null;if(typeof o!="object"||typeof o.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof o),null;s=o}catch(o){return t("beforeSend hook threw, dropping event:",o),null}return s}function cn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function ln(n){let e=new Set(n),t=s=>Object.fromEntries(Object.entries(s).filter(([r])=>!e.has(r)));return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}var Se="lc_person_identified",te="lc_pending_set_once",yt=new Set(["$identify","$create_alias","$groupidentify"]),vt="$$client_ingestion_warning",dn=6e4,ke=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Se)==="1";try{this.pending=JSON.parse(t.get(te)??"{}")}catch{this.pending={}}}mode;storage;identified;pending;get blocksPersonWrites(){return this.mode==="never"}get isProfile(){return this.mode==="always"||this.mode==="identified_only"&&this.identified}markIdentified(){this.mode!=="identified_only"||this.identified||(this.identified=!0,this.storage.set(Se,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!yt.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let t=Object.entries(e).filter(([s])=>!(s in this.pending));t.length&&(this.pending={...this.pending,...Object.fromEntries(t)},this.storage.set(te,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(te),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Se),this.storage.remove(te)}};function un(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:o,$set_once:a,$unset:l,...p}=e;t={...p,properties:{...e.properties,$process_person_profile:!1}}}else(s=n.person.take())&&(t={...e,$set_once:{...e.$set_once,...s}});let r=n.hooks.length?an(n.hooks,t,n.log):t;return r&&n.limit&&!n.limit()&&(n.log("rate limited, dropped",r.event),n.onLimited?.(),r=null),!r&&s&&n.person.stash(s),r}function pn(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[mt(n.urlPrivacy??{}),...n.propertyDenylist?.length?[ln(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[cn(n.sampleRate)]:[],...e]}function bt(n,e,t,s=Date.now){let r=new ke(e.personProfiles??"always",n.storage),o,a,l=0,p=-1/0,h=()=>{l+=1,!(s()-p<dn)&&(p=s(),queueMicrotask(()=>{let m=l;l=0,n.capture(vt,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==o&&(o=e.rateLimit,a=o?gt(o):void 0),un({hooks:pn(e),person:r,limit:m.event===vt?void 0:a,log:t,onLimited:h},m))),r}var xe=class{m=new Map;get(e){return this.m.get(e)??null}set(e,t){this.m.set(e,t)}remove(e){this.m.delete(e)}},fn=365,gn=new Set("co.uk org.uk ac.uk gov.uk me.uk ltd.uk plc.uk net.uk com.au net.au org.au edu.au gov.au co.nz org.nz net.nz co.jp ne.jp or.jp ac.jp go.jp co.kr or.kr com.cn net.cn org.cn com.hk com.tw com.sg com.my co.in net.in org.in co.id co.th com.ph com.vn com.br net.br org.br com.ar com.mx com.co com.pe com.tr com.ua com.pl co.za co.il com.eg com.sa com.ng co.ke github.io gitlab.io vercel.app netlify.app herokuapp.com pages.dev workers.dev web.app firebaseapp.com azurewebsites.net cloudfront.net appspot.com onrender.com fly.dev glitch.me repl.co blogspot.com wordpress.com myshopify.com vercel.dev netlify.com surge.sh render.com railway.app koyeb.app deno.dev ngrok.io ngrok-free.app trycloudflare.com cloudfunctions.net run.app s3.amazonaws.com elasticbeanstalk.com azurestaticapps.net wixsite.com webflow.io framer.app bubbleapps.io".split(" ")),hn=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function mn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(gn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&hn.has(e[t]))return e.slice(t-1).join(".")}function yn(n=location.hostname){if(/^[\d.]+$/.test(n)||n.includes(":"))return;let e=n.split(".");for(let t=e.length-2;t>=0;t--){let s=e.slice(t).join(".");if(document.cookie=`__lc_probe=1; Domain=${s}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${s}; Path=/; Max-Age=0`,s}return mn(n)}var ne=class{constructor(e={}){this.o=e}o;domain=null;attr(){if(this.domain===null)try{this.domain=this.o.domain??(this.o.crossSubdomain?yn():void 0)}catch{this.domain=void 0}return this.domain?`; Domain=${this.domain}`:""}held=new Map;read(e){try{for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)return decodeURIComponent(t.slice(s+1))}}catch{}return null}get(e){return this.read(e)??this.held.get(e)??null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",r=Math.round((this.o.expiryDays??fn)*86400);try{document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${r}; Path=/${this.attr()}; SameSite=Lax${s}`}catch{}this.read(e)===t?this.held.delete(e):this.held.set(e,t)}remove(e){this.held.delete(e);try{document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}catch{}}},T=class{constructor(e="localStorage"){this.kind=e}kind;store(){try{return globalThis[this.kind]}catch{return}}get(e){try{return this.store()?.getItem(e)??null}catch{return null}}set(e,t){try{this.store()?.setItem(e,t)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},we=class extends T{constructor(){super("localStorage")}},vn=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Ce=class{constructor(e,t,s){this.cookie=e;this.local=t;this.cookieKeys=s}cookie;local;cookieKeys;get(e){let[t,s]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return t.get(e)??s.get(e)}set(e,t){this.local.set(e,t),this.cookieKeys(e)?this.cookie.set(e,t):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},se=class{constructor(e,t){this.inner=e;this.delayMs=t}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,t){this.queue(e,t)}remove(e){this.queue(e,null)}queue(e,t){this.pending.set(e,t),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,t]of this.pending)t===null?this.inner.remove(e):this.inner.set(e,t);this.pending.clear()}},Pe=class{constructor(e,t){this.inner=e;this.suffix=t}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,t){this.inner.set(e+this.suffix,t)}remove(e){this.inner.remove(e+this.suffix)}},re=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function oe(n,e,t){if(n==="memory"||n==="none")return new xe;let s=re(e),r=n==="cookie"?new ne(t):n==="localStorage+cookie"?new Ce(new ne(t),new we,o=>vn.some(a=>o===a+s)):new T(n);return new Pe(r,s)}function _t(n,e,t){let s=re(e),r=new Set;try{for(let o of document.cookie.split("; "))r.add(o.split("=")[0]);for(let o of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<o.length;a++)r.add(o.key(a))}catch{}for(let o of r)if(!(!o.startsWith("lc_")||!o.endsWith(s)||o===t+s)){n.remove(o.slice(0,-s.length));try{localStorage.removeItem(o),sessionStorage.removeItem(o)}catch{}}}async function bn(n){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(n).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function St(n,e={}){let t=e.compress??!0,s=(r,o)=>(e.onError?.({url:r,status:o}),{status:o});return{async send(r,o,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(r,new Blob([o],{type:"text/plain"}))?{status:200}:s(r,0);try{let l=t&&o.length>=1024?await bn(o):void 0,p=await n(l?`${r}${r.includes("?")?"&":"?"}compression=gzip`:r,{method:"POST",body:l??o,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(l?.length??o.length)<6e4});return p.status>=400?s(r,p.status):{status:p.status}}catch{return s(r,0)}}}}var $e={send:async()=>({status:200})};var _n="lucida-browser",Sn="0.1.4",Ie="lc_internal",kn=3e3,kt="https://capture.lucidace.com",Oe=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Ee(n,e={},t=[]){let s=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),r=(...i)=>{s&&console.debug("[lucida]",...i)},o=(e.apiHost??kt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([i,c])=>[i,Oe(c)?{...c}:c]));a.apiHost=o;let l=e.extension??at(),p=i=>l&&(i==="cookie"||i==="localStorage+cookie")?e.extensionPersistence??"localStorage":i,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[o,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...i)=>fetch(...i)),C=i=>ct(i,_,m,e.rewritePath),g=C($e).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,Re=e.blockBots!==!1&&typeof navigator<"u"&&tt(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||Re;Re&&r("bot user agent: capture disabled");let ie,ae=C(e.transport??St(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let i=new $(new T(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>d.hasConsent("analytics"));ae=ie=ge(ae,i,{key:`lc_offline${re(n)}`,isOnline:()=>navigator.onLine!==!1})}let U=k?void 0:ft(e.crossDomains),ce=oe(k?"memory":h,n,e.cookie),H=(e.storageWriteDelayMs??0)>0?new se(ce,e.storageWriteDelayMs):void 0,Ae=U?.sessionId??e.bootstrap?.sessionId,le,W=!1,Te,de=[],d=new L({apiKey:n,apiHost:o,transport:k?$e:ae,storage:H??ce,...e.consentPersistence&&!k?{consentStorage:oe(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:i=>!a.persistedProperties||a.persistedProperties.includes(i),...h==="none"?{cookieless:!0}:{},library:{name:_n,version:Sn},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...e.consent?.geo&&!k?{awaitRemote:!0}:{},respectDnt:!0,dnt:S},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...U||e.bootstrap?.distinctId?{bootstrapDistinctId:U?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!U?{bootstrapIdentified:!0}:{},session:{...e.session,...Ae?{bootstrapId:Ae}:{}},enrich:(i,c)=>{let u=ut(i,c,a.customCampaignParams,e.capturePageview==="hash");if(o!==kt&&(u.properties={...u.properties,$lib_custom_api_host:o}),de.length){let I=d.sessionId;for(let xt of de)u.properties={...u.properties,...xt(I)}}let y=Te?.()??{},P=Object.keys(y);return P.length&&(u.properties={...u.properties,$click_ids:y},i==="$pageview"&&(u.$set_once={...Object.fromEntries(P.map(I=>[`$initial_${I}`,y[I]])),...u.$set_once},u.$set=Object.fromEntries(P.map(I=>[`$last_${I}`,y[I]])))),a.sendFeatureFlags!==!1&&i!=="$snapshot"&&le&&(u.properties={...he(le.all()),...u.properties}),W?{...u,properties:{...u.properties,$internal:!0}}:u},campaignKey:dt,log:r});W=d.storage.get(Ie)==="1",e.clickIds!==!1&&(Te=st(d.storage,e.clickIds?.expiryDays));let x=bt(d,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let M=i=>x.blocksPersonWrites?(r(`personProfiles=never: ${i} ignored`),!0):!1;k||d.onChange(i=>{i!=="consent"||d.hasConsent("analytics")||d.consentStatus()!=="denied"||(H?.flush(),_t(ce,n,e.consent?.storageKey||K))});let Me=[],E=[ot(r,e.nonce)],je=d.storage;if(e.flagPersistence&&!k){let i=new $(oe(p(e.flagPersistence),n,e.cookie),()=>d.hasConsent("analytics"));d.onChange(c=>{c==="consent"&&(d.hasConsent("analytics")?i.flushBuffered():i.discardBuffered())}),je=i}let V=i=>{if(k)return;if(d.hasConsent("analytics"))return i();let c=!1;d.onChange(u=>{!c&&u==="consent"&&d.hasConsent("analytics")&&(c=!0,i())})},De,f={core:d,client:void 0,config:a,flagStorage:je,apiKey:n,log:r,fetch:g,onUnload:i=>{Me.push(i)},whenConsented:V,onCapture:i=>d.onCaptured(i),eventExtras:de,clickExtras:[],flagPersonProps:[],loadConfig:()=>De??=new Promise(i=>V(()=>{g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&d.applyRemote(c),c)).then(i,()=>i(null))}))};if(d.consent.resolving){let i=g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(u=>u.ok?u.json():null).catch(()=>null);De=i;let c=setTimeout(()=>d.applyRemote({}),kn);i.then(u=>{clearTimeout(c),d.applyRemote(u??{})})}let Le=fe(d,{apiHost:o,apiKey:n,fetch:g,whenConsented:V,log:r,disabled:k});E.push(()=>Le.stop());let z={get distinctId(){return d.distinctId},capture:(i,c,u)=>{d.capture(i,c,u?.timestamp!==void 0?{timestamp:u.timestamp}:{})&&(u?.sendInstantly||u?.transport)&&d.flush(u.transport==="beacon"?{beacon:!0}:{})},identify:(i,c,u)=>{M("identify")||(x.markIdentified(),d.identify(i,c,u))},alias:(i,c)=>{M("alias")||(x.markIdentified(),d.alias(i,c))},reset:i=>{d.reset({resetDeviceId:!!i,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{M("createPersonProfile")||x.isProfile||(x.markIdentified(),d.capture("$set",{}))},setConfig:i=>{let c=a;for(let[u,y]of Object.entries(i)){let P=c[u];Oe(P)&&Oe(y)?Object.assign(P,y):c[u]=y}"debug"in i&&(s=!!i.debug)},setPersonProperties:(i,c)=>{!i&&!c||M("setPersonProperties")||(x.markIdentified(),d.capture("$set",{},{...i?{$set:i}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:i=>{!i.length||M("unsetPersonProperties")||(x.markIdentified(),d.capture("$set",{},{$unset:i}))},getSessionId:()=>d.sessionId,onSessionId:i=>d.onSessionId(c=>i(c)),getProperty:i=>d.getProperty(i),hasOptedOut:()=>!d.hasConsent("analytics"),getReplayUrl:i=>{let u=`${(e.uiHost??o).replace(/\/+$/,"")}/replays/${encodeURIComponent(d.sessionId)}`,y=d.sessionStart;return!i?.withTimestamp||y===void 0?u:`${u}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(i.timestampLookBackSeconds??10)))}`},debug:(i=!0)=>{s=i},featureView:(i,c)=>{d.capture("$feature_view",{...c,$feature_flag:i},{$set:{[`$feature_view/${i}`]:!0}})},featureInteraction:(i,c)=>{d.capture("$feature_interaction",{...c,$feature_flag:i},{$set:{[`$feature_interaction/${i}`]:!0}})},updateFlags:(i,c,u)=>f.flags?.update(i,c,u?.merge??!0),register:i=>d.register(i),registerOnce:i=>d.registerOnce(i),unregister:i=>d.unregister(i),group:(i,c,u)=>{x.markIdentified(),d.group(i,c,u)},optIn:(i=["analytics","replay"])=>d.setConsent({analytics:i.includes("analytics"),replay:i.includes("replay"),marketing:i.includes("marketing")}),optOut:()=>d.optOut(),optOutInternal:(i=!0)=>{W=i,i?d.storage.set(Ie,"1"):d.storage.remove(Ie)},get isInternal(){return W},setConsent:i=>d.setConsent(i),getConsent:()=>d.getConsent(),getConsentStatus:i=>d.getConsentStatus(i),consentStatus:()=>d.consentStatus(),getFlag:i=>f.flags?.get(i),getFlagPayload:i=>f.flags?.payload(i),getFlagResult:(i,c)=>f.flags?.result(i,c)??me(i,void 0,void 0,"not_found"),getLayerParam:(i,c,u)=>f.flags?.layerParam(i,c)??u,isFeatureEnabled:i=>{let c=f.flags?.get(i);return c!==void 0&&c!==!1},onFlags:i=>f.flags?.onChange(i)??(()=>{}),onIntervention:i=>Le.on(i),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(i,c)=>f.flags?.override(i,c),setPersonPropertiesForFlags:(i,c)=>f.flags?.setPersonProperties(i,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(i,c)=>f.flags?.setGroupProperties(i,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(i,c,u)=>f.flags?.setContext(i,c,u),clearContext:i=>f.flags?.clearContext(i),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:i=>f.guides?.show(i)??!1,reset:i=>f.guides?.reset(i)},ai:{startConversation:i=>new N((c,u)=>z.capture(c,u),i,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:i=>f.earlyAccess?.optIn(i),optOut:i=>f.earlyAccess?.optOut(i)},replay:{start:i=>f.replay?.start(i)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:i=>f.replay?.tag(i),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:i=>f.consentUi?.showBanner(i)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:i=>f.toolbar?.load(typeof i=="string"?i:i.token)??Promise.resolve(!1),activateExperiment:i=>f.experiments?.activate(i),recommendations:(i,c)=>f.recs?.get(i,c)??Promise.resolve({placement:i,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>d.flush(),shutdown:async()=>{for(let i of E)i();H?.flush(),await d.shutdown()}};if(f.client=z,!k){let i=()=>{for(let u of Me)u();H?.flush(),d.flush({beacon:!0})};window.addEventListener("pagehide",i);let c=()=>{document.visibilityState==="hidden"&&d.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",i),document.removeEventListener("visibilitychange",c)}),ie){let u=()=>{ie.drain()};window.addEventListener("online",u),E.push(()=>window.removeEventListener("online",u)),V(u)}if(e.captureCspViolations){let u=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};E.push(it((y,P)=>{d.capture(y,P)},u))}for(let u of t){let y=u(f);y&&E.push(y)}le=f.flags,t.length||f.loadConfig(),lt(f,z,o)}return r("initialised",{apiHost:o,consent:d.getConsent()}),z}function Ls(n,e={}){return Ee(n,e)}export{Ee as createClient,Ls as init};
1
+ var Y="lc_consent";function he(n,e,t){return e==="opt_in"?"opt_in":t==="opt_in"||t==="opt_out"||t==="cookieless"?t:e==="opt_out"?n:void 0}var ge=["analytics","replay","marketing"],L=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let t=this.opens();this.state={analytics:t,replay:t,marketing:t},this.key=e.storageKey||Y;let s=e.storage.get(this.key);if(s)try{let o=JSON.parse(s);for(let i of ge)typeof o[i]=="boolean"&&(this.state[i]=o[i]);this.decided=ge.some(i=>typeof o[i]=="boolean")}catch{}this.waiting=!!e.awaitRemote&&!this.decided,this.waiting&&(this.state={analytics:!1,replay:!1,marketing:!1})}o;modeNow;queueBeforeConsent;state;decided=!1;waiting;geoCookieless=!1;key;listeners=[];opens(){return this.modeNow==="opt_out"&&!(this.o.respectDnt&&this.o.dnt)}get mode(){return this.modeNow}get resolving(){return this.waiting}get anonymous(){return this.geoCookieless&&!this.decided}resolve(e){if(!this.waiting)return this.state.analytics;this.waiting=!1,(e==="opt_in"||e==="opt_out")&&(this.modeNow=e),this.geoCookieless=e==="cookieless";let t=!this.geoCookieless&&this.opens();return this.state={analytics:t,replay:t,marketing:t},t}get(){return{...this.state}}has(e){return this.state[e]}status(e="analytics"){return this.decided?this.state[e]?"granted":"denied":"pending"}get pending(){return this.waiting||this.modeNow==="opt_in"&&!this.state.analytics}set(e){let t=this.get();for(let s of ge)e[s]!==void 0&&(this.state[s]=e[s]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let s of this.listeners)s(this.get(),t)}onChange(e){this.listeners.push(e)}},$=class{constructor(e,t){this.inner=e;this.allowed=t}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,t){this.allowed()?this.inner.set(e,t):this.mem.set(e,t)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,t]of this.mem)t===null?this.inner.remove(e):this.inner.set(e,t);this.mem.clear()}discardBuffered(){this.mem.clear()}};var J=0,R=0;function He(n){let e=new Uint8Array(n),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let s=0;s<n;s++)e[s]=Math.floor(Math.random()*256);return e}function C(n=Date.now()){if(n>J){J=n;let i=He(2);R=((i[0]??0)<<8|(i[1]??0))&1023}else R++,R>4095&&(J++,R=0);let e=He(8),t=new Uint8Array(16),s=J;t[0]=Math.floor(s/2**40)&255,t[1]=Math.floor(s/2**32)&255,t[2]=Math.floor(s/2**24)&255,t[3]=Math.floor(s/2**16)&255,t[4]=Math.floor(s/2**8)&255,t[5]=s&255,t[6]=112|R>>8,t[7]=R&255,t[8]=128|(e[0]??0)&63;for(let i=1;i<8;i++)t[8+i]=e[i]??0;let o=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var We="lc_identity",Q=class{constructor(e,t,s=!1,o=!1){this.storage=e;this.cookieless=s;let i=e.get(We),a;try{a=i?JSON.parse(i):void 0}catch{a=void 0}if(a?.distinct_id)this.s=a;else if(s)this.s={distinct_id:"",anon_id:"",identified:!1};else{let d=t??C();this.s={distinct_id:d,anon_id:d,identified:o&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(We,JSON.stringify(this.s))}get distinctId(){return this.s.distinct_id}get priorAnonId(){return this.s.identified&&this.s.anon_id&&this.s.anon_id!==this.s.distinct_id?this.s.anon_id:void 0}get isIdentified(){return this.s.identified}identify(e){if(!e||e===this.s.distinct_id)return e&&!this.s.identified&&(this.s.identified=!0,this.save()),{event:null};let t=this.s.distinct_id,s=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),s&&t?{event:"$identify",anonDistinctId:t}:{event:"$identify"}}aliasProps(e,t){return{alias:e,distinct_id:t??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let t=e&&this.s.anon_id||C();this.s={distinct_id:t,anon_id:t,identified:!1},this.save()}};function F(n,e={}){let t=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**n);return Math.round(t*(.5+.5*(e.random??Math.random)()))}function Ve(n){return n===0||n===408||n===429||n>=500}var X=class{constructor(e){this.o=e;this.flushAt=e.flushAt??20,this.intervalMs=e.flushIntervalMs??5e3,this.maxSize=e.maxQueueSize??1e3,this.maxRetries=e.maxRetries??5,this.batchMax=Math.max(1,Math.min(e.maxBatchSize??1e3,1e3))}o;items=[];timer;attempt=0;inflight;closed=!1;warned404=!1;flushAt;intervalMs;maxSize;maxRetries;batchMax;get size(){return this.items.length}enqueue(e){this.closed||(this.items.push(e),this.items.length>this.maxSize&&this.o.onDrop?.(this.items.splice(0,this.items.length-this.maxSize),"queue_full"),this.items.length>=this.flushAt?this.flush():this.arm(this.intervalMs))}arm(e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},e))}disarm(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}flush(e={}){if(this.disarm(),this.inflight)return this.inflight.then(()=>this.items.length?this.flush(e):void 0);if(!this.items.length)return Promise.resolve();let t=this.items.splice(0,this.batchMax),s=(this.o.clock??Date).now(),o=JSON.stringify({api_key:this.o.apiKey,batch:t,sent_at:new Date(s).toISOString()});this.o.log?.("send batch",t.length);let i=this.o.transport.send(this.o.url,o,e.beacon?{beacon:!0}:{}).then(a=>a,()=>({status:0,retryAfterMs:void 0})).then(a=>this.settle(t,a.status,!!e.beacon,a.retryAfterMs)).finally(()=>{this.inflight=void 0});return this.inflight=i,i}settle(e,t,s,o){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Ve(t)||s||this.attempt>=this.maxRetries){t===404&&!this.warned404&&(this.warned404=!0,console.warn(`[lucida] ${this.o.url} returned 404, so events are being dropped. apiHost is probably wrong: use https://capture.lucidace.com (or your own capture host), not the app host.`)),this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let i=Math.max(F(this.attempt++,this.o.backoff),Math.min(o??0,6e4));this.o.log?.("retry in",i,"ms"),this.arm(i)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var me="lc_session";function ze(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var Tt=6e4,Mt=10*36e5,jt=24*36e5,Dt=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function Lt(n,e){let t=Dt.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=jt}var Z=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Mt,Math.max(Tt,t.idleMs??30*6e4)),this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??{now:()=>Date.now()},this.bootstrapId=t.bootstrapId}storage;o;windowId=C();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=ze(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=ze(e.session_max_minutes,5,10080)??this.maxMs),this.o.newOnEvents===void 0&&Array.isArray(e.session_new_on_events)&&(this.newOn=e.session_new_on_events.filter(t=>typeof t=="string"&&t!==""))}read(){try{let e=this.storage.get(me);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),o=this.read(),i=!!(o?.campaign&&e&&o.campaign!==e),a=t!==void 0&&this.newOn.includes(t),d=!o||Math.abs(s-o.last)>this.idleMs||Math.abs(s-o.start)>this.maxMs||i||a;return(d||!o)&&(o={id:!o&&this.bootstrapId&&Lt(this.bootstrapId,s)?this.bootstrapId:C(s),start:s,last:s}),this.bootstrapId=void 0,o.last=s,e&&(o.campaign=e),this.storage.set(me,JSON.stringify(o)),{sessionId:o.id,windowId:this.windowId,isNew:d}}startedAt(){return this.read()?.start}reset(){this.storage.remove(me)}};function Ke(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var ee=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Ke(e,t)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([t])=>e(t))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[t,s]of Object.entries(e))t in this.p||(this.p[t]=s);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},te=class{constructor(e){this.storage=e;this.g=Ke(e,"lc_groups")??{}}storage;g;set(e,t){this.g[e]=t,this.storage.set("lc_groups",JSON.stringify(this.g))}all(){return Object.keys(this.g).length?{...this.g}:void 0}clear(){this.g={},this.storage.remove("lc_groups")}};function Ft(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var N=class{constructor(e){this.c=e;this.clock=e.clock??{now:()=>Date.now()},this.consent=new L({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new $(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new Q(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new Z(this.gated,{clock:this.clock,...e.session}),this.props=new ee(this.gated,void 0,e.persistProperty),this.groupState=new te(this.gated),this.queue=new X({transport:e.transport,url:`${e.apiHost.replace(/\/+$/,"")}/v1/batch`,apiKey:e.apiKey,clock:this.clock,...e.log?{log:e.log}:{},...e.onDrop?{onDrop:e.onDrop}:{},...e.queue})}c;consent;identity;session;queue;storage;gated;props;groupState;clock;device;pre=[];listeners=[];captureListeners=[];sessionListeners=[];lastSession="";filter;get anonDistinctId(){return this.identity.priorAnonId}get distinctId(){return this.identity.distinctId}get deviceId(){return this.c.cookieless?"":(this.device||(this.device=this.gated.get("lc_device_id")||C(),this.gated.set("lc_device_id",this.device)),this.device)}get groups(){return this.groupState.all()}get sessionId(){return this.touchSession().sessionId}touchSession(e){let t=this.session.touch(this.c.campaignKey?.(),e);if(t.sessionId!==this.lastSession){this.lastSession=t.sessionId;for(let s of this.sessionListeners)s(t.sessionId,t.windowId)}return t}onSessionId(e){return this.sessionListeners.push(e),()=>{this.sessionListeners.splice(this.sessionListeners.indexOf(e),1)}}get sessionStart(){return this.session.startedAt()}getProperty(e){return this.props.all()[e]}setFilter(e){this.filter=e}onChange(e){this.listeners.push(e)}onCaptured(e){this.captureListeners.push(e)}emit(e){for(let t of this.listeners)t(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,t={},s={}){let o=this.consent.has("analytics"),i=!o&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!o&&!i&&!a){this.c.log?.("dropped (no consent)",e);return}if(i&&(e==="$identify"||e==="$create_alias")){this.c.log?.("withheld (declined, anonymous mode)",e);return}let d=this.touchSession(e),p=this.c.enrich?.(e,t),h=this.consent.status()!=="pending",m=i?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=i?{}:{...p?.$set_once,...s.$set_once},P=this.groupState.all(),g=i?"":this.identity.distinctId,v={uuid:C(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Ft(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:d.sessionId,$window_id:d.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...h?{$consent:this.consent.get()}:{}},...Object.keys(m).length?{$set:m}:{},...Object.keys(_).length?{$set_once:_}:{},...!i&&s.$unset?.length?{$unset:s.$unset}:{},...P?{$groups:P}:{}},b=this.filter?this.filter(v):v;if(!b){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,b),this.c.onCapture?.(b);for(let S of this.captureListeners)S(b);return o||i?this.queue.enqueue(b):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(b),b}identify(e,t,s){let o=this.identity.identify(e);(o.event||t||s)&&this.capture("$identify",o.anonDistinctId?{$anon_distinct_id:o.anonDistinctId}:{},{...t?{$set:t}:{},...s?{$set_once:s}:{}}),this.emit("identify")}alias(e,t){this.capture("$create_alias",this.identity.aliasProps(e,t))}reset(e={}){this.identity.reset(e.reuseAnonymousId),e.resetDeviceId&&(this.device=void 0,this.gated.remove("lc_device_id")),this.props.clear(),this.groupState.clear(),this.session.reset(),this.lastSession="",this.emit("reset")}register(e){this.props.register(e)}registerOnce(e){this.props.registerOnce(e)}unregister(e){this.props.unregister(e)}group(e,t,s){this.groupState.set(e,t),this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s??{}}),this.emit("group")}getConsent(){return this.consent.get()}getConsentStatus(e="analytics"){return this.consent.status(e)}hasConsent(e){return this.consent.has(e)}setConsent(e){let t=this.consent.has("analytics"),s=e.analytics??t;if(t&&!s&&(this.capture("$opt_out"),this.queue.flush()),!t&&s&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!t&&s){this.gated.flushBuffered();for(let o of this.pre.splice(0))this.queue.enqueue(o);this.capture("$opt_in")}else t&&!s&&this.queue.clear();s||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e),this.resolveConsent(he(this.consent.mode,e.consent_mode,e.consent_default))}resolveConsent(e){if(!this.consent.resolving)return;let t=this.consent.resolve(e),s=this.pre.splice(0);if(t){this.gated.flushBuffered();for(let o of s)this.queue.enqueue(o)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let o of s){if(o.event==="$identify"||o.event==="$create_alias")continue;let i={...o};delete i.distinct_id,delete i.$set,delete i.$set_once,delete i.$unset,this.queue.enqueue(i)}}else this.consent.queueBeforeConsent&&this.pre.push(...s);this.emit("consent")}optIn(){this.setConsent({analytics:!0,replay:!0,marketing:!0})}optOut(){this.setConsent({analytics:!1,replay:!1,marketing:!1})}flush(e){return this.queue.flush(e)}shutdown(){return this.queue.shutdown()}};function Ge(n){let e="";return t=>{for(e+=t;;){let s=/\r?\n\r?\n/.exec(e);if(!s)return;let o=e.slice(0,s.index);e=e.slice(s.index+s[0].length);let i="message",a,d=[];for(let p of o.split(/\r?\n/)){if(p.startsWith(":"))continue;let h=p.indexOf(":"),[m,_]=h<0?[p,""]:[p.slice(0,h),p.slice(h+1).replace(/^ /,"")];m==="event"?i=_??"":m==="data"?d.push(_??""):m==="id"&&(a=_)}d.length&&n(a===void 0?{event:i,data:d.join(`
2
+ `)}:{event:i,data:d.join(`
3
+ `),id:a})}}}var ne=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;cursor=0;gen=0;polling=!1;start(){this.stopped&&(this.stopped=!1,this.loop(++this.gen))}stop(){this.stopped=!0,this.gen++,this.ctl?.abort(),this.timer&&clearTimeout(this.timer)}restart(){let e=!this.stopped;this.stop(),this.cursor=0,e&&this.start()}live(e){return!this.stopped&&e===this.gen}deliver(e){if(e.seq>this.cursor){this.cursor=e.seq;try{this.o.onIntervention(e)}catch(t){this.o.log?.("onIntervention threw",t)}}}url(e){let t=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${t}`}sleep(e){return new Promise(t=>{this.timer=setTimeout(t,e),this.timer.unref?.()})}async loop(e){let t=0;for(;this.live(e);){let s;try{let o=await this.connectOnce(e);if(o==="gone")return this.stop();o==="poll"?(t=0,s=this.o.pollMs??15e3):(o==="streamed"&&(t=0),s=F(t++,this.o.backoff))}catch(o){this.live(e)&&this.o.log?.("intervention stream error",o),s=F(t++,this.o.backoff)}if(!this.live(e))return;await this.sleep(s)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let t={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},s=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:t,signal:this.ctl.signal});if(s.status===404)return"gone";if(!s.ok)return"failed";let o=s.body;if(!o||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let i=Ge(d=>{if(!(d.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(d.data))}catch{this.o.log?.("bad intervention payload")}}),a=o.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:d,value:p}=await a.read();if(d)return"streamed";i(p)}}async pollOnce(e){this.ctl=new AbortController;let t=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(t.status===404)return"gone";if(!t.ok)return"failed";let s=await t.json();if(this.live(e))for(let o of s.data??[])this.deliver(o);return"poll"}};function ye(n,e){let t=new Set,{whenConsented:s,disabled:o,...i}=e,a=new ne({...i,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),d=!1;return n.onChange(p=>{d&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!d&&!o&&(d=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function ve(n,e,t={}){let s=t.key??"lc_offline",o=t.maxBatches??50,i=t.maxBytes??1e6,a=t.isOnline??(()=>!0),d,p,h=()=>{try{let g=JSON.parse(e.get(s)??"[]");return Array.isArray(g)?g:[]}catch{return[]}},m=g=>{let v=g.reduce((b,S)=>b+S.body.length,0);for(;g.length>o||v>i&&g.length>1;)v-=g.shift().body.length;g.length?e.set(s,JSON.stringify(g)):e.remove(s)},_=g=>{m([...h(),...g]),d??=setTimeout(()=>{d=void 0,P.drain()},t.retryMs??3e4)},P={async send(g,v,b){if(!a())return _([{url:g,body:v}]),{status:200};let S=await n.send(g,v,b);return S.status!==0?S:(_([{url:g,body:v}]),{status:200})},drain(){return p??=(async()=>{let g=h();if(!g.length||!a())return;e.remove(s);let v=[];for(let[b,S]of g.entries())if((await n.send(S.url,S.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return P}function be(n){let e=Object.keys(n);if(e.length===0)return{};let t={};for(let s of e)t[`$feature/${s}`]=n[s];return t.$active_feature_flags=e.filter(s=>n[s]!==!1).sort(),t}function B(n,e,t,s){return{key:n,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...t!==void 0?{payload:t}:{},reason:e===void 0?"not_found":s}}var A={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Nt=["resolved","unresolved","escalated","abandoned","error"],Bt=4e3,Ut=2e3,Je=["wrong","useless","not helpful","unhelpful","doesn't work","does not work","didn't help","did not help","not what i asked","that's not it","stupid","terrible","awful","frustrating","frustrated","annoying","worst","hate","incorrect","nonsense","confusing","makes no sense","real person","human agent","talk to a human","speak to a human","wtf","ugh"],Qe=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],H=n=>Array.from(n),Se=(n,e)=>H(n).slice(0,e).join(""),qt=0xcbf29ce484222325n,Ht=0x100000001b3n,Wt=0xffffffffffffffffn,Vt=new TextEncoder;function zt(n){let e=qt;for(let t of Vt.encode(n))e=(e^BigInt(t))*Ht&Wt;return e}function Xe(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(o=>H(o).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let o of e){let i=zt(o);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((i>>BigInt(a)&1n)===1n?1:-1)}let s=0n;for(let o=0;o<64;o++)(t[o]??0)>0&&(s|=1n<<BigInt(o));return s.toString(16).padStart(16,"0")}function Ze(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let i of Je)t.includes(` ${i} `)&&(s++,t=t.split(` ${i} `).join(" "));let o=Qe.filter(i=>t.includes(` ${i} `)).length;return s>o?-1:o>s?1:0}var et=n=>H(n).filter(e=>e>="0"&&e<="9").map(Number);function Kt(n){let e=et(n);if(e.length<13||e.length>19)return!1;let t=0;return e.reverse().forEach((s,o)=>t+=o%2===1?s>4?s*2-9:s*2:s),t%10===0}var Ye=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Gt=[[new RegExp(String.raw`(?<!${Ye})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${Ye})`,"gu"),Kt],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,()=>!0],[/\+?\p{Nd}[\p{Nd}\s().-]{7,}\p{Nd}/gu,Yt]];function Yt(n){let e=et(n).length;return e>=10&&e<=15}var Jt=n=>H(n).map(e=>/\s/u.test(e)?e:"*").join("");function we(n){let e=n;for(let[t,s]of Gt)e=e.replace(t,o=>s(o)?Jt(o):o);return e===n?void 0:e}function tt(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var nt=n=>typeof n=="string"&&Nt.includes(n)?n:void 0,U=(n,e)=>typeof n=="string"&&n?Se(n,e):void 0;function Qt(n,e,t){let s=Se(e,t),o=we(s);return o===void 0?{[n]:s}:{[n]:o,$ai_text_redacted:!0}}function st(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let o={$ai_role:n,$ai_message_index:t,$ai_text_length:H(e).length};if(n==="user"){let i=Xe(e);i!==void 0&&(o.$ai_text_hash=i),o.$ai_sentiment=Ze(e)}return s?{...o,...Qt("$ai_text",e,Bt)}:o}function ot(n,e){let t=n.value;if(n.kind==="thumbs"&&t!==1&&t!==-1||n.kind==="rating"&&!(Number.isInteger(t)&&t>=1&&t<=5)||n.kind!=="thumbs"&&n.kind!=="rating"&&n.kind!=="comment")return;let s={$ai_feedback_kind:n.kind};if(n.kind!=="comment"&&(s.$ai_feedback_value=t),n.comment&&e){let o=Se(n.comment,Ut);s.$ai_feedback_comment=we(o)??o}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function _e(n,e){let t=nt(n),s=U(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function Xt(){let n=globalThis.crypto,e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function rt(n={}){let e={$ai_conversation_id:n.conversationId||Xt()},t=(s,o)=>{o!==void 0&&(e[s]=o)};return t("$ai_agent_name",U(n.agentName,128)),t("$ai_agent_version",U(n.agentVersion,64)),t("$ai_topic",U(n.topic,128)),t("$ai_use_case",U(n.useCase,128)),t("$ai_trace_id",tt(n.traceId)),e}var q=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=rt(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(A.started,{}),this}message(e,t,s={}){let o=s.index??this.next,i=st(e,t,o,this.captureText);return i?(this.next=o+1,this.send(A.message,i),!0):!1}feedback(e){let t=ot(e,this.captureText);return t?(this.send(A.feedback,t),!0):!1}end(e,t){this.send(A.ended,_e(e,t))}outcome(e,t){let s=_e(e,t);return s.$ai_outcome?(this.send(A.outcome,s),!0):!1}};var Zt=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client","cypress","lightpanda","hubspot","nessus","prerender","deepscan","screaming frog","sitebulb","turnitin","ia_archiver","chatgpt-user","app.hypefactors.com","google favicon","google web preview","-google","googleother","googleweblight","google-read-aloud","google-inspectiontool","google-hoteladsverifier","google-cloudvertexbot"];function it(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:Zt.some(s=>t.includes(s))&&!/\bcubot\b/.test(t)}var O=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],at="lc_click_ids";function ct(n,e=90,t=Date.now){let s,o=()=>{try{return JSON.parse(n.get(at)??"{}")}catch{return{}}};return()=>{let i=o();if(location.search!==s){s=location.search;let d=new URLSearchParams(s),p=!1;for(let h of O){let m=d.get(h);m&&(i[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(at,JSON.stringify(i))}let a={};for(let d of O){let p=i[d];p&&t()-p.t<e*864e5&&(a[d]=p.v)}return a}}function en(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function tn(n){let e=new Map;for(let s of n.split(";")){let[o,...i]=s.trim().toLowerCase().split(/\s+/);o&&!e.has(o)&&e.set(o,i)}let t=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!t&&!(t.includes("'unsafe-inline'")&&!t.some(s=>s.startsWith("'nonce-")||s.startsWith("'sha")))}function dt(n,e){if(typeof document>"u")return()=>{};!e&&en().some(tn)&&n("CSP hint: this page's Content-Security-Policy blocks inline <style>; set the `nonce` option so guides and the experiment veil render (docs/guides/csp.md)");let t=s=>{let o=s;/^style-src/.test(o.effectiveDirective??"")&&o.blockedURI==="inline"&&n(`CSP hint: an inline style was blocked by ${o.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",t),()=>document.removeEventListener("securitypolicyviolation",t)}var nn=(n,e)=>n.slice(0,e);function lt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return nn(n,64)}}function ut(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,o=i=>{let a=i,d={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:lt(a.blockedURI??""),$csp_source_file:a.sourceFile?lt(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[d.$csp_directive,d.$csp_blocked_uri,d.$csp_source_file,d.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(d).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",o),()=>document.removeEventListener("securitypolicyviolation",o)}var sn=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],pt=()=>typeof location<"u"&&sn.includes(location.protocol);function on(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let o=n.slice(s.length),i=o.search(/[?#]/);return s+t(i<0?o:o.slice(0,i))+(i<0?"":o.slice(i))}function ft(n,e,t,s){if(!s)return{transport:n,fetch:e};let o=i=>on(i,t,s);return{transport:{send:(i,a,d)=>n.send(o(i),a,d)},fetch:((i,a)=>e(typeof i=="string"?o(i):i instanceof URL?o(i.href):i,a))}}var rn="__LUCIDA_DEVTOOLS_HOOK__";function gt(n,e,t){let s=globalThis[rn];if(!(!s||typeof s.emit!="function"||typeof s.attach!="function")){n.onCapture(o=>{try{s.emit(o)}catch{}});try{s.attach({projectKeyPrefix:n.apiKey.slice(0,8),apiHost:t,distinctId:()=>e.distinctId,loadToolbar:o=>e.loadToolbar(o),startReplay:async()=>n.replay?(await n.replay.start(!0),n.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var W=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function an(n){let e={},t=new URLSearchParams(location.search);for(let s of[...W,...O,...n]){let o=t.get(s);o&&(e[`$${s}`]=o)}return e}function ht(){let n=new URLSearchParams(location.search),e=W.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function cn(n){try{return n?new URL(n).hostname:""}catch{return""}}var ln=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function dn(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function mt(n,e,t=[],s=!1){let o={$current_url:ln(),$host:location.host,$pathname:s?dn():location.pathname,$referrer:document.referrer,$title:document.title,$screen_width:screen.width,$screen_height:screen.height,$viewport_width:window.innerWidth,$viewport_height:window.innerHeight,$browser_language:navigator.language,$timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};if(navigator.maxTouchPoints>1&&(o.$touch_points=navigator.maxTouchPoints),n!=="$pageview")return{properties:o};let i=an(t);Object.assign(o,i);let a=e.$current_url??location.href,d=e.$referrer??document.referrer,p={$initial_referrer:d||"$direct",$initial_referring_domain:cn(d)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(i))p[`$initial_${h.slice(1)}`]=m;return{properties:o,$set_once:p}}function yt(n,e,t=globalThis){e&&(t[typeof e=="string"?e:"lucida"]=n,typeof CustomEvent=="function"&&t.dispatchEvent?.(new CustomEvent("lucida:ready",{detail:n})))}var T=()=>{},ke=()=>Promise.resolve(),vt={isInternal:!1,hasOptedOut:()=>!1,hasOptedIn:()=>!1,consentStatus:()=>"pending",getConsentStatus:()=>"pending",getConsent:()=>({analytics:!1,replay:!1,marketing:!1}),getAllFlags:()=>({}),isFeatureEnabled:()=>!1,getFlagResult:n=>B(n,void 0,void 0,"not_found"),getReplayUrl:()=>"",onSessionId:()=>T,onFlags:()=>T,onIntervention:()=>T,onConsent:()=>T,flush:ke,shutdown:ke,reloadFlags:ke,loadToolbar:()=>Promise.resolve(!1),recommendations:n=>Promise.resolve({placement:n,strategy:"",items:[],shown:T,clicked:T})};function bt(n){return new Proxy(()=>{},{get:(e,t)=>{if(!(typeof t!="string"||t==="then"))return n&&Object.hasOwn(vt,t)?vt[t]:bt(!1)}})}var _t=()=>bt(!0);var St="_lcid";var un=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function pn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",o]=n.slice(t+1).split("_",2),i=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&i<=e+5e3&&e-i<=12e4)return o&&/^[\w-]{1,64}$/.test(o)?{distinctId:a,sessionId:o}:{distinctId:a}}function wt(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(St);if(t!==null){e.searchParams.delete(St),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!un(new URL(document.referrer).hostname,n))return}catch{return}return pn(t)}}function kt(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,o=s,i=e();return()=>{let a=e();return o=Math.min(s,o+(a-i)/1e3*t),i=a,o<1?!1:(o-=1,!0)}}var xe="<masked>",fn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],gn=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],xt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function hn(n,e){let t=n,s=[...fn,...e.maskParams??[],...e.maskCampaignParams?[...W,...O]:[]];if(s.length){let o=t.indexOf("#"),i=o<0?t:t.slice(0,o),a=o<0?"":t.slice(o);t=i.replace(new RegExp(`([?&])(${s.map(xt).join("|")})=[^&]*`,"gi"),`$1$2=${xe}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function Ct(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...W,...O].map(xt).join("|")})$`),t=s=>{let o;if(n.maskCampaignParams)for(let[i,a]of Object.entries(s))typeof a=="string"&&e.test(i)?(o??={...s})[i]=xe:i==="$click_ids"&&a&&typeof a=="object"&&((o??={...s})[i]=Object.fromEntries(Object.keys(a).map(d=>[d,xe])));for(let i of gn){let a=(o??s)[i];if(typeof a!="string")continue;let d=hn(a,n);d!==a&&((o??={...s})[i]=d)}return o??s};return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}function mn(n,e,t){let s=e;for(let o of n)try{let i=o(s);if(i==null)return null;if(typeof i!="object"||typeof i.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof i),null;s=i}catch(i){return t("beforeSend hook threw, dropping event:",i),null}return s}function yn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function vn(n){let e=new Set(n),t=s=>Object.fromEntries(Object.entries(s).filter(([o])=>!e.has(o)));return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}var Ce="lc_person_identified",se="lc_pending_set_once",Pt=new Set(["$identify","$create_alias","$groupidentify"]),$t="$$client_ingestion_warning",bn=6e4,Pe=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Ce)==="1";try{this.pending=JSON.parse(t.get(se)??"{}")}catch{this.pending={}}}mode;storage;identified;pending;get blocksPersonWrites(){return this.mode==="never"}get isProfile(){return this.mode==="always"||this.mode==="identified_only"&&this.identified}markIdentified(){this.mode!=="identified_only"||this.identified||(this.identified=!0,this.storage.set(Ce,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!Pt.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let t=Object.entries(e).filter(([s])=>!(s in this.pending));t.length&&(this.pending={...this.pending,...Object.fromEntries(t)},this.storage.set(se,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(se),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Ce),this.storage.remove(se)}};function _n(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:i,$set_once:a,$unset:d,...p}=e;t={...p,properties:{...e.properties,$process_person_profile:!1}}}else(s=n.person.take())&&(t={...e,$set_once:{...e.$set_once,...s}});let o=n.hooks.length?mn(n.hooks,t,n.log):t;return o&&n.limit&&!n.limit()&&(n.log("rate limited, dropped",o.event),n.onLimited?.(),o=null),!o&&s&&n.person.stash(s),o}function Sn(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[Ct(n.urlPrivacy??{}),...n.propertyDenylist?.length?[vn(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[yn(n.sampleRate)]:[],...e]}function It(n,e,t,s=Date.now){let o=new Pe(e.personProfiles??"always",n.storage),i,a,d=0,p=-1/0,h=()=>{d+=1,!(s()-p<bn)&&(p=s(),queueMicrotask(()=>{let m=d;d=0,n.capture($t,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==i&&(i=e.rateLimit,a=i?kt(i):void 0),_n({hooks:Sn(e),person:o,limit:m.event===$t?void 0:a,log:t,onLimited:h},m))),o}var $e=class{m=new Map;get(e){return this.m.get(e)??null}set(e,t){this.m.set(e,t)}remove(e){this.m.delete(e)}},wn=365,kn=new Set("co.uk org.uk ac.uk gov.uk me.uk ltd.uk plc.uk net.uk com.au net.au org.au edu.au gov.au co.nz org.nz net.nz co.jp ne.jp or.jp ac.jp go.jp co.kr or.kr com.cn net.cn org.cn com.hk com.tw com.sg com.my co.in net.in org.in co.id co.th com.ph com.vn com.br net.br org.br com.ar com.mx com.co com.pe com.tr com.ua com.pl co.za co.il com.eg com.sa com.ng co.ke github.io gitlab.io vercel.app netlify.app herokuapp.com pages.dev workers.dev web.app firebaseapp.com azurewebsites.net cloudfront.net appspot.com onrender.com fly.dev glitch.me repl.co blogspot.com wordpress.com myshopify.com vercel.dev netlify.com surge.sh render.com railway.app koyeb.app deno.dev ngrok.io ngrok-free.app trycloudflare.com cloudfunctions.net run.app s3.amazonaws.com elasticbeanstalk.com azurestaticapps.net wixsite.com webflow.io framer.app bubbleapps.io".split(" ")),xn=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function Cn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(kn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&xn.has(e[t]))return e.slice(t-1).join(".")}function Pn(n=location.hostname){if(/^[\d.]+$/.test(n)||n.includes(":"))return;let e=n.split(".");for(let t=e.length-2;t>=0;t--){let s=e.slice(t).join(".");if(document.cookie=`__lc_probe=1; Domain=${s}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${s}; Path=/; Max-Age=0`,s}return Cn(n)}var oe=class{constructor(e={}){this.o=e}o;domain=null;attr(){if(this.domain===null)try{this.domain=this.o.domain??(this.o.crossSubdomain?Pn():void 0)}catch{this.domain=void 0}return this.domain?`; Domain=${this.domain}`:""}held=new Map;read(e){try{for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)return decodeURIComponent(t.slice(s+1))}}catch{}return null}get(e){return this.read(e)??this.held.get(e)??null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",o=Math.round((this.o.expiryDays??wn)*86400);try{document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${o}; Path=/${this.attr()}; SameSite=Lax${s}`}catch{}this.read(e)===t?this.held.delete(e):this.held.set(e,t)}remove(e){this.held.delete(e);try{document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}catch{}}},M=class{constructor(e="localStorage"){this.kind=e}kind;store(){try{return globalThis[this.kind]}catch{return}}get(e){try{return this.store()?.getItem(e)??null}catch{return null}}set(e,t){try{this.store()?.setItem(e,t)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},Ie=class extends M{constructor(){super("localStorage")}},$n=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Oe=class{constructor(e,t,s){this.cookie=e;this.local=t;this.cookieKeys=s}cookie;local;cookieKeys;get(e){let[t,s]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return t.get(e)??s.get(e)}set(e,t){this.local.set(e,t),this.cookieKeys(e)?this.cookie.set(e,t):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},re=class{constructor(e,t){this.inner=e;this.delayMs=t}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,t){this.queue(e,t)}remove(e){this.queue(e,null)}queue(e,t){this.pending.set(e,t),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,t]of this.pending)t===null?this.inner.remove(e):this.inner.set(e,t);this.pending.clear()}},Ee=class{constructor(e,t){this.inner=e;this.suffix=t}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,t){this.inner.set(e+this.suffix,t)}remove(e){this.inner.remove(e+this.suffix)}},ie=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function ae(n,e,t){if(n==="memory"||n==="none")return new $e;let s=ie(e),o=n==="cookie"?new oe(t):n==="localStorage+cookie"?new Oe(new oe(t),new Ie,i=>$n.some(a=>i===a+s)):new M(n);return new Ee(o,s)}function Ot(n,e,t){let s=ie(e),o=new Set;try{for(let i of document.cookie.split("; "))o.add(i.split("=")[0]);for(let i of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<i.length;a++)o.add(i.key(a))}catch{}for(let i of o)if(!(!i.startsWith("lc_")||!i.endsWith(s)||i===t+s)){n.remove(i.slice(0,-s.length));try{localStorage.removeItem(i),sessionStorage.removeItem(i)}catch{}}}async function In(n){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(n).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function Et(n,e={}){let t=e.compress??!0,s=(o,i)=>(e.onError?.({url:o,status:i}),{status:i});return{async send(o,i,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(o,new Blob([i],{type:"text/plain"}))?{status:200}:s(o,0);try{let d=t&&i.length>=1024?await In(i):void 0,p=await n(d?`${o}${o.includes("?")?"&":"?"}compression=gzip`:o,{method:"POST",body:d??i,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(d?.length??i.length)<6e4});return p.status>=400?s(o,p.status):{status:p.status}}catch{return s(o,0)}}}}var Re={send:async()=>({status:200})};var On="lucida-browser",En="0.1.6",Ae="lc_internal",Rn=3e3,Rt="https://capture.lucidace.com",Te=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Me(n,e={},t=[]){if(typeof window>"u"||typeof navigator>"u")return _t();let s=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),o=(...r)=>{s&&console.debug("[lucida]",...r)},i=(e.apiHost??Rt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([r,c])=>[r,Te(c)?{...c}:c]));a.apiHost=i;let d=e.extension??pt(),p=r=>d&&(r==="cookie"||r==="localStorage+cookie")?e.extensionPersistence??"localStorage":r,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[i,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...r)=>fetch(...r)),P=r=>ft(r,_,m,e.rewritePath),g=P(Re).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,je=e.blockBots!==!1&&typeof navigator<"u"&&it(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||je;je&&o("bot user agent: capture disabled");let ce,le=P(e.transport??Et(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let r=new $(new M(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));le=ce=ve(le,r,{key:`lc_offline${ie(n)}`,isOnline:()=>navigator.onLine!==!1})}let V=k?void 0:wt(e.crossDomains),de=ae(k?"memory":h,n,e.cookie),z=(e.storageWriteDelayMs??0)>0?new re(de,e.storageWriteDelayMs):void 0,De=V?.sessionId??e.bootstrap?.sessionId,ue,K=!1,Le,pe=[],l=new N({apiKey:n,apiHost:i,transport:k?Re:le,storage:z??de,...e.consentPersistence&&!k?{consentStorage:ae(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:r=>!a.persistedProperties||a.persistedProperties.includes(r),...h==="none"?{cookieless:!0}:{},library:{name:On,version:En},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...!k&&(e.consent?.geo||e.consent?.mode!=="opt_in")?{awaitRemote:!0}:{},respectDnt:!0,dnt:S},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...V||e.bootstrap?.distinctId?{bootstrapDistinctId:V?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!V?{bootstrapIdentified:!0}:{},session:{...e.session,...De?{bootstrapId:De}:{}},enrich:(r,c)=>{let u=mt(r,c,a.customCampaignParams,e.capturePageview==="hash");if(i!==Rt&&(u.properties={...u.properties,$lib_custom_api_host:i}),pe.length){let I=l.sessionId;for(let At of pe)u.properties={...u.properties,...At(I)}}let y=Le?.()??{},w=Object.keys(y);return w.length&&(u.properties={...u.properties,$click_ids:y},r==="$pageview"&&(u.$set_once={...Object.fromEntries(w.map(I=>[`$initial_${I}`,y[I]])),...u.$set_once},u.$set=Object.fromEntries(w.map(I=>[`$last_${I}`,y[I]])))),a.sendFeatureFlags!==!1&&r!=="$snapshot"&&ue&&(u.properties={...be(ue.all()),...u.properties}),K?{...u,properties:{...u.properties,$internal:!0}}:u},campaignKey:ht,log:o});K=l.storage.get(Ae)==="1",e.clickIds!==!1&&(Le=ct(l.storage,e.clickIds?.expiryDays));let x=It(l,a,o);e.bootstrap?.isIdentified&&x.markIdentified();let j=r=>x.blocksPersonWrites?(o(`personProfiles=never: ${r} ignored`),!0):!1;k||l.onChange(r=>{r!=="consent"||l.hasConsent("analytics")||l.consentStatus()!=="denied"||(z?.flush(),Ot(de,n,e.consent?.storageKey||Y))});let fe=new Set;l.onChange(r=>{r==="consent"&&[...fe].forEach(c=>c())});let Fe=[],E=[dt(o,e.nonce)],Ne=l.storage;if(e.flagPersistence&&!k){let r=new $(ae(p(e.flagPersistence),n,e.cookie),()=>l.hasConsent("analytics"));l.onChange(c=>{c==="consent"&&(l.hasConsent("analytics")?r.flushBuffered():r.discardBuffered())}),Ne=r}let G=r=>{if(k)return;if(l.hasConsent("analytics"))return r();let c=!1;l.onChange(u=>{!c&&u==="consent"&&l.hasConsent("analytics")&&(c=!0,r())})},Be,f={core:l,client:void 0,config:a,flagStorage:Ne,apiKey:n,log:o,fetch:g,onUnload:r=>{Fe.push(r)},whenConsented:G,onCapture:r=>l.onCaptured(r),eventExtras:pe,clickExtras:[],flagPersonProps:[],loadConfig:()=>Be??=new Promise(r=>G(()=>{g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&l.applyRemote(c),c)).then(r,()=>r(null))}))},Ue=Promise.resolve();if(l.consent.resolving){let r=!1,c=g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(u=>(r=u.status>=500,u.ok?u.json():null)).catch(()=>(r=!0,null));Be=c,Ue=new Promise(u=>{let y=setTimeout(()=>(l.resolveConsent("opt_in"),u()),Rn);c.then(w=>{clearTimeout(y),w?l.applyRemote(w):r?l.resolveConsent("opt_in"):l.applyRemote({}),u()})})}let qe=ye(l,{apiHost:i,apiKey:n,fetch:g,whenConsented:G,log:o,disabled:k});E.push(()=>qe.stop());let D={get distinctId(){return l.distinctId},capture:(r,c,u)=>{l.capture(r,c,u?.timestamp!==void 0?{timestamp:u.timestamp}:{})&&(u?.sendInstantly||u?.transport)&&l.flush(u.transport==="beacon"?{beacon:!0}:{})},identify:(r,c,u)=>{j("identify")||(x.markIdentified(),l.identify(r,c,u))},alias:(r,c)=>{j("alias")||(x.markIdentified(),l.alias(r,c))},reset:r=>{l.reset({resetDeviceId:!!r,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{j("createPersonProfile")||x.isProfile||(x.markIdentified(),l.capture("$set",{}))},setConfig:r=>{let c=a;for(let[u,y]of Object.entries(r)){let w=c[u];Te(w)&&Te(y)?Object.assign(w,y):c[u]=y}"debug"in r&&(s=!!r.debug)},setPersonProperties:(r,c)=>{!r&&!c||j("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...r?{$set:r}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:r=>{!r.length||j("unsetPersonProperties")||(x.markIdentified(),l.capture("$set",{},{$unset:r}))},getDistinctId:()=>l.distinctId,getSessionId:()=>l.sessionId,onSessionId:r=>l.onSessionId(c=>r(c)),getProperty:r=>l.getProperty(r),hasOptedOut:()=>l.consentStatus()==="denied",hasOptedIn:()=>l.consentStatus()==="granted",onConsent:r=>(fe.add(r),()=>{fe.delete(r)}),getReplayUrl:r=>{let u=`${(e.uiHost??i).replace(/\/+$/,"")}/replays/${encodeURIComponent(l.sessionId)}`,y=l.sessionStart;return!r?.withTimestamp||y===void 0?u:`${u}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(r.timestampLookBackSeconds??10)))}`},debug:(r=!0)=>{s=r},featureView:(r,c)=>{l.capture("$feature_view",{...c,$feature_flag:r},{$set:{[`$feature_view/${r}`]:!0}})},featureInteraction:(r,c)=>{l.capture("$feature_interaction",{...c,$feature_flag:r},{$set:{[`$feature_interaction/${r}`]:!0}})},updateFlags:(r,c,u)=>f.flags?.update(r,c,u?.merge??!0),register:r=>l.register(r),registerOnce:r=>l.registerOnce(r),unregister:r=>l.unregister(r),group:(r,c,u)=>{x.markIdentified(),l.group(r,c,u)},optIn:(r=["analytics","replay"])=>l.setConsent({analytics:r.includes("analytics"),replay:r.includes("replay"),marketing:r.includes("marketing")}),optOut:()=>l.optOut(),optOutInternal:(r=!0)=>{K=r,r?l.storage.set(Ae,"1"):l.storage.remove(Ae)},get isInternal(){return K},setConsent:r=>l.setConsent(r),getConsent:()=>l.getConsent(),getConsentStatus:r=>l.getConsentStatus(r),consentStatus:()=>l.consentStatus(),getFlag:r=>f.flags?.get(r),getFlagPayload:r=>f.flags?.payload(r),getFlagResult:(r,c)=>f.flags?.result(r,c)??B(r,void 0,void 0,"not_found"),getLayerParam:(r,c,u)=>f.flags?.layerParam(r,c)??u,isFeatureEnabled:r=>{let c=f.flags?.get(r);return c!==void 0&&c!==!1},onFlags:r=>f.flags?.onChange(r)??(()=>{}),onIntervention:r=>qe.on(r),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(r,c)=>f.flags?.override(r,c),setPersonPropertiesForFlags:(r,c)=>f.flags?.setPersonProperties(r,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(r,c)=>f.flags?.setGroupProperties(r,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(r,c,u)=>f.flags?.setContext(r,c,u),clearContext:r=>f.flags?.clearContext(r),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:r=>f.guides?.show(r)??!1,reset:r=>f.guides?.reset(r)},ai:{startConversation:r=>new q((c,u)=>D.capture(c,u),r,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:r=>f.earlyAccess?.optIn(r),optOut:r=>f.earlyAccess?.optOut(r)},replay:{start:r=>f.replay?.start(r)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:r=>f.replay?.tag(r),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:r=>f.consentUi?.showBanner(r)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:r=>f.toolbar?.load(typeof r=="string"?r:r.token)??Promise.resolve(!1),activateExperiment:r=>f.experiments?.activate(r),recommendations:(r,c)=>f.recs?.get(r,c)??Promise.resolve({placement:r,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>Ue.then(()=>l.flush()),shutdown:async()=>{for(let r of E)r();z?.flush(),await l.shutdown()}};if(f.client=D,!k){let r=()=>{for(let u of Fe)u();z?.flush(),l.flush({beacon:!0})};window.addEventListener("pagehide",r);let c=()=>{document.visibilityState==="hidden"&&l.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",r),document.removeEventListener("visibilitychange",c)}),ce){let u=()=>{ce.drain()};window.addEventListener("online",u),E.push(()=>window.removeEventListener("online",u)),G(u)}if(e.captureCspViolations){let u=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};E.push(ut((y,w)=>{l.capture(y,w)},u))}for(let u of t){let y=u(f);y&&E.push(y)}ue=f.flags,t.length||f.loadConfig(),gt(f,D,i)}return yt(D,e.exposeGlobal),o("initialised",{apiHost:i,consent:l.getConsent()}),D}function Qs(n,e={}){return Me(n,e)}export{Me as createClient,Qs as init};
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module, H as Host } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /** Merge `lucida.session_id=<id>` into an existing W3C baggage header, replacing a stale entry. */
@@ -11,5 +11,11 @@ declare function correlatable(url: string, allow?: Array<string | RegExp>): bool
11
11
  * spans and errors to the Lucida session. Lucida's own ingest host is never touched.
12
12
  */
13
13
  declare const correlate: Module;
14
+ /**
15
+ * One session id across both SDKs: when a Watchtower browser client is present (`watchtower.client`, else
16
+ * `globalThis.watchtower`) the Lucida session id is set as its `lucida.session_id` attribute, now and on every
17
+ * rotation, once analytics consent is granted. Absent client: nothing happens.
18
+ */
19
+ declare function stampSession(host: Host): (() => void) | undefined;
14
20
 
15
- export { correlatable, correlate, withBaggage };
21
+ export { correlatable, correlate, stampSession, withBaggage };
package/dist/correlate.js CHANGED
@@ -1 +1 @@
1
- function f(s){let o=window.fetch;window.fetch=function(n,i){let c=n instanceof Request?n.url:String(n),a=new Headers(i?.headers??(n instanceof Request?n.headers:void 0)),l=[...a.entries()].join("|");return s(c,a),[...a.entries()].join("|")===l?o.call(this,n,i):o.call(this,n,{...i,headers:a})};let t=XMLHttpRequest.prototype,{open:e,send:u}=t,r=new WeakMap;return t.open=function(n,i,...c){return r.set(this,String(i)),e.call(this,n,i,...c)},t.send=function(n){let i=r.get(this);if(i){let c=new Headers;s(i,c),c.forEach((a,l)=>this.setRequestHeader(l,a))}return u.call(this,n)},()=>{window.fetch=o,t.open=e,t.send=u}}var g="lucida.session_id";function p(s,o){return[...(s??"").split(",").map(e=>e.trim()).filter(e=>e&&!e.startsWith(`${g}=`)),`${g}=${encodeURIComponent(o)}`].join(",")}function d(s,o=[]){let t;try{t=new URL(s,location.href)}catch{return!1}return t.origin===location.origin||o.some(e=>typeof e=="string"?t.origin===e:e.test(t.href))}var w=s=>{let o=s.config.watchtower;if(!o?.correlate)return;let{core:t}=s,e=t.sessionId;s.onCapture(r=>e=String(r.properties.$session_id??e));let u=r=>t.hasConsent("analytics")&&!r.startsWith(s.config.apiHost)&&d(r,o.origins);return f((r,n)=>{u(r)&&n.set("baggage",p(n.get("baggage"),e))})};export{d as correlatable,w as correlate,p as withBaggage};
1
+ function d(n){let o=window.fetch;window.fetch=function(r,s){let i=r instanceof Request?r.url:String(r),a=new Headers(s?.headers??(r instanceof Request?r.headers:void 0)),f=[...a.entries()].join("|");return n(i,a),[...a.entries()].join("|")===f?o.call(this,r,s):o.call(this,r,{...s,headers:a})};let t=XMLHttpRequest.prototype,{open:e,send:c}=t,u=new WeakMap;return t.open=function(r,s,...i){return u.set(this,String(s)),e.call(this,r,s,...i)},t.send=function(r){let s=u.get(this);if(s){let i=new Headers;n(s,i),i.forEach((a,f)=>this.setRequestHeader(f,a))}return c.call(this,r)},()=>{window.fetch=o,t.open=e,t.send=c}}var l="lucida.session_id";function p(n,o){return[...(n??"").split(",").map(e=>e.trim()).filter(e=>e&&!e.startsWith(`${l}=`)),`${l}=${encodeURIComponent(o)}`].join(",")}function g(n,o=[]){let t;try{t=new URL(n,location.href)}catch{return!1}return t.origin===location.origin||o.some(e=>typeof e=="string"?t.origin===e:e.test(t.href))}var q=n=>{let o=n.config.watchtower,{core:t}=n,e=h(n);if(!o?.correlate)return e;let c=t.sessionId;n.onCapture(s=>c=String(s.properties.$session_id??c));let u=s=>t.hasConsent("analytics")&&!s.startsWith(n.config.apiHost)&&g(s,o.origins),r=d((s,i)=>{u(s)&&i.set("baggage",p(i.get("baggage"),c))});return()=>(r(),e?.())};function h(n){let o=n.config.watchtower?.client??globalThis.watchtower;if(typeof o?.setAttribute!="function")return;let{core:t}=n,e=c=>{t.hasConsent("analytics")&&o.setAttribute(l,c)};return n.whenConsented(()=>e(t.sessionId)),t.onSessionId(e)}export{g as correlatable,q as correlate,h as stampSession,p as withBaggage};
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /** One visual-editor change against a CSS selector (stored as JSON on the variant payload). `url`
package/dist/flags.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /**
package/dist/forms.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /** Opaque, stable field/form identifier. Names and labels are hashed; values are never read. */
package/dist/guides.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as GuideStep, f as GuideAutomation, g as Guide, h as GuideTokens, M as Module } from './types-DKM0hGl2.js';
1
+ import { G as GuideStep, f as GuideAutomation, g as Guide, h as GuideTokens, M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  /** `POST /v1/guides/answer` response. */
@@ -1,5 +1,5 @@
1
1
  import { Props } from '@lucida-analytics/sdk-core';
2
- import { M as Module } from './types-DKM0hGl2.js';
2
+ import { M as Module } from './types-QPJGHOv0.js';
3
3
 
4
4
  type ViewportBucket = "mobile" | "tablet" | "desktop";
5
5
  declare function viewportBucket(width: number): ViewportBucket;
@@ -1,4 +1,4 @@
1
- import { M as Module } from './types-DKM0hGl2.js';
1
+ import { M as Module } from './types-QPJGHOv0.js';
2
2
  import '@lucida-analytics/sdk-core';
3
3
 
4
4
  declare const DISTINCT_ID_HEADER = "X-Lucida-Distinct-Id";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { L as LazyModuleName, M as Module, d as BrowserConfig, e as Client } from './types-DKM0hGl2.js';
2
- export { A as AgentAnalytics, i as AutocaptureConfig, j as BeforeSend, k as BootstrapConfig, l as CaptureOptions, D as DeliveryConfig, m as FlagOptions, F as FlagValue, n as FlagsService, o as FrustrationConfig, g as Guide, f as GuideAutomation, p as GuideButton, q as GuideKind, r as GuideRule, G as GuideStep, h as GuideTokens, s as GuidesService, H as Host, P as Persistence, t as PersonProfiles, u as PropFilter, R as RECS_PAYLOAD_KEY, v as RecommendationItem, w as RecommendationOptions, x as Recommendations, y as RecsService, z as RemoteConfig, E as ReplayControl, S as StorageConfig, T as TargetConditions, U as UrlPrivacy, I as denylistHook, J as placementFlag, K as privatizeUrl, N as recommendations, O as sampleHook, Q as urlPrivacyHook } from './types-DKM0hGl2.js';
3
- export { D as DEFAULT_HOST, L as LIB_VERSION, c as createClient } from './client--prXZN9c.js';
1
+ import { L as LazyModuleName, M as Module, e as Client, d as BrowserConfig } from './types-QPJGHOv0.js';
2
+ export { A as AgentAnalytics, i as AutocaptureConfig, j as BeforeSend, k as BootstrapConfig, l as CaptureOptions, D as DeliveryConfig, m as FlagOptions, F as FlagValue, n as FlagsService, o as FrustrationConfig, g as Guide, f as GuideAutomation, p as GuideButton, q as GuideKind, r as GuideRule, G as GuideStep, h as GuideTokens, s as GuidesService, H as Host, P as Persistence, t as PersonProfiles, u as PropFilter, R as RECS_PAYLOAD_KEY, v as RecommendationItem, w as RecommendationOptions, x as Recommendations, y as RecsService, z as RemoteConfig, E as ReplayControl, S as StorageConfig, T as TargetConditions, U as UrlPrivacy, W as WatchtowerLike, I as denylistHook, J as placementFlag, K as privatizeUrl, N as recommendations, O as sampleHook, Q as urlPrivacyHook } from './types-QPJGHOv0.js';
3
+ export { D as DEFAULT_HOST, L as LIB_VERSION, c as createClient } from './client-pxkkaWtR.js';
4
4
  export { autocapture, tag404 } from './autocapture.js';
5
5
  export { flags } from './flags.js';
6
6
  export { hostHeaders } from './host-headers.js';
@@ -15,11 +15,15 @@ type Importer = (url: string) => Promise<Record<string, unknown>>;
15
15
  /**
16
16
  * Loads the named ESM entries from the versioned asset path (same version as this script, so a pinned loader always
17
17
  * gets matching modules). A module that fails to load is logged and skipped; the client still starts.
18
+ * With a manifest, each module is fetched and hashed (WebCrypto SHA-384) against it before it runs; a mismatch, a
19
+ * module the manifest does not list, or no WebCrypto refuses it. No manifest (an old deploy): load as before.
20
+ * shortcut: the verified bytes are fetched again by `import()` (immutable URL, so the HTTP cache serves it), and
21
+ * lazy chunks a module imports are not hashed; upgrade to blob-import plus chunk hashes when needed.
18
22
  */
19
23
  declare function loadModules(names: readonly LazyModuleName[], base: {
20
24
  assetHost: string;
21
25
  version: string;
22
- }, log: (...a: unknown[]) => void, importer?: Importer): Promise<Module[]>;
26
+ }, log: (...a: unknown[]) => void, importer?: Importer, fetchImpl?: typeof fetch): Promise<Module[]>;
23
27
  /** URL with its path rewritten when it points at one of `origins` (query kept); other URLs pass through. */
24
28
  declare function rewriteUrl(url: string, origins: readonly string[], rewrite: (path: string) => string): string;
25
29
 
@@ -41,6 +45,12 @@ declare function captureCspViolations(capture: (event: string, props: Record<str
41
45
  /** Decorates links to the configured domains with the current distinct id and session id, only while analytics consent is held. */
42
46
  declare const crossDomain: Module;
43
47
 
48
+ /** Publish `client` as `target[name]` (default `globalThis.lucida`, the classic script's `window.lucida`) and fire `lucida:ready` on it. */
49
+ declare function exposeGlobal(client: Client, opt: boolean | string | undefined, target?: Window | typeof globalThis): void;
50
+
51
+ /** What `init()` returns on the server (no window): the client's shape, every method a silent no-op. */
52
+ declare const noopClient: () => Client;
53
+
44
54
  /** What the SDK hands a devtools hook: enough to inspect events and open the toolbar or a replay. */
45
55
  interface DevtoolsTarget {
46
56
  readonly projectKeyPrefix: string;
@@ -86,4 +96,4 @@ declare const flagSources: Module;
86
96
  * Opt-in modules (replay, heatmaps, forms, toolbar, inspector, consent adapters) have their own entry points. Import "@lucida-analytics/browser/core" for the minimal build. */
87
97
  declare function init(apiKey: string, config?: BrowserConfig, extra?: Module[]): Client;
88
98
 
89
- export { BrowserConfig, Client, type CspCaptureOptions, type DevtoolsHook, type DevtoolsTarget, type FlagTargetingSources, LazyModuleName, Module, assetUrl, blocksInlineStyle, captureCspViolations, crossDomain, flagSourceProps, flagSources, init, isExtensionPage, loadModules, rewriteUrl, styleTag };
99
+ export { BrowserConfig, Client, type CspCaptureOptions, type DevtoolsHook, type DevtoolsTarget, type FlagTargetingSources, LazyModuleName, Module, assetUrl, blocksInlineStyle, captureCspViolations, crossDomain, exposeGlobal, flagSourceProps, flagSources, init, isExtensionPage, loadModules, noopClient, rewriteUrl, styleTag };