@lucida-analytics/browser 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +228 -2
- package/dist/autocapture.d.ts +78 -0
- package/dist/autocapture.js +1 -0
- package/dist/banner-CGEWCIGP.js +1 -0
- package/dist/chunk-3PWTJFHH.js +1 -0
- package/dist/chunk-AWIQCFGN.js +1 -0
- package/dist/chunk-GVYMMTQM.js +1 -0
- package/dist/chunk-MCWQHOEV.js +1 -0
- package/dist/chunk-MI35SSIT.js +1 -0
- package/dist/client-ts5YMCoB.d.ts +8 -0
- package/dist/consent.d.ts +84 -0
- package/dist/consent.js +1 -0
- package/dist/core.d.ts +9 -0
- package/dist/core.js +3 -0
- package/dist/correlate.d.ts +15 -0
- package/dist/correlate.js +1 -0
- package/dist/early-access.d.ts +12 -0
- package/dist/early-access.js +1 -0
- package/dist/experiments.d.ts +199 -0
- package/dist/experiments.js +1 -0
- package/dist/flags.d.ts +13 -0
- package/dist/flags.js +3 -0
- package/dist/forms.d.ts +13 -0
- package/dist/forms.js +1 -0
- package/dist/guides.d.ts +1158 -0
- package/dist/guides.js +1 -0
- package/dist/heatmaps.d.ts +17 -0
- package/dist/heatmaps.js +1 -0
- package/dist/host-headers.d.ts +16 -0
- package/dist/host-headers.js +1 -0
- package/dist/index.d.ts +89 -0
- package/dist/index.js +3 -0
- package/dist/inspector.d.ts +13 -0
- package/dist/inspector.js +1 -0
- package/dist/lucida.js +3 -0
- package/dist/modules-FANMZRDJ.js +1 -0
- package/dist/persistent-XLGNSZQR.js +1 -0
- package/dist/recommendations.d.ts +2 -0
- package/dist/recommendations.js +1 -0
- package/dist/recorder-LFUTDRP4.js +78 -0
- package/dist/replay.d.ts +18 -0
- package/dist/replay.js +1 -0
- package/dist/static/v0/autocapture.js +1 -0
- package/dist/static/v0/banner-CGEWCIGP.js +1 -0
- package/dist/static/v0/chunk-3PWTJFHH.js +1 -0
- package/dist/static/v0/chunk-AWIQCFGN.js +1 -0
- package/dist/static/v0/chunk-GVYMMTQM.js +1 -0
- package/dist/static/v0/chunk-MCWQHOEV.js +1 -0
- package/dist/static/v0/chunk-MI35SSIT.js +1 -0
- package/dist/static/v0/consent.js +1 -0
- package/dist/static/v0/core.js +3 -0
- package/dist/static/v0/correlate.js +1 -0
- package/dist/static/v0/early-access.js +1 -0
- package/dist/static/v0/experiments.js +1 -0
- package/dist/static/v0/flags.js +3 -0
- package/dist/static/v0/forms.js +1 -0
- package/dist/static/v0/guides.js +1 -0
- package/dist/static/v0/heatmaps.js +1 -0
- package/dist/static/v0/host-headers.js +1 -0
- package/dist/static/v0/index.js +3 -0
- package/dist/static/v0/inspector.js +1 -0
- package/dist/static/v0/lucida.js +3 -0
- package/dist/static/v0/modules-FANMZRDJ.js +1 -0
- package/dist/static/v0/persistent-XLGNSZQR.js +1 -0
- package/dist/static/v0/recommendations.js +1 -0
- package/dist/static/v0/recorder-LFUTDRP4.js +78 -0
- package/dist/static/v0/replay.js +1 -0
- package/dist/static/v0/toolbar.js +4 -0
- package/dist/static/v0/validation-ENITEP6V.js +1 -0
- package/dist/static/v0/webmcp.js +1 -0
- package/dist/static/v0.1.0/autocapture.js +1 -0
- package/dist/static/v0.1.0/banner-CGEWCIGP.js +1 -0
- package/dist/static/v0.1.0/chunk-3PWTJFHH.js +1 -0
- package/dist/static/v0.1.0/chunk-AWIQCFGN.js +1 -0
- package/dist/static/v0.1.0/chunk-GVYMMTQM.js +1 -0
- package/dist/static/v0.1.0/chunk-MCWQHOEV.js +1 -0
- package/dist/static/v0.1.0/chunk-MI35SSIT.js +1 -0
- package/dist/static/v0.1.0/consent.js +1 -0
- package/dist/static/v0.1.0/core.js +3 -0
- package/dist/static/v0.1.0/correlate.js +1 -0
- package/dist/static/v0.1.0/early-access.js +1 -0
- package/dist/static/v0.1.0/experiments.js +1 -0
- package/dist/static/v0.1.0/flags.js +3 -0
- package/dist/static/v0.1.0/forms.js +1 -0
- package/dist/static/v0.1.0/guides.js +1 -0
- package/dist/static/v0.1.0/heatmaps.js +1 -0
- package/dist/static/v0.1.0/host-headers.js +1 -0
- package/dist/static/v0.1.0/index.js +3 -0
- package/dist/static/v0.1.0/inspector.js +1 -0
- package/dist/static/v0.1.0/integrity.json +30 -0
- package/dist/static/v0.1.0/lucida.js +3 -0
- package/dist/static/v0.1.0/modules-FANMZRDJ.js +1 -0
- package/dist/static/v0.1.0/persistent-XLGNSZQR.js +1 -0
- package/dist/static/v0.1.0/recommendations.js +1 -0
- package/dist/static/v0.1.0/recorder-LFUTDRP4.js +78 -0
- package/dist/static/v0.1.0/replay.js +1 -0
- package/dist/static/v0.1.0/toolbar.js +4 -0
- package/dist/static/v0.1.0/validation-ENITEP6V.js +1 -0
- package/dist/static/v0.1.0/webmcp.js +1 -0
- package/dist/toolbar.d.ts +193 -0
- package/dist/toolbar.js +4 -0
- package/dist/types-BWd9sbCh.d.ts +1071 -0
- package/dist/types-Cv4pBbPu.d.ts +898 -0
- package/dist/validation-ENITEP6V.js +1 -0
- package/dist/webmcp.d.ts +21 -0
- package/dist/webmcp.js +1 -0
- package/package.json +104 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var je="lc_consent",ae=["analytics","replay","marketing"],M=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||je;let s=e.storage.get(this.key);if(s)try{let r=JSON.parse(s);for(let o of ae)typeof r[o]=="boolean"&&(this.state[o]=r[o]);this.decided=ae.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 ae)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 W=0,E=0;function De(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>W){W=n;let o=De(2);E=((o[0]??0)<<8|(o[1]??0))&1023}else E++,E>4095&&(W++,E=0);let e=De(8),t=new Uint8Array(16),s=W;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|E>>8,t[7]=E&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 Le="lc_identity",V=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let o=e.get(Le),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 u=t??w();this.s={distinct_id:u,anon_id:u,identified:r&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(Le,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 j(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 Fe(n){return n===0||n===408||n===429||n>=500}var z=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;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).then(a=>this.settle(t,a,!!e.beacon)).finally(()=>{this.inflight=void 0});return this.inflight=o,o}settle(e,t,s){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Fe(t)||s||this.attempt>=this.maxRetries){this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let r=j(this.attempt++,this.o.backoff);this.o.log?.("retry in",r,"ms"),this.arm(r)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var ce="lc_session";function Ne(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var K=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=t.idleMs??30*6e4,this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??Date,this.bootstrapId=t.bootstrapId}storage;o;windowId=w();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=Ne(e.session_idle_minutes,1,1440)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=Ne(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(ce);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),u=!r||s-r.last>this.idleMs||s-r.start>this.maxMs||o||a;return(u||!r)&&(r={id:!r&&this.bootstrapId||w(s),start:s,last:s}),this.bootstrapId=void 0,r.last=s,e&&(r.campaign=e),this.storage.set(ce,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:u}}startedAt(){return this.read()?.start}reset(){this.storage.remove(ce)}};function Be(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var G=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Be(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)}},J=class{constructor(e){this.storage=e;this.g=Be(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 _t(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var D=class{constructor(e){this.c=e;this.clock=e.clock??Date,this.consent=new M({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new $(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new V(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new K(this.gated,{clock:this.clock,...e.session}),this.props=new G(this.gated,void 0,e.persistProperty),this.groupState=new J(this.gated),this.queue=new z({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 u=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:_t(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:u.sessionId,$window_id:u.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 qe(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,u=[];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"?u.push(_??""):m==="id"&&(a=_)}u.length&&n(a===void 0?{event:o,data:u.join(`
|
|
2
|
+
`)}:{event:o,data:u.join(`
|
|
3
|
+
`),id:a})}}}var Y=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=j(t++,this.o.backoff))}catch(r){this.live(e)&&this.o.log?.("intervention stream error",r),s=j(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=qe(u=>{if(!(u.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(u.data))}catch{this.o.log?.("bad intervention payload")}}),a=r.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:u,value:p}=await a.read();if(u)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 de(n,e){let t=new Set,{whenConsented:s,disabled:r,...o}=e,a=new Y({...o,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),u=!1;return n.onChange(p=>{u&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!u&&!r&&(u=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function le(n,e,t={}){let s=t.key??"lc_offline",r=t.maxBatches??50,o=t.maxBytes??1e6,a=t.isOnline??(()=>!0),u,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]),u??=setTimeout(()=>{u=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 ue(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 pe(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 R={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},St=["resolved","unresolved","escalated","abandoned","error"],xt=4e3,kt=2e3,Ue=["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"],We=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],N=n=>Array.from(n),ge=(n,e)=>N(n).slice(0,e).join(""),wt=0xcbf29ce484222325n,Ct=0x100000001b3n,Pt=0xffffffffffffffffn,$t=new TextEncoder;function It(n){let e=wt;for(let t of $t.encode(n))e=(e^BigInt(t))*Ct&Pt;return e}function Ve(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(r=>N(r).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let r of e){let o=It(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 ze(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let o of Ue)t.includes(` ${o} `)&&(s++,t=t.split(` ${o} `).join(" "));let r=We.filter(o=>t.includes(` ${o} `)).length;return s>r?-1:r>s?1:0}var Ke=n=>N(n).filter(e=>e>="0"&&e<="9").map(Number);function Ot(n){let e=Ke(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 He=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Et=[[new RegExp(String.raw`(?<!${He})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${He})`,"gu"),Ot],[/[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,Rt]];function Rt(n){let e=Ke(n).length;return e>=10&&e<=15}var At=n=>N(n).map(e=>/\s/u.test(e)?e:"*").join("");function he(n){let e=n;for(let[t,s]of Et)e=e.replace(t,r=>s(r)?At(r):r);return e===n?void 0:e}function Ge(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var Je=n=>typeof n=="string"&&St.includes(n)?n:void 0,L=(n,e)=>typeof n=="string"&&n?ge(n,e):void 0;function Tt(n,e,t){let s=ge(e,t),r=he(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function Ye(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let r={$ai_role:n,$ai_message_index:t,$ai_text_length:N(e).length};if(n==="user"){let o=Ve(e);o!==void 0&&(r.$ai_text_hash=o),r.$ai_sentiment=ze(e)}return s?{...r,...Tt("$ai_text",e,xt)}:r}function Qe(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=ge(n.comment,kt);s.$ai_feedback_comment=he(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function fe(n,e){let t=Je(n),s=L(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function Mt(){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 Ze(n={}){let e={$ai_conversation_id:n.conversationId||Mt()},t=(s,r)=>{r!==void 0&&(e[s]=r)};return t("$ai_agent_name",L(n.agentName,128)),t("$ai_agent_version",L(n.agentVersion,64)),t("$ai_topic",L(n.topic,128)),t("$ai_use_case",L(n.useCase,128)),t("$ai_trace_id",Ge(n.traceId)),e}var F=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=Ze(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(R.started,{}),this}message(e,t,s={}){let r=s.index??this.next,o=Ye(e,t,r,this.captureText);return o?(this.next=r+1,this.send(R.message,o),!0):!1}feedback(e){let t=Qe(e,this.captureText);return t?(this.send(R.feedback,t),!0):!1}end(e,t){this.send(R.ended,fe(e,t))}outcome(e,t){let s=fe(e,t);return s.$ai_outcome?(this.send(R.outcome,s),!0):!1}};var jt=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client"];function Xe(n){let e=n.toLowerCase();return jt.some(t=>e.includes(t))&&!/\bcubot\b/.test(e)}var Q=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid"],et="lc_click_ids";function tt(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(et)??"{}")}catch{return{}}};return()=>{let o=r();if(location.search!==s){s=location.search;let u=new URLSearchParams(s),p=!1;for(let h of Q){let m=u.get(h);m&&(o[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(et,JSON.stringify(o))}let a={};for(let u of Q){let p=o[u];p&&t()-p.t<e*864e5&&(a[u]=p.v)}return a}}function Dt(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function Lt(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 st(n,e){if(typeof document>"u")return()=>{};!e&&Dt().some(Lt)&&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 Ft=(n,e)=>n.slice(0,e);function nt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return Ft(n,64)}}function rt(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,r=o=>{let a=o,u={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:nt(a.blockedURI??""),$csp_source_file:a.sourceFile?nt(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[u.$csp_directive,u.$csp_blocked_uri,u.$csp_source_file,u.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(u).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",r),()=>document.removeEventListener("securitypolicyviolation",r)}var Nt=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],it=()=>typeof location<"u"&&Nt.includes(location.protocol);function Bt(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 ot(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=o=>Bt(o,t,s);return{transport:{send:(o,a,u)=>n.send(r(o),a,u)},fetch:((o,a)=>e(typeof o=="string"?r(o):o instanceof URL?r(o.href):o,a))}}var qt="__LUCIDA_DEVTOOLS_HOOK__";function at(n,e,t){let s=globalThis[qt];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 ct=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Ht(n){let e={},t=new URLSearchParams(location.search);for(let s of[...ct,...Q,...n]){let r=t.get(s);r&&(e[`$${s}`]=r)}return e}function dt(){let n=new URLSearchParams(location.search),e=ct.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function Ut(n){try{return n?new URL(n).hostname:""}catch{return""}}var Wt=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function Vt(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function lt(n,e,t=[],s=!1){let r={$current_url:Wt(),$host:location.host,$pathname:s?Vt():location.pathname,$referrer:document.referrer,$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=Ht(t);Object.assign(r,o);let a=e.$current_url??location.href,u=e.$referrer??document.referrer,p={$initial_referrer:u||"$direct",$initial_referring_domain:Ut(u)||"$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 ut="_lcid";var zt=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function Kt(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 pt(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(ut);if(t!==null){e.searchParams.delete(ut),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!zt(new URL(document.referrer).hostname,n))return}catch{return}return Kt(t)}}function ft(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)}}function Gt(n,e,t){let s=e;for(let r of n)try{let o=r(s);if(o==null)return null;s=o}catch(o){t("beforeSend hook threw, keeping event:",o)}return s}function Jt(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function Yt(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 me="lc_person_identified",Z="lc_pending_set_once",gt=new Set(["$identify","$create_alias","$groupidentify"]),ht="$$client_ingestion_warning",Qt=6e4,ye=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(me)==="1";try{this.pending=JSON.parse(t.get(Z)??"{}")}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(me,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!gt.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(Z,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(Z),e}reset(){this.identified=!1,this.pending={},this.storage.remove(me),this.storage.remove(Z)}};function Zt(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:u,...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?Gt(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 Xt(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[...n.propertyDenylist?.length?[Yt(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[Jt(n.sampleRate)]:[],...e]}function mt(n,e,t,s=Date.now){let r=new ye(e.personProfiles??"always",n.storage),o,a,u=0,p=-1/0,h=()=>{u+=1,!(s()-p<Qt)&&(p=s(),queueMicrotask(()=>{let m=u;u=0,n.capture(ht,{$$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?ft(o):void 0),Zt({hooks:Xt(e),person:r,limit:m.event===ht?void 0:a,log:t,onLimited:h},m))),r}var ve=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)}},en=365,tn=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(" ")),nn=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function sn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(tn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&nn.has(e[t]))return e.slice(t-1).join(".")}function rn(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 sn(n)}var X=class{constructor(e={}){this.o=e}o;domain=null;attr(){return this.domain===null&&(this.domain=this.o.domain??(this.o.crossSubdomain?rn():void 0)),this.domain?`; Domain=${this.domain}`:""}get(e){for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)try{return decodeURIComponent(t.slice(s+1))}catch{return null}}return null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",r=Math.round((this.o.expiryDays??en)*86400);document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${r}; Path=/${this.attr()}; SameSite=Lax${s}`}remove(e){document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}},A=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{}}},be=class extends A{constructor(){super("localStorage")}},on=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],_e=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)}},ee=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()}},Se=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)}},xe=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function te(n,e,t){if(n==="memory"||n==="none")return new ve;let s=xe(e),r=n==="cookie"?new X(t):n==="localStorage+cookie"?new _e(new X(t),new be,o=>on.some(a=>o===a+s)):new A(n);return new Se(r,s)}async function an(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 yt(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 u=t&&o.length>=1024?await an(o):void 0,p=await n(u?`${r}${r.includes("?")?"&":"?"}compression=gzip`:r,{method:"POST",body:u??o,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(u?.length??o.length)<6e4});return p.status>=400?s(r,p.status):{status:p.status}}catch{return s(r,0)}}}}var ke={send:async()=>({status:200})};var cn="lucida-browser",dn="0.1.0",we="lc_internal",ln=3e3,vt="https://app.lucida.dev",Ce=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Pe(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??vt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([i,c])=>[i,Ce(c)?{...c}:c]));a.apiHost=o;let u=e.extension??it(),p=i=>u&&(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=>ot(i,_,m,e.rewritePath),g=C(ke).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,$e=e.blockBots!==!1&&typeof navigator<"u"&&Xe(navigator.userAgent??""),k=!!e.disabled||$e;$e&&r("bot user agent: capture disabled");let ne,se=C(e.transport??yt(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let i=new $(new A(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));se=ne=le(se,i,{key:`lc_offline${xe(n)}`,isOnline:()=>navigator.onLine!==!1})}let B=k?void 0:pt(e.crossDomains),Ie=te(k?"memory":h,n,e.cookie),re=(e.storageWriteDelayMs??0)>0?new ee(Ie,e.storageWriteDelayMs):void 0,Oe=B?.sessionId??e.bootstrap?.sessionId,ie,q=!1,Ee,oe=[],l=new D({apiKey:n,apiHost:o,transport:k?ke:se,storage:re??Ie,...e.consentPersistence&&!k?{consentStorage:te(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:i=>!a.persistedProperties||a.persistedProperties.includes(i),...h==="none"?{cookieless:!0}:{},library:{name:cn,version:dn},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}:{}},...B||e.bootstrap?.distinctId?{bootstrapDistinctId:B?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!B?{bootstrapIdentified:!0}:{},session:{...e.session,...Oe?{bootstrapId:Oe}:{}},enrich:(i,c)=>{let d=lt(i,c,a.customCampaignParams,e.capturePageview==="hash");if(o!==vt&&(d.properties={...d.properties,$lib_custom_api_host:o}),oe.length){let I=l.sessionId;for(let bt of oe)d.properties={...d.properties,...bt(I)}}let y=Ee?.()??{},P=Object.keys(y);return P.length&&(d.properties={...d.properties,$click_ids:y},i==="$pageview"&&(d.$set_once={...Object.fromEntries(P.map(I=>[`$initial_${I}`,y[I]])),...d.$set_once},d.$set=Object.fromEntries(P.map(I=>[`$last_${I}`,y[I]])))),a.sendFeatureFlags!==!1&&i!=="$snapshot"&&ie&&(d.properties={...ue(ie.all()),...d.properties}),q?{...d,properties:{...d.properties,$internal:!0}}:d},campaignKey:dt,log:r});q=l.storage.get(we)==="1",e.clickIds!==!1&&(Ee=tt(l.storage,e.clickIds?.expiryDays));let x=mt(l,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let T=i=>x.blocksPersonWrites?(r(`personProfiles=never: ${i} ignored`),!0):!1,Re=[],O=[st(r,e.nonce)],Ae=l.storage;if(e.flagPersistence&&!k){let i=new $(te(p(e.flagPersistence),n,e.cookie),()=>l.hasConsent("analytics"));l.onChange(c=>{c==="consent"&&(l.hasConsent("analytics")?i.flushBuffered():i.discardBuffered())}),Ae=i}let H=i=>{if(k)return;if(l.hasConsent("analytics"))return i();let c=!1;l.onChange(d=>{!c&&d==="consent"&&l.hasConsent("analytics")&&(c=!0,i())})},Te,f={core:l,client:void 0,config:a,flagStorage:Ae,apiKey:n,log:r,fetch:g,onUnload:i=>{Re.push(i)},whenConsented:H,onCapture:i=>l.onCaptured(i),eventExtras:oe,clickExtras:[],flagPersonProps:[],loadConfig:()=>Te??=new Promise(i=>H(()=>{g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&l.applyRemote(c),c)).then(i,()=>i(null))}))};if(l.consent.resolving){let i=g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(d=>d.ok?d.json():null).catch(()=>null);Te=i;let c=setTimeout(()=>l.applyRemote({}),ln);i.then(d=>{clearTimeout(c),l.applyRemote(d??{})})}let Me=de(l,{apiHost:o,apiKey:n,fetch:g,whenConsented:H,log:r,disabled:k});O.push(()=>Me.stop());let U={get distinctId(){return l.distinctId},capture:(i,c,d)=>{l.capture(i,c,d?.timestamp!==void 0?{timestamp:d.timestamp}:{})&&(d?.sendInstantly||d?.transport)&&l.flush(d.transport==="beacon"?{beacon:!0}:{})},identify:(i,c,d)=>{T("identify")||(x.markIdentified(),l.identify(i,c,d))},alias:(i,c)=>{T("alias")||(x.markIdentified(),l.alias(i,c))},reset:i=>{l.reset({resetDeviceId:!!i,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{T("createPersonProfile")||x.isProfile||(x.markIdentified(),l.capture("$set",{}))},setConfig:i=>{let c=a;for(let[d,y]of Object.entries(i)){let P=c[d];Ce(P)&&Ce(y)?Object.assign(P,y):c[d]=y}"debug"in i&&(s=!!i.debug)},setPersonProperties:(i,c)=>{!i&&!c||T("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...i?{$set:i}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:i=>{!i.length||T("unsetPersonProperties")||(x.markIdentified(),l.capture("$set",{},{$unset:i}))},getSessionId:()=>l.sessionId,onSessionId:i=>l.onSessionId(c=>i(c)),getProperty:i=>l.getProperty(i),hasOptedOut:()=>!l.hasConsent("analytics"),getReplayUrl:i=>{let d=`${(e.uiHost??o).replace(/\/+$/,"")}/replays/${encodeURIComponent(l.sessionId)}`,y=l.sessionStart;return!i?.withTimestamp||y===void 0?d:`${d}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(i.timestampLookBackSeconds??10)))}`},debug:(i=!0)=>{s=i},featureView:(i,c)=>{l.capture("$feature_view",{...c,$feature_flag:i},{$set:{[`$feature_view/${i}`]:!0}})},featureInteraction:(i,c)=>{l.capture("$feature_interaction",{...c,$feature_flag:i},{$set:{[`$feature_interaction/${i}`]:!0}})},updateFlags:(i,c,d)=>f.flags?.update(i,c,d?.merge??!0),register:i=>l.register(i),registerOnce:i=>l.registerOnce(i),unregister:i=>l.unregister(i),group:(i,c,d)=>{x.markIdentified(),l.group(i,c,d)},optIn:()=>l.optIn(),optOut:()=>l.optOut(),optOutInternal:(i=!0)=>{q=i,i?l.storage.set(we,"1"):l.storage.remove(we)},get isInternal(){return q},setConsent:i=>l.setConsent(i),getConsent:()=>l.getConsent(),getConsentStatus:i=>l.getConsentStatus(i),consentStatus:()=>l.consentStatus(),getFlag:i=>f.flags?.get(i),getFlagPayload:i=>f.flags?.payload(i),getFlagResult:(i,c)=>f.flags?.result(i,c)??pe(i,void 0,void 0,"not_found"),getLayerParam:(i,c,d)=>f.flags?.layerParam(i,c)??d,isFeatureEnabled:i=>{let c=f.flags?.get(i);return c!==void 0&&c!==!1},onFlags:i=>f.flags?.onChange(i)??(()=>{}),onIntervention:i=>Me.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,d)=>f.flags?.setContext(i,c,d),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 F((c,d)=>U.capture(c,d),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:()=>l.flush(),shutdown:async()=>{for(let i of O)i();re?.flush(),await l.shutdown()}};if(f.client=U,!k){let i=()=>{for(let d of Re)d();re?.flush(),l.flush({beacon:!0})};window.addEventListener("pagehide",i);let c=()=>{document.visibilityState==="hidden"&&l.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),O.push(()=>{window.removeEventListener("pagehide",i),document.removeEventListener("visibilitychange",c)}),ne){let d=()=>{ne.drain()};window.addEventListener("online",d),O.push(()=>window.removeEventListener("online",d)),H(d)}if(e.captureCspViolations){let d=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};O.push(rt((y,P)=>{l.capture(y,P)},d))}for(let d of t){let y=d(f);y&&O.push(y)}ie=f.flags,at(f,U,o)}return r("initialised",{apiHost:o,consent:l.getConsent()}),U}function Ss(n,e={}){return Pe(n,e)}export{Pe as createClient,Ss as init};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c="$early_access_opt_in",s=e=>`$feature_enrollment/${e}`;function p(e,o){return{event:c,props:{$feature_flag:e,$enrolled:o},extra:{$set:{[s(e)]:o}}}}var m="lc_early_access",x=e=>{let{core:o}=e,a=()=>{try{return JSON.parse(o.storage.get(m)??"{}")}catch{return{}}},i=(r,t)=>{o.storage.set(m,JSON.stringify({...a(),[r]:t}));let n=p(r,t);o.capture(n.event,n.props,n.extra),e.flags?.reload()};e.flagPersonProps.push(()=>Object.fromEntries(Object.entries(a()).map(([r,t])=>[s(r),t]))),e.earlyAccess={list:()=>new Promise(r=>e.whenConsented(()=>{e.fetch(`${e.config.apiHost}/v1/early-access?api_key=${encodeURIComponent(e.apiKey)}`,{credentials:"omit"}).then(t=>t.ok?t.json():Promise.reject(new Error(`status ${t.status}`))).then(t=>{let n=a();r((t.features??[]).map(l=>({...l,enrolled:n[l.flag_key]===!0})))}).catch(t=>{e.log("early access fetch failed",t),r([])})})),optIn:r=>i(r,!0),optOut:r=>i(r,!1)}};export{x as earlyAccess};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function b(t,e){let r=document.createElement("style");return e&&r.setAttribute("nonce",e),r.textContent=t,r}var $=new Set(["SCRIPT","STYLE","IFRAME","FRAME","FRAMESET","OBJECT","EMBED","APPLET","TEMPLATE","NOSCRIPT","SVG","MATH","FORM","INPUT","TEXTAREA","SELECT","OPTION","LINK","META","BASE","AUDIO","VIDEO","PORTAL"]),B=new Set(["A","ABBR","B","BLOCKQUOTE","BR","BUTTON","CAPTION","CITE","CODE","DD","DEL","DETAILS","DIV","DL","DT","EM","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","I","IMG","INS","KBD","LABEL","LI","MARK","NAV","OL","P","PICTURE","PRE","Q","S","SECTION","ARTICLE","ASIDE","SMALL","SOURCE","SPAN","STRONG","SUB","SUMMARY","SUP","TABLE","TBODY","TD","TFOOT","TH","THEAD","TIME","TR","U","UL"]),K=new Set(["class","id","title","alt","href","src","srcset","sizes","width","height","role","target","rel","colspan","rowspan","loading","decoding","lang","dir","style","datetime","media"]),W=/^data:image\/(png|jpe?g|gif|webp|avif);/i;function T(t){let e=t.trim();return e?/^data:/i.test(e)?W.test(e):/^(https?:)?\/\//i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e):!1}function Y(t){let e=t.trim();return/^(https?:|mailto:|tel:)/i.test(e)||!/^[a-z][a-z0-9+.-]*:/i.test(e)}var z=t=>t.split(",").every(e=>T(e.trim().split(/\s+/)[0]??"")),q=t=>!/url\s*\(|expression\s*\(|@import|behavior\s*:|javascript:/i.test(t);function V(t){for(let{name:e,value:r}of[...t.attributes]){let n=e.toLowerCase();(K.has(n)||n.startsWith("aria-")||n.startsWith("data-")&&!n.startsWith("data-lc"))&&(n!=="href"||Y(r))&&(n!=="src"||T(r))&&(n!=="srcset"||z(r))&&(n!=="style"||q(r))||t.removeAttribute(e)}t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer")}function k(t){for(let e of[...t.childNodes]){if(e.nodeType===3)continue;if(e.nodeType!==1){e.remove();continue}let r=e,n=r.tagName.toUpperCase();if($.has(n)){r.remove();continue}if(k(r),!B.has(n)){r.replaceWith(...r.childNodes);continue}V(r)}}function L(t){let e=document.createElement("template");return e.innerHTML=t,k(e.content),document.importNode(e.content,!0)}var H="lc_changes",A="data-lc-change",J=/^on/i,X=/^\s*(javascript|data|vbscript):/i,Q=new Set(["css","js"]),Z=new Set(["before","after","prepend","append"]),R="data-lc-inserted";function O(t){let e=JSON.stringify(t),r=5381;for(let n=0;n<e.length;n++)r=(r<<5)+r+e.charCodeAt(n)|0;return`c${(r>>>0).toString(36)}`}function _(t,e){let r=t?.[H];return Array.isArray(r)?r.filter(n=>!!n&&typeof n=="object"&&typeof n.type=="string"&&(typeof n.selector=="string"||Q.has(n.type))&&(e===void 0||!n.url||e.includes(n.url))):[]}function ee(t,e){let r=O(e),n=(t.getAttribute(R)??"").split(" ").filter(Boolean);if(n.includes(r)||!Z.has(e.position)||typeof e.html!="string")return;let s=L(e.html);for(let i of[...s.children])i.setAttribute(A,r);e.position==="before"?t.before(s):e.position==="after"?t.after(s):e.position==="prepend"?t.prepend(s):t.append(s),t.setAttribute(R,[...n,r].join(" "))}var te=t=>t.split(",").every(e=>T(e.trim().split(/\s+/)[0]??""));function ne(t,e){let r=t.tagName.toUpperCase();if(!(typeof e.src!="string"||!T(e.src))){if(r==="SOURCE"){t.setAttribute("srcset",e.src);return}r==="IMG"&&(t.setAttribute("src",e.src),e.srcset&&te(e.srcset)?t.setAttribute("srcset",e.srcset):t.removeAttribute("srcset"),typeof e.alt=="string"&&t.setAttribute("alt",e.alt))}}function re(t,e,r){let n=O(t);if(r.querySelector(`[${A}="${n}"]`))return;let s;if(t.type==="css"){if(typeof t.css!="string")return;s=r.importNode(b(t.css,e.nonce),!0)}else{if(t.approved!==!0||!e.allowJs||typeof t.js!="string")return;s=r.createElement("script"),e.nonce&&s.setAttribute("nonce",e.nonce),s.textContent=t.js}s.setAttribute(A,n),r.head.append(s)}function se(t,e){let r=t;switch(e.type){case"text":t.textContent=e.value;break;case"attr":if(J.test(e.name)||typeof e.value=="string"&&/^(href|src|action|formaction)$/i.test(e.name)&&X.test(e.value))break;e.value===null?t.removeAttribute(e.name):t.setAttribute(e.name,e.value);break;case"style":for(let[n,s]of Object.entries(e.styles))r.style.setProperty(n,s);break;case"hide":r.style.setProperty("display","none","important");break;case"insert":ee(t,e);break;case"image":ne(t,e);break;case"reorder":{let n=t.parentElement;if(!n)break;let s=[...n.children].filter(c=>c!==t),i=Math.max(0,Math.min(e.index,s.length));n.insertBefore(t,s[i]??null);break}}}function x(t,e=document,r={}){let n=[];for(let s of t){if(r.requireApproval&&(s.type==="css"||s.type==="js"||s.type==="insert")&&s.approved!==!0)continue;if(s.type==="css"||s.type==="js"){let c=e.nodeType===9?e:e.ownerDocument;c?.head&&re(s,r,c);continue}let i;try{i=[...e.querySelectorAll(s.selector)]}catch{continue}i.length||n.push(s);for(let c of i)se(c,s)}return n}function ie(t=document){for(let e of[...t.querySelectorAll(`[${A}]`)])e.remove();for(let e of[...t.querySelectorAll(`[${R}]`)])e.removeAttribute(R)}var D="lc_trigger";function I(t){let e=t?.[D];return e&&typeof e=="object"&&(e.op==="and"||e.op==="or")&&Array.isArray(e.conditions)&&e.conditions.length?e:void 0}function C(t,e,r=0){if("op"in t)return r>=3||!Array.isArray(t.conditions)||!t.conditions.length?!1:t.op==="and"?t.conditions.every(n=>C(n,e,r+1)):t.conditions.some(n=>C(n,e,r+1));switch(t.type){case"time_on_page":return e.pageMs>=t.seconds*1e3;case"time_in_session":return e.sessionMs>=t.seconds*1e3;case"pages_viewed":return e.pages>=t.count;case"scroll":return e.scroll>=t.percent;case"exit_intent":return e.exit;case"element_visible":return typeof t.selector=="string"&&e.visible(t.selector);case"custom_event":return e.events.has(t.event);case"manual":return e.manual;default:return!1}}var U="lc_xp_trig",oe=500;function ae(t){let e;try{e=[...document.querySelectorAll(t)]}catch{return!1}let r=window.innerHeight||document.documentElement.clientHeight,n=window.innerWidth||document.documentElement.clientWidth;return e.some(s=>{let i=s.getBoundingClientRect();return i.width>0&&i.height>0&&i.bottom>0&&i.right>0&&i.top<r&&i.left<n})}function N(){let t=document.documentElement,e=Math.max(t.scrollHeight,document.body?.scrollHeight??0);return e<=window.innerHeight?100:Math.min(100,Math.round((window.scrollY+window.innerHeight)/e*100))}function j(t){let{core:e}=t,n=(()=>{try{let o=JSON.parse(e.storage.get(U)??"null");if(o&&o.sid===e.sessionId)return o}catch{}return{sid:e.sessionId,pages:0,fired:[]}})(),s=()=>{e.hasConsent("analytics")&&e.storage.set(U,JSON.stringify(n))},i=()=>{n.sid!==e.sessionId&&(n={sid:e.sessionId,pages:0,fired:[]})},c=Date.now(),u=0,l=!1,d=new Set,g=new Set,m=new Set,f=[],h=()=>f.forEach(o=>o());t.onCapture(o=>{i(),o.event==="$pageview"?(c=Date.now(),u=0,l=!1,d.clear(),g.clear(),n.pages+=1,s()):g.add(o.event),h()});let y,v=()=>{u=Math.max(u,N()),h()},w=o=>{!o.relatedTarget&&o.clientY<=0&&(l=!0,h())},a=o=>{o!==(y!==void 0)&&(o?(y=setInterval(h,oe),window.addEventListener("scroll",v,{passive:!0}),document.addEventListener("mouseout",w),u=Math.max(u,N())):(clearInterval(y),y=void 0,window.removeEventListener("scroll",v),document.removeEventListener("mouseout",w)))};return{facts(o){i();let p=Date.now();return{pageMs:p-c,sessionMs:p-(e.sessionStart??c),pages:Math.max(1,n.pages),scroll:u,exit:l,visible:E=>(!d.has(E)&&ae(E)&&d.add(E),d.has(E)),events:g,manual:m.has(o)}},fired(o){return i(),n.fired.includes(o)},fire(o){i(),!n.fired.includes(o)&&(n.fired.push(o),s())},activate(o){m.add(o),h()},sense:a,onChange:o=>{f.push(o)},dispose:()=>a(!1)}}var G="lc_split_url",S="__lc_split",ce=300;function F(t,e,r,n=[]){let s=t?.[G]?.url;if(typeof s!="string"||!s)return null;let i;try{i=new URL(s,r)}catch{return null}if(i.protocol!=="http:"&&i.protocol!=="https:"||i.origin!==r.origin&&!n.includes(i.origin)||r.searchParams.has(S))return null;for(let[c,u]of r.searchParams)i.searchParams.has(c)||i.searchParams.set(c,u);return i.hash||(i.hash=r.hash),i.origin===r.origin&&i.pathname===r.pathname&&i.search===r.search?null:(i.searchParams.set(S,e),i)}var le=t=>{if(typeof document>"u")return;let e=t.config.splitUrl??{},r=new URL(location.href);if(r.searchParams.has(S)){r.searchParams.delete(S),history.replaceState(history.state,"",r);return}let n,s=()=>{n?.remove(),n=void 0};(e.antiFlickerMs??0)>0&&(n=b("html{opacity:0 !important}",t.config.nonce),document.head.append(n),setTimeout(s,e.antiFlickerMs));let i=!1,c=t.client.onFlags(u=>{if(!i){for(let l of Object.keys(u)){let d=F(t.flags?.payload(l),l,new URL(location.href),e.allowedOrigins);if(!d)continue;i=!0,t.flags?.get(l),t.log("split url redirect",l,d.href);let g=()=>(e.navigate??(m=>location.replace(m)))(d.href);Promise.race([t.client.flush(),new Promise(m=>setTimeout(m,ce))]).then(g,g);return}s()}});return()=>{c(),s()}};var ue=5e3,Ae=t=>{if(typeof document>"u")return;let e=t.config.visualChanges?.antiFlickerMs??0,r={nonce:t.config.nonce,allowJs:t.config.visualChanges?.allowCustomJs===!0,requireApproval:!0},n,s=()=>{n?.remove(),n=void 0};e>0&&(n=b("html{opacity:0 !important}",t.config.nonce),document.head.append(n),setTimeout(s,e));let i=j(t),c,u,l=[],d=()=>{c?.disconnect(),clearTimeout(u)},g=a=>{l=[...l,...x(a,document,r)],!(!l.length||typeof MutationObserver>"u")&&(c??=new MutationObserver(()=>{l=x(l,document,r),l.length||d()}),c.observe(document.documentElement,{childList:!0,subtree:!0}),clearTimeout(u),u=setTimeout(d,ue))},m=(a,o)=>{let p=i.facts(a);return p.manual||C(o,p)},f=new Map,h=a=>(i.fire(a),t.flags?.get(a),_(t.flags?.payload(a),location.href)),y=a=>{d(),l=[],f.clear();let o=[];for(let p of Object.keys(a)){let E=t.flags?.payload(p),M=I(E);if(M)i.fired(p)||m(p,M)?o.push(...h(p)):f.set(p,M);else{let P=_(E,location.href);P.length&&t.flags?.get(p),o.push(...P)}}g(o),s(),i.sense(f.size>0)};i.onChange(()=>{if(!f.size)return;let a=[];for(let[o,p]of[...f])m(o,p)&&(f.delete(o),a.push(...h(o)));a.length&&g(a),f.size||i.sense(!1)});let v,w=t.client.onFlags(a=>y(v=a));return t.onCapture(a=>{a.event==="$pageview"&&v&&y(v)}),t.experiments={activate(a){i.activate(a),v&&!f.has(a)&&y(v)}},()=>{w(),d(),i.dispose(),s()}};export{H as CHANGES_KEY,A as CHANGE_MARKER,S as SPLIT_MARKER,G as SPLIT_URL_KEY,D as TRIGGER_KEY,x as applyChanges,O as changeId,_ as changesOf,ie as removeInserted,T as safeImageUrl,L as sanitizeHtml,F as splitTarget,le as splitUrl,C as triggerMatches,I as triggerOf,Ae as visualChanges};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function Ae(e,t={}){let n=Math.min(t.maxMs??3e4,(t.baseMs??1e3)*2**e);return Math.round(n*(.5+.5*(t.random??Math.random)()))}function st(e){let t="";return n=>{for(t+=n;;){let r=/\r?\n\r?\n/.exec(t);if(!r)return;let i=t.slice(0,r.index);t=t.slice(r.index+r[0].length);let o="message",s,a=[];for(let u of i.split(/\r?\n/)){if(u.startsWith(":"))continue;let l=u.indexOf(":"),[d,g]=l<0?[u,""]:[u.slice(0,l),u.slice(l+1).replace(/^ /,"")];d==="event"?o=g??"":d==="data"?a.push(g??""):d==="id"&&(s=g)}a.length&&e(s===void 0?{event:o,data:a.join(`
|
|
2
|
+
`)}:{event:o,data:a.join(`
|
|
3
|
+
`),id:s})}}}var U=class{constructor(t){this.o=t}o;ctl;stopped=!0;timer;start(){this.stopped&&(this.stopped=!1,this.loop())}stop(){this.stopped=!0,this.ctl?.abort(),this.timer&&clearTimeout(this.timer),this.o.onState?.(!1)}async loop(){let t=0;for(;!this.stopped;){try{await this.connectOnce()&&(t=0)}catch(r){this.stopped||this.o.log?.("flag stream error",r)}if(this.o.onState?.(!1),this.stopped)return;let n=Ae(t++,this.o.backoff);await new Promise(r=>{this.timer=setTimeout(r,n),this.timer.unref?.()})}}async connectOnce(){this.ctl=new AbortController;let t=await this.o.fetch(this.o.url,{headers:{Authorization:`Bearer ${this.o.secretKey}`,Accept:"text/event-stream"},signal:this.ctl.signal});if(!t.ok||!t.body)throw new Error(`stream status ${t.status}`);this.o.onState?.(!0);let n=st(i=>{if(i.event==="definitions")try{this.o.onChange(JSON.parse(i.data).etag)}catch{this.o.onChange(void 0)}}),r=t.body.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:i,value:o}=await r.read();if(i)return!0;n(o)}}};function Y(e){let t=!1,n,r=new U({url:`${e.apiHost}/v1/flags/stream`,secretKey:e.apiKey,fetch:e.fetch,...e.backoff?{backoff:e.backoff}:{},...e.log?{log:e.log}:{},onState:l=>t=l,onChange:l=>{l!==void 0&&l===n||(n=l,e.reload())}}),i=()=>e.visibility?.hidden()??!1,o=e.pollMs??6e4,s=o>0?setInterval(()=>!t&&!i()&&e.reload(),o):void 0,a=()=>{i()?r.stop():(r.start(),e.reload())};i()||r.start();let u=e.visibility?.subscribe(a);return()=>{r.stop(),u?.(),s&&clearInterval(s)}}var at=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),E=(e,t)=>e>>>t|e<<32-t;function $e(e){let t=new TextEncoder().encode(e),n=t.length+9+63>>6<<6,r=new Uint8Array(n);r.set(t),r[t.length]=128;let i=new DataView(r.buffer);i.setUint32(n-8,Math.floor(t.length*8/2**32)),i.setUint32(n-4,t.length*8>>>0);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],s=new Uint32Array(64);for(let a=0;a<n;a+=64){for(let l=0;l<16;l++)s[l]=i.getUint32(a+l*4);for(let l=16;l<64;l++){let d=s[l-15],g=s[l-2],m=E(d,7)^E(d,18)^d>>>3,b=E(g,17)^E(g,19)^g>>>10;s[l]=s[l-16]+m+s[l-7]+b|0}let u=o.slice();for(let l=0;l<64;l++){let[d,g,m,,b,k,y,R]=u,P=R+(E(b,6)^E(b,11)^E(b,25))+(b&k^~b&y)+at[l]+s[l]|0,A=(E(d,2)^E(d,13)^E(d,22))+(d&g^d&m^g&m)|0;u.pop(),u.unshift(P+A|0),u[4]=u[4]+P|0}for(let l=0;l<8;l++)o[l]=o[l]+u[l]|0}return o.map(a=>(a>>>0).toString(16).padStart(8,"0")).join("")}var ct=/^(0|[1-9]\d{0,2})$/,lt=/^[0-9a-fA-F]{1,4}$/,ut=/^(0|[1-9]\d*)$/;function je(e){let t=e.split(".");if(t.length!==4)return;let n=[];for(let r of t){if(!ct.test(r)||Number(r)>255)return;n.push(Number(r))}return n}function ft(e){if(e.includes("%"))return;let t=e,n=e.lastIndexOf(":"),r=e.slice(n+1);if(r.includes(".")){let d=je(r);if(!d)return;t=`${e.slice(0,n+1)}${(d[0]<<8|d[1]).toString(16)}:${(d[2]<<8|d[3]).toString(16)}`}let i=t.split("::");if(i.length>2)return;let o=d=>{if(d==="")return[];let g=[];for(let m of d.split(":")){if(!lt.test(m))return;g.push(parseInt(m,16))}return g},s=o(i[0]),a=i.length===2?o(i[1]):[];if(!s||!a)return;let u=s.length+a.length;return(i.length===2?u>7:u!==8)?void 0:[...s,...Array(8-u).fill(0),...a].flatMap(d=>[d>>8,d&255])}function Me(e){return e.includes(":")?ft(e):je(e)}var dt=e=>e.length===16&&e.slice(0,10).every(t=>t===0)&&e[10]===255&&e[11]===255;function Ve(e){if(typeof e!="string")return;let t=Me(e.trim());return t&&dt(t)?t.slice(12):t}function pt(e){let t=typeof e=="string"?[e]:Array.isArray(e)?e:[],n=[];for(let r of t){if(typeof r!="string")continue;let i=r.trim(),o=i.indexOf("/");if(o<0){let u=Ve(i);u&&n.push({bytes:u,bits:u.length*8});continue}let s=Me(i.slice(0,o)),a=i.slice(o+1);!s||!ut.test(a)||Number(a)>s.length*8||n.push({bytes:s,bits:Number(a)})}return n}function gt(e,t){if(e.bytes.length!==t.length)return!1;for(let n=0;n<e.bits;n+=8){let i=255<<8-Math.min(8,e.bits-n)&255,o=n/8;if((e.bytes[o]&i)!==(t[o]&i))return!1}return!0}function Te(e,t,n,r){switch(e){case"array_contains_any":case"array_contains_all":case"array_contains_none":{if(!Array.isArray(t)||!Array.isArray(n))return!1;let i=n.filter(o=>t.some(s=>r(s,o))).length;return e==="array_contains_any"?i>0:e==="array_contains_all"?i===n.length:i===0}case"ip_in_cidr":case"ip_not_in_cidr":{let i=Ve(t),o=pt(n);return!i||!o.length?!1:o.some(s=>gt(s,i))===(e==="ip_in_cidr")}}return!1}var mt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,Ie=/^\d{4}-\d{2}-\d{2}$/,vt=/^-?(\d{1,6})([hdwmy])$/,yt={h:3600,d:86400,w:604800,m:2592e3,y:31536e3};function bt(e){let t=vt.exec(e.trim());return t?Number(t[1])*yt[t[2]]:void 0}function qe(e,t,n){if(typeof e=="number")return e*1e3;if(typeof e!="string")return;let r=e.trim();if(n){let o=bt(r);if(o!==void 0)return t-o*1e3}if(!mt.test(r)&&!Ie.test(r))return;let i=Date.parse(Ie.test(r)?`${r}T00:00:00Z`:r);return Number.isNaN(i)?void 0:i}function De(e,t){for(let n=0;n<Math.max(e.length,t.length);n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r<i?-1:1}return 0}function ht(e,t,n){if(typeof t!="string")return;let r=t.trim().replace(/^v/,"").split(".");if(e==="semver_wildcard"){let l=r[r.length-1];if(l!=="*"&&l!=="x"&&l!=="X")return;if(r.length===1)return[[0],[2**30]];let d=n.parseVersion(r.slice(0,-1).join("."));if(!d)return;let g=[...d];return g[g.length-1]=g[g.length-1]+1,[d,g]}let i=n.parseVersion(t);if(!i)return;for(;i.length<3;)i.push(0);let[o,s,a]=i,u;return e==="semver_tilde"&&r.length===1?u=[o+1,0,0]:e==="semver_tilde"||o===0&&s>0?u=[o,s+1,0]:o>0?u=[o+1,0,0]:u=[0,0,a+1],[i,u]}function Ne(e,t,n,r,i){switch(e){case"icontains":case"not_icontains":case"starts_with":case"not_starts_with":case"ends_with":case"not_ends_with":return typeof t!="string"||typeof n!="string"?!1:e.endsWith("icontains")?t.toLowerCase().includes(n.toLowerCase())===(e==="icontains"):e.endsWith("starts_with")?t.startsWith(n)===(e==="starts_with"):t.endsWith(n)===(e==="ends_with");case"between":case"not_between":{let o=i.toFloat(t);if(!Array.isArray(n)||n.length!==2||o===void 0)return!1;let[s,a]=n;return typeof s!="number"||typeof a!="number"?!1:(o>=s&&o<=a)==(e==="between")}case"is_date_before":case"is_date_after":{let o=qe(t,r,!1),s=qe(n,r,!0);return o===void 0||s===void 0?!1:e==="is_date_before"?o<s:o>s}case"semver_eq":case"semver_neq":case"semver_gt":case"semver_gte":case"semver_lt":case"semver_lte":{let o=i.cmpVersion(t,n);if(o===void 0)return!1;let s=e.slice(7);return s==="eq"?o===0:s==="neq"?o!==0:s==="gt"?o>0:s==="gte"?o>=0:s==="lt"?o<0:o<=0}case"semver_tilde":case"semver_caret":case"semver_wildcard":{let o=i.parseVersion(t),s=ht(e,n,i);return!!o&&!!s&&De(o,s[0])>=0&&De(o,s[1])<0}}return!1}var _t=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function X(e){if(typeof e=="number")return e;if(typeof e=="string"&&_t.test(e.trim()))return Number(e.trim())}function Z(e,t){let n=typeof e=="number",r=typeof t=="number";return n||r?n&&r&&e===t:e===t}function Q(e){if(typeof e!="string")return;let t=e.trim().replace(/^v/,""),n=t.search(/[-+]/);n>=0&&(t=t.slice(0,n));let r=[];for(let i of t.split(".")){if(!/^[+-]?\d+$/.test(i))return;let o=parseInt(i,10);if(o<0)return;r.push(o)}return r}function z(e,t){let n=Q(e),r=Q(t);if(!(!n||!r)){for(let i=0;i<Math.max(n.length,r.length);i++){let o=n[i]??0,s=r[i]??0;if(o!==s)return o<s?-1:1}return 0}}var xt=(e,t)=>e<t?-1:e>t?1:0;function C(e,t,n,r,i,o=Date.now()){let s=n&&t!==null&&t!==void 0;if(e==="is_set")return s;if(e==="is_not_set")return!s;if(!s)return!1;switch(e){case"eq":case"neq":{let a;if(i){let u=z(t,r);if(u===void 0)return!1;a=u===0}else a=Z(t,r);return a===(e==="eq")}case"contains":case"ncontains":case"regex":case"nregex":{if(typeof t!="string"||typeof r!="string")return!1;if(e==="contains"||e==="ncontains")return t.includes(r)===(e==="contains");let a;try{a=new RegExp(r)}catch{return!1}return a.test(t)===(e==="regex")}case"gt":case"gte":case"lt":case"lte":{let a;if(i)a=z(t,r);else{let u=X(t),l=X(r);a=u===void 0||l===void 0?void 0:xt(u,l)}return a===void 0?!1:e==="gt"?a>0:e==="gte"?a>=0:e==="lt"?a<0:a<=0}case"in":case"not_in":return Array.isArray(r)?r.some(a=>Z(t,a))===(e==="in"):!1}return e.startsWith("array_")||e.startsWith("ip_")?Te(e,t,r,Z):Ne(e,t,r,o,{toFloat:X,parseVersion:Q,cmpVersion:z})}function te(e){return e.properties?.length?`${e.key}|${JSON.stringify(e.properties.map(t=>[t.key,t.op,t.value??null]))}`:e.key}function Le(e,t,n=Date.now()){return(e.properties??[]).every(r=>C(r.op,t[r.key],Object.hasOwn(t,r.key),r.value,!1,n))}function ne(e,t){let n=t[e.scope??"session"]?.[te(e)]??0;return e.op==="is_set"?n>0:e.op==="is_not_set"?n===0:C(e.op,n,!0,e.value,!1)}var He=e=>(e??[]).filter(t=>t.type==="event");function Ke(e,t,n){for(let o of e.runtime??[])if(o.filters.every(a=>{if(a.type!=="flag")return ne(a,t);let u=n(a.key);return!!u&&C(a.op,u.value,!0,a.value,!1)}))return Ke(o.result,t,n);if(!e.runtime)return e;let{runtime:r,...i}=e;return i}function re(e,t){let n={},r=new Map,i=o=>{if(r.get(o)===2)return n[o];let s=e[o];if(!s||r.get(o)===1)return;r.set(o,1);let a=Ke(s,t,i);return n[o]=a,r.set(o,2),a};for(let o of Object.keys(e))i(o);return n}function B(e,t){let n=[],r=o=>{o.type==="event"&&o.properties?.length&&n.push(o)};for(let o of e??[])for(let s of o.conditions)for(let a of s.filters??[])r(a);let i=o=>{for(let s of o.runtime??[])s.filters.forEach(r),i(s.result)};return Object.values(t).forEach(i),n}var ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function G(e,t){if(!ee(t))return t;let n=ee(e)?{...e}:{};for(let[r,i]of Object.entries(t))i===null?delete n[r]:n[r]=G(n[r],i);return n}var q=class{session={};page={};sid="";constructor(t){if(t&&typeof t.sid=="string"&&ee(t.session)){this.sid=t.sid;for(let[n,r]of Object.entries(t.session))typeof r=="number"&&r>0&&(this.session[n]=r)}}record(t,n,r={},i=[]){n!==this.sid&&(this.sid=n,this.session={},this.page={}),t==="$pageview"&&(this.page={});let o=new Set([t]);for(let s of i)s.type==="event"&&s.key===t&&s.properties?.length&&Le(s,r)&&o.add(te(s));for(let s of o)this.session[s]=(this.session[s]??0)+1,this.page[s]=(this.page[s]??0)+1}counts(t){return t===this.sid?{session:{...this.session},page:{...this.page}}:{session:{},page:{}}}saved(){return{sid:this.sid,session:{...this.session}}}};function Ue(e,t){let n=t?e.contexts?.[t]:void 0;if(n)return n;if(t==="user")return{key:e.bucketing_key||e.distinct_id,properties:e.person_properties};if(t==="device")return{key:e.device_id,properties:e.device_properties}}var kt=["user","device","org"],Rt=16**13;function D(e,t,n,r=!1){let i=r?`${e}.${t}.variant.${n}`:`${e}.${t}.${n}`;return parseInt($e(i).slice(0,13),16)/Rt}var w=(e,t=-1)=>({value:!1,reason:e,condition_index:t});function wt(e,t){return typeof t=="boolean"?typeof e=="boolean"?e===t:t:e===t}function Ft(e,t,n){let r=t.now?Date.parse(t.now):NaN,i=Number.isNaN(r)?Date.now():r,o;switch(e.type){case"person":o=t.person_properties;break;case"group":o=t.group_properties?.[e.group_type??""];break;case"device":o=t.device_properties;break;case"geo":o=t.geo_properties;break;case"context":if(!kt.includes(e.context_kind??""))return!1;o=Ue(t,e.context_kind)?.properties;break;case"app_version":return C(e.op,t.app_version,!!t.app_version,e.value,!0,i);case"flag":{let s=n[e.key];return!!s&&C(e.op,s.value,!0,e.value,!1,i)}default:return!1}return C(e.op,o?.[e.key],!!o&&Object.hasOwn(o,e.key),e.value,!1,i)}function St(e,t,n){let r=e.variants;if(t.variant_override){let s=r.find(a=>a.key===t.variant_override);if(s)return s}let i=D(e.key,e.salt,n,!0)*100,o=0;for(let s of r)if(o+=s.rollout_pct,i<o)return s;return r[r.length-1]}function Be(e,t){return Ge(e.aggregation,t)}function Ge(e,t){return e.kind==="group"?t.groups?.[e.group_type??""]:e.kind==="device"?t.device_id:e.kind==="context"?Ue(t,e.context_kind)?.key:t.bucketing_key||t.distinct_id}function Et(e,t,n,r){let i=e.sticky?r.sticky_assignments?.[e.key]:void 0;if(i===void 0)return;let o={value:!0,reason:"sticky_bucket",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){if(e.variants.some(a=>a.key===t.variant_override))return;let s=e.variants.find(a=>a.key===i);return s?(o.value=o.variant=s.key,J(o,s.payload,t)):void 0}if(i===!0)return J(o,e.type==="json"?e.payload:void 0,t)}function J(e,t,n){let r=n.payload_patch===void 0||n.payload_patch===null?t:G(t,n.payload_patch);return r!==void 0&&(e.payload=r),e}var oe=(e,t)=>t.length?{...e,runtime:t}:e;function Ot(e,t){return!e.app_contexts?.length||!t.app_contexts?.length?!0:e.app_contexts.some(n=>t.app_contexts?.includes(n))}function Je(e,t,n={}){if(!Ot(e,t))return w("app_context_excluded");if(!e.active)return w("inactive");if(e.kill_switch)return w("kill_switch");let r=!1;for(let u of e.prerequisites??[]){let l=n[u.flag];if(!l)return w("prerequisite_missing");if(l.reason==="requires_server")r=!0;else if(l.reason==="prerequisite_cycle"||!wt(l.value,u.value))return w("prerequisite_failed")}if(r)return w("requires_server");let i=Be(e,t),o=e.conditions.some(u=>u.aggregation);if(!i&&(!o||e.holdout||e.namespace))return w("no_bucketing_key");if(e.holdout&&D("holdout",e.holdout.salt,i??"")*100<e.holdout.percentage)return w("holdout");if(e.namespace&&e.namespace.total>0){let u=Math.floor(D("namespace",e.namespace.salt,i??"")*e.namespace.total);if(u<e.namespace.start||u>=e.namespace.end)return w("namespace_excluded")}let s=0,a=[];for(let[u,l]of e.conditions.entries()){let d=l.aggregation?Ge(l.aggregation,t):i;if(!d){s++;continue}let g=!1,m=!0,b=!1;for(let y of l.filters??[]){if(y.type==="event"){if(t.runtime_events===void 0)b=!0;else if(!ne(y,t.runtime_events)){m=!1;break}continue}let R=y.type==="cohort"?t.cohorts?.[y.key]:void 0;if(R!==void 0){if(R===(y.op==="not_in"||y.op==="neq")){m=!1;break}}else if(y.type==="cohort"||y.type==="flag"&&n[y.key]?.reason==="requires_server")g=!0;else if(!Ft(y,t,n)){m=!1;break}}if(!m)continue;if(g)return oe(w("requires_server",u),a);let k=Pt(e,l,u,t,d);if(k)if(b)a.push({filters:He(l.filters),result:k});else return oe(k,a)}return oe(w(s>0&&s===e.conditions.length?"no_bucketing_key":"no_condition_match"),a)}function Pt(e,t,n,r,i){let o=t.aggregation?void 0:Et(e,t,n,r);if(o)return o;if(D(e.key,e.salt,i)*100>=t.rollout_pct)return e.early_exit?w("out_of_rollout",n):void 0;let s={value:!0,reason:"condition_match",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){let a=St(e,t,i);return s.value=s.variant=a.key,J(s,a.payload,t)}return J(s,e.type==="json"?e.payload:void 0,t)}function We(e){return[...(e.prerequisites??[]).map(t=>t.flag),...e.conditions.flatMap(t=>(t.filters??[]).filter(n=>n.type==="flag").map(n=>n.key))]}function se(e,t){let n=new Map(e.map(s=>[s.key,s])),r={},i=new Map,o=s=>{let a=n.get(s);if(!a||i.has(s))return;i.set(s,1);let u=!1;for(let l of We(a))o(l),(i.get(l)===1||r[l]?.reason==="prerequisite_cycle")&&(u=!0);r[s]=u?w("prerequisite_cycle"):At(a,t,r),i.set(s,2)};for(let s of e)o(s.key);return r}var Ct=4;function At(e,t,n){let r=[];for(let i of We(e))!r.includes(i)&&n[i]?.runtime?.length&&r.length<Ct&&r.push(i);return ie(e,t,n,r)}function ie(e,t,n,r){let[i,...o]=r;if(i===void 0)return Je(e,t,n);let s=ie(e,t,n,o),a=n[i],u=new Set([a.value]),l=[];for(let b of Ye(a)){if(u.has(b.value))continue;u.add(b.value);let k=ie(e,t,{...n,[i]:b},o);Xe(k,s)||l.push({filters:[{type:"flag",key:i,op:"eq",value:b.value}],result:k})}let d=[...l,...s.runtime??[]],{runtime:g,...m}=s;return d.length?{...m,runtime:d}:m}function Ye(e){return(e.runtime??[]).flatMap(t=>{let{runtime:n,...r}=t.result;return[r,...Ye(t.result)]})}function Xe(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let o of i)if(!Xe(n[o],r[o]))return!1;return!0}var ae=e=>e.reason==="requires_server",ce=e=>e.reason!=="app_context_excluded";function le(e,t,n,r){return{key:e,value:t,enabled:t!==void 0&&t!==!1,...typeof t=="string"?{variant:t}:{},...n!==void 0?{payload:n}:{},reason:t===void 0?"not_found":r}}var N=class{constructor(t,n=Date.now){this.ttlMs=t;this.now=n}ttlMs;now;stamp;mark(t){return this.stamp={at:this.now(),id:t}}restore(t){typeof t?.at=="number"&&typeof t.id=="string"&&(this.stamp={at:t.at,id:t.id})}fresh(t){return!!this.ttlMs&&this.ttlMs>0&&!!this.stamp&&this.stamp.id===t&&this.now()-this.stamp.at<this.ttlMs}clear(){this.stamp=void 0}};var $t="lc_preview",ue="lc_preview";function jt(e){let t={};for(let n of(e??"").split(",")){let r=n.indexOf(":");r>0&&r<n.length-1&&(t[n.slice(0,r)]=n.slice(r+1))}return t}function Ze(e){let t=new URL(e).searchParams.get($t),n=null;try{n=sessionStorage.getItem(ue)}catch{}return{forced:jt(t==="off"?null:t??n),persist(){try{t==="off"?sessionStorage.removeItem(ue):t&&sessionStorage.setItem(ue,t)}catch{}}}}var fe=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid"];var de=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];var pe="lc_flag_initial";function Mt(e){try{return e?new URL(e).hostname:""}catch{return""}}function Vt(){let e=new URLSearchParams(location.search),t={$initial_referrer:document.referrer||"$direct",$initial_referring_domain:Mt(document.referrer)||"$direct",$initial_current_url:location.href.split("#")[0]};for(let n of[...de,...fe]){let r=e.get(n);r&&(t[`$initial_${n}`]=r)}return t}function ze(e,t){if(typeof location>"u")return{};let n=e.get(pe);if(n)try{return JSON.parse(n)}catch{}let r=Vt();return t(()=>{e.get(pe)||e.set(pe,JSON.stringify(r))}),r}function Tt(){let e=navigator.userAgent,t=/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":/Firefox\//.test(e)?"Firefox":/Chrome\/|CriOS/.test(e)?"Chrome":/Safari\//.test(e)?"Safari":"Other",n=/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"Mac OS X":/CrOS/.test(e)?"Chrome OS":/Linux/.test(e)?"Linux":"Other";return{browser:t,os:n}}function Qe(){if(typeof location>"u"||typeof navigator>"u")return{};let e={},t=new URLSearchParams(location.search);for(let i of[...de,...fe]){let o=t.get(i);o&&(e[`$${i}`]=o)}let{browser:n,os:r}=Tt();return e.$browser=n,e.$os=r,e.$device_type=String(ge().$device_type??"Desktop"),e}function ge(){if(typeof window>"u")return{};let e=window.innerWidth;return{$viewport_width:e,$viewport_height:window.innerHeight,$screen_width:screen.width,$screen_height:screen.height,$browser_language:navigator.language,$device_type:e<768?"Mobile":e<1024?"Tablet":"Desktop"}}function me(e){return typeof e=="object"?e.value??e.variant??!!e.enabled:e}function ve(e){let t={value:me(e),reason:e.reason??"remote",condition_index:e.condition_index??-1};return e.variant&&(t.variant=e.variant),e.payload!==void 0&&(t.payload=e.payload),e.runtime?.length&&(t.runtime=e.runtime.map(n=>({filters:n.filters,result:ve(n.result)}))),t}var et="lc_rt_events",tt=e=>!!e?.some(t=>t.conditions.some(n=>n.filters?.some(r=>r.type==="event")));function nt(e,t){let n;try{let s=e.flagStorage.get(et);s&&(n=JSON.parse(s))}catch{}let r=new q(n),i={},o=B(t,i);return{counts:()=>r.counts(e.core.sessionId),setServer(s){i=s,o=B(t,i)},server:()=>i,drop(s){for(let a of s)delete i[a]},resolved(){return re(i,r.counts(e.core.sessionId))},record(s,a,u){r.record(s,e.core.sessionId,a,o),u&&e.whenConsented(()=>e.flagStorage.set(et,JSON.stringify(r.saved())))}}}var rt="lc_flags",ye="lc_flag_overrides_api";function ot(e){try{let t=localStorage.getItem("lc_flag_overrides");return t?JSON.parse(t)[e]:void 0}catch{return}}var kn=e=>{let{core:t,config:n}=e,r={},i={},o={},s,a=!1,u=0,l=new Set,d=new Set,g="",m={},b=()=>Object.keys(m).length>0,k={},y={},R={},P=new Set,A=typeof location>"u"?{forced:{},persist(){}}:Ze(location.href),it=Object.keys(A.forced).length>0,$=()=>({...r,...R}),h=e.config.flagOptions??{},j=new N(h.cacheTtlMs),be=(e.config.flagsApiHost??e.config.apiHost).replace(/\/+$/,""),he=h.keys?.length?new Set(h.keys):void 0,_e=c=>he?Object.fromEntries(Object.entries(c).filter(([f])=>he.has(f))):c,I=(c,f,p=!0)=>{if(r=_e(c),i=_e(f),a=!0,p)for(let v of P)v($())},M=nt(e,n.localFlags),xe=e.flagStorage.get(rt);if(xe)try{let c=JSON.parse(xe);r=c.values,i=c.payloads,o=Object.fromEntries(Object.keys(r).map(f=>[f,"cached"])),c.rt&&M.setServer(c.rt),j.restore(c)}catch{}let ke=e.flagStorage.get(ye);if(ke)try{R=JSON.parse(ke)}catch{}let L=n.bootstrap;if(L?.flags){I({...L.flags},{...L.payloads});for(let c of Object.keys(L.flags))o[c]="bootstrap"}let Re={},we=()=>({...h.autoProperties===!1?{}:Qe(),...ze(t.storage,e.whenConsented),...Object.assign({},...e.flagPersonProps.map(c=>c())),...k}),Fe=h.evaluationContexts?.length?{app_contexts:h.evaluationContexts}:{},W=(c=!0)=>{let f=n.localFlags;if(!f?.length)return!0;let p=n.localFlagsContext,v=se(f,{runtime_events:M.counts(),distinct_id:t.distinctId,...t.groups?{groups:t.groups}:{},...t.deviceId?{device_id:t.deviceId}:{},...b()?{contexts:m}:{},...Fe,...p,person_properties:{...we(),...p?.person_properties},group_properties:{...p?.group_properties,...y}}),_={},x={},V=!1;for(let[T,F]of Object.entries(v))ae(F)?V=!0:ce(F)&&(_[T]=F.value,o[T]=F.reason,F.payload!==void 0&&(x[T]=F.payload));return Re=_,I({...r,..._},{...i,...x},c),V},Se=c=>{let f={...r},p={...i};for(let[v,_]of Object.entries(M.resolved()))f[v]=_.value,o[v]=_.reason,_.payload!==void 0?p[v]=_.payload:delete p[v];I(f,p,c)},Ee=tt(n.localFlags);e.onCapture(c=>{let f=Ee||Object.keys(M.server()).length>0;if(M.record(c.event,c.properties,f),!f)return;let p=JSON.stringify([$(),i]);if(Ee&&W(!1),Se(!1),JSON.stringify([$(),i])!==p)for(let v of P)v($())});let O=(c=!0)=>{let f=++u;return!W()||h.disableRemote||!c&&j.fresh(t.distinctId)?Promise.resolve():new Promise(p=>{e.whenConsented(()=>{if(f!==u)return p();A.persist();let v=new AbortController,_=setTimeout(()=>v.abort(),h.timeoutMs??1e4);e.fetch(`${be}/v1/flags`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",signal:v.signal,body:JSON.stringify({api_key:e.apiKey,...t.distinctId?{distinct_id:t.distinctId}:{},...t.anonDistinctId?{anon_distinct_id:t.anonDistinctId}:{},groups:t.groups??{},person_properties:we(),...Object.keys(y).length?{group_properties:y}:{},device_properties:ge(),...t.deviceId?{device_id:t.deviceId}:{},...b()?{contexts:m}:{},...Fe,...it?{preview:A.forced}:{},...h.keys?.length?{flag_keys:h.keys}:{}})}).then(x=>x.ok?x.json():Promise.reject(new Error(`status ${x.status}`))).then(x=>{if(f!==u)return;if(x.quota_limited)return e.log("flags quota limited; keeping cached values");let V={},T={},F={};for(let[K,S]of Object.entries(x.flags??{}))V[K]=me(S),typeof S=="object"&&S.payload!==void 0&&(T[K]=S.payload),o[K]=typeof S=="object"&&typeof S.reason=="string"?S.reason:"remote",typeof S=="object"&&S.runtime?.length&&(F[K]=ve(S));s=x.request_id,M.setServer(F),I({...Re,...V},T,!1),Se(!0),e.flagStorage.set(rt,JSON.stringify({values:V,payloads:T,rt:F,...j.mark(t.distinctId)})),e.log("flags loaded",V)}).catch(x=>e.log("flags fetch failed",x)).finally(()=>{clearTimeout(_),p()})})})},Oe=c=>R[c]??ot(c)??r[c];e.flags={get(c){let f=Oe(c);if(f===void 0)return;if(c in A.forced||c in R)return f;let p=t.sessionId;p!==g&&(l.clear(),d.clear(),g=p),d.has(c)||(d.add(c),t.capture("$exposure",{$feature_flag:c,$feature_flag_response:f,...typeof f=="string"?{$feature_flag_variant:f}:{},...s?{$feature_flag_request_id:s}:{}}));let v=`${c}:${String(f)}`;return l.has(v)||(l.add(v),t.capture("$feature_flag_called",{$feature_flag:c,$feature_flag_response:f,...s?{$feature_flag_request_id:s}:{}})),f},all:()=>a||Object.keys(r).length||Object.keys(R).length?$():{},payload:c=>i[c],result(c,f){let p=f?.sendExposure===!1?Oe(c):this.get(c),v=c in R||ot(c)!==void 0?"override":c in A.forced?"preview":o[c]??"remote";return le(c,p,i[c],v)},layerParam(c,f){for(let[p,v]of Object.entries(i)){let _=v;if(_?.lc_layer!==c||!_.lc_params||!(f in _.lc_params))continue;let x=this.get(p);if(x!==void 0&&x!==!1)return _.lc_params[f]}},onChange(c){return P.add(c),a&&c($()),()=>{P.delete(c)}},reload:O,update(c,f,p=!0){for(let v of Object.keys(c))o[v]="pushed";M.drop(Object.keys(c)),I(p?{...r,...c}:{...c},p?{...i,...f}:{...f})},override(c,f){R=c?{...c}:{},c?f?.persist&&e.whenConsented(()=>e.flagStorage.set(ye,JSON.stringify(R))):e.flagStorage.remove(ye);for(let p of P)p($())},setPersonProperties(c,f=!0){j.clear(),k={...k,...c},f&&O()},resetPersonProperties(){k={}},setGroupProperties(c,f=!0){j.clear();for(let[p,v]of Object.entries(c))y[p]={...y[p],...v};f&&O()},resetGroupProperties(){y={}},setContext(c,f,p){j.clear(),m={...m,[c]:{key:f,properties:p??{}}},O()},clearContext(c){j.clear();let{[c]:f,...p}=m;m=p,O()}},t.onChange(c=>{c==="reset"&&(m={},k={},y={}),(c==="identify"||c==="reset"||c==="group")&&O()}),n.disableFlagsOnFirstLoad?W():O(!1);let H=n.flagStream,Pe;H&&!h.disableRemote&&e.whenConsented(()=>{Pe=Y({apiHost:be,apiKey:e.apiKey,fetch:e.fetch,reload:()=>{O()},visibility:{hidden:()=>document.visibilityState==="hidden",subscribe:c=>(document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c))},...typeof H=="object"&&H.pollMs!==void 0?{pollMs:H.pollMs}:{},log:e.log})});let Ce=h.refreshMs&&h.refreshMs>0&&!h.disableRemote?setInterval(()=>document.visibilityState!=="hidden"&&void O(!1),h.refreshMs):void 0;return()=>{Pe?.(),Ce&&clearInterval(Ce)}};export{kn as flags};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var C=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),f=(r,o)=>r>>>o|r<<32-o;function d(r){let o=new TextEncoder().encode(r),a=o.length+9+63>>6<<6,u=new Uint8Array(a);u.set(o),u[o.length]=128;let p=new DataView(u.buffer);p.setUint32(a-8,Math.floor(o.length*8/2**32)),p.setUint32(a-4,o.length*8>>>0);let x=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c=new Uint32Array(64);for(let l=0;l<a;l+=64){for(let e=0;e<16;e++)c[e]=p.getUint32(l+e*4);for(let e=16;e<64;e++){let t=c[e-15],n=c[e-2],i=f(t,7)^f(t,18)^t>>>3,s=f(n,17)^f(n,19)^n>>>10;c[e]=c[e-16]+i+c[e-7]+s|0}let m=x.slice();for(let e=0;e<64;e++){let[t,n,i,,s,y,v,A]=m,b=A+(f(s,6)^f(s,11)^f(s,25))+(s&y^~s&v)+C[e]+c[e]|0,h=(f(t,2)^f(t,13)^f(t,22))+(t&n^t&i^n&i)|0;m.pop(),m.unshift(b+h|0),m[4]=m[4]+b|0}for(let e=0;e<8;e++)x[e]=x[e]+m[e]|0}return x.map(l=>(l>>>0).toString(16).padStart(8,"0")).join("")}var g="[data-lc-ignore]",E="input,select,textarea";function S(r){let o=r,a=o.labels?.[0]?.textContent?.trim()??r.getAttribute("aria-label")??"";return d(`${o.name??""}|${r.id}|${a}`).slice(0,12)}function F(r){let o="";try{o=new URL(r.action||location.href,location.href).pathname}catch{}let a=Array.from(document.forms).indexOf(r);return d(`${r.id}|${r.getAttribute("name")??""}|${o}|${a}`).slice(0,12)}function T(r){if(r.getAttribute("aria-invalid")==="true")return!0;try{return r.matches(":invalid")}catch{return!1}}var I=r=>{let o=new WeakMap,a=new Set,u=new Map,p=e=>{let t=e.target;if(!(t instanceof Element)||!t.matches(E)||t.closest(g))return;let n=t.form;return n?{el:t,form:n}:void 0},x=e=>{let t=o.get(e);return t||(t={id:F(e),startedAt:Date.now(),submitted:!1,touched:new Set},o.set(e,t),a.add(t),r.client.capture("$form_start",{form:t.id,$form_field_count:e.querySelectorAll(E).length})),t},c=e=>{let t=p(e);if(!t)return;let n=x(t.form),i=S(t.el),s=u.get(n.id+i);u.set(n.id+i,{n:(s?.n??0)+1,since:Date.now()}),n.last=i,n.touched.add(i)},l=e=>{let t=p(e),n=t&&o.get(t.form);if(!t||!n)return;let i=S(t.el),s=u.get(n.id+i);s&&r.client.capture("$form_field_interact",{form:n.id,field:i,$field_type:t.el.tagName==="INPUT"?t.el.type:t.el.tagName.toLowerCase(),interaction_ms:Date.now()-s.since,refill_count:s.n-1,error:T(t.el)})},m=e=>{let t=e.target;if(!(t instanceof HTMLFormElement)||t.closest(g))return;let n=x(t);n.submitted=!0,a.delete(n),r.client.capture("$form_submit",{form:n.id,$duration_ms:Date.now()-n.startedAt,$fields_touched:n.touched.size})};return document.addEventListener("focusin",c,!0),document.addEventListener("focusout",l,!0),document.addEventListener("submit",m,!0),r.onUnload(()=>{for(let e of a)e.submitted||r.client.capture("$form_abandon",{form:e.id,last_field:e.last,$fields_touched:e.touched.size,$duration_ms:Date.now()-e.startedAt});a.clear()}),()=>{document.removeEventListener("focusin",c,!0),document.removeEventListener("focusout",l,!0),document.removeEventListener("submit",m,!0)}};export{S as fieldId,I as forms};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as I}from"./chunk-AWIQCFGN.js";import{a as ee,c as Ge,d as $e,e as C,f as Ee,h as te,i as ne,k as x}from"./chunk-MCWQHOEV.js";function ie(t,n){let o=2166136261;for(let r of`${n}:${t}`)o=Math.imul(o^r.codePointAt(0),16777619);return o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),o^=o>>>16,(o>>>0)/2**32}function oe(t,n,o){let r=t.conditions.ab_group;if(!r)return t;let s=n.filter(i=>i.conditions.ab_group===r).sort((i,a)=>i.id<a.id?-1:1),u=s.reduce((i,a)=>i+(a.conditions.ab_weight??1),0),c=ie(o,`ab:${r}`)*u;for(let i of s)if(c-=i.conditions.ab_weight??1,c<0)return i;return s[s.length-1]}function se(t,n){let o=t.conditions,r=o.holdout_pct??0,s=o.holdout_scope==="variant"?t.id:o.ab_group??t.id;return r>0&&ie(n,`holdout:${s}`)*100<r}function re(t,n,o,r){let s=t.filter(i=>i.kind==="banner"&&i.steps[0]);if(!s.length)return;let u={id:"changelog",name:"What's new",kind:"resource_center",steps:s.map(i=>({id:i.id,title:i.steps[0].title??i.name,...i.steps[0].body?{body:i.steps[0].body}:{}})),conditions:{}},c=()=>{};return x(u,{shown:n,step:c,completed:c,dismissed:c,event:c},o,r?{nonce:r}:{})}function Me(t,n){for(let o of t){let r=o?.toLowerCase().replace("_","-");if(!r)continue;if(n.has(r))return r;let s=r.split("-")[0];if(n.has(s))return s}}function de(t,n){let o=new Set;for(let c of t.steps)for(let i of Object.keys(c.i18n??{}))o.add(i.toLowerCase());for(let c of Object.keys(t.appearance?.i18n??{}))o.add(c.toLowerCase());let r=Me(n,o);if(!r)return t;let s=c=>{let i=Object.keys(c??{}).find(a=>a.toLowerCase()===r);return i===void 0?void 0:c[i]},u=t.steps.map((c,i)=>{let a=s(c.i18n);if(!a)return c;let m=a.buttons,h=m&&(c.buttons??te(t.kind,i===t.steps.length-1)).map((g,l)=>({...g,label:m[l]??g.label}));return{...c,...a.title!==void 0?{title:a.title}:{},...a.body!==void 0?{body:a.body}:{},...h?{buttons:h}:{}}});return{...t,name:s(t.appearance?.i18n)?.name??t.name,steps:u}}function ce(t){let n=(r,s)=>{try{return JSON.parse(t.get(r)??"null")??s}catch{return s}},o=r=>({get:s=>n(r,{})[s],set(s,u){let c=n(r,{});u===void 0?delete c[s]:c[s]=u,t.set(r,JSON.stringify(c))}});return{views:o("lc_guide_views"),tour:o("lc_guide_progress"),checked:o("lc_guide_checked"),dismissed:o("lc_guide_dismissed"),held:o("lc_guide_holdout"),snoozed:o("lc_guide_snoozed")}}var O="lc_guide_seen",le=["lc_guide_views","lc_guide_progress","lc_guide_checked","lc_guide_dismissed","lc_guide_holdout","lc_guide_snoozed"],F=[O,...le],Oe=2e3,N=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},ae=t=>Array.isArray(t)?t:[],D=(t,n)=>[...new Set([...ae(t),...ae(n)])];function Ae(t,n){let o={[O]:D(t[O],n[O])};for(let r of le){let s=N(t[r]),u=N(n[r]),c={};for(let i of new Set([...Object.keys(s),...Object.keys(u)]))r==="lc_guide_checked"?c[i]=D(s[i],u[i]):r==="lc_guide_views"?c[i]=D(s[i],u[i]).sort((a,m)=>a-m).slice(-50):r==="lc_guide_progress"?c[i]=s[i]??u[i]:c[i]=Math.max(Number(s[i])||0,Number(u[i])||0);o[r]=c}return o}var ue=t=>Object.fromEntries(F.map(n=>{try{return[n,JSON.parse(t.get(n)??"null")]}catch{return[n,null]}}));function fe(t,n){let{core:o}=t,r,s=!1,u=async a=>{let m=await t.fetch(`${t.config.apiHost}/v1/guide-state`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,distinct_id:o.distinctId,...a?{state:a}:{}})});if(!m.ok)throw new Error(`status ${m.status}`);return N((await m.json()).state)},c=()=>t.config.guides?.syncState!==!1&&!!o.distinctId&&o.hasConsent("analytics"),i=()=>{r=void 0,c()&&u(ue(n)).catch(a=>t.log("guide state push failed",a))};return{async pull(){if(c())try{let a=Ae(ue(n),await u());for(let[m,h]of Object.entries(a))n.set(m,JSON.stringify(h));s=!0,i()}catch(a){t.log("guide state pull failed",a)}},touch(){s&&!r&&(r=setTimeout(i,Oe))},stop(){r&&clearTimeout(r)}}}var z="lc_guide";function pe(t,n,o,r){let{core:s}=t;return{async ask(u){try{let c=await t.fetch(`${t.config.apiHost}/v1/guides/answer?api_key=${encodeURIComponent(t.apiKey)}`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,query:u.slice(0,500),distinct_id:s.distinctId||s.sessionId,url:location.href.slice(0,2e3),...r?{locale:r.slice(0,35)}:{}})});if(c.status===503)return"unavailable";if(!c.ok)return null;let i=await c.json();return{answer:typeof i.answer=="string"?i.answer:"",citations:Array.isArray(i.citations)?i.citations.filter(a=>a&&typeof a.url=="string"):[],guide_ids:Array.isArray(i.guide_ids)?i.guide_ids.filter(a=>typeof a=="string"):[]}}catch(c){return t.log("guide answer failed",c),null}},searched({query:u,results:c,answered:i,feedback:a}){s.capture("$guide_search",{$guide_id:n.id,guide_id:n.id,query_length:u.length,results:c,answered:i,...a?{feedback:a}:{},...o()?{query:u.slice(0,500)}:{}})}}}function ge(){if(typeof location>"u"||typeof history>"u")return null;try{let t=new URL(location.href),n=t.searchParams.get(z);return n?(t.searchParams.delete(z),history.replaceState(history.state,"",t.toString()),n.slice(0,100)):null}catch{return null}}var q="lc:guide",me=["shown","step","completed","dismissed","event","progress","snoozed","targetMissing"],K=new Set(["tooltip","modal","banner","tour","checklist","resource_center","announcement","slideout","carousel"]),ye=t=>!!t&&typeof t=="object"&&t.lc===q&&typeof t.key=="string",xe=t=>{if(!t)return null;let n=t.getBoundingClientRect();return{x:n.left,y:n.top,width:n.width,height:n.height}};function he(){try{return window.top!==window}catch{return!0}}var Te=0;function ke(t,n,o,r,s){let u=window.top,c=`${Date.now().toString(36)}-${++Te}`,i=!1,a=y=>{try{u?.postMessage({...y,lc:q,key:c},s)}catch{}},m=t.steps.filter(y=>y.selector||y.fallback_selectors?.length),h=()=>{let y={};for(let _ of m)y[_.id]=xe(ne(_));a({op:"rects",rects:y})},g=y=>{if(y.source!==u||y.origin!==s||!ye(y.data)||y.data.key!==c)return;let _=y.data;if(_.op==="closed")return R(!1);if(_.op!=="hook"||!me.includes(_.name)||!Array.isArray(_.args))return;let A=n[_.name];if(A?.(..._.args),_.name==="step"){let E=t.steps.find(G=>G.id===_.args[1]);E?.automation&&r.automate!==!1&&n.automated?.(E.id,C(E.automation))}};addEventListener("message",g);let l=m.length?setInterval(h,200):void 0;addEventListener("scroll",h,!0),addEventListener("resize",h);let R=y=>{i||(i=!0,l&&clearInterval(l),removeEventListener("message",g),removeEventListener("scroll",h,!0),removeEventListener("resize",h),y&&a({op:"close"}),o())};return a({op:"render",guide:t,...r.start?{start:r.start}:{},...r.checked?{checked:r.checked}:{}}),m.length&&h(),Object.assign(()=>R(!0),{markDone:y=>a({op:"mark",stepId:y})})}function Pe(t){for(let n of document.querySelectorAll("iframe"))if(n.contentWindow===t)return n;return null}function He(t,n){let o=()=>{let s=t.getBoundingClientRect();return new DOMRect(s.left+t.clientLeft+n.x,s.top+t.clientTop+n.y,n.width,n.height)},r=()=>{};return{getBoundingClientRect:o,addEventListener:r,removeEventListener:r}}function _e(t,n){let o=new Set(t.map(u=>u.replace(/\/+$/,""))),r=new Map,s=u=>{if(!o.has(u.origin)||!ye(u.data))return;let c=Pe(u.source);if(!c)return;let i=u.data,a=`${u.origin}|${i.key}`,m=g=>{try{u.source.postMessage({...g,lc:q,key:i.key},u.origin)}catch{}},h=r.get(a);if(i.op==="rects"&&h)h.rects=i.rects&&typeof i.rects=="object"?i.rects:{};else if(i.op==="close")h?.handle();else if(i.op==="mark")h?.handle.markDone(String(i.stepId));else if(i.op==="render"&&!h){let g=i.guide;if(!g||typeof g.id!="string"||typeof g.name!="string"||!Array.isArray(g.steps)||!K.has(g.kind))return;let l=g.kind==="banner"?()=>{}:I();if(!l)return m({op:"closed"});let R=G=>(...v)=>m({op:"hook",name:G,args:v}),y=Object.fromEntries(me.map(G=>[G,R(G)])),_={rects:{},release:l,handle:void 0};r.set(a,_);let E={resolveTarget:G=>{let v=_.rects[G.id];return v&&typeof v.x=="number"?He(c,v):null},automate:!1,...n?{nonce:n}:{},...typeof i.start=="number"?{start:i.start}:{},...Array.isArray(i.checked)?{checked:i.checked}:{}};_.handle=x(g,y,()=>{r.delete(a),l(),m({op:"closed"})},E)}};return addEventListener("message",s),()=>{removeEventListener("message",s);for(let u of[...r.values()])u.handle()}}var we="lc_guide_last",ve=new Set(["hotspot","beacon","badge","launcher"]),Ie=()=>{try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t?`&tz=${encodeURIComponent(t)}`:""}catch{return""}},J=new Set([...ve,"form_validation"]),U=t=>J.has(t.kind)||t.kind==="inline",Le=new Set(["tour","checklist"]),je=30*6e4,Ce=()=>{let t=innerWidth;return t<640?"mobile":t<1024?"tablet":"desktop"},dt=t=>{let{core:n}=t,o=[],r=!1,s=new Set,u=new Map,c=ge(),i=!1,a={get:e=>n.storage.get(e),set(e,d){n.storage.set(e,d),F.includes(e)&&m.touch()},remove:e=>n.storage.remove(e)},m=fe(t,n.storage),h=()=>JSON.parse(a.get(O)??"[]"),g=new Set(h()),l=ce(a),R=new Set,y=[],_=t.config.localFlagsContext,A={..._?.person_properties},E={..._?.group_properties},G=e=>{let d=t.flags?.get(e);return d!==void 0&&d!==!1},v=(e,d={})=>({$guide_id:e.id,$guide_kind:e.kind,...d}),Y=()=>n.distinctId||n.sessionId,B=new Set,P=(e,d=!1)=>{if(e.preview){let f=()=>{};return{shown:f,step:f,completed:f,dismissed:f,event:f}}let k=J.has(e.kind),w=f=>({guide_id:e.id,step_id:f,$guide_step_id:f}),S=()=>{l.tour.set(e.id,void 0),l.checked.set(e.id,void 0),k&&l.dismissed.set(e.id,Date.now())};return{shown(){let f=Date.now(),p=l.views.get(e.id)??[],b=k&&(p.at(-1)??0)>f-je;g.add(e.id),l.snoozed.get(e.id)&&l.snoozed.set(e.id,void 0),a.set(O,JSON.stringify([...g])),n.storage.set(we,String(f)),e.kind==="checklist"&&!l.checked.get(e.id)&&l.checked.set(e.id,[]),!(b||d)&&(l.views.set(e.id,[...p,f].slice(-50)),n.capture("$guide_shown",v(e)))},step:(f,p)=>{e.kind==="checklist"&&l.checked.set(e.id,[...new Set([...l.checked.get(e.id)??[],p])]),n.capture("$guide_step",v(e,{$guide_step_id:p,$guide_step_index:f}))},progress:f=>e.kind==="tour"&&l.tour.set(e.id,f),completed:()=>(S(),n.capture("$guide_completed",v(e))),dismissed:(f,p,b)=>{b!=="snooze"&&S(),n.capture("$guide_dismissed",v(e,{$guide_step_id:p,$guide_step_index:f,...b?{reason:b}:{}}))},event:f=>t.client.capture(f,{$guide_id:e.id}),snoozed:(f,p)=>l.snoozed.set(e.id,Date.now()+p*36e5),targetMissing:(f,p)=>n.capture("$guide_target_missing",v(e,{...w(f),selector:p})),validationFailed:(f,p)=>n.capture("$guide_validation_failed",v(e,{...w(f),rule:p})),automated:(f,p)=>p!=="done"&&t.log(`guide ${e.id} step ${f}: automation ${p}`)}},T=(e,d=0)=>{let k=ve.has(e.kind),w=U(e)?()=>{}:I();if(!w)return void s.delete(e.id);let S=de(e,[t.config.guides?.locale,A.locale,navigator.language]),f=H=>{let L=o.find(Re=>Re.id===H);L&&!s.has(L.id)&&(s.add(L.id),T(L))},p={start:d,person:A,checked:l.checked.get(e.id)??[],library:o,launch:f,flag:G,...t.config.nonce?{nonce:t.config.nonce}:{},...e.kind==="resource_center"&&!e.preview?{assist:pe(t,e,()=>i,t.config.guides?.locale??navigator.language)}:{}},b=d>0||e.kind==="checklist"&&l.checked.get(e.id)!==void 0,$=()=>{R.delete(M),u.delete(e.id),w(),s.delete(e.id)},M=()=>{};if(k){import("./persistent-XLGNSZQR.js").then(H=>{M=H.renderPersistent(S,P(e,b),$,p),r?M():R.add(M)});return}if(e.kind==="form_validation"){import("./validation-ENITEP6V.js").then(H=>{M=H.renderValidation(S,P(e,b),$,p),r?M():R.add(M)});return}let Z=t.config.guides?.renderInTop,X=Z&&K.has(e.kind)&&he()?ke(S,P(e,b),$,p,Z):x(S,P(e,b),$,p);M=X,u.set(e.id,X),R.add(M)},j=(e,d=!1)=>{let k=J.has(e.kind),w=e.conditions,S=e.steps[0]?.selector;if(e.kind==="inline"&&!(S&&document.querySelector(S)))return!1;if(e.preview)return!B.has(e.id)&&(B.add(e.id),!0);let f=l.views.get(e.id)??[],p=l.snoozed.get(e.id);if(!d&&p&&p>Date.now()||!d&&(k?l.dismissed.get(e.id):g.has(e.id)&&!w.frequency&&!p))return!1;let b={url:location.href,flags:G,flagValue:$=>t.flags?.get($),lastShownMs:e.queued?void 0:Number(n.storage.get(we))||void 0,nowMs:Date.now(),random:e.queued?()=>0:Math.random,person:A,groups:E,device:Ce(),seen:$=>g.has($),views:k?[]:f};return!ee(e,b)||oe(e,o,Y())!==e?!1:e.held_out||se(e,Y())?(l.held.get(e.id)||(l.held.set(e.id,Date.now()),n.capture("$guide_holdout",v(e,w.ab_group?{$guide_group:w.ab_group}:{}))),!1):!0},Se=()=>{let e=c?o.find(d=>d.id===c):void 0;c=null,!(!e||s.has(e.id)||t.config.guides?.render===!1||!j(e,!0))&&(s.add(e.id),T(e))},V=()=>{if(!(t.config.guides?.render===!1||typeof document>"u")){for(let e of o){if(s.has(e.id)||!Le.has(e.kind))continue;let d=e.kind==="tour"?e.steps.findIndex(w=>w.id===l.tour.get(e.id)):l.checked.get(e.id)?0:-1,k=e.steps[d];if(!(d<0||!k||k.url&&!location.href.includes(k.url)))return s.add(e.id),T(e,d)}for(let e of o)s.has(e.id)||!U(e)||!j(e)||(s.add(e.id),T(e));for(let e of[...o.filter(d=>d.queued),...o.filter(d=>!d.queued)])if(!(s.has(e.id)||U(e)||!j(e))){s.add(e.id),y.push(setTimeout(()=>T(e),e.queued?0:(e.conditions.delay_seconds??0)*1e3));return}}},be=e=>{for(let d of o)if(!(d.kind!=="checklist"||!s.has(d.id)&&!l.checked.get(d.id)))for(let[k,w]of d.steps.entries()){let S=w.complete_on;if(!S||S.event!==e.event||!Object.entries(S.props??{}).every(([b,$])=>e.properties[b]===$))continue;let f=l.checked.get(d.id)??[];if(f.includes(w.id))continue;let p=u.get(d.id);p?p.markDone(w.id):(l.checked.set(d.id,[...f,w.id]),n.capture("$guide_step",v(d,{$guide_step_id:w.id,$guide_step_index:k,$guide_auto:!0})),f.length+1>=d.steps.length&&P(d).completed())}},W=()=>{let e=t.fetch(`${t.config.apiHost}/v1/guides?api_key=${encodeURIComponent(t.apiKey)}${n.distinctId?`&distinct_id=${encodeURIComponent(n.distinctId)}`:""}${Ie()}&url=${encodeURIComponent(location.origin+location.pathname)}`,{credentials:"omit"}).then(d=>d.ok?d.json():Promise.reject(new Error(`status ${d.status}`)));Promise.all([e,m.pull()]).then(([d])=>{for(let k of h())g.add(k);o=d.guides??[],i=d.settings?.guide_search_capture_query===!0,Se(),V()}).catch(d=>t.log("guides fetch failed",d))};t.guides={showChangelog(){if(typeof document>"u")return 0;let e=I();if(!e)return 0;let d=re(o,()=>n.capture("$changelog_viewed"),()=>(R.delete(d),e()),t.config.nonce);return d?(R.add(d),o.filter(k=>k.kind==="banner").length):(e(),0)},show(e){let d=o.find(k=>k.id===e);return!d||s.has(d.id)||typeof document>"u"||t.config.guides?.render===!1?!1:(s.add(d.id),T(d),s.has(d.id))},reset(e){g.delete(e),a.set(O,JSON.stringify([...g]));for(let d of[l.views,l.dismissed,l.tour,l.checked,l.held])d.set(e,void 0)}},t.whenConsented(W);let Q=t.config.guides?.frameOrigins;return Q?.length&&typeof document<"u"&&R.add(_e(Q,t.config.nonce)),t.onCapture(e=>{if(e.event==="$identify"&&W(),e.$set&&Object.assign(A,e.$set),e.event==="$groupidentify"){let d=String(e.properties.$group_type);E[d]={...E[d],...e.properties.$group_set}}e.event==="$pageview"?V():e.event.startsWith("$guide_")||be(e)}),()=>{r=!0,m.stop();for(let e of y)clearTimeout(e);for(let e of[...R])e()}};export{z as PERMALINK_PARAM,Ge as branchOk,dt as guides,x as renderGuide,Ee as resolveTokens,C as runAutomation,$e as sensitive};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var $=new Set(["input","textarea","select","option"]),T=["name","type","role","aria-label","title","alt","placeholder"],S=/(?:\d[ -]?){9,}/;function I(t){if($.has(t.tagName.toLowerCase())||t.isContentEditable)return;let n="";for(let e of Array.from(t.childNodes))e.nodeType===3&&(n+=e.textContent??"");if(n=n.replace(/\s+/g," ").trim(),!(!n||S.test(n)))return n.slice(0,255)}function b(t){if(!t?.length)return()=>!1;let n=t.map(e=>e.toLowerCase());return e=>n.some(r=>r.endsWith("*")?e.startsWith(r.slice(0,-1)):e===r)}var C="***";function H(t,n,e,r){let c=t.parentElement,i=c?Array.from(c.children):[t],o={tag_name:t.tagName.toLowerCase(),nth_child:i.indexOf(t)+1,nth_of_type:i.filter(u=>u.tagName===t.tagName).indexOf(t)+1},s=(t.getAttribute("class")??"").split(/\s+/).filter(Boolean);s.length&&!e("class")&&(o.classes=s),t.id&&!e("id")&&(o.attr__id=r("id",t.id));let a=t.getAttribute("href");a&&!e("href")&&(o.href=r("href",a.slice(0,1024)));let l={};for(let u of Array.from(t.attributes))(u.name.startsWith("data-lc-")||T.includes(u.name))&&!e(u.name)&&(l[u.name]=r(u.name,u.value.slice(0,255)));if(Object.keys(l).length&&(o.attrs=l),n){let u=I(t);u&&(o.text=u)}return o}function E(t,n,e,r,c={}){let i=[],o=b(r),s=b(c.allow),a=c.maskAll?(u,d)=>s(u)?d:C:(u,d)=>d,l=n;for(let u=t;u&&i.length<10;u=u.parentElement)i.push(H(u,l,o,a)),(u===e||!e)&&(l=!1);return i}var m=t=>t.replace(/(["\\])/g,"\\$1");function w(t){return t.map(n=>{let e=n.tag_name+(n.classes?"."+n.classes.join("."):"")+":";n.attr__id&&(e+=`attr__id="${m(n.attr__id)}"`),n.href&&(e+=`href="${m(n.href)}"`),n.text&&(e+=`text="${m(n.text)}"`);for(let[r,c]of Object.entries(n.attrs??{}))e+=`attr__${r}="${m(c)}"`;return e+`nth-child="${n.nth_child}"nth-of-type="${n.nth_of_type}"`}).join(";")}var f=[],P=/^[+\-−–‹›<>«»←→↑↓▲▼▶◀^ˇ˄˅]$/,X=/\b(increase|decrease|increment|decrement|plus|minus|add one|remove one|next|prev|previous|scroll (left|right))\b/i,L=/(^|[-_\s])(stepper|spinner|quantity|qty|increment|decrement|inc|dec|plus|minus|carousel|slider|swiper|slick|glide|splide|arrow|next|prev)([-_\s]|$)/i,D="button,[role=button],a,input[type=button],input[type=submit],[role=spinbutton]";function j(t,n=[]){if(n.length&&t.closest(n.join(","))||t.closest("input[type=number],[role=spinbutton],[role=slider]"))return!0;let e=t.closest(D)??t,r=`${e.getAttribute("aria-label")??""} ${e.getAttribute("title")??""}`;if(P.test((e.textContent??"").trim())||X.test(r))return!0;for(let c=e,i=0;c&&i<3;c=c.parentElement,i++)if(L.test(c.getAttribute("class")??""))return!0;return!1}var N=()=>typeof getSelection=="function"?(getSelection()?.toString()??"")!=="":!1;function _(t,n=Date.now(),e={},r){if(r&&e.ignoreSelectors?.length&&r.closest(e.ignoreSelectors.join(",")))return{};if(r&&e.suppressSteppers!==!1&&j(r,e.stepperSelectors))return{};if(e.ignoreTextSelection!==!1&&N())return{};let c=e.windowMs??1e3,i=e.radiusPx??30;for(f.length&&n<f[f.length-1].t&&(f.length=0),f.push({t:n,x:t.clientX,y:t.clientY});f.length&&n-f[0].t>c;)f.shift();let o=f.filter(s=>Math.hypot(s.x-t.clientX,s.y-t.clientY)<=i).length;return o>=(e.count??3)?{$rageclick:!0,$rageclick_count:o}:{}}function v(t,n,e=700){if(typeof MutationObserver>"u")return;let r=!1,c=new MutationObserver(()=>r=!0);c.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let i=()=>{r=!0};window.addEventListener("scroll",i,{capture:!0,passive:!0}),document.addEventListener("selectionchange",i);let o=()=>{c.disconnect(),window.removeEventListener("scroll",i,{capture:!0}),document.removeEventListener("selectionchange",i)},s=setTimeout(()=>{o(),!r&&document.visibilityState!=="hidden"&&t.client.capture("$deadclick_hint",{$selector:n,$no_mutation_ms:e})},e);t.onUnload(()=>{clearTimeout(s),o()})}var y=/^[A-Za-z_][\w-]*$/,O=5;function p(t){let n=[];for(let e=t;e&&n.length<O;e=e.parentElement){let r=e.tagName.toLowerCase();if(e.id&&y.test(e.id)){n.unshift(`${r}#${e.id}`);break}let c=(e.getAttribute("class")??"").split(/\s+/).filter(i=>y.test(i)).slice(0,2);n.unshift(r+c.map(i=>`.${i}`).join(""))}return n.join(" ")}function M(t,n,e,r,c={}){let i={$selector:p(e),$el_interactive:r};(n.clientX||n.clientY||n.detail)&&(i.$click_x=Math.round(n.clientX+(window.scrollX||0)),i.$click_y=Math.round(n.clientY+(window.scrollY||0))),c.rageClicks!==!1&&!e.closest(".lc-no-rageclick,[data-lc-no-rageclick]")&&Object.assign(i,_(n,Date.now(),c.rageClicks||{},e));let o=c.deadClicks;!r&&n.isTrusted&&o!==!1&&!(o?.ignoreSelectors?.length&&e.closest(o.ignoreSelectors.join(",")))&&v(t,i.$selector,o?.waitMs);for(let s of t.clickExtras)Object.assign(i,s(n,e));return i}function k(t){let n=new Array(10).fill(0),e=new Map,r=new Map,c=t.now(),i=(o,s)=>{e.set(o,(e.get(o)??0)+s)};return{tick(){let o=t.now(),s=o-c;if(c=o,s<=0||!t.visible())return;let a=Math.max(t.pageH(),1),l=Math.max(0,t.scrollY()),u=Math.min(a,l+t.viewportH());for(let d=0;d<10;d++){let A=d*a/10,x=(d+1)*a/10;l<x&&u>A&&(n[d]=(n[d]??0)+s)}},enter(o){r.has(o)||r.set(o,t.now())},leave(o){let s=r.get(o);s!==void 0&&(r.delete(o),t.visible()&&i(o,t.now()-s))},drain(){let o=t.now();for(let[a,l]of r)t.visible()&&i(a,o-l),r.set(a,o);let s={bands:n.flatMap((a,l)=>a>=100?[[l,Math.round(a)]]:[]),elements:[...e].filter(([,a])=>a>=100).map(([a,l])=>[a,Math.round(l)])};return n.fill(0),e.clear(),s}}}var g="[data-lc-ignore]",W="a,button,input,select,textarea,label,summary,[role=button],[role=link],[data-lc-capture]";function h(t){return t<768?"mobile":t<1024?"tablet":"desktop"}function Y(t,n){let e=n.getBoundingClientRect();return{$click_el_x:Math.round(t.clientX-e.left),$click_el_y:Math.round(t.clientY-e.top),$el_width:Math.round(e.width),$el_height:Math.round(e.height),$viewport_bucket:h(window.innerWidth)}}function B(t,n){let e=[],r=0,c=0,i=()=>{e.length&&(t.client.capture("$heatmap_moves",{$points:e,$viewport_bucket:h(window.innerWidth)}),e=[])},o=a=>{let l=Date.now();l-c<n||a.target instanceof Element&&a.target.closest(g)||(e.length||(r=l),c=l,e.push([Math.round(a.clientX+scrollX),Math.round(a.clientY+scrollY),l-r]),e.length>=100&&i())};document.addEventListener("mousemove",o,{passive:!0,capture:!0});let s=setInterval(i,5e3);return t.onUnload(i),()=>{document.removeEventListener("mousemove",o,!0),clearInterval(s),i()}}var R="h1,h2,h3,section,article,main,form,[data-lc-attention]",V=200;function q(t){let n=k({now:Date.now,scrollY:()=>window.scrollY,viewportH:()=>window.innerHeight,pageH:()=>document.documentElement.scrollHeight,visible:()=>document.visibilityState!=="hidden"}),e=new WeakMap,r=typeof IntersectionObserver>"u"?void 0:new IntersectionObserver(s=>{for(let a of s){let l=e.get(a.target);l&&(a.isIntersecting?n.enter(l):n.leave(l))}},{threshold:.5});for(let s of[...document.querySelectorAll(R)].slice(0,V))s.closest(g)||(e.set(s,p(s)),r?.observe(s));let c=()=>{let s=n.drain();(s.bands.length||s.elements.length)&&t.client.capture("$attention",{$bands:s.bands,$elements:s.elements,$viewport_bucket:h(window.innerWidth)})},i=setInterval(()=>n.tick(),1e3),o=setInterval(c,15e3);return t.onUnload(()=>(n.tick(),c())),()=>{clearInterval(i),clearInterval(o),r?.disconnect(),n.tick(),c()}}var tt=t=>{let n=!1;t.loadConfig().then(a=>n=a?.heatmaps!==!1);let e=t.config.autocapture,r=typeof e=="object"?e.denySelectors:void 0;t.clickExtras.push((a,l)=>n?Y(a,l):{});let c=a=>{let l=a.target;if(!n||!(l instanceof Element)||l.closest(g)||r?.length&&l.closest(r.join(",")))return;let u=!!l.closest(W);if(u&&t.autocaptureClicks||l instanceof HTMLInputElement&&l.type==="password")return;let d=E(l,!1);t.client.capture("$autocapture",{$event_type:"click",$elements:d,$elements_chain:w(d),...M(t,a,l,u)})};document.addEventListener("click",c,!0);let i=t.config.heatmaps,o=i?.moves?B(t,i.moveIntervalMs??250):void 0,s=i?.attention?q(t):void 0;return()=>{document.removeEventListener("click",c,!0),o?.(),s?.()}};export{Y as heatmapProps,tt as heatmaps,h as viewportBucket};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function h(e){let r=window.fetch;window.fetch=function(s,o){let c=s instanceof Request?s.url:String(s),a=new Headers(o?.headers??(s instanceof Request?s.headers:void 0)),d=[...a.entries()].join("|");return e(c,a),[...a.entries()].join("|")===d?r.call(this,s,o):r.call(this,s,{...o,headers:a})};let t=XMLHttpRequest.prototype,{open:i,send:n}=t,u=new WeakMap;return t.open=function(s,o,...c){return u.set(this,String(o)),i.call(this,s,o,...c)},t.send=function(s){let o=u.get(this);if(o){let c=new Headers;e(o,c),c.forEach((a,d)=>this.setRequestHeader(d,a))}return n.call(this,s)},()=>{window.fetch=r,t.open=i,t.send=n}}var l="X-Lucida-Distinct-Id",p="X-Lucida-Session-Id";function R(e,r){let t;try{t=new URL(e,location.href).hostname.toLowerCase()}catch{return!1}return r.some(i=>{let n=i.toLowerCase();return n.startsWith(".")?t===n.slice(1)||t.endsWith(n):t===n})}var f=e=>/^[\x20-\x7e]*$/.test(e)?e:encodeURIComponent(e),H=e=>{let r=e.config.tracingHeaders;if(!r?.length)return;let{core:t}=e;return h((i,n)=>{!t.hasConsent("analytics")||i.startsWith(e.config.apiHost)||!R(i,r)||(t.distinctId&&n.set(l,f(t.distinctId)),n.set(p,f(t.sessionId)))})};export{l as DISTINCT_ID_HEADER,p as SESSION_ID_HEADER,H as hostHeaders,R as hostListed};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var en,Xe,ue,G,Ye=E(()=>{"use strict";en="lc_consent",Xe=["analytics","replay","marketing"],ue=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let n=this.opens();this.state={analytics:n,replay:n,marketing:n},this.key=e.storageKey||en;let r=e.storage.get(this.key);if(r)try{let s=JSON.parse(r);for(let o of Xe)typeof s[o]=="boolean"&&(this.state[o]=s[o]);this.decided=Xe.some(o=>typeof s[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 n=!this.geoCookieless&&this.opens();return this.state={analytics:n,replay:n,marketing:n},n}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 n=this.get();for(let r of Xe)e[r]!==void 0&&(this.state[r]=e[r]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let r of this.listeners)r(this.get(),n)}onChange(e){this.listeners.push(e)}},G=class{constructor(e,n){this.inner=e;this.allowed=n}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,n){this.allowed()?this.inner.set(e,n):this.mem.set(e,n)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,n]of this.mem)n===null?this.inner.remove(e):this.inner.set(e,n);this.mem.clear()}discardBuffered(){this.mem.clear()}}});function tn(t){let e=new Uint8Array(t),n=globalThis.crypto;if(n?.getRandomValues)n.getRandomValues(e);else for(let r=0;r<t;r++)e[r]=Math.floor(Math.random()*256);return e}function V(t=Date.now()){if(t>Se){Se=t;let o=tn(2);se=((o[0]??0)<<8|(o[1]??0))&1023}else se++,se>4095&&(Se++,se=0);let e=tn(8),n=new Uint8Array(16),r=Se;n[0]=Math.floor(r/2**40)&255,n[1]=Math.floor(r/2**32)&255,n[2]=Math.floor(r/2**24)&255,n[3]=Math.floor(r/2**16)&255,n[4]=Math.floor(r/2**8)&255,n[5]=r&255,n[6]=112|se>>8,n[7]=se&255,n[8]=128|(e[0]??0)&63;for(let o=1;o<8;o++)n[8+o]=e[o]??0;let s=Array.from(n,o=>o.toString(16).padStart(2,"0")).join("");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}var Se,se,Re=E(()=>{"use strict";Se=0,se=0});var nn,Ee,rn=E(()=>{"use strict";Re();nn="lc_identity",Ee=class{constructor(e,n,r=!1,s=!1){this.storage=e;this.cookieless=r;let o=e.get(nn),i;try{i=o?JSON.parse(o):void 0}catch{i=void 0}if(i?.distinct_id)this.s=i;else if(r)this.s={distinct_id:"",anon_id:"",identified:!1};else{let a=n??V();this.s={distinct_id:a,anon_id:a,identified:s&&!!n},this.save()}}storage;cookieless;s;save(){this.storage.set(nn,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 n=this.s.distinct_id,r=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),r&&n?{event:"$identify",anonDistinctId:n}:{event:"$identify"}}aliasProps(e,n){return{alias:e,distinct_id:n??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let n=e&&this.s.anon_id||V();this.s={distinct_id:n,anon_id:n,identified:!1},this.save()}}});function Q(t,e={}){let n=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**t);return Math.round(n*(.5+.5*(e.random??Math.random)()))}function sn(t){return t===0||t===408||t===429||t>=500}var Ce=E(()=>{"use strict"});var $e,on=E(()=>{"use strict";Ce();$e=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;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 n=this.items.splice(0,this.batchMax),r=(this.o.clock??Date).now(),s=JSON.stringify({api_key:this.o.apiKey,batch:n,sent_at:new Date(r).toISOString()});this.o.log?.("send batch",n.length);let o=this.o.transport.send(this.o.url,s,e.beacon?{beacon:!0}:{}).then(i=>i.status,()=>0).then(i=>this.settle(n,i,!!e.beacon)).finally(()=>{this.inflight=void 0});return this.inflight=o,o}settle(e,n,r){if(n>=200&&n<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!sn(n)||r||this.attempt>=this.maxRetries){this.o.onDrop?.(e,`status_${n}`),this.attempt=0;return}this.items.unshift(...e);let s=Q(this.attempt++,this.o.backoff);this.o.log?.("retry in",s,"ms"),this.arm(s)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}}});function an(t,e,n){return typeof t=="number"&&Number.isInteger(t)&&t>=e&&t<=n?t*6e4:void 0}var Je,Pe,cn=E(()=>{"use strict";Re();Je="lc_session";Pe=class{constructor(e,n={}){this.storage=e;this.o=n;this.idleMs=n.idleMs??30*6e4,this.maxMs=n.maxMs??24*36e5,this.newOn=n.newOnEvents??[],this.clock=n.clock??Date,this.bootstrapId=n.bootstrapId}storage;o;windowId=V();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=an(e.session_idle_minutes,1,1440)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=an(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(n=>typeof n=="string"&&n!==""))}read(){try{let e=this.storage.get(Je);return e?JSON.parse(e):void 0}catch{return}}touch(e,n){let r=this.clock.now(),s=this.read(),o=!!(s?.campaign&&e&&s.campaign!==e),i=n!==void 0&&this.newOn.includes(n),a=!s||r-s.last>this.idleMs||r-s.start>this.maxMs||o||i;return(a||!s)&&(s={id:!s&&this.bootstrapId||V(r),start:r,last:r}),this.bootstrapId=void 0,s.last=r,e&&(s.campaign=e),this.storage.set(Je,JSON.stringify(s)),{sessionId:s.id,windowId:this.windowId,isNew:a}}startedAt(){return this.read()?.start}reset(){this.storage.remove(Je)}}});function ln(t,e){let n=t.get(e);if(n)try{return JSON.parse(n)}catch{return}}var Oe,Ae,un=E(()=>{"use strict";Oe=class{constructor(e,n="lc_props",r){this.storage=e;this.key=n;this.persist=r;this.p=ln(e,n)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([n])=>e(n))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[n,r]of Object.entries(e))n in this.p||(this.p[n]=r);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},Ae=class{constructor(e){this.storage=e;this.g=ln(e,"lc_groups")??{}}storage;g;set(e,n){this.g[e]=n,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 ds(t,e){let n=new Date(t??e);return(Number.isNaN(n.getTime())?new Date(e):n).toISOString()}var de,dn=E(()=>{"use strict";Ye();rn();on();cn();un();Re();de=class{constructor(e){this.c=e;this.clock=e.clock??Date,this.consent=new ue({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new G(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new Ee(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new Pe(this.gated,{clock:this.clock,...e.session}),this.props=new Oe(this.gated,void 0,e.persistProperty),this.groupState=new Ae(this.gated),this.queue=new $e({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")||V(),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 n=this.session.touch(this.c.campaignKey?.(),e);if(n.sessionId!==this.lastSession){this.lastSession=n.sessionId;for(let r of this.sessionListeners)r(n.sessionId,n.windowId)}return n}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 n of this.listeners)n(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,n={},r={}){let s=this.consent.has("analytics"),o=!s&&(this.anonymousOnReject||this.consent.anonymous),i=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!s&&!o&&!i){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 a=this.touchSession(e),c=this.c.enrich?.(e,n),l=this.consent.status()!=="pending",u=o?{}:{...c?.$set,...r.$set,...e==="$consent_updated"&&l?{$consent:this.consent.get()}:{}},f=o?{}:{...c?.$set_once,...r.$set_once},g=this.groupState.all(),m=o?"":this.identity.distinctId,_={uuid:V(this.clock.now()),event:e,...m?{distinct_id:m}:{},timestamp:ds(r.timestamp,this.clock.now()),properties:{...this.props.all(),...c?.properties,...n,$session_id:a.sessionId,$window_id:a.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...l?{$consent:this.consent.get()}:{}},...Object.keys(u).length?{$set:u}:{},...Object.keys(f).length?{$set_once:f}:{},...!o&&r.$unset?.length?{$unset:r.$unset}:{},...g?{$groups:g}:{}},y=this.filter?this.filter(_):_;if(!y){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,y),this.c.onCapture?.(y);for(let k of this.captureListeners)k(y);return s||o?this.queue.enqueue(y):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(y),y}identify(e,n,r){let s=this.identity.identify(e);(s.event||n||r)&&this.capture("$identify",s.anonDistinctId?{$anon_distinct_id:s.anonDistinctId}:{},{...n?{$set:n}:{},...r?{$set_once:r}:{}}),this.emit("identify")}alias(e,n){this.capture("$create_alias",this.identity.aliasProps(e,n))}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,n,r){this.groupState.set(e,n),this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r??{}}),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 n=this.consent.has("analytics"),r=e.analytics??n;if(n&&!r&&(this.capture("$opt_out"),this.queue.flush()),!n&&r&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!n&&r){this.gated.flushBuffered();for(let s of this.pre.splice(0))this.queue.enqueue(s);this.capture("$opt_in")}else n&&!r&&this.queue.clear();r||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e);let n=e.consent_default;this.resolveConsent(n==="opt_in"||n==="opt_out"||n==="cookieless"?n:void 0)}resolveConsent(e){if(!this.consent.resolving)return;let n=this.consent.resolve(e),r=this.pre.splice(0);if(n){this.gated.flushBuffered();for(let s of r)this.queue.enqueue(s)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let s of r){if(s.event==="$identify"||s.event==="$create_alias")continue;let o={...s};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(...r);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 Ze(t,e){return{event:pn,props:{$feature_flag:t,$enrolled:e},extra:{$set:{[Ie(t)]:e}}}}var pn,Ie,fn=E(()=>{"use strict";pn="$early_access_opt_in",Ie=t=>`$feature_enrollment/${t}`});function Qe(t){let e="";return n=>{for(e+=n;;){let r=/\r?\n\r?\n/.exec(e);if(!r)return;let s=e.slice(0,r.index);e=e.slice(r.index+r[0].length);let o="message",i,a=[];for(let c of s.split(/\r?\n/)){if(c.startsWith(":"))continue;let l=c.indexOf(":"),[u,f]=l<0?[c,""]:[c.slice(0,l),c.slice(l+1).replace(/^ /,"")];u==="event"?o=f??"":u==="data"?a.push(f??""):u==="id"&&(i=f)}a.length&&t(i===void 0?{event:o,data:a.join(`
|
|
2
|
+
`)}:{event:o,data:a.join(`
|
|
3
|
+
`),id:i})}}}var Me,et=E(()=>{"use strict";Ce();Me=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;start(){this.stopped&&(this.stopped=!1,this.loop())}stop(){this.stopped=!0,this.ctl?.abort(),this.timer&&clearTimeout(this.timer),this.o.onState?.(!1)}async loop(){let e=0;for(;!this.stopped;){try{await this.connectOnce()&&(e=0)}catch(r){this.stopped||this.o.log?.("flag stream error",r)}if(this.o.onState?.(!1),this.stopped)return;let n=Q(e++,this.o.backoff);await new Promise(r=>{this.timer=setTimeout(r,n),this.timer.unref?.()})}}async connectOnce(){this.ctl=new AbortController;let e=await this.o.fetch(this.o.url,{headers:{Authorization:`Bearer ${this.o.secretKey}`,Accept:"text/event-stream"},signal:this.ctl.signal});if(!e.ok||!e.body)throw new Error(`stream status ${e.status}`);this.o.onState?.(!0);let n=Qe(s=>{if(s.event==="definitions")try{this.o.onChange(JSON.parse(s.data).etag)}catch{this.o.onChange(void 0)}}),r=e.body.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:s,value:o}=await r.read();if(s)return!0;n(o)}}}});function tt(t){let e=!1,n,r=new Me({url:`${t.apiHost}/v1/flags/stream`,secretKey:t.apiKey,fetch:t.fetch,...t.backoff?{backoff:t.backoff}:{},...t.log?{log:t.log}:{},onState:l=>e=l,onChange:l=>{l!==void 0&&l===n||(n=l,t.reload())}}),s=()=>t.visibility?.hidden()??!1,o=t.pollMs??6e4,i=o>0?setInterval(()=>!e&&!s()&&t.reload(),o):void 0,a=()=>{s()?r.stop():(r.start(),t.reload())};s()||r.start();let c=t.visibility?.subscribe(a);return()=>{r.stop(),c?.(),i&&clearInterval(i)}}var gn=E(()=>{"use strict";et()});function nt(t,e){let n=new Set,{whenConsented:r,disabled:s,...o}=e,i=new Te({...o,distinctId:()=>t.distinctId,onIntervention:c=>{for(let l of[...n])l(c)}}),a=!1;return t.onChange(c=>{a&&((c==="identify"||c==="reset")&&i.restart(),c==="consent"&&(t.hasConsent("analytics")?i.start():i.stop()))}),{on(c){return n.add(c),!a&&!s&&(a=!0,r(()=>i.start())),()=>{n.delete(c)}},stop:()=>i.stop()}}var Te,mn=E(()=>{"use strict";et();Ce();Te=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(n){this.o.log?.("onIntervention threw",n)}}}url(e){let n=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${n}`}sleep(e){return new Promise(n=>{this.timer=setTimeout(n,e),this.timer.unref?.()})}async loop(e){let n=0;for(;this.live(e);){let r;try{let s=await this.connectOnce(e);if(s==="gone")return this.stop();s==="poll"?(n=0,r=this.o.pollMs??15e3):(s==="streamed"&&(n=0),r=Q(n++,this.o.backoff))}catch(s){this.live(e)&&this.o.log?.("intervention stream error",s),r=Q(n++,this.o.backoff)}if(!this.live(e))return;await this.sleep(r)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let n={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},r=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:n,signal:this.ctl.signal});if(r.status===404)return"gone";if(!r.ok)return"failed";let s=r.body;if(!s||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let o=Qe(a=>{if(!(a.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(a.data))}catch{this.o.log?.("bad intervention payload")}}),i=s.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:a,value:c}=await i.read();if(a)return"streamed";o(c)}}async pollOnce(e){this.ctl=new AbortController;let n=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(n.status===404)return"gone";if(!n.ok)return"failed";let r=await n.json();if(this.live(e))for(let s of r.data??[])this.deliver(s);return"poll"}}});function rt(t,e,n={}){let r=n.key??"lc_offline",s=n.maxBatches??50,o=n.maxBytes??1e6,i=n.isOnline??(()=>!0),a,c,l=()=>{try{let m=JSON.parse(e.get(r)??"[]");return Array.isArray(m)?m:[]}catch{return[]}},u=m=>{let _=m.reduce((y,k)=>y+k.body.length,0);for(;m.length>s||_>o&&m.length>1;)_-=m.shift().body.length;m.length?e.set(r,JSON.stringify(m)):e.remove(r)},f=m=>{u([...l(),...m]),a??=setTimeout(()=>{a=void 0,g.drain()},n.retryMs??3e4)},g={async send(m,_,y){if(!i())return f([{url:m,body:_}]),{status:200};let k=await t.send(m,_,y);return k.status!==0?k:(f([{url:m,body:_}]),{status:200})},drain(){return c??=(async()=>{let m=l();if(!m.length||!i())return;e.remove(r);let _=[];for(let[y,k]of m.entries())if((await t.send(k.url,k.body)).status===0){_.push(...m.slice(y));break}_.length&&f(_)})().finally(()=>{c=void 0}),c}};return g}var hn=E(()=>{"use strict"});function yn(t){let e=new TextEncoder().encode(t),n=e.length+9+63>>6<<6,r=new Uint8Array(n);r.set(e),r[e.length]=128;let s=new DataView(r.buffer);s.setUint32(n-8,Math.floor(e.length*8/2**32)),s.setUint32(n-4,e.length*8>>>0);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],i=new Uint32Array(64);for(let a=0;a<n;a+=64){for(let l=0;l<16;l++)i[l]=s.getUint32(a+l*4);for(let l=16;l<64;l++){let u=i[l-15],f=i[l-2],g=N(u,7)^N(u,18)^u>>>3,m=N(f,17)^N(f,19)^f>>>10;i[l]=i[l-16]+g+i[l-7]+m|0}let c=o.slice();for(let l=0;l<64;l++){let[u,f,g,,m,_,y,k]=c,$=k+(N(m,6)^N(m,11)^N(m,25))+(m&_^~m&y)+ps[l]+i[l]|0,P=(N(u,2)^N(u,13)^N(u,22))+(u&f^u&g^f&g)|0;c.pop(),c.unshift($+P|0),c[4]=c[4]+$|0}for(let l=0;l<8;l++)o[l]=o[l]+c[l]|0}return o.map(a=>(a>>>0).toString(16).padStart(8,"0")).join("")}var ps,N,vn=E(()=>{"use strict";ps=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),N=(t,e)=>t>>>e|t<<32-e});function bn(t){let e=t.split(".");if(e.length!==4)return;let n=[];for(let r of e){if(!fs.test(r)||Number(r)>255)return;n.push(Number(r))}return n}function hs(t){if(t.includes("%"))return;let e=t,n=t.lastIndexOf(":"),r=t.slice(n+1);if(r.includes(".")){let u=bn(r);if(!u)return;e=`${t.slice(0,n+1)}${(u[0]<<8|u[1]).toString(16)}:${(u[2]<<8|u[3]).toString(16)}`}let s=e.split("::");if(s.length>2)return;let o=u=>{if(u==="")return[];let f=[];for(let g of u.split(":")){if(!gs.test(g))return;f.push(parseInt(g,16))}return f},i=o(s[0]),a=s.length===2?o(s[1]):[];if(!i||!a)return;let c=i.length+a.length;return(s.length===2?c>7:c!==8)?void 0:[...i,...Array(8-c).fill(0),...a].flatMap(u=>[u>>8,u&255])}function _n(t){return t.includes(":")?hs(t):bn(t)}function xn(t){if(typeof t!="string")return;let e=_n(t.trim());return e&&ys(e)?e.slice(12):e}function vs(t){let e=typeof t=="string"?[t]:Array.isArray(t)?t:[],n=[];for(let r of e){if(typeof r!="string")continue;let s=r.trim(),o=s.indexOf("/");if(o<0){let c=xn(s);c&&n.push({bytes:c,bits:c.length*8});continue}let i=_n(s.slice(0,o)),a=s.slice(o+1);!i||!ms.test(a)||Number(a)>i.length*8||n.push({bytes:i,bits:Number(a)})}return n}function bs(t,e){if(t.bytes.length!==e.length)return!1;for(let n=0;n<t.bits;n+=8){let s=255<<8-Math.min(8,t.bits-n)&255,o=n/8;if((t.bytes[o]&s)!==(e[o]&s))return!1}return!0}function kn(t,e,n,r){switch(t){case"array_contains_any":case"array_contains_all":case"array_contains_none":{if(!Array.isArray(e)||!Array.isArray(n))return!1;let s=n.filter(o=>e.some(i=>r(i,o))).length;return t==="array_contains_any"?s>0:t==="array_contains_all"?s===n.length:s===0}case"ip_in_cidr":case"ip_not_in_cidr":{let s=xn(e),o=vs(n);return!s||!o.length?!1:o.some(i=>bs(i,s))===(t==="ip_in_cidr")}}return!1}var fs,gs,ms,ys,wn=E(()=>{"use strict";fs=/^(0|[1-9]\d{0,2})$/,gs=/^[0-9a-fA-F]{1,4}$/,ms=/^(0|[1-9]\d*)$/;ys=t=>t.length===16&&t.slice(0,10).every(e=>e===0)&&t[10]===255&&t[11]===255});function ws(t){let e=xs.exec(t.trim());return e?Number(e[1])*ks[e[2]]:void 0}function Rn(t,e,n){if(typeof t=="number")return t*1e3;if(typeof t!="string")return;let r=t.trim();if(n){let o=ws(r);if(o!==void 0)return e-o*1e3}if(!_s.test(r)&&!Sn.test(r))return;let s=Date.parse(Sn.test(r)?`${r}T00:00:00Z`:r);return Number.isNaN(s)?void 0:s}function En(t,e){for(let n=0;n<Math.max(t.length,e.length);n++){let r=t[n]??0,s=e[n]??0;if(r!==s)return r<s?-1:1}return 0}function Ss(t,e,n){if(typeof e!="string")return;let r=e.trim().replace(/^v/,"").split(".");if(t==="semver_wildcard"){let l=r[r.length-1];if(l!=="*"&&l!=="x"&&l!=="X")return;if(r.length===1)return[[0],[2**30]];let u=n.parseVersion(r.slice(0,-1).join("."));if(!u)return;let f=[...u];return f[f.length-1]=f[f.length-1]+1,[u,f]}let s=n.parseVersion(e);if(!s)return;for(;s.length<3;)s.push(0);let[o,i,a]=s,c;return t==="semver_tilde"&&r.length===1?c=[o+1,0,0]:t==="semver_tilde"||o===0&&i>0?c=[o,i+1,0]:o>0?c=[o+1,0,0]:c=[0,0,a+1],[s,c]}function Cn(t,e,n,r,s){switch(t){case"icontains":case"not_icontains":case"starts_with":case"not_starts_with":case"ends_with":case"not_ends_with":return typeof e!="string"||typeof n!="string"?!1:t.endsWith("icontains")?e.toLowerCase().includes(n.toLowerCase())===(t==="icontains"):t.endsWith("starts_with")?e.startsWith(n)===(t==="starts_with"):e.endsWith(n)===(t==="ends_with");case"between":case"not_between":{let o=s.toFloat(e);if(!Array.isArray(n)||n.length!==2||o===void 0)return!1;let[i,a]=n;return typeof i!="number"||typeof a!="number"?!1:(o>=i&&o<=a)==(t==="between")}case"is_date_before":case"is_date_after":{let o=Rn(e,r,!1),i=Rn(n,r,!0);return o===void 0||i===void 0?!1:t==="is_date_before"?o<i:o>i}case"semver_eq":case"semver_neq":case"semver_gt":case"semver_gte":case"semver_lt":case"semver_lte":{let o=s.cmpVersion(e,n);if(o===void 0)return!1;let i=t.slice(7);return i==="eq"?o===0:i==="neq"?o!==0:i==="gt"?o>0:i==="gte"?o>=0:i==="lt"?o<0:o<=0}case"semver_tilde":case"semver_caret":case"semver_wildcard":{let o=s.parseVersion(e),i=Ss(t,n,s);return!!o&&!!i&&En(o,i[0])>=0&&En(o,i[1])<0}}return!1}var _s,Sn,xs,ks,$n=E(()=>{"use strict";_s=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,Sn=/^\d{4}-\d{2}-\d{2}$/,xs=/^-?(\d{1,6})([hdwmy])$/,ks={h:3600,d:86400,w:604800,m:2592e3,y:31536e3}});function st(t){if(typeof t=="number")return t;if(typeof t=="string"&&Rs.test(t.trim()))return Number(t.trim())}function ot(t,e){let n=typeof t=="number",r=typeof e=="number";return n||r?n&&r&&t===e:t===e}function at(t){if(typeof t!="string")return;let e=t.trim().replace(/^v/,""),n=e.search(/[-+]/);n>=0&&(e=e.slice(0,n));let r=[];for(let s of e.split(".")){if(!/^[+-]?\d+$/.test(s))return;let o=parseInt(s,10);if(o<0)return;r.push(o)}return r}function it(t,e){let n=at(t),r=at(e);if(!(!n||!r)){for(let s=0;s<Math.max(n.length,r.length);s++){let o=n[s]??0,i=r[s]??0;if(o!==i)return o<i?-1:1}return 0}}function z(t,e,n,r,s,o=Date.now()){let i=n&&e!==null&&e!==void 0;if(t==="is_set")return i;if(t==="is_not_set")return!i;if(!i)return!1;switch(t){case"eq":case"neq":{let a;if(s){let c=it(e,r);if(c===void 0)return!1;a=c===0}else a=ot(e,r);return a===(t==="eq")}case"contains":case"ncontains":case"regex":case"nregex":{if(typeof e!="string"||typeof r!="string")return!1;if(t==="contains"||t==="ncontains")return e.includes(r)===(t==="contains");let a;try{a=new RegExp(r)}catch{return!1}return a.test(e)===(t==="regex")}case"gt":case"gte":case"lt":case"lte":{let a;if(s)a=it(e,r);else{let c=st(e),l=st(r);a=c===void 0||l===void 0?void 0:Es(c,l)}return a===void 0?!1:t==="gt"?a>0:t==="gte"?a>=0:t==="lt"?a<0:a<=0}case"in":case"not_in":return Array.isArray(r)?r.some(a=>ot(e,a))===(t==="in"):!1}return t.startsWith("array_")||t.startsWith("ip_")?kn(t,e,r,ot):Cn(t,e,r,o,{toFloat:st,parseVersion:at,cmpVersion:it})}var Rs,Es,ct=E(()=>{"use strict";wn();$n();Rs=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;Es=(t,e)=>t<e?-1:t>e?1:0});function ut(t){return t.properties?.length?`${t.key}|${JSON.stringify(t.properties.map(e=>[e.key,e.op,e.value??null]))}`:t.key}function Pn(t,e,n=Date.now()){return(t.properties??[]).every(r=>z(r.op,e[r.key],Object.hasOwn(e,r.key),r.value,!1,n))}function dt(t,e){let n=e[t.scope??"session"]?.[ut(t)]??0;return t.op==="is_set"?n>0:t.op==="is_not_set"?n===0:z(t.op,n,!0,t.value,!1)}function An(t,e,n){for(let o of t.runtime??[])if(o.filters.every(a=>{if(a.type!=="flag")return dt(a,e);let c=n(a.key);return!!c&&z(a.op,c.value,!0,a.value,!1)}))return An(o.result,e,n);if(!t.runtime)return t;let{runtime:r,...s}=t;return s}function pt(t,e){let n={},r=new Map,s=o=>{if(r.get(o)===2)return n[o];let i=t[o];if(!i||r.get(o)===1)return;r.set(o,1);let a=An(i,e,s);return n[o]=a,r.set(o,2),a};for(let o of Object.keys(t))s(o);return n}function Fe(t,e){let n=[],r=o=>{o.type==="event"&&o.properties?.length&&n.push(o)};for(let o of t??[])for(let i of o.conditions)for(let a of i.filters??[])r(a);let s=o=>{for(let i of o.runtime??[])i.filters.forEach(r),s(i.result)};return Object.values(e).forEach(s),n}function je(t,e){if(!lt(e))return e;let n=lt(t)?{...t}:{};for(let[r,s]of Object.entries(e))s===null?delete n[r]:n[r]=je(n[r],s);return n}var On,lt,pe,ft=E(()=>{"use strict";ct();On=t=>(t??[]).filter(e=>e.type==="event");lt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t);pe=class{session={};page={};sid="";constructor(e){if(e&&typeof e.sid=="string"&<(e.session)){this.sid=e.sid;for(let[n,r]of Object.entries(e.session))typeof r=="number"&&r>0&&(this.session[n]=r)}}record(e,n,r={},s=[]){n!==this.sid&&(this.sid=n,this.session={},this.page={}),e==="$pageview"&&(this.page={});let o=new Set([e]);for(let i of s)i.type==="event"&&i.key===e&&i.properties?.length&&Pn(i,r)&&o.add(ut(i));for(let i of o)this.session[i]=(this.session[i]??0)+1,this.page[i]=(this.page[i]??0)+1}counts(e){return e===this.sid?{session:{...this.session},page:{...this.page}}:{session:{},page:{}}}saved(){return{sid:this.sid,session:{...this.session}}}}});function In(t,e){let n=e?t.contexts?.[e]:void 0;if(n)return n;if(e==="user")return{key:t.bucketing_key||t.distinct_id,properties:t.person_properties};if(e==="device")return{key:t.device_id,properties:t.device_properties}}function fe(t,e,n,r=!1){let s=r?`${t}.${e}.variant.${n}`:`${t}.${e}.${n}`;return parseInt(yn(s).slice(0,13),16)/$s}function Ps(t,e){return typeof e=="boolean"?typeof t=="boolean"?t===e:e:t===e}function Os(t,e,n){let r=e.now?Date.parse(e.now):NaN,s=Number.isNaN(r)?Date.now():r,o;switch(t.type){case"person":o=e.person_properties;break;case"group":o=e.group_properties?.[t.group_type??""];break;case"device":o=e.device_properties;break;case"geo":o=e.geo_properties;break;case"context":if(!Cs.includes(t.context_kind??""))return!1;o=In(e,t.context_kind)?.properties;break;case"app_version":return z(t.op,e.app_version,!!e.app_version,t.value,!0,s);case"flag":{let i=n[t.key];return!!i&&z(t.op,i.value,!0,t.value,!1,s)}default:return!1}return z(t.op,o?.[t.key],!!o&&Object.hasOwn(o,t.key),t.value,!1,s)}function As(t,e,n){let r=t.variants;if(e.variant_override){let i=r.find(a=>a.key===e.variant_override);if(i)return i}let s=fe(t.key,t.salt,n,!0)*100,o=0;for(let i of r)if(o+=i.rollout_pct,s<o)return i;return r[r.length-1]}function Mn(t,e){return Tn(t.aggregation,e)}function Tn(t,e){return t.kind==="group"?e.groups?.[t.group_type??""]:t.kind==="device"?e.device_id:t.kind==="context"?In(e,t.context_kind)?.key:e.bucketing_key||e.distinct_id}function Is(t,e,n,r){let s=t.sticky?r.sticky_assignments?.[t.key]:void 0;if(s===void 0)return;let o={value:!0,reason:"sticky_bucket",condition_index:n};if(t.type==="multivariate"&&t.variants?.length){if(t.variants.some(a=>a.key===e.variant_override))return;let i=t.variants.find(a=>a.key===s);return i?(o.value=o.variant=i.key,Le(o,i.payload,e)):void 0}if(s===!0)return Le(o,t.type==="json"?t.payload:void 0,e)}function Le(t,e,n){let r=n.payload_patch===void 0||n.payload_patch===null?e:je(e,n.payload_patch);return r!==void 0&&(t.payload=r),t}function Ms(t,e){return!t.app_contexts?.length||!e.app_contexts?.length?!0:t.app_contexts.some(n=>e.app_contexts?.includes(n))}function Fn(t,e,n={}){if(!Ms(t,e))return T("app_context_excluded");if(!t.active)return T("inactive");if(t.kill_switch)return T("kill_switch");let r=!1;for(let c of t.prerequisites??[]){let l=n[c.flag];if(!l)return T("prerequisite_missing");if(l.reason==="requires_server")r=!0;else if(l.reason==="prerequisite_cycle"||!Ps(l.value,c.value))return T("prerequisite_failed")}if(r)return T("requires_server");let s=Mn(t,e),o=t.conditions.some(c=>c.aggregation);if(!s&&(!o||t.holdout||t.namespace))return T("no_bucketing_key");if(t.holdout&&fe("holdout",t.holdout.salt,s??"")*100<t.holdout.percentage)return T("holdout");if(t.namespace&&t.namespace.total>0){let c=Math.floor(fe("namespace",t.namespace.salt,s??"")*t.namespace.total);if(c<t.namespace.start||c>=t.namespace.end)return T("namespace_excluded")}let i=0,a=[];for(let[c,l]of t.conditions.entries()){let u=l.aggregation?Tn(l.aggregation,e):s;if(!u){i++;continue}let f=!1,g=!0,m=!1;for(let y of l.filters??[]){if(y.type==="event"){if(e.runtime_events===void 0)m=!0;else if(!dt(y,e.runtime_events)){g=!1;break}continue}let k=y.type==="cohort"?e.cohorts?.[y.key]:void 0;if(k!==void 0){if(k===(y.op==="not_in"||y.op==="neq")){g=!1;break}}else if(y.type==="cohort"||y.type==="flag"&&n[y.key]?.reason==="requires_server")f=!0;else if(!Os(y,e,n)){g=!1;break}}if(!g)continue;if(f)return gt(T("requires_server",c),a);let _=Ts(t,l,c,e,u);if(_)if(m)a.push({filters:On(l.filters),result:_});else return gt(_,a)}return gt(T(i>0&&i===t.conditions.length?"no_bucketing_key":"no_condition_match"),a)}function Ts(t,e,n,r,s){let o=e.aggregation?void 0:Is(t,e,n,r);if(o)return o;if(fe(t.key,t.salt,s)*100>=e.rollout_pct)return t.early_exit?T("out_of_rollout",n):void 0;let i={value:!0,reason:"condition_match",condition_index:n};if(t.type==="multivariate"&&t.variants?.length){let a=As(t,e,s);return i.value=i.variant=a.key,Le(i,a.payload,e)}return Le(i,t.type==="json"?t.payload:void 0,e)}function jn(t){return[...(t.prerequisites??[]).map(e=>e.flag),...t.conditions.flatMap(e=>(e.filters??[]).filter(n=>n.type==="flag").map(n=>n.key))]}function ht(t,e){let n=new Map(t.map(i=>[i.key,i])),r={},s=new Map,o=i=>{let a=n.get(i);if(!a||s.has(i))return;s.set(i,1);let c=!1;for(let l of jn(a))o(l),(s.get(l)===1||r[l]?.reason==="prerequisite_cycle")&&(c=!0);r[i]=c?T("prerequisite_cycle"):js(a,e,r),s.set(i,2)};for(let i of t)o(i.key);return r}function js(t,e,n){let r=[];for(let s of jn(t))!r.includes(s)&&n[s]?.runtime?.length&&r.length<Fs&&r.push(s);return mt(t,e,n,r)}function mt(t,e,n,r){let[s,...o]=r;if(s===void 0)return Fn(t,e,n);let i=mt(t,e,n,o),a=n[s],c=new Set([a.value]),l=[];for(let m of Ln(a)){if(c.has(m.value))continue;c.add(m.value);let _=mt(t,e,{...n,[s]:m},o);Dn(_,i)||l.push({filters:[{type:"flag",key:s,op:"eq",value:m.value}],result:_})}let u=[...l,...i.runtime??[]],{runtime:f,...g}=i;return u.length?{...g,runtime:u}:g}function Ln(t){return(t.runtime??[]).flatMap(e=>{let{runtime:n,...r}=e.result;return[r,...Ln(e.result)]})}function Dn(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Array.isArray(t)!==Array.isArray(e))return!1;let n=t,r=e,s=new Set([...Object.keys(n),...Object.keys(r)]);for(let o of s)if(!Dn(n[o],r[o]))return!1;return!0}var Cs,$s,T,gt,Fs,yt,vt,Nn=E(()=>{"use strict";ct();ft();vn();Cs=["user","device","org"],$s=16**13;T=(t,e=-1)=>({value:!1,reason:t,condition_index:e});gt=(t,e)=>e.length?{...t,runtime:e}:t;Fs=4;yt=t=>t.reason==="requires_server",vt=t=>t.reason!=="app_context_excluded"});function bt(t){let e=Object.keys(t);if(e.length===0)return{};let n={};for(let r of e)n[`$feature/${r}`]=t[r];return n.$active_feature_flags=e.filter(r=>t[r]!==!1).sort(),n}var Hn=E(()=>{"use strict"});function me(t,e,n,r){return{key:t,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...n!==void 0?{payload:n}:{},reason:e===void 0?"not_found":r}}var ge,qn=E(()=>{"use strict";ge=class{constructor(e,n=Date.now){this.ttlMs=e;this.now=n}ttlMs;now;stamp;mark(e){return this.stamp={at:this.now(),id:e}}restore(e){typeof e?.at=="number"&&typeof e.id=="string"&&(this.stamp={at:e.at,id:e.id})}fresh(e){return!!this.ttlMs&&this.ttlMs>0&&!!this.stamp&&this.stamp.id===e&&this.now()-this.stamp.at<this.ttlMs}clear(){this.stamp=void 0}}});function Us(t){let e=Hs;for(let n of Vs.encode(t))e=(e^BigInt(n))*qs&Bs;return e}function Wn(t){let e=(t.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(s=>ve(s).length>=2);if(!e.length)return;let n=new Array(64).fill(0);for(let s of e){let o=Us(s);for(let i=0;i<64;i++)n[i]=(n[i]??0)+((o>>BigInt(i)&1n)===1n?1:-1)}let r=0n;for(let s=0;s<64;s++)(n[s]??0)>0&&(r|=1n<<BigInt(s));return r.toString(16).padStart(16,"0")}function Kn(t){let n=` ${t.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,r=0;for(let o of Vn)n.includes(` ${o} `)&&(r++,n=n.split(` ${o} `).join(" "));let s=Un.filter(o=>n.includes(` ${o} `)).length;return r>s?-1:s>r?1:0}function Ws(t){let e=Gn(t);if(e.length<13||e.length>19)return!1;let n=0;return e.reverse().forEach((r,s)=>n+=s%2===1?r>4?r*2-9:r*2:r),n%10===0}function Gs(t){let e=Gn(t).length;return e>=10&&e<=15}function kt(t){let e=t;for(let[n,r]of Ks)e=e.replace(n,s=>r(s)?zs(s):s);return e===t?void 0:e}function zn(t){if(typeof t!="string")return;let e=t.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}function Xs(t,e,n){let r=xt(e,n),s=kt(r);return s===void 0?{[t]:r}:{[t]:s,$ai_text_redacted:!0}}function Yn(t,e,n,r){if(t!=="user"&&t!=="assistant")return;let s={$ai_role:t,$ai_message_index:n,$ai_text_length:ve(e).length};if(t==="user"){let o=Wn(e);o!==void 0&&(s.$ai_text_hash=o),s.$ai_sentiment=Kn(e)}return r?{...s,...Xs("$ai_text",e,Ds)}:s}function Jn(t,e){let n=t.value;if(t.kind==="thumbs"&&n!==1&&n!==-1||t.kind==="rating"&&!(Number.isInteger(n)&&n>=1&&n<=5)||t.kind!=="thumbs"&&t.kind!=="rating"&&t.kind!=="comment")return;let r={$ai_feedback_kind:t.kind};if(t.kind!=="comment"&&(r.$ai_feedback_value=n),t.comment&&e){let s=xt(t.comment,Ns);r.$ai_feedback_comment=kt(s)??s}return t.messageIndex!==void 0&&(r.$ai_message_index=t.messageIndex),r}function _t(t,e){let n=Xn(t),r=he(e,64);return{...n?{$ai_outcome:n}:{},...r?{$ai_resolution:r}:{}}}function Ys(){let t=globalThis.crypto,e=new Uint8Array(16);if(t?.getRandomValues)t.getRandomValues(e);else for(let r=0;r<16;r++)e[r]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let n=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}function Zn(t={}){let e={$ai_conversation_id:t.conversationId||Ys()},n=(r,s)=>{s!==void 0&&(e[r]=s)};return n("$ai_agent_name",he(t.agentName,128)),n("$ai_agent_version",he(t.agentVersion,64)),n("$ai_topic",he(t.topic,128)),n("$ai_use_case",he(t.useCase,128)),n("$ai_trace_id",zn(t.traceId)),e}var oe,Ls,Ds,Ns,Vn,Un,ve,xt,Hs,qs,Bs,Vs,Gn,Bn,Ks,zs,Xn,he,ye,Qn=E(()=>{"use strict";oe={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Ls=["resolved","unresolved","escalated","abandoned","error"],Ds=4e3,Ns=2e3,Vn=["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"],Un=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],ve=t=>Array.from(t),xt=(t,e)=>ve(t).slice(0,e).join(""),Hs=0xcbf29ce484222325n,qs=0x100000001b3n,Bs=0xffffffffffffffffn,Vs=new TextEncoder;Gn=t=>ve(t).filter(e=>e>="0"&&e<="9").map(Number);Bn=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Ks=[[new RegExp(String.raw`(?<!${Bn})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${Bn})`,"gu"),Ws],[/[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,Gs]];zs=t=>ve(t).map(e=>/\s/u.test(e)?e:"*").join("");Xn=t=>typeof t=="string"&&Ls.includes(t)?t:void 0,he=(t,e)=>typeof t=="string"&&t?xt(t,e):void 0;ye=class{next=0;common;emit;captureText;constructor(e,n={},r=!1){this.emit=e,this.captureText=r,this.common=Zn(n)}get id(){return this.common.$ai_conversation_id}send(e,n){this.emit(e,{...this.common,...n})}start(){return this.send(oe.started,{}),this}message(e,n,r={}){let s=r.index??this.next,o=Yn(e,n,s,this.captureText);return o?(this.next=s+1,this.send(oe.message,o),!0):!1}feedback(e){let n=Jn(e,this.captureText);return n?(this.send(oe.feedback,n),!0):!1}end(e,n){this.send(oe.ended,_t(e,n))}outcome(e,n){let r=_t(e,n);return r.$ai_outcome?(this.send(oe.outcome,r),!0):!1}}});var be=E(()=>{"use strict";dn();Ye();fn();gn();mn();hn();Nn();ft();Hn();qn();Qn()});function gr(t,e=Date.now){let n=t.eventsPerSecond??10,r=t.burst??100,s=r,o=e();return()=>{let i=e();return s=Math.min(r,s+(i-o)/1e3*n),o=i,s<1?!1:(s-=1,!0)}}var mr=E(()=>{"use strict"});function ei(t){return t.startsWith("re:")?t.slice(3):t.split("*").map(e=>e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}function Bt(t,e){return!!t?.some(n=>{try{return new RegExp(ei(n),"i").test(e)}catch{return!1}})}var qr=E(()=>{"use strict"});be();var Js=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client"];function er(t){let e=t.toLowerCase();return Js.some(n=>e.includes(n))&&!/\bcubot\b/.test(e)}var ee=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid"],tr="lc_click_ids";function nr(t,e=90,n=Date.now){let r,s=()=>{try{return JSON.parse(t.get(tr)??"{}")}catch{return{}}};return()=>{let o=s();if(location.search!==r){r=location.search;let a=new URLSearchParams(r),c=!1;for(let l of ee){let u=a.get(l);u&&(o[l]={v:u.slice(0,512),t:n()},c=!0)}c&&t.set(tr,JSON.stringify(o))}let i={};for(let a of ee){let c=o[a];c&&n()-c.t<e*864e5&&(i[a]=c.v)}return i}}function Zs(t,e){let n=document.createElement("style");return e&&n.setAttribute("nonce",e),n.textContent=t,n}function Qs(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(t=>t.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(t=>t.getAttribute("content")??"")}function sr(t){let e=new Map;for(let r of t.split(";")){let[s,...o]=r.trim().toLowerCase().split(/\s+/);s&&!e.has(s)&&e.set(s,o)}let n=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!n&&!(n.includes("'unsafe-inline'")&&!n.some(r=>r.startsWith("'nonce-")||r.startsWith("'sha")))}function or(t,e){if(typeof document>"u")return()=>{};!e&&Qs().some(sr)&&t("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 n=r=>{let s=r;/^style-src/.test(s.effectiveDirective??"")&&s.blockedURI==="inline"&&t(`CSP hint: an inline style was blocked by ${s.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",n),()=>document.removeEventListener("securitypolicyviolation",n)}var eo=(t,e)=>t.slice(0,e);function rr(t){try{let e=new URL(t);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return eo(t,64)}}function wt(t,e={}){if(typeof document>"u")return()=>{};let n=e.maxPerPage??20,r=new Set,s=o=>{let i=o,a={$csp_directive:i.effectiveDirective??i.violatedDirective,$csp_blocked_uri:rr(i.blockedURI??""),$csp_source_file:i.sourceFile?rr(i.sourceFile):void 0,$csp_line:i.lineNumber||void 0,$csp_column:i.columnNumber||void 0,$csp_disposition:i.disposition},c=[a.$csp_directive,a.$csp_blocked_uri,a.$csp_source_file,a.$csp_line].join("|");r.has(c)||r.size>=n||(r.add(c),t("$csp_violation",Object.fromEntries(Object.entries(a).filter(([,l])=>l!==void 0))))};return document.addEventListener("securitypolicyviolation",s),()=>document.removeEventListener("securitypolicyviolation",s)}var to=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],St=()=>typeof location<"u"&&to.includes(location.protocol),ir=(t,e,n)=>`${t.replace(/\/+$/,"")}/static/v${e}/${n}`,no={replay:"replay",heatmaps:"heatmaps",forms:"forms",toolbar:"toolbar",guides:"guides",inspector:"inspector",experiments:"visualChanges","early-access":"earlyAccess",consent:"consentBanner"},ro=t=>import(t);async function so(t,e,n,r=ro){return(await Promise.all(t.map(async o=>{let i=no[o];if(!i)return n("unknown module",o);try{let a=(await r(ir(e.assetHost,e.version,`${o}.js`)))[i];return typeof a=="function"?a:n("module has no export",o,i)}catch(a){return n("module failed to load",o,a)}}))).filter(o=>!!o)}function ar(t,e,n){let r=e.find(i=>t.startsWith(`${i}/`));if(!r)return t;let s=t.slice(r.length),o=s.search(/[?#]/);return r+n(o<0?s:s.slice(0,o))+(o<0?"":s.slice(o))}function cr(t,e,n,r){if(!r)return{transport:t,fetch:e};let s=o=>ar(o,n,r);return{transport:{send:(o,i,a)=>t.send(s(o),i,a)},fetch:((o,i)=>e(typeof o=="string"?s(o):o instanceof URL?s(o.href):o,i))}}var oo="__LUCIDA_DEVTOOLS_HOOK__";function lr(t,e,n){let r=globalThis[oo];if(!(!r||typeof r.emit!="function"||typeof r.attach!="function")){t.onCapture(s=>{try{r.emit(s)}catch{}});try{r.attach({projectKeyPrefix:t.apiKey.slice(0,8),apiHost:n,distinctId:()=>e.distinctId,loadToolbar:s=>e.loadToolbar(s),startReplay:async()=>t.replay?(await t.replay.start(!0),t.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var _e=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function io(t){let e={},n=new URLSearchParams(location.search);for(let r of[..._e,...ee,...t]){let s=n.get(r);s&&(e[`$${r}`]=s)}return e}function ur(){let t=new URLSearchParams(location.search),e=_e.map(n=>t.get(n)??"");return e.some(Boolean)?e.join("|"):void 0}function ao(t){try{return t?new URL(t).hostname:""}catch{return""}}var co=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function lo(){let t=location.hash;return t.length>1?location.pathname+t.split("?")[0]:location.pathname}function dr(t,e,n=[],r=!1){let s={$current_url:co(),$host:location.host,$pathname:r?lo():location.pathname,$referrer:document.referrer,$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&&(s.$touch_points=navigator.maxTouchPoints),t!=="$pageview")return{properties:s};let o=io(n);Object.assign(s,o);let i=e.$current_url??location.href,a=e.$referrer??document.referrer,c={$initial_referrer:a||"$direct",$initial_referring_domain:ao(a)||"$direct",$initial_current_url:i};for(let[l,u]of Object.entries(o))c[`$initial_${l.slice(1)}`]=u;return{properties:s,$set_once:c}}var Rt="_lcid";var pr=(t,e)=>e.some(n=>{let r=n.replace(/^\./,"").toLowerCase();return t.toLowerCase()===r||t.toLowerCase().endsWith(`.${r}`)}),uo=(t,e=Date.now(),n)=>`${t}.${e.toString(36)}${n?`_${n}`:""}`;function po(t,e=Date.now()){let n=t.lastIndexOf("."),[r="",s]=t.slice(n+1).split("_",2),o=/^[0-9a-z]+$/.test(r)?parseInt(r,36):NaN,i=t.slice(0,n);if(n>0&&i.length<=200&&o<=e+5e3&&e-o<=12e4)return s&&/^[\w-]{1,64}$/.test(s)?{distinctId:i,sessionId:s}:{distinctId:i}}function fr(t){if(!t?.length)return;let e=new URL(location.href),n=e.searchParams.get(Rt);if(n!==null){e.searchParams.delete(Rt),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!pr(new URL(document.referrer).hostname,t))return}catch{return}return po(n)}}var Et=t=>{let e=t.config.crossDomains;if(!e?.length)return;let n=r=>{let s=r.target instanceof Element?r.target.closest("a[href]"):null;if(!s||!t.core.hasConsent("analytics"))return;let o=s;if(!/^https?:$/.test(o.protocol)||o.host===location.host||!pr(o.hostname,e))return;let i=new URL(o.href);i.searchParams.set(Rt,uo(t.client.distinctId,Date.now(),t.core.sessionId)),o.href=i.toString()};return document.addEventListener("click",n,!0),document.addEventListener("auxclick",n,!0),()=>{document.removeEventListener("click",n,!0),document.removeEventListener("auxclick",n,!0)}};mr();function fo(t,e,n){let r=e;for(let s of t)try{let o=s(r);if(o==null)return null;r=o}catch(o){n("beforeSend hook threw, keeping event:",o)}return r}function vr(t,e=Math.random){return n=>t>=1?n:t<=0||e()>=t?null:{...n,properties:{...n.properties,$sample_rate:t}}}function br(t){let e=new Set(t),n=r=>Object.fromEntries(Object.entries(r).filter(([s])=>!e.has(s)));return r=>({...r,properties:n(r.properties),...r.$set?{$set:n(r.$set)}:{},...r.$set_once?{$set_once:n(r.$set_once)}:{}})}var Ct="lc_person_identified",De="lc_pending_set_once",hr=new Set(["$identify","$create_alias","$groupidentify"]),yr="$$client_ingestion_warning",go=6e4,$t=class{constructor(e,n){this.mode=e;this.storage=n;this.identified=n.get(Ct)==="1";try{this.pending=JSON.parse(n.get(De)??"{}")}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(Ct,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!hr.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let n=Object.entries(e).filter(([r])=>!(r in this.pending));n.length&&(this.pending={...this.pending,...Object.fromEntries(n)},this.storage.set(De,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(De),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Ct),this.storage.remove(De)}};function mo(t,e){let n=e,r;if(t.person.personless(e.event)){t.person.stash(e.$set_once);let{$set:o,$set_once:i,$unset:a,...c}=e;n={...c,properties:{...e.properties,$process_person_profile:!1}}}else(r=t.person.take())&&(n={...e,$set_once:{...e.$set_once,...r}});let s=t.hooks.length?fo(t.hooks,n,t.log):n;return s&&t.limit&&!t.limit()&&(t.log("rate limited, dropped",s.event),t.onLimited?.(),s=null),!s&&r&&t.person.stash(r),s}function ho(t){let e=t.beforeSend?Array.isArray(t.beforeSend)?t.beforeSend:[t.beforeSend]:[];return[...t.propertyDenylist?.length?[br(t.propertyDenylist)]:[],...t.sampleRate!==void 0?[vr(t.sampleRate)]:[],...e]}function _r(t,e,n,r=Date.now){let s=new $t(e.personProfiles??"always",t.storage),o,i,a=0,c=-1/0,l=()=>{a+=1,!(r()-c<go)&&(c=r(),queueMicrotask(()=>{let u=a;a=0,t.capture(yr,{$$client_ingestion_warning_message:`client rate limit dropped ${u} event(s)`,$dropped_count:u})}))};return t.setFilter(u=>(e.rateLimit!==o&&(o=e.rateLimit,i=o?gr(o):void 0),mo({hooks:ho(e),person:s,limit:u.event===yr?void 0:i,log:n,onLimited:l},u))),s}var Pt=class{m=new Map;get(e){return this.m.get(e)??null}set(e,n){this.m.set(e,n)}remove(e){this.m.delete(e)}},yo=365,vo=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(" ")),bo=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function _o(t){let e=t.toLowerCase().split(".");for(let n=1;n<e.length-1;n++)if(vo.has(e.slice(n).join("."))||n===e.length-2&&e[n+1].length===2&&bo.has(e[n]))return e.slice(n-1).join(".")}function xo(t=location.hostname){if(/^[\d.]+$/.test(t)||t.includes(":"))return;let e=t.split(".");for(let n=e.length-2;n>=0;n--){let r=e.slice(n).join(".");if(document.cookie=`__lc_probe=1; Domain=${r}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${r}; Path=/; Max-Age=0`,r}return _o(t)}var Ne=class{constructor(e={}){this.o=e}o;domain=null;attr(){return this.domain===null&&(this.domain=this.o.domain??(this.o.crossSubdomain?xo():void 0)),this.domain?`; Domain=${this.domain}`:""}get(e){for(let n of document.cookie.split("; ")){let r=n.indexOf("=");if(n.slice(0,r)===e)try{return decodeURIComponent(n.slice(r+1))}catch{return null}}return null}set(e,n){let r=this.o.secure??location.protocol==="https:"?"; Secure":"",s=Math.round((this.o.expiryDays??yo)*86400);document.cookie=`${e}=${encodeURIComponent(n)}; Max-Age=${s}; Path=/${this.attr()}; SameSite=Lax${r}`}remove(e){document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}},ie=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,n){try{this.store()?.setItem(e,n)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},Ot=class extends ie{constructor(){super("localStorage")}},ko=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],At=class{constructor(e,n,r){this.cookie=e;this.local=n;this.cookieKeys=r}cookie;local;cookieKeys;get(e){let[n,r]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return n.get(e)??r.get(e)}set(e,n){this.local.set(e,n),this.cookieKeys(e)?this.cookie.set(e,n):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},He=class{constructor(e,n){this.inner=e;this.delayMs=n}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,n){this.queue(e,n)}remove(e){this.queue(e,null)}queue(e,n){this.pending.set(e,n),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,n]of this.pending)n===null?this.inner.remove(e):this.inner.set(e,n);this.pending.clear()}},It=class{constructor(e,n){this.inner=e;this.suffix=n}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,n){this.inner.set(e+this.suffix,n)}remove(e){this.inner.remove(e+this.suffix)}},Mt=t=>`_${t.replace(/\W/g,"").slice(-8)}`;function qe(t,e,n){if(t==="memory"||t==="none")return new Pt;let r=Mt(e),s=t==="cookie"?new Ne(n):t==="localStorage+cookie"?new At(new Ne(n),new Ot,o=>ko.some(i=>o===i+r)):new ie(t);return new It(s,r)}async function wo(t){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(t).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function xr(t,e={}){let n=e.compress??!0,r=(s,o)=>(e.onError?.({url:s,status:o}),{status:o});return{async send(s,o,i){if(i?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(s,new Blob([o],{type:"text/plain"}))?{status:200}:r(s,0);try{let a=n&&o.length>=1024?await wo(o):void 0,c=await t(a?`${s}${s.includes("?")?"&":"?"}compression=gzip`:s,{method:"POST",body:a??o,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(a?.length??o.length)<6e4});return c.status>=400?r(s,c.status):{status:c.status}}catch{return r(s,0)}}}}var Tt={send:async()=>({status:200})};var So="lucida-browser",kr="0.1.0",Ft="lc_internal",Ro=3e3,Lt="https://app.lucida.dev",jt=t=>!!t&&typeof t=="object"&&Object.getPrototypeOf(t)===Object.prototype;function Dt(t,e={},n=[]){let r=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),s=(...d)=>{r&&console.debug("[lucida]",...d)},o=(e.apiHost??Lt).replace(/\/+$/,""),i=Object.fromEntries(Object.entries(e).map(([d,h])=>[d,jt(h)?{...h}:h]));i.apiHost=o;let a=e.extension??St(),c=d=>a&&(d==="cookie"||d==="localStorage+cookie")?e.extensionPersistence??"localStorage":d,l=c(e.cookieless==="always"?"none":e.persistence??"cookie"),u=[o,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],f=e.fetch??((...d)=>fetch(...d)),g=d=>cr(d,f,u,e.rewritePath),m=g(Tt).fetch,_=e.consent?.respectDnt,y=navigator.globalPrivacyControl===!0,k=(e.respectDnt??_)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??_)===!0&&y,$=e.blockBots!==!1&&typeof navigator<"u"&&er(navigator.userAgent??""),P=!!e.disabled||$;$&&s("bot user agent: capture disabled");let W,M=g(e.transport??xr(f,{headers:i.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&l!=="memory"&&l!=="none"){let d=new G(new ie(l==="sessionStorage"?"sessionStorage":"localStorage"),()=>b.hasConsent("analytics"));M=W=rt(M,d,{key:`lc_offline${Mt(t)}`,isOnline:()=>navigator.onLine!==!1})}let C=P?void 0:fr(e.crossDomains),R=qe(P?"memory":l,t,e.cookie),H=(e.storageWriteDelayMs??0)>0?new He(R,e.storageWriteDelayMs):void 0,X=C?.sessionId??e.bootstrap?.sessionId,te,F=!1,j,ne=[],b=new de({apiKey:t,apiHost:o,transport:P?Tt:M,storage:H??R,...e.consentPersistence&&!P?{consentStorage:qe(c(e.consentPersistence),t,e.cookie)}:{},persistProperty:d=>!i.persistedProperties||i.persistedProperties.includes(d),...l==="none"?{cookieless:!0}:{},library:{name:So,version:kr},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...e.consent?.geo&&!P?{awaitRemote:!0}:{},respectDnt:!0,dnt:k},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...C||e.bootstrap?.distinctId?{bootstrapDistinctId:C?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!C?{bootstrapIdentified:!0}:{},session:{...e.session,...X?{bootstrapId:X}:{}},enrich:(d,h)=>{let p=dr(d,h,i.customCampaignParams,e.capturePageview==="hash");if(o!==Lt&&(p.properties={...p.properties,$lib_custom_api_host:o}),ne.length){let S=b.sessionId;for(let O of ne)p.properties={...p.properties,...O(S)}}let v=j?.()??{},w=Object.keys(v);return w.length&&(p.properties={...p.properties,$click_ids:v},d==="$pageview"&&(p.$set_once={...Object.fromEntries(w.map(S=>[`$initial_${S}`,v[S]])),...p.$set_once},p.$set=Object.fromEntries(w.map(S=>[`$last_${S}`,v[S]])))),i.sendFeatureFlags!==!1&&d!=="$snapshot"&&te&&(p.properties={...bt(te.all()),...p.properties}),F?{...p,properties:{...p.properties,$internal:!0}}:p},campaignKey:ur,log:s});F=b.storage.get(Ft)==="1",e.clickIds!==!1&&(j=nr(b.storage,e.clickIds?.expiryDays));let A=_r(b,i,s);e.bootstrap?.isIdentified&&A.markIdentified();let K=d=>A.blocksPersonWrites?(s(`personProfiles=never: ${d} ignored`),!0):!1,ae=[],q=[or(s,e.nonce)],re=b.storage;if(e.flagPersistence&&!P){let d=new G(qe(c(e.flagPersistence),t,e.cookie),()=>b.hasConsent("analytics"));b.onChange(h=>{h==="consent"&&(b.hasConsent("analytics")?d.flushBuffered():d.discardBuffered())}),re=d}let Y=d=>{if(P)return;if(b.hasConsent("analytics"))return d();let h=!1;b.onChange(p=>{!h&&p==="consent"&&b.hasConsent("analytics")&&(h=!0,d())})},ce,x={core:b,client:void 0,config:i,flagStorage:re,apiKey:t,log:s,fetch:m,onUnload:d=>{ae.push(d)},whenConsented:Y,onCapture:d=>b.onCaptured(d),eventExtras:ne,clickExtras:[],flagPersonProps:[],loadConfig:()=>ce??=new Promise(d=>Y(()=>{m(`${o}/v1/config?api_key=${encodeURIComponent(t)}`).then(h=>h.ok?h.json():null).then(h=>(h&&b.applyRemote(h),h)).then(d,()=>d(null))}))};if(b.consent.resolving){let d=m(`${o}/v1/config?api_key=${encodeURIComponent(t)}`,{credentials:"omit"}).then(p=>p.ok?p.json():null).catch(()=>null);ce=d;let h=setTimeout(()=>b.applyRemote({}),Ro);d.then(p=>{clearTimeout(h),b.applyRemote(p??{})})}let le=nt(b,{apiHost:o,apiKey:t,fetch:m,whenConsented:Y,log:s,disabled:P});q.push(()=>le.stop());let B={get distinctId(){return b.distinctId},capture:(d,h,p)=>{b.capture(d,h,p?.timestamp!==void 0?{timestamp:p.timestamp}:{})&&(p?.sendInstantly||p?.transport)&&b.flush(p.transport==="beacon"?{beacon:!0}:{})},identify:(d,h,p)=>{K("identify")||(A.markIdentified(),b.identify(d,h,p))},alias:(d,h)=>{K("alias")||(A.markIdentified(),b.alias(d,h))},reset:d=>{b.reset({resetDeviceId:!!d,reuseAnonymousId:!!e.reuseAnonymousId}),A.reset()},createPersonProfile:()=>{K("createPersonProfile")||A.isProfile||(A.markIdentified(),b.capture("$set",{}))},setConfig:d=>{let h=i;for(let[p,v]of Object.entries(d)){let w=h[p];jt(w)&&jt(v)?Object.assign(w,v):h[p]=v}"debug"in d&&(r=!!d.debug)},setPersonProperties:(d,h)=>{!d&&!h||K("setPersonProperties")||(A.markIdentified(),b.capture("$set",{},{...d?{$set:d}:{},...h?{$set_once:h}:{}}))},unsetPersonProperties:d=>{!d.length||K("unsetPersonProperties")||(A.markIdentified(),b.capture("$set",{},{$unset:d}))},getSessionId:()=>b.sessionId,onSessionId:d=>b.onSessionId(h=>d(h)),getProperty:d=>b.getProperty(d),hasOptedOut:()=>!b.hasConsent("analytics"),getReplayUrl:d=>{let p=`${(e.uiHost??o).replace(/\/+$/,"")}/replays/${encodeURIComponent(b.sessionId)}`,v=b.sessionStart;return!d?.withTimestamp||v===void 0?p:`${p}?t=${Math.max(0,Math.round((Date.now()-v)/1e3-(d.timestampLookBackSeconds??10)))}`},debug:(d=!0)=>{r=d},featureView:(d,h)=>{b.capture("$feature_view",{...h,$feature_flag:d},{$set:{[`$feature_view/${d}`]:!0}})},featureInteraction:(d,h)=>{b.capture("$feature_interaction",{...h,$feature_flag:d},{$set:{[`$feature_interaction/${d}`]:!0}})},updateFlags:(d,h,p)=>x.flags?.update(d,h,p?.merge??!0),register:d=>b.register(d),registerOnce:d=>b.registerOnce(d),unregister:d=>b.unregister(d),group:(d,h,p)=>{A.markIdentified(),b.group(d,h,p)},optIn:()=>b.optIn(),optOut:()=>b.optOut(),optOutInternal:(d=!0)=>{F=d,d?b.storage.set(Ft,"1"):b.storage.remove(Ft)},get isInternal(){return F},setConsent:d=>b.setConsent(d),getConsent:()=>b.getConsent(),getConsentStatus:d=>b.getConsentStatus(d),consentStatus:()=>b.consentStatus(),getFlag:d=>x.flags?.get(d),getFlagPayload:d=>x.flags?.payload(d),getFlagResult:(d,h)=>x.flags?.result(d,h)??me(d,void 0,void 0,"not_found"),getLayerParam:(d,h,p)=>x.flags?.layerParam(d,h)??p,isFeatureEnabled:d=>{let h=x.flags?.get(d);return h!==void 0&&h!==!1},onFlags:d=>x.flags?.onChange(d)??(()=>{}),onIntervention:d=>le.on(d),reloadFlags:()=>x.flags?.reload()??Promise.resolve(),getAllFlags:()=>x.flags?.all()??{},overrideFlags:(d,h)=>x.flags?.override(d,h),setPersonPropertiesForFlags:(d,h)=>x.flags?.setPersonProperties(d,h),resetPersonPropertiesForFlags:()=>x.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(d,h)=>x.flags?.setGroupProperties(d,h),resetGroupPropertiesForFlags:()=>x.flags?.resetGroupProperties(),setContext:(d,h,p)=>x.flags?.setContext(d,h,p),clearContext:d=>x.flags?.clearContext(d),guides:{showChangelog:()=>x.guides?.showChangelog()??0,show:d=>x.guides?.show(d)??!1,reset:d=>x.guides?.reset(d)},ai:{startConversation:d=>new ye((h,p)=>B.capture(h,p),d,i.ai?.captureText===!0).start()},earlyAccess:{list:()=>x.earlyAccess?.list()??Promise.resolve([]),optIn:d=>x.earlyAccess?.optIn(d),optOut:d=>x.earlyAccess?.optOut(d)},replay:{start:d=>x.replay?.start(d)??Promise.resolve(),stop:()=>x.replay?.stop(),pause:()=>x.replay?.pause(),resume:()=>x.replay?.resume(),tag:d=>x.replay?.tag(d),isRecording:()=>x.replay?.isRecording()??!1},consent:{showBanner:d=>x.consentUi?.showBanner(d)??Promise.resolve(null),hideBanner:()=>x.consentUi?.hideBanner()},loadToolbar:d=>x.toolbar?.load(typeof d=="string"?d:d.token)??Promise.resolve(!1),activateExperiment:d=>x.experiments?.activate(d),recommendations:(d,h)=>x.recs?.get(d,h)??Promise.resolve({placement:d,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>b.flush(),shutdown:async()=>{for(let d of q)d();H?.flush(),await b.shutdown()}};if(x.client=B,!P){let d=()=>{for(let p of ae)p();H?.flush(),b.flush({beacon:!0})};window.addEventListener("pagehide",d);let h=()=>{document.visibilityState==="hidden"&&b.flush({beacon:!0})};if(document.addEventListener("visibilitychange",h),q.push(()=>{window.removeEventListener("pagehide",d),document.removeEventListener("visibilitychange",h)}),W){let p=()=>{W.drain()};window.addEventListener("online",p),q.push(()=>window.removeEventListener("online",p)),Y(p)}if(e.captureCspViolations){let p=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};q.push(wt((v,w)=>{b.capture(v,w)},p))}for(let p of n){let v=p(x);v&&q.push(v)}te=x.flags,lr(x,B,o)}return s("initialised",{apiHost:o,consent:b.getConsent()}),B}var Eo='[data-lc-region="article"]';function wr(t,e,n){if(e.articles===!1)return()=>{};let r;t.loadConfig().then(y=>{typeof y?.article_selector=="string"&&(r=y.article_selector)});let s=()=>{for(let y of[e.articleSelector,r,Eo])if(y)try{let k=document.querySelector(y);if(k)return k}catch{}return null},o=location.href,i=location.pathname,a=null,c=0,l=!1,u=()=>{if(a??=s(),!a)return;let y=a.getBoundingClientRect();if(y.height<=0)return;let k=Math.round(Math.min(100,Math.max(0,(window.innerHeight-y.top)/y.height*100)));c=Math.max(c,k);let $=a.querySelector("h1,h2");$&&$.getBoundingClientRect().bottom<0&&(l=!0)},f=()=>{!a||!n()||(u(),t.client.capture("$article_read",{$article_id:(a.getAttribute("data-lc-article-id")??"").trim().slice(0,200)||i,$article_depth:c,$article_finished:c>=90,$article_headline_exit:!l&&c<25}),a=null)},g=()=>{f(),a=null,c=0,l=!1,o=location.href,i=location.pathname},m=()=>location.href!==o?g():u(),_=new MutationObserver(m);return _.observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("scroll",m,{passive:!0}),t.onUnload(f),u(),()=>{_.disconnect(),window.removeEventListener("scroll",m)}}var Be="data-lc-content",Co="data-lc-content-piece",$o="data-lc-content-target";var Nt=(t,e)=>(t.getAttribute(e)??"").trim().slice(0,200);function Sr(t,e,n){if(e.contentBlocks===!1||typeof IntersectionObserver>"u")return()=>{};let r=new WeakSet,s=u=>{let f={$content_name:Nt(u,Be)},g=Nt(u,Co),m=Nt(u,$o);return g&&(f.$content_piece=g),m&&(f.$content_target=m),f},o=location.href,i=new IntersectionObserver(u=>{for(let f of u)!f.isIntersecting||r.has(f.target)||!n()||(r.add(f.target),t.client.capture("$content_impression",s(f.target)))},{threshold:.5}),a=u=>u.querySelectorAll(`[${Be}]`).forEach(f=>i.observe(f));a(document);let c=new MutationObserver(()=>{location.href!==o&&(o=location.href,i.disconnect(),document.querySelectorAll(`[${Be}]`).forEach(u=>r.delete(u))),a(document)});c.observe(document.documentElement,{childList:!0,subtree:!0});let l=u=>{let f=u.target?.closest?.(`[${Be}]`);f&&n()&&t.client.capture("$content_interaction",{...s(f),$content_interaction_type:"click"})};return document.addEventListener("click",l,!0),()=>{i.disconnect(),c.disconnect(),document.removeEventListener("click",l,!0)}}var Po=new Set(["input","textarea","select","option"]),Oo=["name","type","role","aria-label","title","alt","placeholder"],Ao=/(?:\d[ -]?){9,}/;function Io(t){if(Po.has(t.tagName.toLowerCase())||t.isContentEditable)return;let e="";for(let n of Array.from(t.childNodes))n.nodeType===3&&(e+=n.textContent??"");if(e=e.replace(/\s+/g," ").trim(),!(!e||Ao.test(e)))return e.slice(0,255)}function Rr(t){if(!t?.length)return()=>!1;let e=t.map(n=>n.toLowerCase());return n=>e.some(r=>r.endsWith("*")?n.startsWith(r.slice(0,-1)):n===r)}var Mo="***";function Ue(t){let e={};for(let n=t,r=0;n&&r<10;n=n.parentElement,r++)for(let s of Array.from(n.attributes)){let o=s.name.startsWith("data-lc-attr-")?s.name.slice(13):"";o&&!(o in e)&&!o.startsWith("$")&&(e[o]=s.value.slice(0,255))}return e}function To(t,e,n,r){let s=t.parentElement,o=s?Array.from(s.children):[t],i={tag_name:t.tagName.toLowerCase(),nth_child:o.indexOf(t)+1,nth_of_type:o.filter(u=>u.tagName===t.tagName).indexOf(t)+1},a=(t.getAttribute("class")??"").split(/\s+/).filter(Boolean);a.length&&!n("class")&&(i.classes=a),t.id&&!n("id")&&(i.attr__id=r("id",t.id));let c=t.getAttribute("href");c&&!n("href")&&(i.href=r("href",c.slice(0,1024)));let l={};for(let u of Array.from(t.attributes))(u.name.startsWith("data-lc-")||Oo.includes(u.name))&&!n(u.name)&&(l[u.name]=r(u.name,u.value.slice(0,255)));if(Object.keys(l).length&&(i.attrs=l),e){let u=Io(t);u&&(i.text=u)}return i}function We(t,e,n,r,s={}){let o=[],i=Rr(r),a=Rr(s.allow),c=s.maskAll?(u,f)=>a(u)?f:Mo:(u,f)=>f,l=e;for(let u=t;u&&o.length<10;u=u.parentElement)o.push(To(u,l,i,c)),(u===n||!n)&&(l=!1);return o}var Ve=t=>t.replace(/(["\\])/g,"\\$1");function Ke(t){return t.map(e=>{let n=e.tag_name+(e.classes?"."+e.classes.join("."):"")+":";e.attr__id&&(n+=`attr__id="${Ve(e.attr__id)}"`),e.href&&(n+=`href="${Ve(e.href)}"`),e.text&&(n+=`text="${Ve(e.text)}"`);for(let[r,s]of Object.entries(e.attrs??{}))n+=`attr__${r}="${Ve(s)}"`;return n+`nth-child="${e.nth_child}"nth-of-type="${e.nth_of_type}"`}).join(";")}var U=[],Fo=/^[+\-−–‹›<>«»←→↑↓▲▼▶◀^ˇ˄˅]$/,jo=/\b(increase|decrease|increment|decrement|plus|minus|add one|remove one|next|prev|previous|scroll (left|right))\b/i,Lo=/(^|[-_\s])(stepper|spinner|quantity|qty|increment|decrement|inc|dec|plus|minus|carousel|slider|swiper|slick|glide|splide|arrow|next|prev)([-_\s]|$)/i,Do="button,[role=button],a,input[type=button],input[type=submit],[role=spinbutton]";function No(t,e=[]){if(e.length&&t.closest(e.join(","))||t.closest("input[type=number],[role=spinbutton],[role=slider]"))return!0;let n=t.closest(Do)??t,r=`${n.getAttribute("aria-label")??""} ${n.getAttribute("title")??""}`;if(Fo.test((n.textContent??"").trim())||jo.test(r))return!0;for(let s=n,o=0;s&&o<3;s=s.parentElement,o++)if(Lo.test(s.getAttribute("class")??""))return!0;return!1}var Ho=()=>typeof getSelection=="function"?(getSelection()?.toString()??"")!=="":!1;function Er(t,e=Date.now(),n={},r){if(r&&n.ignoreSelectors?.length&&r.closest(n.ignoreSelectors.join(",")))return{};if(r&&n.suppressSteppers!==!1&&No(r,n.stepperSelectors))return{};if(n.ignoreTextSelection!==!1&&Ho())return{};let s=n.windowMs??1e3,o=n.radiusPx??30;for(U.length&&e<U[U.length-1].t&&(U.length=0),U.push({t:e,x:t.clientX,y:t.clientY});U.length&&e-U[0].t>s;)U.shift();let i=U.filter(a=>Math.hypot(a.x-t.clientX,a.y-t.clientY)<=o).length;return i>=(n.count??3)?{$rageclick:!0,$rageclick_count:i}:{}}function Cr(t,e,n=700){if(typeof MutationObserver>"u")return;let r=!1,s=new MutationObserver(()=>r=!0);s.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let o=()=>{r=!0};window.addEventListener("scroll",o,{capture:!0,passive:!0}),document.addEventListener("selectionchange",o);let i=()=>{s.disconnect(),window.removeEventListener("scroll",o,{capture:!0}),document.removeEventListener("selectionchange",o)},a=setTimeout(()=>{i(),!r&&document.visibilityState!=="hidden"&&t.client.capture("$deadclick_hint",{$selector:e,$no_mutation_ms:n})},n);t.onUnload(()=>{clearTimeout(a),i()})}var $r=/^[A-Za-z_][\w-]*$/,qo=5;function Bo(t){let e=[];for(let n=t;n&&e.length<qo;n=n.parentElement){let r=n.tagName.toLowerCase();if(n.id&&$r.test(n.id)){e.unshift(`${r}#${n.id}`);break}let s=(n.getAttribute("class")??"").split(/\s+/).filter(o=>$r.test(o)).slice(0,2);e.unshift(r+s.map(o=>`.${o}`).join(""))}return e.join(" ")}function Pr(t,e,n,r,s={}){let o={$selector:Bo(n),$el_interactive:r};(e.clientX||e.clientY||e.detail)&&(o.$click_x=Math.round(e.clientX+(window.scrollX||0)),o.$click_y=Math.round(e.clientY+(window.scrollY||0))),s.rageClicks!==!1&&!n.closest(".lc-no-rageclick,[data-lc-no-rageclick]")&&Object.assign(o,Er(e,Date.now(),s.rageClicks||{},n));let i=s.deadClicks;!r&&e.isTrusted&&i!==!1&&!(i?.ignoreSelectors?.length&&n.closest(i.ignoreSelectors.join(",")))&&Cr(t,o.$selector,i?.waitMs);for(let a of t.clickExtras)Object.assign(o,a(e,n));return o}var Vo="a,button,input,select,textarea,label,summary,[role=button],[role=link],[data-lc-capture]",Uo="[data-lc-ignore]",Ht=t=>t.some(e=>typeof e=="string"?location.href.includes(e):e.test(location.href)),Wo=t=>!t?.length||Ht(t),qt=t=>({maskAll:t.maskAllAttributes,allow:t.attributeAllowlist}),xe=(t,e)=>!!t.closest(Uo)||!!(e.denySelectors?.length&&t.closest(e.denySelectors.join(",")));function Or(t,e,n){let r=e.events??["click","change","submit"],s=0,o=c=>{let l=c.target;!n()||c.isComposing||!(l instanceof Element)||xe(l,e)||l instanceof HTMLInputElement&&l.type==="password"||(s+=1)},i=c=>l=>{if(!n())return;let u=l.target;if(!(u instanceof Element)||xe(u,e)||e.allowSelectors?.length&&!u.closest(e.allowSelectors.join(","))||e.elementAllowlist?.length&&!u.closest(e.elementAllowlist.join(","))||!Wo(e.urlAllowlist)||c==="change"&&!/^(input|select|textarea)$/i.test(u.tagName)||u instanceof HTMLInputElement&&u.type==="password")return;let f=u.closest(Vo);if(c==="click"&&!f&&!e.allowSelectors?.length)return;let g=We(u,e.captureText??!0,f??void 0,e.attributeIgnore,qt(e)),m=g.find(y=>y.text)?.text,_=s;s=0,t.client.capture("$autocapture",{...Ue(u),$event_type:c,..._>0?{$keystroke_count:_}:{},$elements:g,$elements_chain:Ke(g),...m?{$el_text:m}:{},...c==="click"?Pr(t,l,u,!!f,e):{}})};t.autocaptureClicks=r.includes("click");let a=r.map(c=>[c,i(c)]);for(let[c,l]of a)document.addEventListener(c,l,!0);return document.addEventListener("keydown",o,!0),()=>{for(let[c,l]of a)document.removeEventListener(c,l,!0);document.removeEventListener("keydown",o,!0)}}var Ko='[contenteditable]:not([contenteditable="false"])',Ar="input,textarea,select",Go=255;function zo(t){return t.replace(/\d(?:[ -]?\d){5,}/g,"***").replace(/[^\s@]+@[^\s@]+\.[^\s@]+/g,"***").replace(/\s+/g," ").trim().slice(0,Go)}var Xo=t=>t?t instanceof Element?t:t.parentElement:null;function Ir(t,e,n){let r=e.events??["click","change","submit"],s=e.contentEditable!==!1&&r.includes("change"),o=new WeakSet,i=f=>{let g=We(f,!1,f,e.attributeIgnore,qt(e));return{...Ue(f),$elements:g,$elements_chain:Ke(g)}},a=f=>{let g=f instanceof Element?f.closest(Ko):null;return g&&!xe(g,e)?g:null},c=f=>{let g=n()?a(f.target):null;g&&o.add(g)},l=f=>{let g=a(f.target);!g||!o.has(g)||f.relatedTarget instanceof Node&&g.contains(f.relatedTarget)||(o.delete(g),n()&&t.client.capture("$autocapture",{$event_type:"change",$el_contenteditable:!0,...i(g)}))},u=f=>{if(!n()||!e.copyCut)return;let g=typeof getSelection=="function"?getSelection():null,m=f.target instanceof Element?f.target:null,_=Xo(g?.anchorNode)??m;if(!_||xe(_,e)||_.closest(Ar)||m?.closest(Ar))return;let y=e.captureCopiedText?zo(g?.toString()??""):"";t.client.capture("$copy_autocapture",{$copy_type:f.type,...i(_),...y?{$selected_content:y}:{}})};return s&&(document.addEventListener("input",c,!0),document.addEventListener("focusout",l,!0)),document.addEventListener("copy",u,!0),document.addEventListener("cut",u,!0),()=>{document.removeEventListener("input",c,!0),document.removeEventListener("focusout",l,!0),document.removeEventListener("copy",u,!0),document.removeEventListener("cut",u,!0)}}var Yo="[data-lc-ignore]",Tr=["pdf","zip","gz","tar","rar","7z","doc","docx","xls","xlsx","ppt","pptx","csv","epub","dmg","exe","msi","pkg","apk","iso","mp3","mp4","mov"],Fr=["q","s","search","query"],Mr=t=>t.origin+t.pathname;function jr(t,e,n){let r=Array.isArray(e.fileDownloads)?e.fileDownloads.map(o=>o.toLowerCase()):Tr,s=[];if(e.outboundLinks!==!1||e.fileDownloads!==!1){let o=i=>{let a=i.target instanceof Element?i.target.closest("a[href]"):null;if(!a||!n()||a.closest(Yo))return;let c;try{c=new URL(a.href,location.href)}catch{return}if(c.protocol!=="http:"&&c.protocol!=="https:")return;let l=decodeURIComponent(c.pathname.split("/").pop()??""),u=l.includes(".")?l.split(".").pop().toLowerCase():"";e.fileDownloads!==!1&&(a.hasAttribute("download")||r.includes(u))?t.client.capture("$file_download",{$url:Mr(c),$file_name:l,$file_extension:u}):e.outboundLinks!==!1&&c.host!==location.host&&t.client.capture("$outbound_click",{$url:Mr(c),$outbound_host:c.host})};document.addEventListener("click",o,!0),s.push(()=>document.removeEventListener("click",o,!0))}if(e.siteSearch!==!1){let o=typeof e.siteSearch=="object"&&e.siteSearch.params?e.siteSearch.params:Fr,i=!0;s.push(()=>{i=!1}),t.onCapture(a=>{if(!i||a.event!=="$pageview"||!n())return;let c=new URLSearchParams(location.search);for(let l of o){let u=c.get(l)?.trim();if(u)return void t.client.capture("$site_search",{$search_term:u.slice(0,200),$search_param:l})}})}return()=>s.forEach(o=>o())}function Lr(t,e={}){t.capture("$page_not_found",{$status:404,...e})}var Jo=[25,50,75],Zo="data-lc-media-title";function Dr(t){let e=t.currentSrc||t.src;if(!e||e.startsWith("blob:")||e.startsWith("data:"))return"";try{let n=new URL(e,location.href);return`${n.origin}${n.pathname}`}catch{return""}}var Qo=t=>(t.getAttribute(Zo)??t.getAttribute("title")??t.getAttribute("aria-label")??"").trim().slice(0,200);function Nr(t,e,n){if(e.media===!1)return()=>{};let r=new WeakMap,s=c=>{let l={$media_type:c instanceof HTMLVideoElement?"video":"audio",$media_src:Dr(c)},u=Qo(c);return u&&(l.$media_title=u),Number.isFinite(c.duration)&&(l.$media_duration=Math.round(c.duration)),l},o=c=>{let l=Dr(c);if(!l)return null;let u=r.get(c);return(!u||u.src!==l)&&r.set(c,u={src:l,played:!1,reached:new Set,done:!1}),u},i=c=>{let l=c.target;if(!(l instanceof HTMLMediaElement)||!n())return;let u=o(l);if(u)if(c.type==="play"){if(u.done&&Object.assign(u,{played:!1,reached:new Set,done:!1}),u.played)return;u.played=!0,t.client.capture("$media_play",s(l))}else if(c.type==="timeupdate"){if(!u.played||u.done||!Number.isFinite(l.duration)||l.duration<=0)return;let f=l.currentTime/l.duration*100;for(let g of Jo)f>=g&&!u.reached.has(g)&&(u.reached.add(g),t.client.capture("$media_progress",{...s(l),$media_progress:g}))}else c.type==="ended"&&u.played&&!u.done&&(u.done=!0,t.client.capture("$media_complete",s(l)))},a=["play","timeupdate","ended"];return a.forEach(c=>document.addEventListener(c,i,!0)),()=>a.forEach(c=>document.removeEventListener(c,i,!0))}function Hr(t=()=>performance.now()){let e=()=>document.visibilityState!=="hidden",n=0,r=e()?t():null,s=()=>{e()?r===null&&(r=t()):(r!==null&&(n+=t()-r),r=null)};return document.addEventListener("visibilitychange",s),{read:()=>Math.round(n+(r===null?0:t()-r)),reset:()=>{n=0,r=e()?t():null},stop:()=>document.removeEventListener("visibilitychange",s)}}qr();var Br=255,ti=new Set(["input","textarea","select","option"]),ni="[data-lc-mask],.lc-mask,[data-lc-no-capture],.lc-no-capture,[data-lc-block]",ri=new Set(["value","password","autocomplete"]),si=/(?:\d[ -]?){9,}/,ke=new WeakMap;function oi(t){return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!="object")return!1;let n=e;return typeof n.name=="string"&&n.name!==""&&!n.name.startsWith("$")&&typeof n.selector=="string"&&(n.source==="text"||n.source==="attribute"&&typeof n.attribute=="string")&&Array.isArray(n.events)}):[]}function ii(t){if(!t||ti.has(t.tagName.toLowerCase())||t.isContentEditable)return!1;try{return!t.closest(ni)}catch{return!1}}function ai(t,e){if(t.source==="attribute"){let r=(t.attribute??"").toLowerCase();if(!r||ri.has(r)||r.startsWith("on"))return;let s=e.getAttribute(r);return s===null?void 0:s.slice(0,Br)}let n=(e.textContent??"").replace(/\s+/g," ").trim();if(!(!n||si.test(n)))return n.slice(0,Br)}function Vr(t,e,n,r=location.href){let s={};for(let o of t){if(!o.events.includes(e)||o.url&&!Bt([o.url],r))continue;let i=null;try{i=o.scope==="target"?e==="click"&&n?n.closest(o.selector):null:document.querySelector(o.selector)}catch{continue}if(!ii(i))continue;let a=ai(o,i);a!==void 0&&(s[o.name]=a)}return s}function Ur(t){let e=!0;return t.loadConfig().then(n=>{e&&ke.set(t,oi(n?.snapshot_properties))}),t.clickExtras.push((n,r)=>e?Vr(ke.get(t)??[],"click",r):{}),()=>{e=!1,ke.delete(t)}}function Wr(t){let e=ke.get(t);return e?.length?Vr(e,"pageview"):{}}function Kr(t){return!!ke.get(t)?.some(e=>e.events.includes("pageview"))}function Gr(){let t=0,e=0,n=()=>{let r=document.documentElement,s=Math.max(r.scrollHeight,document.body?.scrollHeight??0),o=Math.min(s,(window.scrollY||window.pageYOffset||0)+window.innerHeight);o>t&&(t=o,e=s>0?Math.min(100,Math.round(o/s*100)):0)};return n(),window.addEventListener("scroll",n,{passive:!0}),{read:()=>({pct:e,px:t}),stop:()=>window.removeEventListener("scroll",n)}}function Ge(t,e,n={}){let r=n.views??!0,s=n.leave??!0,o=location.href,i=Gr(),a=Hr(),c,l=()=>{if(!s||c===o)return;c=o;let{pct:y,px:k}=i.read();t.client.capture("$pageleave",{$current_url:o,$scroll_depth:y,$scroll_depth_px:k,$engagement_time_ms:a.read()})},u=!1,f=y=>{if(!r)return;let{core:k}=t;if(!k.hasConsent("analytics")&&!k.anonymousOnReject&&!(k.consent.pending&&k.consent.queueBeforeConsent)){if(!u){u=!0;let $=()=>{u&&(u=!1,f())};t.whenConsented($),k.onChange(P=>{P==="consent"&&k.anonymousOnReject&&$()})}return}t.client.capture("$pageview",{...Wr(t),...y===void 0?{}:{$referrer:y}})},g=()=>{if(location.href===o)return;let y=o;l(),i.stop(),o=location.href,i=Gr(),a.reset(),Kr(t)?setTimeout(()=>f(y),0):f(y)};if(t.onUnload(l),f(),e!=="history"&&e!=="hash")return()=>(i.stop(),a.stop());let{pushState:m,replaceState:_}=history;return history.pushState=function(...y){m.apply(this,y),g()},history.replaceState=function(...y){_.apply(this,y),g()},window.addEventListener("popstate",g),e==="hash"&&window.addEventListener("hashchange",g),()=>{window.removeEventListener("hashchange",g),history.pushState=m,history.replaceState=_,window.removeEventListener("popstate",g),i.stop(),a.stop()}}var Vt=t=>{let e=[],n=t.config.autocapture,r=!1;if(n!==!1){let i=typeof n=="object"?n:{},a=()=>!r&&!(i.urlIgnorelist?.length&&Ht(i.urlIgnorelist));e.push(Or(t,i,a),Ir(t,i,a),jr(t,i,a),Sr(t,i,a),wr(t,i,a),Nr(t,i,a),Ur(t)),n===void 0&&t.loadConfig().then(c=>r=c?.autocapture===!1)}let s=t.config.capturePageview??"history",o=t.config.capturePageleave??"if_capture_pageview";return s!==!1&&o!==!1?e.push(Ge(t,s)):s!==!1?e.push(Ge(t,s,{leave:!1})):o===!0&&e.push(Ge(t,"history",{views:!1})),()=>e.forEach(i=>i())};be();var ci="lc_preview",Ut="lc_preview";function li(t){let e={};for(let n of(t??"").split(",")){let r=n.indexOf(":");r>0&&r<n.length-1&&(e[n.slice(0,r)]=n.slice(r+1))}return e}function zr(t){let e=new URL(t).searchParams.get(ci),n=null;try{n=sessionStorage.getItem(Ut)}catch{}return{forced:li(e==="off"?null:e??n),persist(){try{e==="off"?sessionStorage.removeItem(Ut):e&&sessionStorage.setItem(Ut,e)}catch{}}}}var Wt="lc_flag_initial";function ui(t){try{return t?new URL(t).hostname:""}catch{return""}}function di(){let t=new URLSearchParams(location.search),e={$initial_referrer:document.referrer||"$direct",$initial_referring_domain:ui(document.referrer)||"$direct",$initial_current_url:location.href.split("#")[0]};for(let n of[..._e,...ee]){let r=t.get(n);r&&(e[`$initial_${n}`]=r)}return e}function Yr(t,e){if(typeof location>"u")return{};let n=t.get(Wt);if(n)try{return JSON.parse(n)}catch{}let r=di();return e(()=>{t.get(Wt)||t.set(Wt,JSON.stringify(r))}),r}function pi(){let t=navigator.userAgent,e=/Edg\//.test(t)?"Edge":/OPR\/|Opera/.test(t)?"Opera":/Firefox\//.test(t)?"Firefox":/Chrome\/|CriOS/.test(t)?"Chrome":/Safari\//.test(t)?"Safari":"Other",n=/Windows/.test(t)?"Windows":/Android/.test(t)?"Android":/iPhone|iPad|iPod/.test(t)?"iOS":/Mac OS X/.test(t)?"Mac OS X":/CrOS/.test(t)?"Chrome OS":/Linux/.test(t)?"Linux":"Other";return{browser:e,os:n}}function Jr(){if(typeof location>"u"||typeof navigator>"u")return{};let t={},e=new URLSearchParams(location.search);for(let s of[..._e,...ee]){let o=e.get(s);o&&(t[`$${s}`]=o)}let{browser:n,os:r}=pi();return t.$browser=n,t.$os=r,t.$device_type=String(Gt().$device_type??"Desktop"),t}function Gt(){if(typeof window>"u")return{};let t=window.innerWidth;return{$viewport_width:t,$viewport_height:window.innerHeight,$screen_width:screen.width,$screen_height:screen.height,$browser_language:navigator.language,$device_type:t<768?"Mobile":t<1024?"Tablet":"Desktop"}}var fi=/^[A-Za-z0-9_.-]{1,100}$/,gi=/^[A-Za-z_$][A-Za-z0-9_$]*(\.[A-Za-z_$][A-Za-z0-9_$]*){0,5}$/,mi=new Set(["__proto__","prototype","constructor"]),hi=50,Zr=200;function Xr(t,e){if(!gi.test(e))return;let n=t;for(let r of e.split(".")){if(mi.has(r)||n===null||typeof n!="object"||typeof Node<"u"&&n instanceof Node)return;n=n[r]}if(typeof n=="string")return n.slice(0,Zr);if(typeof n=="number"&&Number.isFinite(n)||typeof n=="boolean")return n}function yi(){let t=new Map;for(let e of(typeof document>"u"?"":document.cookie).split(";")){let n=e.indexOf("=");if(n<1)continue;let r=e.slice(0,n).trim(),s=e.slice(n+1).trim();try{s=decodeURIComponent(s)}catch{}t.has(r)||t.set(r,s.slice(0,Zr))}return t}function Kt(t){let e={};if(!t||typeof window>"u")return e;let n=o=>Array.isArray(o)?o.filter(i=>typeof i=="string").slice(0,hi):[],r=n(t.cookies).filter(o=>fi.test(o));if(r.length){let o=yi();for(let i of r){let a=o.get(i);a!==void 0&&(e[`$cookie/${i}`]=a)}}for(let o of n(t.globals)){let i=Xr(window,o);i!==void 0&&(e[`$global/${o}`]=i)}let s=window.dataLayer;if(Array.isArray(s))for(let o of n(t.data_layer))for(let i=s.length-1;i>=0;i--){let a=Xr(s[i],o);if(a!==void 0){e[`$datalayer/${o}`]=a;break}}return e}var zt=t=>{if(t.config.flagOptions?.disableRemote&&!t.config.localFlags?.length)return;let e;t.flagPersonProps.push(()=>e&&t.core.hasConsent("analytics")?Kt(e):{}),t.loadConfig().then(n=>{let r=n?.flag_targeting_sources;!r||typeof r!="object"||(e=r,Object.keys(Kt(r)).length&&t.flags?.reload())})};be();function Xt(t){return typeof t=="object"?t.value??t.variant??!!t.enabled:t}function Yt(t){let e={value:Xt(t),reason:t.reason??"remote",condition_index:t.condition_index??-1};return t.variant&&(e.variant=t.variant),t.payload!==void 0&&(e.payload=t.payload),t.runtime?.length&&(e.runtime=t.runtime.map(n=>({filters:n.filters,result:Yt(n.result)}))),e}var Qr="lc_rt_events",es=t=>!!t?.some(e=>e.conditions.some(n=>n.filters?.some(r=>r.type==="event")));function ts(t,e){let n;try{let i=t.flagStorage.get(Qr);i&&(n=JSON.parse(i))}catch{}let r=new pe(n),s={},o=Fe(e,s);return{counts:()=>r.counts(t.core.sessionId),setServer(i){s=i,o=Fe(e,s)},server:()=>s,drop(i){for(let a of i)delete s[a]},resolved(){return pt(s,r.counts(t.core.sessionId))},record(i,a,c){r.record(i,t.core.sessionId,a,o),c&&t.whenConsented(()=>t.flagStorage.set(Qr,JSON.stringify(r.saved())))}}}var ns="lc_flags",Jt="lc_flag_overrides_api";function rs(t){try{let e=localStorage.getItem("lc_flag_overrides");return e?JSON.parse(e)[t]:void 0}catch{return}}var Zt=t=>{let{core:e,config:n}=t,r={},s={},o={},i,a=!1,c=0,l=new Set,u=new Set,f="",g={},m=()=>Object.keys(g).length>0,_={},y={},k={},$=new Set,P=typeof location>"u"?{forced:{},persist(){}}:zr(location.href),W=Object.keys(P.forced).length>0,M=()=>({...r,...k}),C=t.config.flagOptions??{},R=new ge(C.cacheTtlMs),H=(t.config.flagsApiHost??t.config.apiHost).replace(/\/+$/,""),X=C.keys?.length?new Set(C.keys):void 0,te=p=>X?Object.fromEntries(Object.entries(p).filter(([v])=>X.has(v))):p,F=(p,v,w=!0)=>{if(r=te(p),s=te(v),a=!0,w)for(let S of $)S(M())},j=ts(t,n.localFlags),ne=t.flagStorage.get(ns);if(ne)try{let p=JSON.parse(ne);r=p.values,s=p.payloads,o=Object.fromEntries(Object.keys(r).map(v=>[v,"cached"])),p.rt&&j.setServer(p.rt),R.restore(p)}catch{}let b=t.flagStorage.get(Jt);if(b)try{k=JSON.parse(b)}catch{}let A=n.bootstrap;if(A?.flags){F({...A.flags},{...A.payloads});for(let p of Object.keys(A.flags))o[p]="bootstrap"}let K={},ae=()=>({...C.autoProperties===!1?{}:Jr(),...Yr(e.storage,t.whenConsented),...Object.assign({},...t.flagPersonProps.map(p=>p())),..._}),q=C.evaluationContexts?.length?{app_contexts:C.evaluationContexts}:{},re=(p=!0)=>{let v=n.localFlags;if(!v?.length)return!0;let w=n.localFlagsContext,S=ht(v,{runtime_events:j.counts(),distinct_id:e.distinctId,...e.groups?{groups:e.groups}:{},...e.deviceId?{device_id:e.deviceId}:{},...m()?{contexts:g}:{},...q,...w,person_properties:{...ae(),...w?.person_properties},group_properties:{...w?.group_properties,...y}}),O={},I={},J=!1;for(let[Z,L]of Object.entries(S))yt(L)?J=!0:vt(L)&&(O[Z]=L.value,o[Z]=L.reason,L.payload!==void 0&&(I[Z]=L.payload));return K=O,F({...r,...O},{...s,...I},p),J},Y=p=>{let v={...r},w={...s};for(let[S,O]of Object.entries(j.resolved()))v[S]=O.value,o[S]=O.reason,O.payload!==void 0?w[S]=O.payload:delete w[S];F(v,w,p)},ce=es(n.localFlags);t.onCapture(p=>{let v=ce||Object.keys(j.server()).length>0;if(j.record(p.event,p.properties,v),!v)return;let w=JSON.stringify([M(),s]);if(ce&&re(!1),Y(!1),JSON.stringify([M(),s])!==w)for(let S of $)S(M())});let x=(p=!0)=>{let v=++c;return!re()||C.disableRemote||!p&&R.fresh(e.distinctId)?Promise.resolve():new Promise(w=>{t.whenConsented(()=>{if(v!==c)return w();P.persist();let S=new AbortController,O=setTimeout(()=>S.abort(),C.timeoutMs??1e4);t.fetch(`${H}/v1/flags`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",signal:S.signal,body:JSON.stringify({api_key:t.apiKey,...e.distinctId?{distinct_id:e.distinctId}:{},...e.anonDistinctId?{anon_distinct_id:e.anonDistinctId}:{},groups:e.groups??{},person_properties:ae(),...Object.keys(y).length?{group_properties:y}:{},device_properties:Gt(),...e.deviceId?{device_id:e.deviceId}:{},...m()?{contexts:g}:{},...q,...W?{preview:P.forced}:{},...C.keys?.length?{flag_keys:C.keys}:{}})}).then(I=>I.ok?I.json():Promise.reject(new Error(`status ${I.status}`))).then(I=>{if(v!==c)return;if(I.quota_limited)return t.log("flags quota limited; keeping cached values");let J={},Z={},L={};for(let[we,D]of Object.entries(I.flags??{}))J[we]=Xt(D),typeof D=="object"&&D.payload!==void 0&&(Z[we]=D.payload),o[we]=typeof D=="object"&&typeof D.reason=="string"?D.reason:"remote",typeof D=="object"&&D.runtime?.length&&(L[we]=Yt(D));i=I.request_id,j.setServer(L),F({...K,...J},Z,!1),Y(!0),t.flagStorage.set(ns,JSON.stringify({values:J,payloads:Z,rt:L,...R.mark(e.distinctId)})),t.log("flags loaded",J)}).catch(I=>t.log("flags fetch failed",I)).finally(()=>{clearTimeout(O),w()})})})},le=p=>k[p]??rs(p)??r[p];t.flags={get(p){let v=le(p);if(v===void 0)return;if(p in P.forced||p in k)return v;let w=e.sessionId;w!==f&&(l.clear(),u.clear(),f=w),u.has(p)||(u.add(p),e.capture("$exposure",{$feature_flag:p,$feature_flag_response:v,...typeof v=="string"?{$feature_flag_variant:v}:{},...i?{$feature_flag_request_id:i}:{}}));let S=`${p}:${String(v)}`;return l.has(S)||(l.add(S),e.capture("$feature_flag_called",{$feature_flag:p,$feature_flag_response:v,...i?{$feature_flag_request_id:i}:{}})),v},all:()=>a||Object.keys(r).length||Object.keys(k).length?M():{},payload:p=>s[p],result(p,v){let w=v?.sendExposure===!1?le(p):this.get(p),S=p in k||rs(p)!==void 0?"override":p in P.forced?"preview":o[p]??"remote";return me(p,w,s[p],S)},layerParam(p,v){for(let[w,S]of Object.entries(s)){let O=S;if(O?.lc_layer!==p||!O.lc_params||!(v in O.lc_params))continue;let I=this.get(w);if(I!==void 0&&I!==!1)return O.lc_params[v]}},onChange(p){return $.add(p),a&&p(M()),()=>{$.delete(p)}},reload:x,update(p,v,w=!0){for(let S of Object.keys(p))o[S]="pushed";j.drop(Object.keys(p)),F(w?{...r,...p}:{...p},w?{...s,...v}:{...v})},override(p,v){k=p?{...p}:{},p?v?.persist&&t.whenConsented(()=>t.flagStorage.set(Jt,JSON.stringify(k))):t.flagStorage.remove(Jt);for(let w of $)w(M())},setPersonProperties(p,v=!0){R.clear(),_={..._,...p},v&&x()},resetPersonProperties(){_={}},setGroupProperties(p,v=!0){R.clear();for(let[w,S]of Object.entries(p))y[w]={...y[w],...S};v&&x()},resetGroupProperties(){y={}},setContext(p,v,w){R.clear(),g={...g,[p]:{key:v,properties:w??{}}},x()},clearContext(p){R.clear();let{[p]:v,...w}=g;g=w,x()}},e.onChange(p=>{p==="reset"&&(g={},_={},y={}),(p==="identify"||p==="reset"||p==="group")&&x()}),n.disableFlagsOnFirstLoad?re():x(!1);let B=n.flagStream,d;B&&!C.disableRemote&&t.whenConsented(()=>{d=tt({apiHost:H,apiKey:t.apiKey,fetch:t.fetch,reload:()=>{x()},visibility:{hidden:()=>document.visibilityState==="hidden",subscribe:p=>(document.addEventListener("visibilitychange",p),()=>document.removeEventListener("visibilitychange",p))},...typeof B=="object"&&B.pollMs!==void 0?{pollMs:B.pollMs}:{},log:t.log})});let h=C.refreshMs&&C.refreshMs>0&&!C.disableRemote?setInterval(()=>document.visibilityState!=="hidden"&&void x(!1),C.refreshMs):void 0;return()=>{d?.(),h&&clearInterval(h)}};function ze(t){let e=window.fetch;window.fetch=function(i,a){let c=i instanceof Request?i.url:String(i),l=new Headers(a?.headers??(i instanceof Request?i.headers:void 0)),u=[...l.entries()].join("|");return t(c,l),[...l.entries()].join("|")===u?e.call(this,i,a):e.call(this,i,{...a,headers:l})};let n=XMLHttpRequest.prototype,{open:r,send:s}=n,o=new WeakMap;return n.open=function(i,a,...c){return o.set(this,String(a)),r.call(this,i,a,...c)},n.send=function(i){let a=o.get(this);if(a){let c=new Headers;t(a,c),c.forEach((l,u)=>this.setRequestHeader(u,l))}return s.call(this,i)},()=>{window.fetch=e,n.open=r,n.send=s}}var ss="lucida.session_id";function vi(t,e){return[...(t??"").split(",").map(r=>r.trim()).filter(r=>r&&!r.startsWith(`${ss}=`)),`${ss}=${encodeURIComponent(e)}`].join(",")}function bi(t,e=[]){let n;try{n=new URL(t,location.href)}catch{return!1}return n.origin===location.origin||e.some(r=>typeof r=="string"?n.origin===r:r.test(n.href))}var os=t=>{let e=t.config.watchtower;if(!e?.correlate)return;let{core:n}=t,r=n.sessionId;t.onCapture(o=>r=String(o.properties.$session_id??r));let s=o=>n.hasConsent("analytics")&&!o.startsWith(t.config.apiHost)&&bi(o,e.origins);return ze((o,i)=>{s(o)&&i.set("baggage",vi(i.get("baggage"),r))})};var _i="X-Lucida-Distinct-Id",xi="X-Lucida-Session-Id";function ki(t,e){let n;try{n=new URL(t,location.href).hostname.toLowerCase()}catch{return!1}return e.some(r=>{let s=r.toLowerCase();return s.startsWith(".")?n===s.slice(1)||n.endsWith(s):n===s})}var is=t=>/^[\x20-\x7e]*$/.test(t)?t:encodeURIComponent(t),Qt=t=>{let e=t.config.tracingHeaders;if(!e?.length)return;let{core:n}=t;return ze((r,s)=>{!n.hasConsent("analytics")||r.startsWith(t.config.apiHost)||!ki(r,e)||(n.distinctId&&s.set(_i,is(n.distinctId)),s.set(xi,is(n.sessionId)))})};be();var as="lc_early_access",wi=t=>{let{core:e}=t,n=()=>{try{return JSON.parse(e.storage.get(as)??"{}")}catch{return{}}},r=(s,o)=>{e.storage.set(as,JSON.stringify({...n(),[s]:o}));let i=Ze(s,o);e.capture(i.event,i.props,i.extra),t.flags?.reload()};t.flagPersonProps.push(()=>Object.fromEntries(Object.entries(n()).map(([s,o])=>[Ie(s),o]))),t.earlyAccess={list:()=>new Promise(s=>t.whenConsented(()=>{t.fetch(`${t.config.apiHost}/v1/early-access?api_key=${encodeURIComponent(t.apiKey)}`,{credentials:"omit"}).then(o=>o.ok?o.json():Promise.reject(new Error(`status ${o.status}`))).then(o=>{let i=n();s((o.features??[]).map(a=>({...a,enrolled:i[a.flag_key]===!0})))}).catch(o=>{t.log("early access fetch failed",o),s([])})})),optIn:s=>r(s,!0),optOut:s=>r(s,!1)}};var ls="lc_recs",cs="lc_recs_recent";function us(t,e,n,r){for(let s of r?[r]:n){let o=e(s)?.[ls];if(o&&typeof o=="object"&&(o.placement===t||r!==void 0&&o.placement===void 0))return{flag:s,cfg:o}}}var Si=t=>{let{core:e}=t,n=t.config.recommendations??{},r=n.viewEvent??"$product_viewed",s=n.itemIdProperty??"item_id",o=[];try{let c=JSON.parse(e.storage.get(cs)??"[]");Array.isArray(c)&&(o=c.filter(l=>typeof l=="string").slice(0,20))}catch{}let i=()=>e.hasConsent("analytics"),a=c=>{c&&(o=[c,...o.filter(l=>l!==c)].slice(0,20),i()&&e.storage.set(cs,JSON.stringify(o)))};t.onCapture(c=>{let l=c.properties?.[s];c.event===r&&(typeof l=="string"||typeof l=="number")&&a(String(l))}),t.recs={viewed:a,async get(c,l={}){let u=Object.keys(t.flags?.all()??{}),f=us(c,R=>t.flags?.payload(R),u,l.flag),g=f?t.flags?.get(f.flag):void 0,m=new URLSearchParams({api_key:t.apiKey,placement:c});l.itemId&&m.set("item_id",l.itemId),i()&&o.length&&m.set("recent",o.filter(R=>R!==l.itemId).slice(0,10).join(","));let _=f?.cfg.strategy;typeof _=="string"&&m.set("strategy",_);let y=l.limit??f?.cfg.limit;typeof y=="number"&&y>0&&m.set("limit",String(Math.min(50,Math.floor(y)))),l.exclude?.length&&m.set("exclude",l.exclude.slice(0,50).join(","));let k={};try{let R=await t.fetch(`${t.config.apiHost}/v1/recommendations?${m}`,{credentials:"omit"});R.ok?k=await R.json():t.log("recommendations failed",R.status)}catch(R){t.log("recommendations failed",R)}let $=Array.isArray(k.items)?k.items:[],P=k.strategy??_??"",W={$recommendation_placement:c,$recommendation_strategy:P,...f?{$recommendation_flag:f.flag}:{},...g!==void 0?{$recommendation_variant:String(g)}:{}},M=!1,C={placement:c,strategy:P,items:$,...f?{flag:f.flag}:{},...g!==void 0?{variant:g}:{},shown(){M||!$.length||(M=!0,e.capture("$recommendation_shown",{...W,$recommendation_items:$.map(R=>R.item_id)}))},clicked(R){let H=$.findIndex(X=>X.item_id===R);e.capture("$recommendation_clicked",{...W,$recommendation_item:R,...H>=0?{$recommendation_position:H+1}:{}})}};return l.autoShown!==!1&&C.shown(),C}}};function ll(t,e={},n=[]){return Dt(t,e,[Vt,Zt,zt,os,Qt,Et,...n])}export{Lt as DEFAULT_HOST,kr as LIB_VERSION,ls as RECS_PAYLOAD_KEY,ir as assetUrl,Vt as autocapture,sr as blocksInlineStyle,wt as captureCspViolations,Dt as createClient,Et as crossDomain,br as denylistHook,wi as earlyAccess,Kt as flagSourceProps,zt as flagSources,Zt as flags,Qt as hostHeaders,ll as init,St as isExtensionPage,so as loadModules,us as placementFlag,Si as recommendations,ar as rewriteUrl,vr as sampleHook,Zs as styleTag,Lr as tag404};
|