@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 @@
|
|
|
1
|
+
function ie(e,t){if(!e.url)return!0;if(e.url_match==="exact")return t===e.url;if(e.url_match==="regex")try{return new RegExp(e.url).test(t)}catch{return!1}return t.includes(e.url)}function S(e,t){let n=t?.[e.key];if(e.op==="exists")return n!=null;if(n==null)return e.op==="neq";let[o,s]=[String(n),String(e.value??"")];return e.op==="eq"?o===s:e.op==="neq"?o!==s:o.includes(s)}var re=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function se(e,t){try{let n=new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"numeric",hourCycle:"h23"}).formatToParts(e),o=s=>n.find(u=>u.type===s)?.value??"";return{day:re.indexOf(o("weekday")),h:Number(o("hour"))%24}}catch{return{day:new Date(e).getDay(),h:new Date(e).getHours()}}}function ae(e,t){if(e.start&&t<Date.parse(e.start)||e.end&&t>=Date.parse(e.end))return!1;let{day:n,h:o}=e.timezone?se(t,e.timezone):{day:new Date(t).getDay(),h:new Date(t).getHours()};return e.days?.length&&!e.days.includes(n)?!1:!e.hours||o>=(e.hours.from??0)&&o<(e.hours.to??24)}function ce(e,t,n){let o=e.per_days?n-e.per_days*864e5:0;return t.filter(s=>s>=o).length<(e.max_views??1)}function le(e,t){let n=e.split("*").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp("^"+n+"$").test(t)}function ue(e,t){if(!e||!t?.length)return!1;let n=e;try{n=new URL(e).pathname||e}catch{}return t.some(o=>typeof o=="string"&&o!==""&&le(o,o.startsWith("/")?n:e))}function Se(e,t){let n=e.conditions;return!(ue(t.url,n.exclude_url_patterns)||!ie(n,t.url)||n.flag_key&&!t.flags(n.flag_key)||n.flag_key&&n.flag_variant&&String(t.flagValue?.(n.flag_key))!==n.flag_variant||n.wait_days&&t.lastShownMs!==void 0&&t.nowMs-t.lastShownMs<n.wait_days*864e5||n.devices?.length&&t.device&&!n.devices.includes(t.device)||n.person_filters?.some(o=>!S(o,t.person))||n.group_filters?.some(o=>!S(o,t.groups?.[o.group_type??""]))||n.seen_guides?.some(o=>!t.seen?.(o))||n.not_seen_guides?.some(o=>t.seen?.(o))||n.schedule&&!ae(n.schedule,t.nowMs)||n.frequency&&!ce(n.frequency,t.views??[],t.nowMs)||n.sample_pct!==void 0&&n.sample_pct>0&&n.sample_pct<100&&t.random()*100>=n.sample_pct)}function j(e,t){let n=document.createElement("style");return t&&n.setAttribute("nonce",t),n.textContent=e,n}var F=e=>{if(typeof e!="string"||!e)return!1;try{return!!document.querySelector(e)}catch{return!1}};function U(e,t){if(e.op==="element_present")return F(e.value);if(e.op==="element_absent")return!F(e.value);if(e.op==="flag_on"||e.op==="flag_off"){let n=typeof e.value=="string"&&!!t.flag?.(e.value);return e.op==="flag_on"?n:!n}return S({key:e.key,op:e.op,value:e.value},t.person)}function de(e){return e.matches("input[type=password],[data-lc-mask],.lc-mask,[autocomplete^=cc-]")?!0:!!e.closest("[data-lc-mask],.lc-mask")}var pe="input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),textarea";function K(e,t=document){if(!e.selector||e.selector.length>500)return"invalid";let n;try{n=t.querySelector(e.selector)}catch{return"invalid"}if(!n)return"missing";if(de(n))return"refused";if(e.action==="click")n.click();else if(e.action==="focus")n.focus();else if(e.action==="fill"){if(typeof e.value!="string"||e.value.length>200||!n.matches(pe))return"refused";let o=n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,s=Object.getOwnPropertyDescriptor(o,"value")?.set;s?s.call(n,e.value):n.value=e.value,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}else return"invalid";return"done"}var fe=()=>{try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}};function W(e=["#e5484d","#30a46c","#0090ff","#f5d90a","#8e4ec6"]){if(typeof document>"u"||fe())return;let t=document.createElement("canvas");t.setAttribute("data-lc-ignore",""),t.setAttribute("aria-hidden","true"),t.width=innerWidth,t.height=innerHeight,t.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483001";let n=t.getContext("2d");if(!n)return;document.body.append(t);let o=Array.from({length:120},(a,r)=>({x:innerWidth/2,y:innerHeight/3,vx:(Math.random()-.5)*12,vy:Math.random()*-10-2,color:e[r%e.length]})),s=Date.now()+1500,u=()=>{n.clearRect(0,0,t.width,t.height);for(let a of o)a.x+=a.vx,a.y+=a.vy,a.vy+=.35,n.fillStyle=a.color,n.fillRect(a.x,a.y,6,4);Date.now()<s?requestAnimationFrame(u):t.remove()};requestAnimationFrame(u)}var me=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,be=/^[\w\s,'"-]{1,100}$/,V={none:"none",sm:"0 1px 4px rgba(0,0,0,.15)",lg:"0 8px 32px rgba(0,0,0,.3)"};function ve(e,t=ye()){if(!e?.dark?.tokens)return!1;let n=e.theme_mode??"auto";return n==="dark"||n==="auto"&&t}function ye(){try{return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function X(e,t){let n={...e?.font_family?{font:e.font_family}:{},...e?.tokens};return ve(e,t)?{...n,...e?.dark?.tokens}:n}function Y(e,t){let n=o=>typeof o=="string"&&me.test(o);n(t?.background)&&(e.style.background=t.background),n(t?.text)&&(e.style.color=t.text),n(t?.accent)&&(e.style.setProperty("--a",t.accent),e.style.setProperty("--at","#fff")),typeof t?.radius=="number"&&t.radius>=0&&t.radius<=32&&(e.style.borderRadius=`${t.radius}px`),typeof t?.font=="string"&&be.test(t.font)&&(e.style.fontFamily=t.font),t?.shadow&&t.shadow in V&&(e.style.boxShadow=V[t.shadow]),typeof t?.button_radius=="number"&&t.button_radius>=0&&t.button_radius<=32&&e.style.setProperty("--br",`${t.button_radius}px`),n(t?.secondary)&&e.style.setProperty("--s",t.secondary),n(t?.secondary_text)&&e.style.setProperty("--st",t.secondary_text)}var J=".cd{display:flex;gap:6px;justify-content:center;margin:8px 0}.cd button{width:10px;height:10px;min-width:0;padding:0;margin:0;border-radius:50%;background:#ccc;border:0}.cd button[aria-current=true]{background:var(--a,#111)}.cn{display:flex;justify-content:space-between}",A=(e,t,n)=>{let o=document.createElement("button");return o.type="button",o.textContent=e,n&&o.setAttribute("aria-label",n),o.onclick=t,o};function Q(e){let t=document.createElement("div"),n=document.createElement("div");n.className="cd",n.setAttribute("role","tablist");for(let u=0;u<e.count;u++){let a=A("",()=>e.to(u),`Slide ${u+1} of ${e.count}`);a.setAttribute("role","tab"),a.setAttribute("aria-current",String(u===e.index)),n.append(a)}let o=document.createElement("div");o.className="cn";let s=e.index===e.count-1;return o.append(e.index>0?A("Back",()=>e.to(e.index-1)):A("Skip",e.dismiss),A(s?"Done":"Next",()=>s?e.complete():e.to(e.index+1))),t.append(n,o),t}function Z(e,t){let n,o=a=>{n=a.clientX},s=a=>{if(n===void 0)return;let r=a.clientX-n;n=void 0;let y=t();r<-40&&y.index<y.count-1?y.to(y.index+1):r>40&&y.index>0&&y.to(y.index-1)},u=a=>{let r=t();a.key==="ArrowRight"&&r.index<r.count-1?r.to(r.index+1):a.key==="ArrowLeft"&&r.index>0&&r.to(r.index-1)};return e.addEventListener("pointerdown",o),e.addEventListener("pointerup",s),e.addEventListener("keydown",u),()=>{e.removeEventListener("pointerdown",o),e.removeEventListener("pointerup",s),e.removeEventListener("keydown",u)}}function ge(e,t,n=!0,o=!1){if(e==="banner")return[{label:"Dismiss",action:"dismiss"}];let s=n?[]:[{label:"Back",action:"back"}];return o||s.push({label:t?"Done":"Next",action:"next"}),[...s,{label:"Dismiss",action:"dismiss"}]}function he(e){for(let t of[e.selector,...e.fallback_selectors??[]])if(t)try{let n=document.querySelector(t);if(n)return n}catch{}return null}var xe=".g{position:fixed;z-index:2147483000;background:#fff;color:#111;border:1px solid #ccc;border-radius:8px;padding:14px;font:14px system-ui;max-width:320px;box-shadow:0 4px 16px rgba(0,0,0,.2)}.m{top:50%;left:50%;transform:translate(-50%,-50%)}.bn{top:0;left:0;right:0;max-width:none;border-radius:0}.bb{top:auto;bottom:0}.p{right:16px;bottom:16px}.o{position:fixed;inset:0;z-index:2146999999;background:rgba(0,0,0,.4)}button{margin:2px;padding:4px 10px;cursor:pointer;background:var(--a,buttonface);color:var(--at,buttontext);border:1px solid #bbb;border-radius:var(--br,4px)}button+button{background:var(--s,buttonface);color:var(--st,buttontext)}h2{margin:0 0 6px;font-size:16px}p{margin:0 0 8px}li{margin:4px 0}.so{top:0;bottom:0;right:0;max-width:360px;border-radius:0;overflow:auto;animation:s .2s}.so.sl{right:auto;left:0}@keyframes s{from{transform:translateX(30px);opacity:0}}@media (prefers-reduced-motion:reduce){.so{animation:none}}.in{position:static;box-shadow:none;max-width:none;margin:8px 0}img,video,iframe{display:block;width:100%;max-width:100%;border:0;margin:0 0 8px;border-radius:4px}iframe{aspect-ratio:16/9}",ke=xe+J,we=["www.youtube-nocookie.com","www.youtube.com","player.vimeo.com","www.loom.com","fast.wistia.net"],_e="button,[href],input,textarea,select,[tabindex]:not([tabindex='-1'])";function v(e,t,n){let o=document.createElement(e);return t!==void 0&&(o.textContent=t),n&&(o.className=n),o}function Ee(e){let t;try{t=new URL(e.url)}catch{return null}if(t.protocol!=="https:")return null;if(e.type==="image")return Object.assign(v("img"),{src:t.href,alt:e.alt??"",loading:"lazy"});if(e.type==="video")return Object.assign(v("video"),{src:t.href,controls:!0,preload:"metadata"});if(e.type!=="embed"||!we.includes(t.host))return null;let n=Object.assign(v("iframe"),{src:t.href,title:e.alt??"Video",allowFullscreen:!0,referrerPolicy:"no-referrer"});return n.setAttribute("sandbox","allow-scripts allow-same-origin allow-presentation"),n}function Me(e,t,n){e.addEventListener("keydown",o=>{if(o.key==="Escape")return n();if(o.key!=="Tab")return;let s=[...e.querySelectorAll(_e)];if(!s.length)return;let u=s[0],a=s[s.length-1],r=t.activeElement;o.shiftKey&&r===u?(o.preventDefault(),a.focus()):!o.shiftKey&&r===a&&(o.preventDefault(),u.focus())})}function Te(e,t,n="bottom"){let o=t.getBoundingClientRect(),s=e.offsetWidth||280,u=e.offsetHeight||120,a=o.left,r=o.bottom+8;n==="top"?r=o.top-u-8:n==="left"?(a=o.left-s-8,r=o.top):n==="right"&&(a=o.right+8,r=o.top);let y=(k,w)=>Math.max(8,Math.min(k,w-8));e.style.left=`${y(a,window.innerWidth-s)}px`,e.style.top=`${y(r,window.innerHeight-u)}px`}function Ne(e,t,n,o={}){let s=document.createElement("div");s.setAttribute("data-lc-ignore","");let u=s.attachShadow({mode:"open"});u.append(j(ke,o.nonce));let a=document.activeElement,r=Math.min(Math.max(o.start??0,0),e.steps.length-1),y=!1,k,w=[],h=[],H=()=>{for(let i of h)i();h=[]},D=()=>{},d=v("div",void 0,"g"),_=()=>{y||(y=!0,H(),D(),s.remove(),a?.focus?.(),n())},L=i=>{t.dismissed(r,e.steps[r]?.id??"",i),_()},x=()=>L(),M=()=>{t.completed(),_(),e.steps.at(-1)?.confetti&&W()},R=i=>(o.resolveTarget??he)(i),$=i=>{let c=i?.goto?void 0:e.steps[r]?.branch?.find(m=>U(m,{...o.person?{person:o.person}:{},...o.flag?{flag:o.flag}:{}})),p=i?.goto??c?.goto,l=p==="end"?e.steps.length:p?e.steps.findIndex(m=>m.id===p):-1;w.push(r),r=l>r?l:r+1,C()},C=()=>{let i=e.steps[r];if(!i)return M();if(t.progress?.(i.id),i.url&&!location.href.includes(i.url))return _();I()},O=i=>{i<0||i>=e.steps.length||i===r||(r=i,C())},ee=()=>{let i=w.pop();i!==void 0&&(r=i,C())},P=i=>{if(i.action==="next"||i.action==="start_tour")$(i);else if(i.action==="back")ee();else if(i.action==="dismiss")x();else if(i.action==="snooze"){let c=Math.min(Math.max(Math.round(i.snooze_hours??24),1),720);t.snoozed?.(e.steps[r]?.id??"",c),L("snooze")}else i.action==="link"&&i.url&&/^https?:\/\//i.test(i.url)?window.open(i.url,"_blank","noopener,noreferrer"):i.action==="event"&&i.event&&t.event(i.event)},te=(i,c)=>{let p=v("div"),l=i.buttons?.length?i.buttons:ge(e.kind,c,w.length===0,i.advance==="click"||i.advance==="input");for(let m of l){let g=v("button",m.label);g.type="button",g.onclick=()=>P(m),p.append(g)}return p},ne=i=>[...i.title?[v("h2",i.title)]:[],...i.body?[v("p",i.body)]:[],...(i.media??[]).flatMap(c=>Ee(c)??[])],T=new Set(o.checked),N=new Map;function G(i,c,p){let l=N.get(c.id);l&&!l.hasAttribute("data-done")&&(l.setAttribute("data-done",""),l.setAttribute("aria-pressed","true"),l.textContent=`\u2713 ${c.title??c.id}`),!(!p||T.has(c.id)&&l?.hasAttribute("data-reported"))&&(l?.setAttribute("data-reported",""),T.add(c.id),t.step(i,c.id),T.size>=e.steps.length&&M())}let oe=()=>{let i=v("ul");for(let[p,l]of e.steps.entries()){let m=v("li"),g=v("button",`${l.title??l.id}`);if(g.type="button",g.setAttribute("aria-pressed","false"),N.set(l.id,g),T.has(l.id)&&(G(p,l,!1),g.setAttribute("data-reported","")),g.onclick=()=>{if(e.kind==="checklist")G(p,l,!0);else if(e.kind==="resource_center"){t.step(p,l.id);let f=l.buttons?.find(b=>b.action==="link");f&&P(f)}},l.module){let f={library:o.library??[],launch:b=>(_(),o.launch?.(b)),opened:()=>t.step(p,l.id),...o.assist?{assist:o.assist}:{}};import("./modules-FANMZRDJ.js").then(b=>m.append(b.renderModule(l,f))),i.append(m);continue}m.append(g),l.body&&m.append(v("p",l.body)),i.append(m)}d.append(v("h2",e.name),i);let c=v("button",e.kind==="resource_center"?"Close":"Dismiss");c.type="button",c.onclick=x,d.append(c)};function I(){H(),d.replaceChildren(),d.style.visibility="";let i=e.steps[r];if(!i)return;let c=e.kind==="carousel";if(e.kind==="checklist"||e.kind==="resource_center")oe();else{let f={index:r,count:e.steps.length,to:O,complete:M,dismiss:x};d.append(...ne(i),c?Q(f):te(i,r===e.steps.length-1)),t.step(r,i.id)}d.setAttribute("role",e.kind==="banner"||e.kind==="inline"?"region":"dialog"),d.setAttribute("aria-label",i?.title??e.name),c&&d.setAttribute("aria-roledescription","carousel");let p={modal:"m",carousel:"m",banner:`bn${i.placement==="bottom"?" bb":""}`,slideout:`so${e.appearance?.side==="left"?" sl":""}`,inline:"in"};if(d.className=`g ${p[e.kind]??"p"}`,Y(d,X(e.appearance)),(e.kind==="modal"||c)&&d.setAttribute("aria-modal","true"),c&&h.push(Z(d,()=>({index:r,count:e.steps.length,to:O,complete:M,dismiss:x}))),i.auto_close_s&&i.auto_close_s>0){let f=setTimeout(()=>L("auto_close"),Math.min(i.auto_close_s,600)*1e3);h.push(()=>clearTimeout(f))}if(i.automation&&o.automate!==!1){let f=i.automation,b=setTimeout(()=>t.automated?.(i.id,K(f)));h.push(()=>clearTimeout(b))}let l=(e.kind==="tooltip"||e.kind==="tour")&&!!(i.selector||i.fallback_selectors?.length),m=f=>{d.style.visibility="",d.classList.remove("p"),Te(d,f,i.placement);let b=i.advance==="click"?"click":i.advance==="input"?"change":null;if(!b)return;let E=()=>$();f.addEventListener(b,E,{once:!0}),h.push(()=>f.removeEventListener(b,E))},g=l?R(i):null;if(g)m(g);else if(l){d.style.visibility="hidden";let f=Date.now()+Math.min(Math.max(i.wait_ms??3e3,0),15e3),b=setInterval(()=>{let E=R(i);E?(clearInterval(b),m(E)):Date.now()>=f&&(clearInterval(b),d.style.visibility="",t.targetMissing?.(i.id,i.selector??i.fallback_selectors?.[0]??""))},150);h.push(()=>clearInterval(b))}e.kind!=="inline"&&d.querySelector("button")?.focus()}Me(d,u,x);let B=e.kind==="modal"||e.kind==="carousel",q=e.appearance?.dismiss_on_outside_click??B;if(e.appearance?.overlay??B)k=v("div",void 0,"o"),q&&(k.onclick=x),u.append(k);else if(q&&e.kind!=="inline"){let i=p=>{p.composedPath().includes(s)||x()},c=setTimeout(()=>document.addEventListener("click",i,!0));D=()=>(clearTimeout(c),document.removeEventListener("click",i,!0))}u.append(d);let z=e.kind==="inline"&&e.steps[0]?.selector?document.querySelector(e.steps[0].selector):null;return z?z.after(s):document.body.append(s),t.shown(),I(),Object.assign(_,{markDone(i){let c=e.steps.findIndex(p=>p.id===i);e.kind==="checklist"&&c>=0&&!y&&G(c,e.steps[c],!0)}})}export{Se as a,j as b,U as c,de as d,K as e,X as f,Y as g,ge as h,he as i,Te as j,Ne as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=0,a=0;function p(t){let o=new Uint8Array(t),e=globalThis.crypto;if(e?.getRandomValues)e.getRandomValues(o);else for(let r=0;r<t;r++)o[r]=Math.floor(Math.random()*256);return o}function f(t=Date.now()){if(t>i){i=t;let n=p(2);a=((n[0]??0)<<8|(n[1]??0))&1023}else a++,a>4095&&(i++,a=0);let o=p(8),e=new Uint8Array(16),r=i;e[0]=Math.floor(r/2**40)&255,e[1]=Math.floor(r/2**32)&255,e[2]=Math.floor(r/2**24)&255,e[3]=Math.floor(r/2**16)&255,e[4]=Math.floor(r/2**8)&255,e[5]=r&255,e[6]=112|a>>8,e[7]=a&255,e[8]=128|(o[0]??0)&63;for(let n=1;n<8;n++)e[8+n]=o[n]??0;let s=Array.from(e,n=>n.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)}`}function l(t,o={}){let e=Math.min(o.maxMs??3e4,(o.baseMs??1e3)*2**t);return Math.round(e*(.5+.5*(o.random??Math.random)()))}function m(t){return t===0||t===408||t===429||t>=500}export{f as a,l as b,m as c};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { B as BrowserConfig, M as Module, C as Client } from './types-BWd9sbCh.js';
|
|
2
|
+
|
|
3
|
+
declare const LIB_VERSION = "0.1.0";
|
|
4
|
+
declare const DEFAULT_HOST = "https://app.lucida.dev";
|
|
5
|
+
/** Build a client from the shared core plus the given modules (pass none for the smallest bundle). */
|
|
6
|
+
declare function createClient(apiKey: string, config?: BrowserConfig, modules?: Module[]): Client;
|
|
7
|
+
|
|
8
|
+
export { DEFAULT_HOST as D, LIB_VERSION as L, createClient as c };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { M as Module, H as Host, C as ConsentSource } from './types-Cv4pBbPu.js';
|
|
2
|
+
export { B as BannerOptions, a as BannerPosition, b as BannerTexts, c as ConsentUi } from './types-Cv4pBbPu.js';
|
|
3
|
+
import { ConsentState } from '@lucida-analytics/sdk-core';
|
|
4
|
+
|
|
5
|
+
type Update = {
|
|
6
|
+
analytics?: boolean;
|
|
7
|
+
replay?: boolean;
|
|
8
|
+
marketing?: boolean;
|
|
9
|
+
};
|
|
10
|
+
interface TCData {
|
|
11
|
+
eventStatus?: string;
|
|
12
|
+
gdprApplies?: boolean;
|
|
13
|
+
listenerId?: number;
|
|
14
|
+
purpose?: {
|
|
15
|
+
consents?: Record<string, boolean>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* TCF v2.2 purposes -> Lucida categories. analytics = purpose 1 (store/access) + 7 (measure ad
|
|
20
|
+
* performance); replay = analytics + 8 (measure content performance); marketing = 1 + 4 (select
|
|
21
|
+
* personalised ads). Returns undefined when the framework says GDPR does not apply (no signal).
|
|
22
|
+
*/
|
|
23
|
+
declare function tcfToConsent(d: TCData): Update | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Consent Mode v2 states -> Lucida categories. analytics_storage drives analytics and replay (no
|
|
26
|
+
* dedicated signal for replay); ad_storage + ad_user_data drive marketing. Only keys present in
|
|
27
|
+
* the update are mapped.
|
|
28
|
+
*/
|
|
29
|
+
declare function gcmToConsent(s: Record<string, unknown>): Update;
|
|
30
|
+
/** OneTrust active groups (`,C0001,C0002,` string or array) -> categories: C0002 (performance) = analytics + replay, C0004 (targeting) = marketing. */
|
|
31
|
+
declare function oneTrustToConsent(groups: string | string[]): Update;
|
|
32
|
+
/** Cookiebot consent object: statistics = analytics + replay, marketing = marketing. */
|
|
33
|
+
declare function cookiebotToConsent(c: {
|
|
34
|
+
statistics?: boolean;
|
|
35
|
+
marketing?: boolean;
|
|
36
|
+
}): Update;
|
|
37
|
+
/** Follow an IAB TCF v2.2 CMP (`window.__tcfapi`); waits up to 10 s for the CMP to appear. */
|
|
38
|
+
declare const tcfConsent: Module;
|
|
39
|
+
/** Follow Google Consent Mode v2: `gtag('consent', 'default'|'update', {...})` entries on dataLayer. */
|
|
40
|
+
declare const gcmConsent: Module;
|
|
41
|
+
/** Follow OneTrust: `OnetrustActiveGroups` now, and the `OneTrustGroupsUpdated` window event. */
|
|
42
|
+
declare const oneTrustConsent: Module;
|
|
43
|
+
/** Follow Cookiebot: `Cookiebot.consent` once the visitor has answered, then its accept/decline events. */
|
|
44
|
+
declare const cookiebotConsent: Module;
|
|
45
|
+
type OsanoConsent = Record<string, string | undefined>;
|
|
46
|
+
/** Osano consent (`ANALYTICS` / `MARKETING`: "ACCEPT" | "DENY"): analytics = analytics + replay, marketing = marketing. */
|
|
47
|
+
declare function osanoToConsent(c: OsanoConsent): Update;
|
|
48
|
+
/** Follow Osano (`Osano.cm`): its current consent once loaded, then its consent events. */
|
|
49
|
+
declare const osanoConsent: Module;
|
|
50
|
+
interface UcService {
|
|
51
|
+
name: string;
|
|
52
|
+
categorySlug?: string;
|
|
53
|
+
consent?: {
|
|
54
|
+
status?: boolean;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Usercentrics services -> categories: the service named `serviceName` (add Lucida as a service in Usercentrics)
|
|
59
|
+
* drives analytics + replay; marketing needs every service in the `marketing` category. Undefined when the
|
|
60
|
+
* service is not listed (no signal).
|
|
61
|
+
*/
|
|
62
|
+
declare function usercentricsToConsent(services: readonly UcService[], serviceName?: string): Update | undefined;
|
|
63
|
+
/** Follow Usercentrics (v2 `UC_UI` API) for the given service name; re-reads on its window events. */
|
|
64
|
+
declare function usercentricsBridge(serviceName?: string): Module;
|
|
65
|
+
/** Usercentrics bridge for a service named "Lucida". */
|
|
66
|
+
declare const usercentricsConsent: Module;
|
|
67
|
+
|
|
68
|
+
/** Registers `client.consent.showBanner()`. The banner itself is a separate chunk, fetched on the first call. */
|
|
69
|
+
declare const consentBanner: Module;
|
|
70
|
+
|
|
71
|
+
declare const CONSENT_EVENT = "$consent_updated";
|
|
72
|
+
/**
|
|
73
|
+
* Apply a consent decision and write the consent-log record `$consent_updated` { categories, source, version }.
|
|
74
|
+
* The record travels like any event, so it is sent only once analytics consent exists. A visitor who declines
|
|
75
|
+
* analytics produces no record unless the page opted in with `consent.logBeacon`: then one anonymous event
|
|
76
|
+
* (no distinct id, no session, no URL, no storage) is POSTed to /v1/batch, carrying only the decision.
|
|
77
|
+
* `onlyIfChanged` (CMP bridges, which re-announce unchanged state) skips the record when nothing changed.
|
|
78
|
+
*/
|
|
79
|
+
declare function applyConsent(host: Host, update: Partial<ConsentState>, source: ConsentSource, opts?: {
|
|
80
|
+
version?: string;
|
|
81
|
+
onlyIfChanged?: boolean;
|
|
82
|
+
}): void;
|
|
83
|
+
|
|
84
|
+
export { CONSENT_EVENT, ConsentSource, type UcService, applyConsent, consentBanner, cookiebotConsent, cookiebotToConsent, gcmConsent, gcmToConsent, oneTrustConsent, oneTrustToConsent, osanoConsent, osanoToConsent, tcfConsent, tcfToConsent, usercentricsBridge, usercentricsConsent, usercentricsToConsent };
|
package/dist/consent.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as w,b as i}from"./chunk-GVYMMTQM.js";import"./chunk-MI35SSIT.js";function p(t){if(t.gdprApplies===!1)return;let n=t.purpose?.consents??{},o=!!n[1]&&!!n[7];return{analytics:o,replay:o&&!!n[8],marketing:!!n[1]&&!!n[4]}}function l(t){let n=a=>a in t?t[a]==="granted":void 0,o={},r=n("analytics_storage");r!==void 0&&(o.analytics=o.replay=r);let e=n("ad_storage"),s=n("ad_user_data");return e!==void 0&&(o.marketing=e&&s!==!1),o}function C(t){let n=typeof t=="string"?t.split(","):t,o=n.includes("C0002");return{analytics:o,replay:o,marketing:n.includes("C0004")}}function g(t){return{analytics:!!t.statistics,replay:!!t.statistics,marketing:!!t.marketing}}var b=t=>{let n,r=u(()=>{let e=window.__tcfapi;return typeof e!="function"?!1:(e("addEventListener",2,(s,a)=>{if(!a||s.eventStatus!=="tcloaded"&&s.eventStatus!=="useractioncomplete")return;n=s.listenerId;let c=p(s);c&&i(t,c,"tcf",{onlyIfChanged:!0})}),!0)});return()=>{r();let e=window.__tcfapi;n!==void 0&&typeof e=="function"&&e("removeEventListener",2,()=>{},n)}},T=t=>{let n=window,o=n.dataLayer??=[],r=s=>{let a=s;a&&typeof a=="object"&&a[0]==="consent"&&(a[1]==="default"||a[1]==="update")&&a[2]&&typeof a[2]=="object"&&i(t,l(a[2]),"gcm",{onlyIfChanged:!0})};o.forEach(r);let e=o.push;return o.push=function(...s){return s.forEach(r),e.apply(this,s)},()=>{o.push=e}},k=t=>{let n=e=>{(typeof e=="string"||Array.isArray(e))&&i(t,C(e),"onetrust",{onlyIfChanged:!0})},o=window,r=e=>n(e.detail??o.OnetrustActiveGroups);return window.addEventListener("OneTrustGroupsUpdated",r),n(o.OnetrustActiveGroups),()=>window.removeEventListener("OneTrustGroupsUpdated",r)},E=t=>{let n=window,o=()=>{let e=n.Cookiebot;e?.consent&&e.hasResponse!==!1&&i(t,g(e.consent),"cookiebot",{onlyIfChanged:!0})},r=["CookiebotOnConsentReady","CookiebotOnAccept","CookiebotOnDecline"];for(let e of r)window.addEventListener(e,o);return o(),()=>r.forEach(e=>window.removeEventListener(e,o))};function m(t){let n=t.ANALYTICS==="ACCEPT";return{analytics:n,replay:n,marketing:t.MARKETING==="ACCEPT"}}function u(t){if(t())return()=>{};let n=0,o=setInterval(()=>(t()||++n>40)&&clearInterval(o),250);return()=>clearInterval(o)}var d=["osano-cm-initialized","osano-cm-consent-saved","osano-cm-consent-changed"],h=t=>{let n,o=e=>{let s=e&&typeof e=="object"&&Object.keys(e).length?e:n?.getConsent?.();s&&Object.keys(s).length&&i(t,m(s),"osano",{onlyIfChanged:!0})},r=u(()=>{if(n=window.Osano?.cm,!n)return!1;for(let e of d)n.addEventListener?.(e,o);return o(n.getConsent?.()),!0});return()=>{r();for(let e of d)n?.removeEventListener?.(e,o)}};function v(t,n="Lucida"){let o=t.find(s=>s.name.toLowerCase()===n.toLowerCase());if(!o)return;let r=o.consent?.status===!0,e=t.filter(s=>s.categorySlug==="marketing");return{analytics:r,replay:r,marketing:e.length>0&&e.every(s=>s.consent?.status===!0)}}var f=["UC_UI_INITIALIZED","UC_UI_CMP_EVENT","ucEvent","UC_CONSENT"];function y(t="Lucida"){return n=>{let o=()=>{let a=window.UC_UI?.getServicesBaseInfo?.();if(!a)return!1;let c=v(a,t);return c?i(n,c,"usercentrics",{onlyIfChanged:!0}):n.log(`usercentrics: no service named "${t}"; consent left unchanged`),!0},r=()=>{o()};for(let s of f)window.addEventListener(s,r);let e=u(o);return()=>{e();for(let s of f)window.removeEventListener(s,r)}}}var O=y();var U=t=>{t.consentUi={showBanner:async n=>(await import("./banner-CGEWCIGP.js")).showBanner(t,n),hideBanner:()=>{import("./banner-CGEWCIGP.js").then(n=>n.hideBanner())}}};export{w as CONSENT_EVENT,i as applyConsent,U as consentBanner,E as cookiebotConsent,g as cookiebotToConsent,T as gcmConsent,l as gcmToConsent,k as oneTrustConsent,C as oneTrustToConsent,h as osanoConsent,m as osanoToConsent,b as tcfConsent,p as tcfToConsent,y as usercentricsBridge,O as usercentricsConsent,v as usercentricsToConsent};
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { B as BrowserConfig, C as Client } from './types-BWd9sbCh.js';
|
|
2
|
+
export { F as FlagValue, H as Host, M as Module, P as Persistence } from './types-BWd9sbCh.js';
|
|
3
|
+
export { c as createClient } from './client-ts5YMCoB.js';
|
|
4
|
+
import '@lucida-analytics/sdk-core';
|
|
5
|
+
|
|
6
|
+
/** Core-only client: capture, identity, sessions, consent, transport. No autocapture, no flags. */
|
|
7
|
+
declare function init(apiKey: string, config?: BrowserConfig): Client;
|
|
8
|
+
|
|
9
|
+
export { BrowserConfig, Client, init };
|
package/dist/core.js
ADDED
|
@@ -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,15 @@
|
|
|
1
|
+
import { M as Module } from './types-BWd9sbCh.js';
|
|
2
|
+
import '@lucida-analytics/sdk-core';
|
|
3
|
+
|
|
4
|
+
/** Merge `lucida.session_id=<id>` into an existing W3C baggage header, replacing a stale entry. */
|
|
5
|
+
declare function withBaggage(existing: string | null | undefined, sessionId: string): string;
|
|
6
|
+
/** Same-origin always; other origins only when listed (exact origin string or RegExp on the URL). */
|
|
7
|
+
declare function correlatable(url: string, allow?: Array<string | RegExp>): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Watchtower seam (docs/seam/watchtower.md): with `watchtower.correlate = true`, same-origin and
|
|
10
|
+
* allowlisted fetch/XHR requests carry `baggage: lucida.session_id=<id>` so Watchtower links its
|
|
11
|
+
* spans and errors to the Lucida session. Lucida's own ingest host is never touched.
|
|
12
|
+
*/
|
|
13
|
+
declare const correlate: Module;
|
|
14
|
+
|
|
15
|
+
export { correlatable, correlate, withBaggage };
|
|
@@ -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,12 @@
|
|
|
1
|
+
import { M as Module } from './types-BWd9sbCh.js';
|
|
2
|
+
import '@lucida-analytics/sdk-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Early-access module (LC-FLG-12): `client.earlyAccess.list()` reads GET /v1/early-access (public key) and marks
|
|
6
|
+
* what this browser opted in to; `optIn/optOut` emit `$early_access_opt_in` with the `$feature_enrollment/<key>`
|
|
7
|
+
* person property the flag's release condition matches on, then reload flags. Enrolment is remembered in
|
|
8
|
+
* consent-gated storage.
|
|
9
|
+
*/
|
|
10
|
+
declare const earlyAccess: Module;
|
|
11
|
+
|
|
12
|
+
export { earlyAccess };
|
|
@@ -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,199 @@
|
|
|
1
|
+
import { M as Module } from './types-BWd9sbCh.js';
|
|
2
|
+
import '@lucida-analytics/sdk-core';
|
|
3
|
+
|
|
4
|
+
/** One visual-editor change against a CSS selector (stored as JSON on the variant payload). `url`
|
|
5
|
+
* (contains) limits it to some pages, so one variant can change several pages (multipage, LC-EXT-33). */
|
|
6
|
+
type Change = {
|
|
7
|
+
url?: string;
|
|
8
|
+
} & ({
|
|
9
|
+
selector: string;
|
|
10
|
+
type: "text";
|
|
11
|
+
value: string;
|
|
12
|
+
} | {
|
|
13
|
+
selector: string;
|
|
14
|
+
type: "attr";
|
|
15
|
+
name: string;
|
|
16
|
+
value: string | null;
|
|
17
|
+
} | {
|
|
18
|
+
selector: string;
|
|
19
|
+
type: "style";
|
|
20
|
+
styles: Record<string, string>;
|
|
21
|
+
} | {
|
|
22
|
+
selector: string;
|
|
23
|
+
type: "hide";
|
|
24
|
+
}
|
|
25
|
+
/** Move the element to child position `index` of its parent. */
|
|
26
|
+
| {
|
|
27
|
+
selector: string;
|
|
28
|
+
type: "reorder";
|
|
29
|
+
index: number;
|
|
30
|
+
}
|
|
31
|
+
/** Insert sanitized HTML relative to the element (see sanitize.ts); applied once per element. Served only with `approved`. */
|
|
32
|
+
| {
|
|
33
|
+
selector: string;
|
|
34
|
+
type: "insert";
|
|
35
|
+
position: InsertPosition;
|
|
36
|
+
html: string;
|
|
37
|
+
approved?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Swap an image (an uploaded asset or any http(s) URL). */
|
|
40
|
+
| {
|
|
41
|
+
selector: string;
|
|
42
|
+
type: "image";
|
|
43
|
+
src: string;
|
|
44
|
+
srcset?: string;
|
|
45
|
+
alt?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Page-level custom CSS (added once, with the configured CSP nonce). Served only with `approved`. */
|
|
48
|
+
| {
|
|
49
|
+
selector?: string;
|
|
50
|
+
type: "css";
|
|
51
|
+
css: string;
|
|
52
|
+
approved?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Page-level custom JS: runs only when the server stamped `approved: true` (the project's
|
|
56
|
+
* `experiment.custom_code` approval) AND the site opted in with `visualChanges.allowCustomJs`.
|
|
57
|
+
*/
|
|
58
|
+
| {
|
|
59
|
+
selector?: string;
|
|
60
|
+
type: "js";
|
|
61
|
+
js: string;
|
|
62
|
+
approved?: boolean;
|
|
63
|
+
});
|
|
64
|
+
type InsertPosition = "before" | "after" | "prepend" | "append";
|
|
65
|
+
/** Options for {@link applyChanges}. */
|
|
66
|
+
interface ApplyOptions {
|
|
67
|
+
/** CSP nonce for injected `<style>` / `<script>` elements. */
|
|
68
|
+
nonce?: string | undefined;
|
|
69
|
+
/** Run approved `js` changes (default false). */
|
|
70
|
+
allowJs?: boolean | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Serving path: page CSS, inserted HTML and JS run only with the server's approval stamp (`approved: true`,
|
|
73
|
+
* set when the project's `experiment.custom_code` policy allows or an approver approved the code). The
|
|
74
|
+
* visual editor previews its own unsaved changes without it.
|
|
75
|
+
*/
|
|
76
|
+
requireApproval?: boolean | undefined;
|
|
77
|
+
}
|
|
78
|
+
/** Payload key holding the change list on a flag / variant payload. */
|
|
79
|
+
declare const CHANGES_KEY = "lc_changes";
|
|
80
|
+
/** Attribute marking DOM the SDK inserted for a change (idempotent re-apply, editor clean-up). */
|
|
81
|
+
declare const CHANGE_MARKER = "data-lc-change";
|
|
82
|
+
/** Stable short id of a change's content (djb2), used as its DOM marker. */
|
|
83
|
+
declare function changeId(c: Change): string;
|
|
84
|
+
/** Pull a well-formed change list out of a flag payload (anything else yields []); with `href`, only the changes for that page. */
|
|
85
|
+
declare function changesOf(payload: unknown, href?: string): Change[];
|
|
86
|
+
/**
|
|
87
|
+
* Apply `changes` under `root`. Idempotent (re-applying yields the same DOM). Returns the changes whose
|
|
88
|
+
* selector matched nothing (yet) so the caller can retry as the page renders; a bad selector is skipped.
|
|
89
|
+
* Page-level `css` / `js` changes are added to `<head>` once; `js` needs `opts.allowJs` and server approval;
|
|
90
|
+
* with `opts.requireApproval` an unstamped css / insert / js change is refused outright.
|
|
91
|
+
*/
|
|
92
|
+
declare function applyChanges(changes: Change[], root?: ParentNode, opts?: ApplyOptions): Change[];
|
|
93
|
+
/** Remove what the SDK inserted for changes (inserted HTML, page CSS / JS elements): the editor's preview reset. */
|
|
94
|
+
declare function removeInserted(root?: ParentNode): void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Allowlist HTML sanitizer for visual-editor `insert` changes (P-H5). Parsing happens in an inert
|
|
98
|
+
* `<template>` (nothing runs, nothing loads); anything not explicitly allowed is dropped: scripts,
|
|
99
|
+
* styles, frames, embeds, forms and SVG with their content, unknown tags are unwrapped (children kept),
|
|
100
|
+
* event handlers and non-allowlisted attributes are removed, and URLs must be http(s), relative,
|
|
101
|
+
* mailto/tel (links) or a raster data:image (images).
|
|
102
|
+
*/
|
|
103
|
+
/** An image URL the SDK may load: http(s), protocol-relative, relative, or a raster data URL. */
|
|
104
|
+
declare function safeImageUrl(u: string): boolean;
|
|
105
|
+
/** Parse `html` inertly and return a sanitized fragment owned by `document`. */
|
|
106
|
+
declare function sanitizeHtml(html: string): DocumentFragment;
|
|
107
|
+
|
|
108
|
+
/** Payload key on a flag / variant payload: `{ "lc_split_url": { "url": "/pricing-b" } }`. */
|
|
109
|
+
declare const SPLIT_URL_KEY = "lc_split_url";
|
|
110
|
+
/** Marker added to the redirect target so the variant page never redirects again (loop guard). */
|
|
111
|
+
declare const SPLIT_MARKER = "__lc_split";
|
|
112
|
+
/** Redirect target for a payload, or null when it must not redirect (no url, same page, foreign origin, loop). */
|
|
113
|
+
declare function splitTarget(payload: unknown, flag: string, loc: URL, allowedOrigins?: string[]): URL | null;
|
|
114
|
+
/**
|
|
115
|
+
* Split-URL tests (LC-EXT-3). When an experiment flag's assigned variant carries `lc_split_url.url`, the
|
|
116
|
+
* visitor is sent to that URL with `location.replace` (no extra history entry), query and hash preserved.
|
|
117
|
+
* Reading the flag records `$exposure` first and the queue is flushed (bounded wait) before navigating.
|
|
118
|
+
* Config `splitUrl`: `antiFlickerMs` hides the page until flags resolve (default 0 = off), `allowedOrigins`
|
|
119
|
+
* lists extra origins a variant may live on (same-origin is always allowed), `navigate` replaces
|
|
120
|
+
* location.replace (tests). The target carries `__lc_split=<flag>`, which the variant page strips again.
|
|
121
|
+
*/
|
|
122
|
+
declare const splitUrl: Module;
|
|
123
|
+
|
|
124
|
+
/** Payload key holding a web experiment's activation trigger (N-EXP-6; validated by lc-experiment). */
|
|
125
|
+
declare const TRIGGER_KEY = "lc_trigger";
|
|
126
|
+
type TriggerCondition = {
|
|
127
|
+
type: "time_on_page";
|
|
128
|
+
seconds: number;
|
|
129
|
+
} | {
|
|
130
|
+
type: "time_in_session";
|
|
131
|
+
seconds: number;
|
|
132
|
+
} | {
|
|
133
|
+
type: "pages_viewed";
|
|
134
|
+
count: number;
|
|
135
|
+
} | {
|
|
136
|
+
type: "scroll";
|
|
137
|
+
percent: number;
|
|
138
|
+
} | {
|
|
139
|
+
type: "exit_intent";
|
|
140
|
+
} | {
|
|
141
|
+
type: "element_visible";
|
|
142
|
+
selector: string;
|
|
143
|
+
} | {
|
|
144
|
+
type: "custom_event";
|
|
145
|
+
event: string;
|
|
146
|
+
}
|
|
147
|
+
/** Waits for `lucida.activateExperiment(flagKey)`. */
|
|
148
|
+
| {
|
|
149
|
+
type: "manual";
|
|
150
|
+
} | TriggerGroup;
|
|
151
|
+
interface TriggerGroup {
|
|
152
|
+
op: "and" | "or";
|
|
153
|
+
conditions: TriggerCondition[];
|
|
154
|
+
/** The saved trigger it was copied from (informational). */
|
|
155
|
+
saved_id?: string;
|
|
156
|
+
}
|
|
157
|
+
/** What the browser knows when a trigger is evaluated. */
|
|
158
|
+
interface TriggerFacts {
|
|
159
|
+
/** ms on this page (SPA navigations start a new page). */
|
|
160
|
+
pageMs: number;
|
|
161
|
+
/** ms since the session started. */
|
|
162
|
+
sessionMs: number;
|
|
163
|
+
/** Pages viewed in this session, the current one included. */
|
|
164
|
+
pages: number;
|
|
165
|
+
/** Deepest scroll on this page, 0..100. */
|
|
166
|
+
scroll: number;
|
|
167
|
+
exit: boolean;
|
|
168
|
+
/** Whether an element matching the selector is (or was, on this page) in the viewport. */
|
|
169
|
+
visible: (selector: string) => boolean;
|
|
170
|
+
/** Events captured on this page. */
|
|
171
|
+
events: ReadonlySet<string>;
|
|
172
|
+
/** `activateExperiment` was called for this flag. */
|
|
173
|
+
manual: boolean;
|
|
174
|
+
}
|
|
175
|
+
/** The trigger of a flag payload, or undefined when it has none (or a malformed one). */
|
|
176
|
+
declare function triggerOf(payload: unknown): TriggerGroup | undefined;
|
|
177
|
+
/** Whether `t` holds for `f`. Unknown condition types never match (a newer server, an older SDK). */
|
|
178
|
+
declare function matches(t: TriggerCondition, f: TriggerFacts, depth?: number): boolean;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Visual-editor experiments and personalization (LC-EXT-16). A flag whose (variant) payload carries
|
|
182
|
+
* `lc_changes` has those DOM changes applied for the assigned value: an experiment flag by its
|
|
183
|
+
* variant payload, personalization by a plain flag whose release conditions target the audience.
|
|
184
|
+
* Changes whose selector is not rendered yet are retried on DOM mutations for 5 s. A change with a
|
|
185
|
+
* `url` applies only on matching pages (multipage tests); SPA page views re-apply the set.
|
|
186
|
+
* `visualChanges.antiFlickerMs` hides the page until flags resolve (or the timeout) to avoid a flash
|
|
187
|
+
* of the control; 0 (default) never hides it. Inserted HTML is sanitized; page CSS carries the CSP
|
|
188
|
+
* `nonce`; page CSS, inserted HTML and JS are served only with the server's approval stamp, and JS
|
|
189
|
+
* also needs `visualChanges.allowCustomJs`.
|
|
190
|
+
*
|
|
191
|
+
* Activation triggers (N-EXP-6): a payload with `lc_trigger` (on every variant, control included)
|
|
192
|
+
* defers both the changes and the `$exposure` until the trigger matches (time on page or in session,
|
|
193
|
+
* pages viewed, scroll depth, exit intent, an element in view, a custom event, `manual`, AND / OR).
|
|
194
|
+
* Once activated, the flag stays active for the session. `client.activateExperiment(flagKey)` forces
|
|
195
|
+
* activation (and re-applies the changes, for SPAs that re-render).
|
|
196
|
+
*/
|
|
197
|
+
declare const visualChanges: Module;
|
|
198
|
+
|
|
199
|
+
export { type ApplyOptions, CHANGES_KEY, CHANGE_MARKER, type Change, type InsertPosition, SPLIT_MARKER, SPLIT_URL_KEY, TRIGGER_KEY, type TriggerCondition, type TriggerFacts, type TriggerGroup, applyChanges, changeId, changesOf, removeInserted, safeImageUrl, sanitizeHtml, splitTarget, splitUrl, matches as triggerMatches, triggerOf, visualChanges };
|
|
@@ -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};
|
package/dist/flags.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { M as Module } from './types-BWd9sbCh.js';
|
|
2
|
+
import '@lucida-analytics/sdk-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Flags module: values come from bootstrap, then the last cached response, then POST /v1/flags
|
|
6
|
+
* (re-fetched on identify/reset/group). $feature_flag_called fires once per (flag, value, session).
|
|
7
|
+
* In opt_in mode nothing is fetched or cached before consent. A QA link (`?lc_preview=flag:variant`,
|
|
8
|
+
* LC-EXT-34) asks the gateway for that variant and its payload; previewed flags record no exposure.
|
|
9
|
+
* `flagOptions.disableRemote` never requests flags; `disableFlagsOnFirstLoad` skips only the request at init.
|
|
10
|
+
*/
|
|
11
|
+
declare const flags: Module;
|
|
12
|
+
|
|
13
|
+
export { flags };
|