@lucida-analytics/browser 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +7 -3
  2. package/dist/autocapture.d.ts +1 -1
  3. package/dist/autocapture.js +1 -1
  4. package/dist/{banner-CGEWCIGP.js → banner-2TSKJ4WK.js} +1 -1
  5. package/dist/{static/v0.1.0/chunk-GVYMMTQM.js → chunk-32K5P5GN.js} +1 -1
  6. package/dist/{static/v0.1.0/chunk-MCWQHOEV.js → chunk-FUE3SDQU.js} +1 -1
  7. package/dist/chunk-NIDQQHZJ.js +1 -0
  8. package/dist/chunk-O4W7SZ2X.js +1 -0
  9. package/dist/{client-ts5YMCoB.d.ts → client-BUpBXyOh.d.ts} +3 -3
  10. package/dist/consent.d.ts +14 -3
  11. package/dist/consent.js +1 -1
  12. package/dist/core.d.ts +3 -3
  13. package/dist/core.js +3 -3
  14. package/dist/correlate.d.ts +1 -1
  15. package/dist/early-access.d.ts +1 -1
  16. package/dist/experiments.d.ts +1 -1
  17. package/dist/flags.d.ts +1 -1
  18. package/dist/flags.js +2 -2
  19. package/dist/forms.d.ts +1 -1
  20. package/dist/forms.js +1 -1
  21. package/dist/guides.d.ts +41 -3
  22. package/dist/guides.js +1 -1
  23. package/dist/heatmaps.d.ts +4 -2
  24. package/dist/heatmaps.js +1 -1
  25. package/dist/host-headers.d.ts +1 -1
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +2 -2
  28. package/dist/inspector.d.ts +1 -1
  29. package/dist/lucida.js +2 -2
  30. package/dist/{persistent-XLGNSZQR.js → persistent-SLVINN5A.js} +1 -1
  31. package/dist/recommendations.d.ts +1 -1
  32. package/dist/recorder-3YIZ6OKD.js +78 -0
  33. package/dist/replay.d.ts +2 -2
  34. package/dist/replay.js +1 -1
  35. package/dist/static/v0/autocapture.js +1 -1
  36. package/dist/static/v0/{banner-CGEWCIGP.js → banner-2TSKJ4WK.js} +1 -1
  37. package/dist/{chunk-GVYMMTQM.js → static/v0/chunk-32K5P5GN.js} +1 -1
  38. package/dist/{chunk-MCWQHOEV.js → static/v0/chunk-FUE3SDQU.js} +1 -1
  39. package/dist/static/v0/chunk-NIDQQHZJ.js +1 -0
  40. package/dist/static/v0/chunk-O4W7SZ2X.js +1 -0
  41. package/dist/static/v0/consent.js +1 -1
  42. package/dist/static/v0/core.js +3 -3
  43. package/dist/static/v0/flags.js +2 -2
  44. package/dist/static/v0/forms.js +1 -1
  45. package/dist/static/v0/guides.js +1 -1
  46. package/dist/static/v0/heatmaps.js +1 -1
  47. package/dist/static/v0/index.js +2 -2
  48. package/dist/static/v0/lucida.js +2 -2
  49. package/dist/static/v0/{persistent-XLGNSZQR.js → persistent-SLVINN5A.js} +1 -1
  50. package/dist/static/v0/recorder-3YIZ6OKD.js +78 -0
  51. package/dist/static/v0/replay.js +1 -1
  52. package/dist/static/v0/toolbar.js +4 -4
  53. package/dist/static/v0/{validation-ENITEP6V.js → validation-HGJXZ553.js} +1 -1
  54. package/dist/static/v0.1.1/autocapture.js +1 -0
  55. package/dist/static/{v0.1.0/banner-CGEWCIGP.js → v0.1.1/banner-2TSKJ4WK.js} +1 -1
  56. package/dist/static/{v0/chunk-GVYMMTQM.js → v0.1.1/chunk-32K5P5GN.js} +1 -1
  57. package/dist/static/{v0/chunk-MCWQHOEV.js → v0.1.1/chunk-FUE3SDQU.js} +1 -1
  58. package/dist/static/v0.1.1/chunk-NIDQQHZJ.js +1 -0
  59. package/dist/static/v0.1.1/chunk-O4W7SZ2X.js +1 -0
  60. package/dist/static/v0.1.1/consent.js +1 -0
  61. package/dist/static/v0.1.1/core.js +3 -0
  62. package/dist/static/v0.1.1/flags.js +3 -0
  63. package/dist/static/{v0.1.0 → v0.1.1}/forms.js +1 -1
  64. package/dist/static/v0.1.1/guides.js +1 -0
  65. package/dist/static/{v0.1.0 → v0.1.1}/heatmaps.js +1 -1
  66. package/dist/static/v0.1.1/index.js +3 -0
  67. package/dist/static/v0.1.1/integrity.json +30 -0
  68. package/dist/static/v0.1.1/lucida.js +3 -0
  69. package/dist/static/{v0.1.0/persistent-XLGNSZQR.js → v0.1.1/persistent-SLVINN5A.js} +1 -1
  70. package/dist/static/v0.1.1/recorder-3YIZ6OKD.js +78 -0
  71. package/dist/static/v0.1.1/replay.js +1 -0
  72. package/dist/static/v0.1.1/toolbar.js +4 -0
  73. package/dist/static/{v0.1.0/validation-ENITEP6V.js → v0.1.1/validation-HGJXZ553.js} +1 -1
  74. package/dist/toolbar.d.ts +1 -1
  75. package/dist/toolbar.js +4 -4
  76. package/dist/{types-Cv4pBbPu.d.ts → types-BtvrrgrR.d.ts} +38 -4
  77. package/dist/{types-BWd9sbCh.d.ts → types-CLEZS45j.d.ts} +42 -4
  78. package/dist/{validation-ENITEP6V.js → validation-HGJXZ553.js} +1 -1
  79. package/dist/webmcp.d.ts +1 -1
  80. package/package.json +2 -2
  81. package/dist/chunk-3PWTJFHH.js +0 -1
  82. package/dist/chunk-MI35SSIT.js +0 -1
  83. package/dist/recorder-LFUTDRP4.js +0 -78
  84. package/dist/static/v0/chunk-3PWTJFHH.js +0 -1
  85. package/dist/static/v0/chunk-MI35SSIT.js +0 -1
  86. package/dist/static/v0/recorder-LFUTDRP4.js +0 -78
  87. package/dist/static/v0.1.0/autocapture.js +0 -1
  88. package/dist/static/v0.1.0/chunk-3PWTJFHH.js +0 -1
  89. package/dist/static/v0.1.0/chunk-MI35SSIT.js +0 -1
  90. package/dist/static/v0.1.0/consent.js +0 -1
  91. package/dist/static/v0.1.0/core.js +0 -3
  92. package/dist/static/v0.1.0/flags.js +0 -3
  93. package/dist/static/v0.1.0/guides.js +0 -1
  94. package/dist/static/v0.1.0/index.js +0 -3
  95. package/dist/static/v0.1.0/integrity.json +0 -30
  96. package/dist/static/v0.1.0/lucida.js +0 -3
  97. package/dist/static/v0.1.0/recorder-LFUTDRP4.js +0 -78
  98. package/dist/static/v0.1.0/replay.js +0 -1
  99. package/dist/static/v0.1.0/toolbar.js +0 -4
  100. /package/dist/static/{v0.1.0 → v0.1.1}/chunk-AWIQCFGN.js +0 -0
  101. /package/dist/static/{v0.1.0 → v0.1.1}/correlate.js +0 -0
  102. /package/dist/static/{v0.1.0 → v0.1.1}/early-access.js +0 -0
  103. /package/dist/static/{v0.1.0 → v0.1.1}/experiments.js +0 -0
  104. /package/dist/static/{v0.1.0 → v0.1.1}/host-headers.js +0 -0
  105. /package/dist/static/{v0.1.0 → v0.1.1}/inspector.js +0 -0
  106. /package/dist/static/{v0.1.0 → v0.1.1}/modules-FANMZRDJ.js +0 -0
  107. /package/dist/static/{v0.1.0 → v0.1.1}/recommendations.js +0 -0
  108. /package/dist/static/{v0.1.0 → v0.1.1}/webmcp.js +0 -0
@@ -0,0 +1 @@
1
+ import{d as c}from"./chunk-O4W7SZ2X.js";function d(e){return e.startsWith("re:")?e.slice(3):e.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}function y(e,t){return!!e?.some(r=>{try{return new RegExp(d(r),"i").test(t)}catch{return!1}})}function T(e,t){return e===!1||!e&&!t?null:{fps:_(e?e.fps??2:2,1,15),quality:_(e?e.quality??.4:.4,.05,1)}}var _=(e,t,r)=>Math.min(r,Math.max(t,e)),C=1e7;function G(e,t){if(t?.session_recording===!1)return null;let r=t?.replay??{},n=(l,i)=>e[l]??r[l]??i,a=[...r.mask_selectors??[],...t?.replay_mask_selectors??[],...e.mask_selectors??[]];return{sample_rate:e.sample_rate??r.sample_rate??t?.replay_sample_rate??1,min_duration_ms:e.min_duration_ms??r.min_duration_ms??t?.replay_min_duration_ms??0,min_duration_mode:e.min_duration_mode??r.min_duration_mode??t?.replay_min_duration_mode??"buffer",trigger:n("trigger",{mode:"always"}),trigger_groups:e.trigger_groups??r.trigger_groups??t?.replay_trigger_groups??[],include_urls:n("include_urls",[]),exclude_urls:[...n("exclude_urls",[]),...(t?.replay_url_blocklist??[]).map(d)],block_selectors:[...r.block_selectors??[],...t?.replay_block_selectors??[],...e.block_selectors??[]],mask_selectors:a,mask_all_inputs:e.mask_all_inputs??(t?.mask_all_inputs===!0||r.mask_all_inputs!==!1),mask_all_text:e.mask_all_text===!0||t?.replay_mask_all_text===!0||r.mask_all_text===!0||a.includes("*"),unmask_selectors:[...e.unmask_selectors??[]],url_privacy_rules:[...Array.isArray(t?.replay_url_privacy_rules)?t?.replay_url_privacy_rules:[],...e.url_privacy_rules??[]],buffer_ms:n("buffer_ms",6e4),flush_interval_ms:n("flush_interval_ms",5e3),idle_threshold_ms:Math.max(0,n("idle_threshold_ms",5*6e4)),chunk_bytes:Math.min(n("chunk_bytes",256*1024),C-16384),canvas:T(e.captureCanvas,t?.replay_capture_canvas===!0),maskInputOptions:e.maskInputOptions,maskInputFn:e.maskInputFn,maskTextFn:e.maskTextFn,maskUrlFn:e.maskUrlFn,crossOriginIframes:e.crossOriginIframes?.allowedOrigins.length?[...e.crossOriginIframes.allowedOrigins]:null,canvasMaskRegions:e.canvasMaskRegions,canvasMask:(Array.isArray(t?.replay_canvas_mask)?t.replay_canvas_mask:[]).filter(l=>typeof l?.selector=="string"),mutationThrottle:e.mutationThrottle===!1?null:{...e.mutationThrottle},assets:e.assets}}var f=(e,t)=>e.some(r=>{try{return new RegExp(r).test(t)}catch{return!1}});function I(e,t,r){return!f(r,e)&&(!t.length||f(t,e))}function E(e){return e==="watchtower"?!1:e?!0:globalThis.__WATCHTOWER__?.replayActive!==!0}function w(e){let t=2166136261;for(let r of new TextEncoder().encode(e))t^=r,t=Math.imul(t,16777619)>>>0;return t>>>0}function M(e,t,r){return w(`${e}:${t}`)/4294967296<r}var O=(e,t)=>{let r=t[e.key];return e.variant===void 0?r!==void 0&&r!==!1&&r!=="false":r===e.variant},v=e=>!!e.events?.length||!!e.event_filters?.length;function A(e,t,r){return e.events?.includes(t)?!0:!!e.event_filters?.some(n=>n.event===t&&(n.properties??[]).every(a=>c(a.op,r?.[a.key],!!r&&Object.hasOwn(r,a.key),a.value,!1)))}var F=(e,t)=>e.flatMap(r=>{try{return[new RegExp(r)]}catch{return t("bad url pattern",r),[]}});function k(e){let t=[];return e.urls.length&&t.push(e.url),v(e.g)&&t.push(e.event),e.g.flag&&t.push(e.flag),t.length?e.g.match==="all"?t.every(Boolean):t.some(Boolean):!0}function U(e,t,r,n,a={}){let l=t.map(s=>({g:s,urls:F(s.url_patterns??[],e.log),url:!!a.url,event:!!a.event,flag:!!a.flag})),i=!1,m=!1,p=()=>{if(!(i||m)){for(let s of l)if(k(s)&&(a.sampling||M(r(),s.g.id,s.g.sample_rate??1))){i=!0,n(s.g);return}}};e.onCapture(s=>{let u=!1;for(let o of l)!o.event&&A(o.g,s.event,s.properties)&&(u=o.event=!0);u&&p()});let h=s=>{let u=!1;for(let o of l)o.g.flag&&!o.flag&&O(o.g.flag,s)&&(u=o.flag=!0);u&&p()},x=e.flags?.onChange(h),g=(s,u)=>l.some(s)?l.some(o=>s(o)&&u(o))?"activated":"pending":"disabled";return{checkUrl(s){let u=!1;for(let o of l)!o.url&&o.urls.some(R=>R.test(s))&&(u=o.url=!0);u&&p()},check:p,stop(){m=!0,x?.()},matched:()=>l.filter(k).map(s=>s.g.id),states:()=>({url:g(s=>s.urls.length>0,s=>s.url),event:g(s=>v(s.g),s=>s.event),flag:g(s=>!!s.g.flag,s=>s.flag)})}}var b=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!==""):[];function j(e){return Array.isArray(e)?e.filter(t=>!!t&&typeof t=="object"&&typeof t.url=="string").map(t=>({url:t.url,mask_all_text:t.mask_all_text===!0,mask_selectors:b(t.mask_selectors),block_selectors:b(t.block_selectors)})):[]}function K(e,t){let r=e.filter(i=>y([i.url],t)),n=r.some(i=>i.mask_all_text===!0),a=[...new Set(r.flatMap(i=>i.mask_selectors??[]))],l=[...new Set(r.flatMap(i=>i.block_selectors??[]))];return{maskAllText:n,mask:a,block:l,key:JSON.stringify([n,a,l])}}export{y as a,C as b,G as c,I as d,E as e,w as f,M as g,U as h,j as i,K as j};
@@ -0,0 +1 @@
1
+ var d=0,m=0;function x(e){let n=new Uint8Array(e),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(n);else for(let r=0;r<e;r++)n[r]=Math.floor(Math.random()*256);return n}function O(e=Date.now()){if(e>d){d=e;let s=x(2);m=((s[0]??0)<<8|(s[1]??0))&1023}else m++,m>4095&&(d++,m=0);let n=x(8),t=new Uint8Array(16),r=d;t[0]=Math.floor(r/2**40)&255,t[1]=Math.floor(r/2**32)&255,t[2]=Math.floor(r/2**24)&255,t[3]=Math.floor(r/2**16)&255,t[4]=Math.floor(r/2**8)&255,t[5]=r&255,t[6]=112|m>>8,t[7]=m&255,t[8]=128|(n[0]??0)&63;for(let s=1;s<8;s++)t[8+s]=n[s]??0;let o=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}function R(e,n={}){let t=Math.min(n.maxMs??3e4,(n.baseMs??1e3)*2**e);return Math.round(t*(.5+.5*(n.random??Math.random)()))}function w(e){return e===0||e===408||e===429||e>=500}var M=/^(0|[1-9]\d{0,2})$/,T=/^[0-9a-fA-F]{1,4}$/,V=/^(0|[1-9]\d*)$/;function h(e){let n=e.split(".");if(n.length!==4)return;let t=[];for(let r of n){if(!M.test(r)||Number(r)>255)return;t.push(Number(r))}return t}function N(e){if(e.includes("%"))return;let n=e,t=e.lastIndexOf(":"),r=e.slice(t+1);if(r.includes(".")){let f=h(r);if(!f)return;n=`${e.slice(0,t+1)}${(f[0]<<8|f[1]).toString(16)}:${(f[2]<<8|f[3]).toString(16)}`}let o=n.split("::");if(o.length>2)return;let s=f=>{if(f==="")return[];let c=[];for(let _ of f.split(":")){if(!T.test(_))return;c.push(parseInt(_,16))}return c},i=s(o[0]),a=o.length===2?s(o[1]):[];if(!i||!a)return;let u=i.length+a.length;return(o.length===2?u>7:u!==8)?void 0:[...i,...Array(8-u).fill(0),...a].flatMap(f=>[f>>8,f&255])}function S(e){return e.includes(":")?N(e):h(e)}var j=e=>e.length===16&&e.slice(0,10).every(n=>n===0)&&e[10]===255&&e[11]===255;function k(e){if(typeof e!="string")return;let n=S(e.trim());return n&&j(n)?n.slice(12):n}function q(e){let n=typeof e=="string"?[e]:Array.isArray(e)?e:[],t=[];for(let r of n){if(typeof r!="string")continue;let o=r.trim(),s=o.indexOf("/");if(s<0){let u=k(o);u&&t.push({bytes:u,bits:u.length*8});continue}let i=S(o.slice(0,s)),a=o.slice(s+1);!i||!V.test(a)||Number(a)>i.length*8||t.push({bytes:i,bits:Number(a)})}return t}function I(e,n){if(e.bytes.length!==n.length)return!1;for(let t=0;t<e.bits;t+=8){let o=255<<8-Math.min(8,e.bits-t)&255,s=t/8;if((e.bytes[s]&o)!==(n[s]&o))return!1}return!0}function v(e,n,t,r){switch(e){case"array_contains_any":case"array_contains_all":case"array_contains_none":{if(!Array.isArray(n)||!Array.isArray(t))return!1;let o=t.filter(s=>n.some(i=>r(i,s))).length;return e==="array_contains_any"?o>0:e==="array_contains_all"?o===t.length:o===0}case"ip_in_cidr":case"ip_not_in_cidr":{let o=k(n),s=q(t);return!o||!s.length?!1:s.some(i=>I(i,o))===(e==="ip_in_cidr")}}return!1}var P=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,A=/^\d{4}-\d{2}-\d{2}$/,$=/^-?(\d{1,6})([hdwmy])$/,H={h:3600,d:86400,w:604800,m:2592e3,y:31536e3};function D(e){let n=$.exec(e.trim());return n?Number(n[1])*H[n[2]]:void 0}function E(e,n,t){if(typeof e=="number")return e*1e3;if(typeof e!="string")return;let r=e.trim();if(t){let s=D(r);if(s!==void 0)return n-s*1e3}if(!P.test(r)&&!A.test(r))return;let o=Date.parse(A.test(r)?`${r}T00:00:00Z`:r);return Number.isNaN(o)?void 0:o}function F(e,n){for(let t=0;t<Math.max(e.length,n.length);t++){let r=e[t]??0,o=n[t]??0;if(r!==o)return r<o?-1:1}return 0}function L(e,n,t){if(typeof n!="string")return;let r=n.trim().replace(/^v/,"").split(".");if(e==="semver_wildcard"){let l=r[r.length-1];if(l!=="*"&&l!=="x"&&l!=="X")return;if(r.length===1)return[[0],[2**30]];let f=t.parseVersion(r.slice(0,-1).join("."));if(!f)return;let c=[...f];return c[c.length-1]=c[c.length-1]+1,[f,c]}let o=t.parseVersion(n);if(!o)return;for(;o.length<3;)o.push(0);let[s,i,a]=o,u;return e==="semver_tilde"&&r.length===1?u=[s+1,0,0]:e==="semver_tilde"||s===0&&i>0?u=[s,i+1,0]:s>0?u=[s+1,0,0]:u=[0,0,a+1],[o,u]}function C(e,n,t,r,o){switch(e){case"icontains":case"not_icontains":case"starts_with":case"not_starts_with":case"ends_with":case"not_ends_with":return typeof n!="string"||typeof t!="string"?!1:e.endsWith("icontains")?n.toLowerCase().includes(t.toLowerCase())===(e==="icontains"):e.endsWith("starts_with")?n.startsWith(t)===(e==="starts_with"):n.endsWith(t)===(e==="ends_with");case"between":case"not_between":{let s=o.toFloat(n);if(!Array.isArray(t)||t.length!==2||s===void 0)return!1;let[i,a]=t;return typeof i!="number"||typeof a!="number"?!1:(s>=i&&s<=a)==(e==="between")}case"is_date_before":case"is_date_after":{let s=E(n,r,!1),i=E(t,r,!0);return s===void 0||i===void 0?!1:e==="is_date_before"?s<i:s>i}case"semver_eq":case"semver_neq":case"semver_gt":case"semver_gte":case"semver_lt":case"semver_lte":{let s=o.cmpVersion(n,t);if(s===void 0)return!1;let i=e.slice(7);return i==="eq"?s===0:i==="neq"?s!==0:i==="gt"?s>0:i==="gte"?s>=0:i==="lt"?s<0:s<=0}case"semver_tilde":case"semver_caret":case"semver_wildcard":{let s=o.parseVersion(n),i=L(e,t,o);return!!s&&!!i&&F(s,i[0])>=0&&F(s,i[1])<0}}return!1}var B=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function g(e){if(typeof e=="number")return e;if(typeof e=="string"&&B.test(e.trim()))return Number(e.trim())}function p(e,n){let t=typeof e=="number",r=typeof n=="number";return t||r?t&&r&&e===n:e===n}function y(e){if(typeof e!="string")return;let n=e.trim().replace(/^v/,""),t=n.search(/[-+]/);t>=0&&(n=n.slice(0,t));let r=[];for(let o of n.split(".")){if(!/^[+-]?\d+$/.test(o))return;let s=parseInt(o,10);if(s<0)return;r.push(s)}return r}function b(e,n){let t=y(e),r=y(n);if(!(!t||!r)){for(let o=0;o<Math.max(t.length,r.length);o++){let s=t[o]??0,i=r[o]??0;if(s!==i)return s<i?-1:1}return 0}}var G=(e,n)=>e<n?-1:e>n?1:0;function W(e,n,t,r,o,s=Date.now()){let i=t&&n!==null&&n!==void 0;if(e==="is_set")return i;if(e==="is_not_set")return!i;if(!i)return!1;switch(e){case"eq":case"neq":{let a;if(o){let u=b(n,r);if(u===void 0)return!1;a=u===0}else a=p(n,r);return a===(e==="eq")}case"contains":case"ncontains":case"regex":case"nregex":{if(typeof n!="string"||typeof r!="string")return!1;if(e==="contains"||e==="ncontains")return n.includes(r)===(e==="contains");let a;try{a=new RegExp(r)}catch{return!1}return a.test(n)===(e==="regex")}case"gt":case"gte":case"lt":case"lte":{let a;if(o)a=b(n,r);else{let u=g(n),l=g(r);a=u===void 0||l===void 0?void 0:G(u,l)}return a===void 0?!1:e==="gt"?a>0:e==="gte"?a>=0:e==="lt"?a<0:a<=0}case"in":case"not_in":return Array.isArray(r)?r.some(a=>p(n,a))===(e==="in"):!1}return e.startsWith("array_")||e.startsWith("ip_")?v(e,n,r,p):C(e,n,r,s,{toFloat:g,parseVersion:y,cmpVersion:b})}export{O as a,R as b,w as c,W as d};
@@ -1 +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};
1
+ import{a as b,b as i}from"./chunk-32K5P5GN.js";import"./chunk-O4W7SZ2X.js";function l(e){if(e.gdprApplies===!1)return;let n=e.purpose?.consents??{},t=!!n[1]&&!!n[7];return{analytics:t,replay:t&&!!n[8],marketing:!!n[1]&&!!n[4]}}function C(e){let n=a=>a in e?e[a]==="granted":void 0,t={},r=n("analytics_storage");r!==void 0&&(t.analytics=t.replay=r);let o=n("ad_storage"),s=n("ad_user_data");return o!==void 0&&(t.marketing=o&&s!==!1),t}function g(e){let n=typeof e=="string"?e.split(","):e,t=n.includes("C0002");return{analytics:t,replay:t,marketing:n.includes("C0004")}}function m(e){return{analytics:!!e.statistics,replay:!!e.statistics,marketing:!!e.marketing}}function v(e){return{analytics:!!e.statistics,replay:!!e.statistics,marketing:!!e.marketing}}var h=e=>{let n,r=u(()=>{let o=window.__tcfapi;return typeof o!="function"?!1:(o("addEventListener",2,(s,a)=>{if(!a||s.eventStatus!=="tcloaded"&&s.eventStatus!=="useractioncomplete")return;n=s.listenerId;let c=l(s);c&&i(e,c,"tcf",{onlyIfChanged:!0})}),!0)});return()=>{r();let o=window.__tcfapi;n!==void 0&&typeof o=="function"&&o("removeEventListener",2,()=>{},n)}},T=e=>{let n=window,t=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(e,C(a[2]),"gcm",{onlyIfChanged:!0})};t.forEach(r);let o=t.push;return t.push=function(...s){return s.forEach(r),o.apply(this,s)},()=>{t.push=o}},E=e=>{let n=o=>{(typeof o=="string"||Array.isArray(o))&&i(e,g(o),"onetrust",{onlyIfChanged:!0})},t=window,r=o=>n(o.detail??t.OnetrustActiveGroups);return window.addEventListener("OneTrustGroupsUpdated",r),n(t.OnetrustActiveGroups),()=>window.removeEventListener("OneTrustGroupsUpdated",r)},O=e=>{let n=window,t=()=>{let o=n.Cookiebot;o?.consent&&o.hasResponse!==!1&&i(e,m(o.consent),"cookiebot",{onlyIfChanged:!0})},r=["CookiebotOnConsentReady","CookiebotOnAccept","CookiebotOnDecline"];for(let o of r)window.addEventListener(o,t);return t(),()=>r.forEach(o=>window.removeEventListener(o,t))};function y(e){let n=e.ANALYTICS==="ACCEPT";return{analytics:n,replay:n,marketing:e.MARKETING==="ACCEPT"}}function u(e){if(e())return()=>{};let n=0,t=setInterval(()=>(e()||++n>40)&&clearInterval(t),250);return()=>clearInterval(t)}var d=["osano-cm-initialized","osano-cm-consent-saved","osano-cm-consent-changed"],U=e=>{let n,t=o=>{let s=o&&typeof o=="object"&&Object.keys(o).length?o:n?.getConsent?.();s&&Object.keys(s).length&&i(e,y(s),"osano",{onlyIfChanged:!0})},r=u(()=>{if(n=window.Osano?.cm,!n)return!1;for(let o of d)n.addEventListener?.(o,t);return t(n.getConsent?.()),!0});return()=>{r();for(let o of d)n?.removeEventListener?.(o,t)}};function w(e,n="Lucida"){let t=e.find(s=>s.name.toLowerCase()===n.toLowerCase());if(!t)return;let r=t.consent?.status===!0,o=e.filter(s=>s.categorySlug==="marketing");return{analytics:r,replay:r,marketing:o.length>0&&o.every(s=>s.consent?.status===!0)}}var f=["UC_UI_INITIALIZED","UC_UI_CMP_EVENT","ucEvent","UC_CONSENT"];function k(e="Lucida"){return n=>{let t=()=>{let a=window.UC_UI?.getServicesBaseInfo?.();if(!a)return!1;let c=w(a,e);return c?i(n,c,"usercentrics",{onlyIfChanged:!0}):n.log(`usercentrics: no service named "${e}"; consent left unchanged`),!0},r=()=>{t()};for(let s of f)window.addEventListener(s,r);let o=u(t);return()=>{o();for(let s of f)window.removeEventListener(s,r)}}}var I=k(),p=["CookieMunchOnConsentReady","CookieMunchOnChange"],_=e=>{let n=()=>{let t=window.CookieMunch;t?.consent&&t.hasResponse===!0&&i(e,v(t.consent),"cookiemunch",{onlyIfChanged:!0})};for(let t of p)window.addEventListener(t,n);return n(),()=>p.forEach(t=>window.removeEventListener(t,n))};var x=e=>{e.consentUi={showBanner:async n=>(await import("./banner-2TSKJ4WK.js")).showBanner(e,n),hideBanner:()=>{import("./banner-2TSKJ4WK.js").then(n=>n.hideBanner())}}};export{b as CONSENT_EVENT,i as applyConsent,x as consentBanner,_ as cookieMunchConsent,v as cookieMunchToConsent,O as cookiebotConsent,m as cookiebotToConsent,T as gcmConsent,C as gcmToConsent,E as oneTrustConsent,g as oneTrustToConsent,U as osanoConsent,y as osanoToConsent,h as tcfConsent,l as tcfToConsent,k as usercentricsBridge,I as usercentricsConsent,w as usercentricsToConsent};
@@ -1,3 +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};
1
+ var K="lc_consent",ue=["analytics","replay","marketing"],j=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let t=this.opens();this.state={analytics:t,replay:t,marketing:t},this.key=e.storageKey||K;let s=e.storage.get(this.key);if(s)try{let r=JSON.parse(s);for(let o of ue)typeof r[o]=="boolean"&&(this.state[o]=r[o]);this.decided=ue.some(o=>typeof r[o]=="boolean")}catch{}this.waiting=!!e.awaitRemote&&!this.decided,this.waiting&&(this.state={analytics:!1,replay:!1,marketing:!1})}o;modeNow;queueBeforeConsent;state;decided=!1;waiting;geoCookieless=!1;key;listeners=[];opens(){return this.modeNow==="opt_out"&&!(this.o.respectDnt&&this.o.dnt)}get mode(){return this.modeNow}get resolving(){return this.waiting}get anonymous(){return this.geoCookieless&&!this.decided}resolve(e){if(!this.waiting)return this.state.analytics;this.waiting=!1,(e==="opt_in"||e==="opt_out")&&(this.modeNow=e),this.geoCookieless=e==="cookieless";let t=!this.geoCookieless&&this.opens();return this.state={analytics:t,replay:t,marketing:t},t}get(){return{...this.state}}has(e){return this.state[e]}status(e="analytics"){return this.decided?this.state[e]?"granted":"denied":"pending"}get pending(){return this.waiting||this.modeNow==="opt_in"&&!this.state.analytics}set(e){let t=this.get();for(let s of ue)e[s]!==void 0&&(this.state[s]=e[s]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let s of this.listeners)s(this.get(),t)}onChange(e){this.listeners.push(e)}},$=class{constructor(e,t){this.inner=e;this.allowed=t}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,t){this.allowed()?this.inner.set(e,t):this.mem.set(e,t)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,t]of this.mem)t===null?this.inner.remove(e):this.inner.set(e,t);this.mem.clear()}discardBuffered(){this.mem.clear()}};var G=0,R=0;function Fe(n){let e=new Uint8Array(n),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let s=0;s<n;s++)e[s]=Math.floor(Math.random()*256);return e}function w(n=Date.now()){if(n>G){G=n;let o=Fe(2);R=((o[0]??0)<<8|(o[1]??0))&1023}else R++,R>4095&&(G++,R=0);let e=Fe(8),t=new Uint8Array(16),s=G;t[0]=Math.floor(s/2**40)&255,t[1]=Math.floor(s/2**32)&255,t[2]=Math.floor(s/2**24)&255,t[3]=Math.floor(s/2**16)&255,t[4]=Math.floor(s/2**8)&255,t[5]=s&255,t[6]=112|R>>8,t[7]=R&255,t[8]=128|(e[0]??0)&63;for(let o=1;o<8;o++)t[8+o]=e[o]??0;let r=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var Ne="lc_identity",Y=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let o=e.get(Ne),a;try{a=o?JSON.parse(o):void 0}catch{a=void 0}if(a?.distinct_id)this.s=a;else if(s)this.s={distinct_id:"",anon_id:"",identified:!1};else{let l=t??w();this.s={distinct_id:l,anon_id:l,identified:r&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(Ne,JSON.stringify(this.s))}get distinctId(){return this.s.distinct_id}get priorAnonId(){return this.s.identified&&this.s.anon_id&&this.s.anon_id!==this.s.distinct_id?this.s.anon_id:void 0}get isIdentified(){return this.s.identified}identify(e){if(!e||e===this.s.distinct_id)return e&&!this.s.identified&&(this.s.identified=!0,this.save()),{event:null};let t=this.s.distinct_id,s=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),s&&t?{event:"$identify",anonDistinctId:t}:{event:"$identify"}}aliasProps(e,t){return{alias:e,distinct_id:t??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let t=e&&this.s.anon_id||w();this.s={distinct_id:t,anon_id:t,identified:!1},this.save()}};function D(n,e={}){let t=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**n);return Math.round(t*(.5+.5*(e.random??Math.random)()))}function Be(n){return n===0||n===408||n===429||n>=500}var J=class{constructor(e){this.o=e;this.flushAt=e.flushAt??20,this.intervalMs=e.flushIntervalMs??5e3,this.maxSize=e.maxQueueSize??1e3,this.maxRetries=e.maxRetries??5,this.batchMax=Math.max(1,Math.min(e.maxBatchSize??1e3,1e3))}o;items=[];timer;attempt=0;inflight;closed=!1;warned404=!1;flushAt;intervalMs;maxSize;maxRetries;batchMax;get size(){return this.items.length}enqueue(e){this.closed||(this.items.push(e),this.items.length>this.maxSize&&this.o.onDrop?.(this.items.splice(0,this.items.length-this.maxSize),"queue_full"),this.items.length>=this.flushAt?this.flush():this.arm(this.intervalMs))}arm(e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},e))}disarm(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}flush(e={}){if(this.disarm(),this.inflight)return this.inflight.then(()=>this.items.length?this.flush(e):void 0);if(!this.items.length)return Promise.resolve();let t=this.items.splice(0,this.batchMax),s=(this.o.clock??Date).now(),r=JSON.stringify({api_key:this.o.apiKey,batch:t,sent_at:new Date(s).toISOString()});this.o.log?.("send batch",t.length);let o=this.o.transport.send(this.o.url,r,e.beacon?{beacon:!0}:{}).then(a=>a,()=>({status:0,retryAfterMs:void 0})).then(a=>this.settle(t,a.status,!!e.beacon,a.retryAfterMs)).finally(()=>{this.inflight=void 0});return this.inflight=o,o}settle(e,t,s,r){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Be(t)||s||this.attempt>=this.maxRetries){t===404&&!this.warned404&&(this.warned404=!0,console.warn(`[lucida] ${this.o.url} returned 404, so events are being dropped. apiHost is probably wrong: use https://capture.lucidace.com (or your own capture host), not the app host.`)),this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let o=Math.max(D(this.attempt++,this.o.backoff),Math.min(r??0,6e4));this.o.log?.("retry in",o,"ms"),this.arm(o)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var pe="lc_session";function qe(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var wt=6e4,Ct=10*36e5,Pt=24*36e5,$t=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function It(n,e){let t=$t.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=Pt}var Q=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Ct,Math.max(wt,t.idleMs??30*6e4)),this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??{now:()=>Date.now()},this.bootstrapId=t.bootstrapId}storage;o;windowId=w();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=qe(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=qe(e.session_max_minutes,5,10080)??this.maxMs),this.o.newOnEvents===void 0&&Array.isArray(e.session_new_on_events)&&(this.newOn=e.session_new_on_events.filter(t=>typeof t=="string"&&t!==""))}read(){try{let e=this.storage.get(pe);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),r=this.read(),o=!!(r?.campaign&&e&&r.campaign!==e),a=t!==void 0&&this.newOn.includes(t),l=!r||Math.abs(s-r.last)>this.idleMs||Math.abs(s-r.start)>this.maxMs||o||a;return(l||!r)&&(r={id:!r&&this.bootstrapId&&It(this.bootstrapId,s)?this.bootstrapId:w(s),start:s,last:s}),this.bootstrapId=void 0,r.last=s,e&&(r.campaign=e),this.storage.set(pe,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:l}}startedAt(){return this.read()?.start}reset(){this.storage.remove(pe)}};function Ue(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var Z=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Ue(e,t)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([t])=>e(t))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[t,s]of Object.entries(e))t in this.p||(this.p[t]=s);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},X=class{constructor(e){this.storage=e;this.g=Ue(e,"lc_groups")??{}}storage;g;set(e,t){this.g[e]=t,this.storage.set("lc_groups",JSON.stringify(this.g))}all(){return Object.keys(this.g).length?{...this.g}:void 0}clear(){this.g={},this.storage.remove("lc_groups")}};function Ot(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var L=class{constructor(e){this.c=e;this.clock=e.clock??{now:()=>Date.now()},this.consent=new j({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new $(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new Y(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new Q(this.gated,{clock:this.clock,...e.session}),this.props=new Z(this.gated,void 0,e.persistProperty),this.groupState=new X(this.gated),this.queue=new J({transport:e.transport,url:`${e.apiHost.replace(/\/+$/,"")}/v1/batch`,apiKey:e.apiKey,clock:this.clock,...e.log?{log:e.log}:{},...e.onDrop?{onDrop:e.onDrop}:{},...e.queue})}c;consent;identity;session;queue;storage;gated;props;groupState;clock;device;pre=[];listeners=[];captureListeners=[];sessionListeners=[];lastSession="";filter;get anonDistinctId(){return this.identity.priorAnonId}get distinctId(){return this.identity.distinctId}get deviceId(){return this.c.cookieless?"":(this.device||(this.device=this.gated.get("lc_device_id")||w(),this.gated.set("lc_device_id",this.device)),this.device)}get groups(){return this.groupState.all()}get sessionId(){return this.touchSession().sessionId}touchSession(e){let t=this.session.touch(this.c.campaignKey?.(),e);if(t.sessionId!==this.lastSession){this.lastSession=t.sessionId;for(let s of this.sessionListeners)s(t.sessionId,t.windowId)}return t}onSessionId(e){return this.sessionListeners.push(e),()=>{this.sessionListeners.splice(this.sessionListeners.indexOf(e),1)}}get sessionStart(){return this.session.startedAt()}getProperty(e){return this.props.all()[e]}setFilter(e){this.filter=e}onChange(e){this.listeners.push(e)}onCaptured(e){this.captureListeners.push(e)}emit(e){for(let t of this.listeners)t(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,t={},s={}){let r=this.consent.has("analytics"),o=!r&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!r&&!o&&!a){this.c.log?.("dropped (no consent)",e);return}if(o&&(e==="$identify"||e==="$create_alias")){this.c.log?.("withheld (declined, anonymous mode)",e);return}let l=this.touchSession(e),p=this.c.enrich?.(e,t),h=this.consent.status()!=="pending",m=o?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=o?{}:{...p?.$set_once,...s.$set_once},C=this.groupState.all(),g=o?"":this.identity.distinctId,v={uuid:w(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Ot(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:l.sessionId,$window_id:l.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...h?{$consent:this.consent.get()}:{}},...Object.keys(m).length?{$set:m}:{},...Object.keys(_).length?{$set_once:_}:{},...!o&&s.$unset?.length?{$unset:s.$unset}:{},...C?{$groups:C}:{}},b=this.filter?this.filter(v):v;if(!b){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,b),this.c.onCapture?.(b);for(let S of this.captureListeners)S(b);return r||o?this.queue.enqueue(b):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(b),b}identify(e,t,s){let r=this.identity.identify(e);(r.event||t||s)&&this.capture("$identify",r.anonDistinctId?{$anon_distinct_id:r.anonDistinctId}:{},{...t?{$set:t}:{},...s?{$set_once:s}:{}}),this.emit("identify")}alias(e,t){this.capture("$create_alias",this.identity.aliasProps(e,t))}reset(e={}){this.identity.reset(e.reuseAnonymousId),e.resetDeviceId&&(this.device=void 0,this.gated.remove("lc_device_id")),this.props.clear(),this.groupState.clear(),this.session.reset(),this.lastSession="",this.emit("reset")}register(e){this.props.register(e)}registerOnce(e){this.props.registerOnce(e)}unregister(e){this.props.unregister(e)}group(e,t,s){this.groupState.set(e,t),this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s??{}}),this.emit("group")}getConsent(){return this.consent.get()}getConsentStatus(e="analytics"){return this.consent.status(e)}hasConsent(e){return this.consent.has(e)}setConsent(e){let t=this.consent.has("analytics"),s=e.analytics??t;if(t&&!s&&(this.capture("$opt_out"),this.queue.flush()),!t&&s&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!t&&s){this.gated.flushBuffered();for(let r of this.pre.splice(0))this.queue.enqueue(r);this.capture("$opt_in")}else t&&!s&&this.queue.clear();s||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e);let t=e.consent_default;this.resolveConsent(t==="opt_in"||t==="opt_out"||t==="cookieless"?t:void 0)}resolveConsent(e){if(!this.consent.resolving)return;let t=this.consent.resolve(e),s=this.pre.splice(0);if(t){this.gated.flushBuffered();for(let r of s)this.queue.enqueue(r)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let r of s){if(r.event==="$identify"||r.event==="$create_alias")continue;let o={...r};delete o.distinct_id,delete o.$set,delete o.$set_once,delete o.$unset,this.queue.enqueue(o)}}else this.consent.queueBeforeConsent&&this.pre.push(...s);this.emit("consent")}optIn(){this.setConsent({analytics:!0,replay:!0,marketing:!0})}optOut(){this.setConsent({analytics:!1,replay:!1,marketing:!1})}flush(e){return this.queue.flush(e)}shutdown(){return this.queue.shutdown()}};function He(n){let e="";return t=>{for(e+=t;;){let s=/\r?\n\r?\n/.exec(e);if(!s)return;let r=e.slice(0,s.index);e=e.slice(s.index+s[0].length);let o="message",a,l=[];for(let p of r.split(/\r?\n/)){if(p.startsWith(":"))continue;let h=p.indexOf(":"),[m,_]=h<0?[p,""]:[p.slice(0,h),p.slice(h+1).replace(/^ /,"")];m==="event"?o=_??"":m==="data"?l.push(_??""):m==="id"&&(a=_)}l.length&&n(a===void 0?{event:o,data:l.join(`
2
+ `)}:{event:o,data:l.join(`
3
+ `),id:a})}}}var ee=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;cursor=0;gen=0;polling=!1;start(){this.stopped&&(this.stopped=!1,this.loop(++this.gen))}stop(){this.stopped=!0,this.gen++,this.ctl?.abort(),this.timer&&clearTimeout(this.timer)}restart(){let e=!this.stopped;this.stop(),this.cursor=0,e&&this.start()}live(e){return!this.stopped&&e===this.gen}deliver(e){if(e.seq>this.cursor){this.cursor=e.seq;try{this.o.onIntervention(e)}catch(t){this.o.log?.("onIntervention threw",t)}}}url(e){let t=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${t}`}sleep(e){return new Promise(t=>{this.timer=setTimeout(t,e),this.timer.unref?.()})}async loop(e){let t=0;for(;this.live(e);){let s;try{let r=await this.connectOnce(e);if(r==="gone")return this.stop();r==="poll"?(t=0,s=this.o.pollMs??15e3):(r==="streamed"&&(t=0),s=D(t++,this.o.backoff))}catch(r){this.live(e)&&this.o.log?.("intervention stream error",r),s=D(t++,this.o.backoff)}if(!this.live(e))return;await this.sleep(s)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let t={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},s=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:t,signal:this.ctl.signal});if(s.status===404)return"gone";if(!s.ok)return"failed";let r=s.body;if(!r||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let o=He(l=>{if(!(l.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(l.data))}catch{this.o.log?.("bad intervention payload")}}),a=r.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:l,value:p}=await a.read();if(l)return"streamed";o(p)}}async pollOnce(e){this.ctl=new AbortController;let t=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(t.status===404)return"gone";if(!t.ok)return"failed";let s=await t.json();if(this.live(e))for(let r of s.data??[])this.deliver(r);return"poll"}};function fe(n,e){let t=new Set,{whenConsented:s,disabled:r,...o}=e,a=new ee({...o,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),l=!1;return n.onChange(p=>{l&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!l&&!r&&(l=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function ge(n,e,t={}){let s=t.key??"lc_offline",r=t.maxBatches??50,o=t.maxBytes??1e6,a=t.isOnline??(()=>!0),l,p,h=()=>{try{let g=JSON.parse(e.get(s)??"[]");return Array.isArray(g)?g:[]}catch{return[]}},m=g=>{let v=g.reduce((b,S)=>b+S.body.length,0);for(;g.length>r||v>o&&g.length>1;)v-=g.shift().body.length;g.length?e.set(s,JSON.stringify(g)):e.remove(s)},_=g=>{m([...h(),...g]),l??=setTimeout(()=>{l=void 0,C.drain()},t.retryMs??3e4)},C={async send(g,v,b){if(!a())return _([{url:g,body:v}]),{status:200};let S=await n.send(g,v,b);return S.status!==0?S:(_([{url:g,body:v}]),{status:200})},drain(){return p??=(async()=>{let g=h();if(!g.length||!a())return;e.remove(s);let v=[];for(let[b,S]of g.entries())if((await n.send(S.url,S.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return C}function he(n){let e=Object.keys(n);if(e.length===0)return{};let t={};for(let s of e)t[`$feature/${s}`]=n[s];return t.$active_feature_flags=e.filter(s=>n[s]!==!1).sort(),t}function me(n,e,t,s){return{key:n,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...t!==void 0?{payload:t}:{},reason:e===void 0?"not_found":s}}var A={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Et=["resolved","unresolved","escalated","abandoned","error"],Rt=4e3,At=2e3,Ve=["wrong","useless","not helpful","unhelpful","doesn't work","does not work","didn't help","did not help","not what i asked","that's not it","stupid","terrible","awful","frustrating","frustrated","annoying","worst","hate","incorrect","nonsense","confusing","makes no sense","real person","human agent","talk to a human","speak to a human","wtf","ugh"],ze=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],B=n=>Array.from(n),ve=(n,e)=>B(n).slice(0,e).join(""),Tt=0xcbf29ce484222325n,Mt=0x100000001b3n,jt=0xffffffffffffffffn,Dt=new TextEncoder;function Lt(n){let e=Tt;for(let t of Dt.encode(n))e=(e^BigInt(t))*Mt&jt;return e}function Ke(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(r=>B(r).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let r of e){let o=Lt(r);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((o>>BigInt(a)&1n)===1n?1:-1)}let s=0n;for(let r=0;r<64;r++)(t[r]??0)>0&&(s|=1n<<BigInt(r));return s.toString(16).padStart(16,"0")}function Ge(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let o of Ve)t.includes(` ${o} `)&&(s++,t=t.split(` ${o} `).join(" "));let r=ze.filter(o=>t.includes(` ${o} `)).length;return s>r?-1:r>s?1:0}var Ye=n=>B(n).filter(e=>e>="0"&&e<="9").map(Number);function Ft(n){let e=Ye(n);if(e.length<13||e.length>19)return!1;let t=0;return e.reverse().forEach((s,r)=>t+=r%2===1?s>4?s*2-9:s*2:s),t%10===0}var We=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Nt=[[new RegExp(String.raw`(?<!${We})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${We})`,"gu"),Ft],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,()=>!0],[/\+?\p{Nd}[\p{Nd}\s().-]{7,}\p{Nd}/gu,Bt]];function Bt(n){let e=Ye(n).length;return e>=10&&e<=15}var qt=n=>B(n).map(e=>/\s/u.test(e)?e:"*").join("");function be(n){let e=n;for(let[t,s]of Nt)e=e.replace(t,r=>s(r)?qt(r):r);return e===n?void 0:e}function Je(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var Qe=n=>typeof n=="string"&&Et.includes(n)?n:void 0,F=(n,e)=>typeof n=="string"&&n?ve(n,e):void 0;function Ut(n,e,t){let s=ve(e,t),r=be(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function Ze(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let r={$ai_role:n,$ai_message_index:t,$ai_text_length:B(e).length};if(n==="user"){let o=Ke(e);o!==void 0&&(r.$ai_text_hash=o),r.$ai_sentiment=Ge(e)}return s?{...r,...Ut("$ai_text",e,Rt)}:r}function Xe(n,e){let t=n.value;if(n.kind==="thumbs"&&t!==1&&t!==-1||n.kind==="rating"&&!(Number.isInteger(t)&&t>=1&&t<=5)||n.kind!=="thumbs"&&n.kind!=="rating"&&n.kind!=="comment")return;let s={$ai_feedback_kind:n.kind};if(n.kind!=="comment"&&(s.$ai_feedback_value=t),n.comment&&e){let r=ve(n.comment,At);s.$ai_feedback_comment=be(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function ye(n,e){let t=Qe(n),s=F(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function Ht(){let n=globalThis.crypto,e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function et(n={}){let e={$ai_conversation_id:n.conversationId||Ht()},t=(s,r)=>{r!==void 0&&(e[s]=r)};return t("$ai_agent_name",F(n.agentName,128)),t("$ai_agent_version",F(n.agentVersion,64)),t("$ai_topic",F(n.topic,128)),t("$ai_use_case",F(n.useCase,128)),t("$ai_trace_id",Je(n.traceId)),e}var N=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=et(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(A.started,{}),this}message(e,t,s={}){let r=s.index??this.next,o=Ze(e,t,r,this.captureText);return o?(this.next=r+1,this.send(A.message,o),!0):!1}feedback(e){let t=Xe(e,this.captureText);return t?(this.send(A.feedback,t),!0):!1}end(e,t){this.send(A.ended,ye(e,t))}outcome(e,t){let s=ye(e,t);return s.$ai_outcome?(this.send(A.outcome,s),!0):!1}};var Wt=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client","cypress","lightpanda","hubspot","nessus","prerender","deepscan","screaming frog","sitebulb","turnitin","ia_archiver","chatgpt-user","app.hypefactors.com","google favicon","google web preview","-google","googleother","googleweblight","google-read-aloud","google-inspectiontool","google-hoteladsverifier","google-cloudvertexbot"];function tt(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:Wt.some(s=>t.includes(s))&&!/\bcubot\b/.test(t)}var O=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],nt="lc_click_ids";function st(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(nt)??"{}")}catch{return{}}};return()=>{let o=r();if(location.search!==s){s=location.search;let l=new URLSearchParams(s),p=!1;for(let h of O){let m=l.get(h);m&&(o[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(nt,JSON.stringify(o))}let a={};for(let l of O){let p=o[l];p&&t()-p.t<e*864e5&&(a[l]=p.v)}return a}}function Vt(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function zt(n){let e=new Map;for(let s of n.split(";")){let[r,...o]=s.trim().toLowerCase().split(/\s+/);r&&!e.has(r)&&e.set(r,o)}let t=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!t&&!(t.includes("'unsafe-inline'")&&!t.some(s=>s.startsWith("'nonce-")||s.startsWith("'sha")))}function ot(n,e){if(typeof document>"u")return()=>{};!e&&Vt().some(zt)&&n("CSP hint: this page's Content-Security-Policy blocks inline <style>; set the `nonce` option so guides and the experiment veil render (docs/guides/csp.md)");let t=s=>{let r=s;/^style-src/.test(r.effectiveDirective??"")&&r.blockedURI==="inline"&&n(`CSP hint: an inline style was blocked by ${r.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",t),()=>document.removeEventListener("securitypolicyviolation",t)}var Kt=(n,e)=>n.slice(0,e);function rt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return Kt(n,64)}}function it(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,r=o=>{let a=o,l={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:rt(a.blockedURI??""),$csp_source_file:a.sourceFile?rt(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[l.$csp_directive,l.$csp_blocked_uri,l.$csp_source_file,l.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(l).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",r),()=>document.removeEventListener("securitypolicyviolation",r)}var Gt=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],at=()=>typeof location<"u"&&Gt.includes(location.protocol);function Yt(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let r=n.slice(s.length),o=r.search(/[?#]/);return s+t(o<0?r:r.slice(0,o))+(o<0?"":r.slice(o))}function ct(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=o=>Yt(o,t,s);return{transport:{send:(o,a,l)=>n.send(r(o),a,l)},fetch:((o,a)=>e(typeof o=="string"?r(o):o instanceof URL?r(o.href):o,a))}}var Jt="__LUCIDA_DEVTOOLS_HOOK__";function lt(n,e,t){let s=globalThis[Jt];if(!(!s||typeof s.emit!="function"||typeof s.attach!="function")){n.onCapture(r=>{try{s.emit(r)}catch{}});try{s.attach({projectKeyPrefix:n.apiKey.slice(0,8),apiHost:t,distinctId:()=>e.distinctId,loadToolbar:r=>e.loadToolbar(r),startReplay:async()=>n.replay?(await n.replay.start(!0),n.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var q=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Qt(n){let e={},t=new URLSearchParams(location.search);for(let s of[...q,...O,...n]){let r=t.get(s);r&&(e[`$${s}`]=r)}return e}function dt(){let n=new URLSearchParams(location.search),e=q.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function Zt(n){try{return n?new URL(n).hostname:""}catch{return""}}var Xt=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function en(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function ut(n,e,t=[],s=!1){let r={$current_url:Xt(),$host:location.host,$pathname:s?en():location.pathname,$referrer:document.referrer,$title:document.title,$screen_width:screen.width,$screen_height:screen.height,$viewport_width:window.innerWidth,$viewport_height:window.innerHeight,$browser_language:navigator.language,$timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};if(navigator.maxTouchPoints>1&&(r.$touch_points=navigator.maxTouchPoints),n!=="$pageview")return{properties:r};let o=Qt(t);Object.assign(r,o);let a=e.$current_url??location.href,l=e.$referrer??document.referrer,p={$initial_referrer:l||"$direct",$initial_referring_domain:Zt(l)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(o))p[`$initial_${h.slice(1)}`]=m;return{properties:r,$set_once:p}}var pt="_lcid";var tn=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function nn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",r]=n.slice(t+1).split("_",2),o=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&o<=e+5e3&&e-o<=12e4)return r&&/^[\w-]{1,64}$/.test(r)?{distinctId:a,sessionId:r}:{distinctId:a}}function ft(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(pt);if(t!==null){e.searchParams.delete(pt),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!tn(new URL(document.referrer).hostname,n))return}catch{return}return nn(t)}}function gt(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,r=s,o=e();return()=>{let a=e();return r=Math.min(s,r+(a-o)/1e3*t),o=a,r<1?!1:(r-=1,!0)}}var _e="<masked>",sn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],rn=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],ht=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function on(n,e){let t=n,s=[...sn,...e.maskParams??[],...e.maskCampaignParams?[...q,...O]:[]];if(s.length){let r=t.indexOf("#"),o=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);t=o.replace(new RegExp(`([?&])(${s.map(ht).join("|")})=[^&]*`,"gi"),`$1$2=${_e}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function mt(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...q,...O].map(ht).join("|")})$`),t=s=>{let r;if(n.maskCampaignParams)for(let[o,a]of Object.entries(s))typeof a=="string"&&e.test(o)?(r??={...s})[o]=_e:o==="$click_ids"&&a&&typeof a=="object"&&((r??={...s})[o]=Object.fromEntries(Object.keys(a).map(l=>[l,_e])));for(let o of rn){let a=(r??s)[o];if(typeof a!="string")continue;let l=on(a,n);l!==a&&((r??={...s})[o]=l)}return r??s};return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}function an(n,e,t){let s=e;for(let r of n)try{let o=r(s);if(o==null)return null;if(typeof o!="object"||typeof o.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof o),null;s=o}catch(o){return t("beforeSend hook threw, dropping event:",o),null}return s}function cn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function ln(n){let e=new Set(n),t=s=>Object.fromEntries(Object.entries(s).filter(([r])=>!e.has(r)));return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}var Se="lc_person_identified",te="lc_pending_set_once",yt=new Set(["$identify","$create_alias","$groupidentify"]),vt="$$client_ingestion_warning",dn=6e4,ke=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Se)==="1";try{this.pending=JSON.parse(t.get(te)??"{}")}catch{this.pending={}}}mode;storage;identified;pending;get blocksPersonWrites(){return this.mode==="never"}get isProfile(){return this.mode==="always"||this.mode==="identified_only"&&this.identified}markIdentified(){this.mode!=="identified_only"||this.identified||(this.identified=!0,this.storage.set(Se,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!yt.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let t=Object.entries(e).filter(([s])=>!(s in this.pending));t.length&&(this.pending={...this.pending,...Object.fromEntries(t)},this.storage.set(te,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(te),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Se),this.storage.remove(te)}};function un(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:o,$set_once:a,$unset:l,...p}=e;t={...p,properties:{...e.properties,$process_person_profile:!1}}}else(s=n.person.take())&&(t={...e,$set_once:{...e.$set_once,...s}});let r=n.hooks.length?an(n.hooks,t,n.log):t;return r&&n.limit&&!n.limit()&&(n.log("rate limited, dropped",r.event),n.onLimited?.(),r=null),!r&&s&&n.person.stash(s),r}function pn(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[mt(n.urlPrivacy??{}),...n.propertyDenylist?.length?[ln(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[cn(n.sampleRate)]:[],...e]}function bt(n,e,t,s=Date.now){let r=new ke(e.personProfiles??"always",n.storage),o,a,l=0,p=-1/0,h=()=>{l+=1,!(s()-p<dn)&&(p=s(),queueMicrotask(()=>{let m=l;l=0,n.capture(vt,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==o&&(o=e.rateLimit,a=o?gt(o):void 0),un({hooks:pn(e),person:r,limit:m.event===vt?void 0:a,log:t,onLimited:h},m))),r}var xe=class{m=new Map;get(e){return this.m.get(e)??null}set(e,t){this.m.set(e,t)}remove(e){this.m.delete(e)}},fn=365,gn=new Set("co.uk org.uk ac.uk gov.uk me.uk ltd.uk plc.uk net.uk com.au net.au org.au edu.au gov.au co.nz org.nz net.nz co.jp ne.jp or.jp ac.jp go.jp co.kr or.kr com.cn net.cn org.cn com.hk com.tw com.sg com.my co.in net.in org.in co.id co.th com.ph com.vn com.br net.br org.br com.ar com.mx com.co com.pe com.tr com.ua com.pl co.za co.il com.eg com.sa com.ng co.ke github.io gitlab.io vercel.app netlify.app herokuapp.com pages.dev workers.dev web.app firebaseapp.com azurewebsites.net cloudfront.net appspot.com onrender.com fly.dev glitch.me repl.co blogspot.com wordpress.com myshopify.com vercel.dev netlify.com surge.sh render.com railway.app koyeb.app deno.dev ngrok.io ngrok-free.app trycloudflare.com cloudfunctions.net run.app s3.amazonaws.com elasticbeanstalk.com azurestaticapps.net wixsite.com webflow.io framer.app bubbleapps.io".split(" ")),hn=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function mn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(gn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&hn.has(e[t]))return e.slice(t-1).join(".")}function yn(n=location.hostname){if(/^[\d.]+$/.test(n)||n.includes(":"))return;let e=n.split(".");for(let t=e.length-2;t>=0;t--){let s=e.slice(t).join(".");if(document.cookie=`__lc_probe=1; Domain=${s}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${s}; Path=/; Max-Age=0`,s}return mn(n)}var ne=class{constructor(e={}){this.o=e}o;domain=null;attr(){if(this.domain===null)try{this.domain=this.o.domain??(this.o.crossSubdomain?yn():void 0)}catch{this.domain=void 0}return this.domain?`; Domain=${this.domain}`:""}held=new Map;read(e){try{for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)return decodeURIComponent(t.slice(s+1))}}catch{}return null}get(e){return this.read(e)??this.held.get(e)??null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",r=Math.round((this.o.expiryDays??fn)*86400);try{document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${r}; Path=/${this.attr()}; SameSite=Lax${s}`}catch{}this.read(e)===t?this.held.delete(e):this.held.set(e,t)}remove(e){this.held.delete(e);try{document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}catch{}}},T=class{constructor(e="localStorage"){this.kind=e}kind;store(){try{return globalThis[this.kind]}catch{return}}get(e){try{return this.store()?.getItem(e)??null}catch{return null}}set(e,t){try{this.store()?.setItem(e,t)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},we=class extends T{constructor(){super("localStorage")}},vn=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Ce=class{constructor(e,t,s){this.cookie=e;this.local=t;this.cookieKeys=s}cookie;local;cookieKeys;get(e){let[t,s]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return t.get(e)??s.get(e)}set(e,t){this.local.set(e,t),this.cookieKeys(e)?this.cookie.set(e,t):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},se=class{constructor(e,t){this.inner=e;this.delayMs=t}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,t){this.queue(e,t)}remove(e){this.queue(e,null)}queue(e,t){this.pending.set(e,t),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,t]of this.pending)t===null?this.inner.remove(e):this.inner.set(e,t);this.pending.clear()}},Pe=class{constructor(e,t){this.inner=e;this.suffix=t}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,t){this.inner.set(e+this.suffix,t)}remove(e){this.inner.remove(e+this.suffix)}},re=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function oe(n,e,t){if(n==="memory"||n==="none")return new xe;let s=re(e),r=n==="cookie"?new ne(t):n==="localStorage+cookie"?new Ce(new ne(t),new we,o=>vn.some(a=>o===a+s)):new T(n);return new Pe(r,s)}function _t(n,e,t){let s=re(e),r=new Set;try{for(let o of document.cookie.split("; "))r.add(o.split("=")[0]);for(let o of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<o.length;a++)r.add(o.key(a))}catch{}for(let o of r)if(!(!o.startsWith("lc_")||!o.endsWith(s)||o===t+s)){n.remove(o.slice(0,-s.length));try{localStorage.removeItem(o),sessionStorage.removeItem(o)}catch{}}}async function bn(n){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(n).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function St(n,e={}){let t=e.compress??!0,s=(r,o)=>(e.onError?.({url:r,status:o}),{status:o});return{async send(r,o,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(r,new Blob([o],{type:"text/plain"}))?{status:200}:s(r,0);try{let l=t&&o.length>=1024?await bn(o):void 0,p=await n(l?`${r}${r.includes("?")?"&":"?"}compression=gzip`:r,{method:"POST",body:l??o,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(l?.length??o.length)<6e4});return p.status>=400?s(r,p.status):{status:p.status}}catch{return s(r,0)}}}}var $e={send:async()=>({status:200})};var _n="lucida-browser",Sn="0.1.1",Ie="lc_internal",kn=3e3,kt="https://capture.lucidace.com",Oe=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Ee(n,e={},t=[]){let s=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),r=(...i)=>{s&&console.debug("[lucida]",...i)},o=(e.apiHost??kt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([i,c])=>[i,Oe(c)?{...c}:c]));a.apiHost=o;let l=e.extension??at(),p=i=>l&&(i==="cookie"||i==="localStorage+cookie")?e.extensionPersistence??"localStorage":i,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[o,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...i)=>fetch(...i)),C=i=>ct(i,_,m,e.rewritePath),g=C($e).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,Re=e.blockBots!==!1&&typeof navigator<"u"&&tt(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||Re;Re&&r("bot user agent: capture disabled");let ie,ae=C(e.transport??St(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let i=new $(new T(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>d.hasConsent("analytics"));ae=ie=ge(ae,i,{key:`lc_offline${re(n)}`,isOnline:()=>navigator.onLine!==!1})}let U=k?void 0:ft(e.crossDomains),ce=oe(k?"memory":h,n,e.cookie),H=(e.storageWriteDelayMs??0)>0?new se(ce,e.storageWriteDelayMs):void 0,Ae=U?.sessionId??e.bootstrap?.sessionId,le,W=!1,Te,de=[],d=new L({apiKey:n,apiHost:o,transport:k?$e:ae,storage:H??ce,...e.consentPersistence&&!k?{consentStorage:oe(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:i=>!a.persistedProperties||a.persistedProperties.includes(i),...h==="none"?{cookieless:!0}:{},library:{name:_n,version:Sn},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...e.consent?.geo&&!k?{awaitRemote:!0}:{},respectDnt:!0,dnt:S},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...U||e.bootstrap?.distinctId?{bootstrapDistinctId:U?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!U?{bootstrapIdentified:!0}:{},session:{...e.session,...Ae?{bootstrapId:Ae}:{}},enrich:(i,c)=>{let u=ut(i,c,a.customCampaignParams,e.capturePageview==="hash");if(o!==kt&&(u.properties={...u.properties,$lib_custom_api_host:o}),de.length){let I=d.sessionId;for(let xt of de)u.properties={...u.properties,...xt(I)}}let y=Te?.()??{},P=Object.keys(y);return P.length&&(u.properties={...u.properties,$click_ids:y},i==="$pageview"&&(u.$set_once={...Object.fromEntries(P.map(I=>[`$initial_${I}`,y[I]])),...u.$set_once},u.$set=Object.fromEntries(P.map(I=>[`$last_${I}`,y[I]])))),a.sendFeatureFlags!==!1&&i!=="$snapshot"&&le&&(u.properties={...he(le.all()),...u.properties}),W?{...u,properties:{...u.properties,$internal:!0}}:u},campaignKey:dt,log:r});W=d.storage.get(Ie)==="1",e.clickIds!==!1&&(Te=st(d.storage,e.clickIds?.expiryDays));let x=bt(d,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let M=i=>x.blocksPersonWrites?(r(`personProfiles=never: ${i} ignored`),!0):!1;k||d.onChange(i=>{i!=="consent"||d.hasConsent("analytics")||d.consentStatus()!=="denied"||(H?.flush(),_t(ce,n,e.consent?.storageKey||K))});let Me=[],E=[ot(r,e.nonce)],je=d.storage;if(e.flagPersistence&&!k){let i=new $(oe(p(e.flagPersistence),n,e.cookie),()=>d.hasConsent("analytics"));d.onChange(c=>{c==="consent"&&(d.hasConsent("analytics")?i.flushBuffered():i.discardBuffered())}),je=i}let V=i=>{if(k)return;if(d.hasConsent("analytics"))return i();let c=!1;d.onChange(u=>{!c&&u==="consent"&&d.hasConsent("analytics")&&(c=!0,i())})},De,f={core:d,client:void 0,config:a,flagStorage:je,apiKey:n,log:r,fetch:g,onUnload:i=>{Me.push(i)},whenConsented:V,onCapture:i=>d.onCaptured(i),eventExtras:de,clickExtras:[],flagPersonProps:[],loadConfig:()=>De??=new Promise(i=>V(()=>{g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&d.applyRemote(c),c)).then(i,()=>i(null))}))};if(d.consent.resolving){let i=g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(u=>u.ok?u.json():null).catch(()=>null);De=i;let c=setTimeout(()=>d.applyRemote({}),kn);i.then(u=>{clearTimeout(c),d.applyRemote(u??{})})}let Le=fe(d,{apiHost:o,apiKey:n,fetch:g,whenConsented:V,log:r,disabled:k});E.push(()=>Le.stop());let z={get distinctId(){return d.distinctId},capture:(i,c,u)=>{d.capture(i,c,u?.timestamp!==void 0?{timestamp:u.timestamp}:{})&&(u?.sendInstantly||u?.transport)&&d.flush(u.transport==="beacon"?{beacon:!0}:{})},identify:(i,c,u)=>{M("identify")||(x.markIdentified(),d.identify(i,c,u))},alias:(i,c)=>{M("alias")||(x.markIdentified(),d.alias(i,c))},reset:i=>{d.reset({resetDeviceId:!!i,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{M("createPersonProfile")||x.isProfile||(x.markIdentified(),d.capture("$set",{}))},setConfig:i=>{let c=a;for(let[u,y]of Object.entries(i)){let P=c[u];Oe(P)&&Oe(y)?Object.assign(P,y):c[u]=y}"debug"in i&&(s=!!i.debug)},setPersonProperties:(i,c)=>{!i&&!c||M("setPersonProperties")||(x.markIdentified(),d.capture("$set",{},{...i?{$set:i}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:i=>{!i.length||M("unsetPersonProperties")||(x.markIdentified(),d.capture("$set",{},{$unset:i}))},getSessionId:()=>d.sessionId,onSessionId:i=>d.onSessionId(c=>i(c)),getProperty:i=>d.getProperty(i),hasOptedOut:()=>!d.hasConsent("analytics"),getReplayUrl:i=>{let u=`${(e.uiHost??o).replace(/\/+$/,"")}/replays/${encodeURIComponent(d.sessionId)}`,y=d.sessionStart;return!i?.withTimestamp||y===void 0?u:`${u}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(i.timestampLookBackSeconds??10)))}`},debug:(i=!0)=>{s=i},featureView:(i,c)=>{d.capture("$feature_view",{...c,$feature_flag:i},{$set:{[`$feature_view/${i}`]:!0}})},featureInteraction:(i,c)=>{d.capture("$feature_interaction",{...c,$feature_flag:i},{$set:{[`$feature_interaction/${i}`]:!0}})},updateFlags:(i,c,u)=>f.flags?.update(i,c,u?.merge??!0),register:i=>d.register(i),registerOnce:i=>d.registerOnce(i),unregister:i=>d.unregister(i),group:(i,c,u)=>{x.markIdentified(),d.group(i,c,u)},optIn:()=>d.optIn(),optOut:()=>d.optOut(),optOutInternal:(i=!0)=>{W=i,i?d.storage.set(Ie,"1"):d.storage.remove(Ie)},get isInternal(){return W},setConsent:i=>d.setConsent(i),getConsent:()=>d.getConsent(),getConsentStatus:i=>d.getConsentStatus(i),consentStatus:()=>d.consentStatus(),getFlag:i=>f.flags?.get(i),getFlagPayload:i=>f.flags?.payload(i),getFlagResult:(i,c)=>f.flags?.result(i,c)??me(i,void 0,void 0,"not_found"),getLayerParam:(i,c,u)=>f.flags?.layerParam(i,c)??u,isFeatureEnabled:i=>{let c=f.flags?.get(i);return c!==void 0&&c!==!1},onFlags:i=>f.flags?.onChange(i)??(()=>{}),onIntervention:i=>Le.on(i),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(i,c)=>f.flags?.override(i,c),setPersonPropertiesForFlags:(i,c)=>f.flags?.setPersonProperties(i,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(i,c)=>f.flags?.setGroupProperties(i,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(i,c,u)=>f.flags?.setContext(i,c,u),clearContext:i=>f.flags?.clearContext(i),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:i=>f.guides?.show(i)??!1,reset:i=>f.guides?.reset(i)},ai:{startConversation:i=>new N((c,u)=>z.capture(c,u),i,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:i=>f.earlyAccess?.optIn(i),optOut:i=>f.earlyAccess?.optOut(i)},replay:{start:i=>f.replay?.start(i)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:i=>f.replay?.tag(i),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:i=>f.consentUi?.showBanner(i)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:i=>f.toolbar?.load(typeof i=="string"?i:i.token)??Promise.resolve(!1),activateExperiment:i=>f.experiments?.activate(i),recommendations:(i,c)=>f.recs?.get(i,c)??Promise.resolve({placement:i,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>d.flush(),shutdown:async()=>{for(let i of E)i();H?.flush(),await d.shutdown()}};if(f.client=z,!k){let i=()=>{for(let u of Me)u();H?.flush(),d.flush({beacon:!0})};window.addEventListener("pagehide",i);let c=()=>{document.visibilityState==="hidden"&&d.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",i),document.removeEventListener("visibilitychange",c)}),ie){let u=()=>{ie.drain()};window.addEventListener("online",u),E.push(()=>window.removeEventListener("online",u)),V(u)}if(e.captureCspViolations){let u=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};E.push(it((y,P)=>{d.capture(y,P)},u))}for(let u of t){let y=u(f);y&&E.push(y)}le=f.flags,t.length||f.loadConfig(),lt(f,z,o)}return r("initialised",{apiHost:o,consent:d.getConsent()}),z}function Ls(n,e={}){return Ee(n,e)}export{Ee as createClient,Ls as init};
@@ -1,3 +1,3 @@
1
- function Ae(e,t={}){let n=Math.min(t.maxMs??3e4,(t.baseMs??1e3)*2**e);return Math.round(n*(.5+.5*(t.random??Math.random)()))}function st(e){let t="";return n=>{for(t+=n;;){let r=/\r?\n\r?\n/.exec(t);if(!r)return;let i=t.slice(0,r.index);t=t.slice(r.index+r[0].length);let o="message",s,a=[];for(let u of i.split(/\r?\n/)){if(u.startsWith(":"))continue;let l=u.indexOf(":"),[d,g]=l<0?[u,""]:[u.slice(0,l),u.slice(l+1).replace(/^ /,"")];d==="event"?o=g??"":d==="data"?a.push(g??""):d==="id"&&(s=g)}a.length&&e(s===void 0?{event:o,data:a.join(`
1
+ function Ve(e,t={}){let n=Math.min(t.maxMs??3e4,(t.baseMs??1e3)*2**e);return Math.round(n*(.5+.5*(t.random??Math.random)()))}function ut(e){let t="";return n=>{for(t+=n;;){let r=/\r?\n\r?\n/.exec(t);if(!r)return;let i=t.slice(0,r.index);t=t.slice(r.index+r[0].length);let o="message",s,a=[];for(let u of i.split(/\r?\n/)){if(u.startsWith(":"))continue;let l=u.indexOf(":"),[d,g]=l<0?[u,""]:[u.slice(0,l),u.slice(l+1).replace(/^ /,"")];d==="event"?o=g??"":d==="data"?a.push(g??""):d==="id"&&(s=g)}a.length&&e(s===void 0?{event:o,data:a.join(`
2
2
  `)}:{event:o,data:a.join(`
3
- `),id:s})}}}var U=class{constructor(t){this.o=t}o;ctl;stopped=!0;timer;start(){this.stopped&&(this.stopped=!1,this.loop())}stop(){this.stopped=!0,this.ctl?.abort(),this.timer&&clearTimeout(this.timer),this.o.onState?.(!1)}async loop(){let t=0;for(;!this.stopped;){try{await this.connectOnce()&&(t=0)}catch(r){this.stopped||this.o.log?.("flag stream error",r)}if(this.o.onState?.(!1),this.stopped)return;let n=Ae(t++,this.o.backoff);await new Promise(r=>{this.timer=setTimeout(r,n),this.timer.unref?.()})}}async connectOnce(){this.ctl=new AbortController;let t=await this.o.fetch(this.o.url,{headers:{Authorization:`Bearer ${this.o.secretKey}`,Accept:"text/event-stream"},signal:this.ctl.signal});if(!t.ok||!t.body)throw new Error(`stream status ${t.status}`);this.o.onState?.(!0);let n=st(i=>{if(i.event==="definitions")try{this.o.onChange(JSON.parse(i.data).etag)}catch{this.o.onChange(void 0)}}),r=t.body.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:i,value:o}=await r.read();if(i)return!0;n(o)}}};function Y(e){let t=!1,n,r=new U({url:`${e.apiHost}/v1/flags/stream`,secretKey:e.apiKey,fetch:e.fetch,...e.backoff?{backoff:e.backoff}:{},...e.log?{log:e.log}:{},onState:l=>t=l,onChange:l=>{l!==void 0&&l===n||(n=l,e.reload())}}),i=()=>e.visibility?.hidden()??!1,o=e.pollMs??6e4,s=o>0?setInterval(()=>!t&&!i()&&e.reload(),o):void 0,a=()=>{i()?r.stop():(r.start(),e.reload())};i()||r.start();let u=e.visibility?.subscribe(a);return()=>{r.stop(),u?.(),s&&clearInterval(s)}}var at=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),E=(e,t)=>e>>>t|e<<32-t;function $e(e){let t=new TextEncoder().encode(e),n=t.length+9+63>>6<<6,r=new Uint8Array(n);r.set(t),r[t.length]=128;let i=new DataView(r.buffer);i.setUint32(n-8,Math.floor(t.length*8/2**32)),i.setUint32(n-4,t.length*8>>>0);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],s=new Uint32Array(64);for(let a=0;a<n;a+=64){for(let l=0;l<16;l++)s[l]=i.getUint32(a+l*4);for(let l=16;l<64;l++){let d=s[l-15],g=s[l-2],m=E(d,7)^E(d,18)^d>>>3,b=E(g,17)^E(g,19)^g>>>10;s[l]=s[l-16]+m+s[l-7]+b|0}let u=o.slice();for(let l=0;l<64;l++){let[d,g,m,,b,k,y,R]=u,P=R+(E(b,6)^E(b,11)^E(b,25))+(b&k^~b&y)+at[l]+s[l]|0,A=(E(d,2)^E(d,13)^E(d,22))+(d&g^d&m^g&m)|0;u.pop(),u.unshift(P+A|0),u[4]=u[4]+P|0}for(let l=0;l<8;l++)o[l]=o[l]+u[l]|0}return o.map(a=>(a>>>0).toString(16).padStart(8,"0")).join("")}var ct=/^(0|[1-9]\d{0,2})$/,lt=/^[0-9a-fA-F]{1,4}$/,ut=/^(0|[1-9]\d*)$/;function je(e){let t=e.split(".");if(t.length!==4)return;let n=[];for(let r of t){if(!ct.test(r)||Number(r)>255)return;n.push(Number(r))}return n}function ft(e){if(e.includes("%"))return;let t=e,n=e.lastIndexOf(":"),r=e.slice(n+1);if(r.includes(".")){let d=je(r);if(!d)return;t=`${e.slice(0,n+1)}${(d[0]<<8|d[1]).toString(16)}:${(d[2]<<8|d[3]).toString(16)}`}let i=t.split("::");if(i.length>2)return;let o=d=>{if(d==="")return[];let g=[];for(let m of d.split(":")){if(!lt.test(m))return;g.push(parseInt(m,16))}return g},s=o(i[0]),a=i.length===2?o(i[1]):[];if(!s||!a)return;let u=s.length+a.length;return(i.length===2?u>7:u!==8)?void 0:[...s,...Array(8-u).fill(0),...a].flatMap(d=>[d>>8,d&255])}function Me(e){return e.includes(":")?ft(e):je(e)}var dt=e=>e.length===16&&e.slice(0,10).every(t=>t===0)&&e[10]===255&&e[11]===255;function Ve(e){if(typeof e!="string")return;let t=Me(e.trim());return t&&dt(t)?t.slice(12):t}function pt(e){let t=typeof e=="string"?[e]:Array.isArray(e)?e:[],n=[];for(let r of t){if(typeof r!="string")continue;let i=r.trim(),o=i.indexOf("/");if(o<0){let u=Ve(i);u&&n.push({bytes:u,bits:u.length*8});continue}let s=Me(i.slice(0,o)),a=i.slice(o+1);!s||!ut.test(a)||Number(a)>s.length*8||n.push({bytes:s,bits:Number(a)})}return n}function gt(e,t){if(e.bytes.length!==t.length)return!1;for(let n=0;n<e.bits;n+=8){let i=255<<8-Math.min(8,e.bits-n)&255,o=n/8;if((e.bytes[o]&i)!==(t[o]&i))return!1}return!0}function Te(e,t,n,r){switch(e){case"array_contains_any":case"array_contains_all":case"array_contains_none":{if(!Array.isArray(t)||!Array.isArray(n))return!1;let i=n.filter(o=>t.some(s=>r(s,o))).length;return e==="array_contains_any"?i>0:e==="array_contains_all"?i===n.length:i===0}case"ip_in_cidr":case"ip_not_in_cidr":{let i=Ve(t),o=pt(n);return!i||!o.length?!1:o.some(s=>gt(s,i))===(e==="ip_in_cidr")}}return!1}var mt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,Ie=/^\d{4}-\d{2}-\d{2}$/,vt=/^-?(\d{1,6})([hdwmy])$/,yt={h:3600,d:86400,w:604800,m:2592e3,y:31536e3};function bt(e){let t=vt.exec(e.trim());return t?Number(t[1])*yt[t[2]]:void 0}function qe(e,t,n){if(typeof e=="number")return e*1e3;if(typeof e!="string")return;let r=e.trim();if(n){let o=bt(r);if(o!==void 0)return t-o*1e3}if(!mt.test(r)&&!Ie.test(r))return;let i=Date.parse(Ie.test(r)?`${r}T00:00:00Z`:r);return Number.isNaN(i)?void 0:i}function De(e,t){for(let n=0;n<Math.max(e.length,t.length);n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r<i?-1:1}return 0}function ht(e,t,n){if(typeof t!="string")return;let r=t.trim().replace(/^v/,"").split(".");if(e==="semver_wildcard"){let l=r[r.length-1];if(l!=="*"&&l!=="x"&&l!=="X")return;if(r.length===1)return[[0],[2**30]];let d=n.parseVersion(r.slice(0,-1).join("."));if(!d)return;let g=[...d];return g[g.length-1]=g[g.length-1]+1,[d,g]}let i=n.parseVersion(t);if(!i)return;for(;i.length<3;)i.push(0);let[o,s,a]=i,u;return e==="semver_tilde"&&r.length===1?u=[o+1,0,0]:e==="semver_tilde"||o===0&&s>0?u=[o,s+1,0]:o>0?u=[o+1,0,0]:u=[0,0,a+1],[i,u]}function Ne(e,t,n,r,i){switch(e){case"icontains":case"not_icontains":case"starts_with":case"not_starts_with":case"ends_with":case"not_ends_with":return typeof t!="string"||typeof n!="string"?!1:e.endsWith("icontains")?t.toLowerCase().includes(n.toLowerCase())===(e==="icontains"):e.endsWith("starts_with")?t.startsWith(n)===(e==="starts_with"):t.endsWith(n)===(e==="ends_with");case"between":case"not_between":{let o=i.toFloat(t);if(!Array.isArray(n)||n.length!==2||o===void 0)return!1;let[s,a]=n;return typeof s!="number"||typeof a!="number"?!1:(o>=s&&o<=a)==(e==="between")}case"is_date_before":case"is_date_after":{let o=qe(t,r,!1),s=qe(n,r,!0);return o===void 0||s===void 0?!1:e==="is_date_before"?o<s:o>s}case"semver_eq":case"semver_neq":case"semver_gt":case"semver_gte":case"semver_lt":case"semver_lte":{let o=i.cmpVersion(t,n);if(o===void 0)return!1;let s=e.slice(7);return s==="eq"?o===0:s==="neq"?o!==0:s==="gt"?o>0:s==="gte"?o>=0:s==="lt"?o<0:o<=0}case"semver_tilde":case"semver_caret":case"semver_wildcard":{let o=i.parseVersion(t),s=ht(e,n,i);return!!o&&!!s&&De(o,s[0])>=0&&De(o,s[1])<0}}return!1}var _t=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function X(e){if(typeof e=="number")return e;if(typeof e=="string"&&_t.test(e.trim()))return Number(e.trim())}function Z(e,t){let n=typeof e=="number",r=typeof t=="number";return n||r?n&&r&&e===t:e===t}function Q(e){if(typeof e!="string")return;let t=e.trim().replace(/^v/,""),n=t.search(/[-+]/);n>=0&&(t=t.slice(0,n));let r=[];for(let i of t.split(".")){if(!/^[+-]?\d+$/.test(i))return;let o=parseInt(i,10);if(o<0)return;r.push(o)}return r}function z(e,t){let n=Q(e),r=Q(t);if(!(!n||!r)){for(let i=0;i<Math.max(n.length,r.length);i++){let o=n[i]??0,s=r[i]??0;if(o!==s)return o<s?-1:1}return 0}}var xt=(e,t)=>e<t?-1:e>t?1:0;function C(e,t,n,r,i,o=Date.now()){let s=n&&t!==null&&t!==void 0;if(e==="is_set")return s;if(e==="is_not_set")return!s;if(!s)return!1;switch(e){case"eq":case"neq":{let a;if(i){let u=z(t,r);if(u===void 0)return!1;a=u===0}else a=Z(t,r);return a===(e==="eq")}case"contains":case"ncontains":case"regex":case"nregex":{if(typeof t!="string"||typeof r!="string")return!1;if(e==="contains"||e==="ncontains")return t.includes(r)===(e==="contains");let a;try{a=new RegExp(r)}catch{return!1}return a.test(t)===(e==="regex")}case"gt":case"gte":case"lt":case"lte":{let a;if(i)a=z(t,r);else{let u=X(t),l=X(r);a=u===void 0||l===void 0?void 0:xt(u,l)}return a===void 0?!1:e==="gt"?a>0:e==="gte"?a>=0:e==="lt"?a<0:a<=0}case"in":case"not_in":return Array.isArray(r)?r.some(a=>Z(t,a))===(e==="in"):!1}return e.startsWith("array_")||e.startsWith("ip_")?Te(e,t,r,Z):Ne(e,t,r,o,{toFloat:X,parseVersion:Q,cmpVersion:z})}function te(e){return e.properties?.length?`${e.key}|${JSON.stringify(e.properties.map(t=>[t.key,t.op,t.value??null]))}`:e.key}function Le(e,t,n=Date.now()){return(e.properties??[]).every(r=>C(r.op,t[r.key],Object.hasOwn(t,r.key),r.value,!1,n))}function ne(e,t){let n=t[e.scope??"session"]?.[te(e)]??0;return e.op==="is_set"?n>0:e.op==="is_not_set"?n===0:C(e.op,n,!0,e.value,!1)}var He=e=>(e??[]).filter(t=>t.type==="event");function Ke(e,t,n){for(let o of e.runtime??[])if(o.filters.every(a=>{if(a.type!=="flag")return ne(a,t);let u=n(a.key);return!!u&&C(a.op,u.value,!0,a.value,!1)}))return Ke(o.result,t,n);if(!e.runtime)return e;let{runtime:r,...i}=e;return i}function re(e,t){let n={},r=new Map,i=o=>{if(r.get(o)===2)return n[o];let s=e[o];if(!s||r.get(o)===1)return;r.set(o,1);let a=Ke(s,t,i);return n[o]=a,r.set(o,2),a};for(let o of Object.keys(e))i(o);return n}function B(e,t){let n=[],r=o=>{o.type==="event"&&o.properties?.length&&n.push(o)};for(let o of e??[])for(let s of o.conditions)for(let a of s.filters??[])r(a);let i=o=>{for(let s of o.runtime??[])s.filters.forEach(r),i(s.result)};return Object.values(t).forEach(i),n}var ee=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function G(e,t){if(!ee(t))return t;let n=ee(e)?{...e}:{};for(let[r,i]of Object.entries(t))i===null?delete n[r]:n[r]=G(n[r],i);return n}var q=class{session={};page={};sid="";constructor(t){if(t&&typeof t.sid=="string"&&ee(t.session)){this.sid=t.sid;for(let[n,r]of Object.entries(t.session))typeof r=="number"&&r>0&&(this.session[n]=r)}}record(t,n,r={},i=[]){n!==this.sid&&(this.sid=n,this.session={},this.page={}),t==="$pageview"&&(this.page={});let o=new Set([t]);for(let s of i)s.type==="event"&&s.key===t&&s.properties?.length&&Le(s,r)&&o.add(te(s));for(let s of o)this.session[s]=(this.session[s]??0)+1,this.page[s]=(this.page[s]??0)+1}counts(t){return t===this.sid?{session:{...this.session},page:{...this.page}}:{session:{},page:{}}}saved(){return{sid:this.sid,session:{...this.session}}}};function Ue(e,t){let n=t?e.contexts?.[t]:void 0;if(n)return n;if(t==="user")return{key:e.bucketing_key||e.distinct_id,properties:e.person_properties};if(t==="device")return{key:e.device_id,properties:e.device_properties}}var kt=["user","device","org"],Rt=16**13;function D(e,t,n,r=!1){let i=r?`${e}.${t}.variant.${n}`:`${e}.${t}.${n}`;return parseInt($e(i).slice(0,13),16)/Rt}var w=(e,t=-1)=>({value:!1,reason:e,condition_index:t});function wt(e,t){return typeof t=="boolean"?typeof e=="boolean"?e===t:t:e===t}function Ft(e,t,n){let r=t.now?Date.parse(t.now):NaN,i=Number.isNaN(r)?Date.now():r,o;switch(e.type){case"person":o=t.person_properties;break;case"group":o=t.group_properties?.[e.group_type??""];break;case"device":o=t.device_properties;break;case"geo":o=t.geo_properties;break;case"context":if(!kt.includes(e.context_kind??""))return!1;o=Ue(t,e.context_kind)?.properties;break;case"app_version":return C(e.op,t.app_version,!!t.app_version,e.value,!0,i);case"flag":{let s=n[e.key];return!!s&&C(e.op,s.value,!0,e.value,!1,i)}default:return!1}return C(e.op,o?.[e.key],!!o&&Object.hasOwn(o,e.key),e.value,!1,i)}function St(e,t,n){let r=e.variants;if(t.variant_override){let s=r.find(a=>a.key===t.variant_override);if(s)return s}let i=D(e.key,e.salt,n,!0)*100,o=0;for(let s of r)if(o+=s.rollout_pct,i<o)return s;return r[r.length-1]}function Be(e,t){return Ge(e.aggregation,t)}function Ge(e,t){return e.kind==="group"?t.groups?.[e.group_type??""]:e.kind==="device"?t.device_id:e.kind==="context"?Ue(t,e.context_kind)?.key:t.bucketing_key||t.distinct_id}function Et(e,t,n,r){let i=e.sticky?r.sticky_assignments?.[e.key]:void 0;if(i===void 0)return;let o={value:!0,reason:"sticky_bucket",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){if(e.variants.some(a=>a.key===t.variant_override))return;let s=e.variants.find(a=>a.key===i);return s?(o.value=o.variant=s.key,J(o,s.payload,t)):void 0}if(i===!0)return J(o,e.type==="json"?e.payload:void 0,t)}function J(e,t,n){let r=n.payload_patch===void 0||n.payload_patch===null?t:G(t,n.payload_patch);return r!==void 0&&(e.payload=r),e}var oe=(e,t)=>t.length?{...e,runtime:t}:e;function Ot(e,t){return!e.app_contexts?.length||!t.app_contexts?.length?!0:e.app_contexts.some(n=>t.app_contexts?.includes(n))}function Je(e,t,n={}){if(!Ot(e,t))return w("app_context_excluded");if(!e.active)return w("inactive");if(e.kill_switch)return w("kill_switch");let r=!1;for(let u of e.prerequisites??[]){let l=n[u.flag];if(!l)return w("prerequisite_missing");if(l.reason==="requires_server")r=!0;else if(l.reason==="prerequisite_cycle"||!wt(l.value,u.value))return w("prerequisite_failed")}if(r)return w("requires_server");let i=Be(e,t),o=e.conditions.some(u=>u.aggregation);if(!i&&(!o||e.holdout||e.namespace))return w("no_bucketing_key");if(e.holdout&&D("holdout",e.holdout.salt,i??"")*100<e.holdout.percentage)return w("holdout");if(e.namespace&&e.namespace.total>0){let u=Math.floor(D("namespace",e.namespace.salt,i??"")*e.namespace.total);if(u<e.namespace.start||u>=e.namespace.end)return w("namespace_excluded")}let s=0,a=[];for(let[u,l]of e.conditions.entries()){let d=l.aggregation?Ge(l.aggregation,t):i;if(!d){s++;continue}let g=!1,m=!0,b=!1;for(let y of l.filters??[]){if(y.type==="event"){if(t.runtime_events===void 0)b=!0;else if(!ne(y,t.runtime_events)){m=!1;break}continue}let R=y.type==="cohort"?t.cohorts?.[y.key]:void 0;if(R!==void 0){if(R===(y.op==="not_in"||y.op==="neq")){m=!1;break}}else if(y.type==="cohort"||y.type==="flag"&&n[y.key]?.reason==="requires_server")g=!0;else if(!Ft(y,t,n)){m=!1;break}}if(!m)continue;if(g)return oe(w("requires_server",u),a);let k=Pt(e,l,u,t,d);if(k)if(b)a.push({filters:He(l.filters),result:k});else return oe(k,a)}return oe(w(s>0&&s===e.conditions.length?"no_bucketing_key":"no_condition_match"),a)}function Pt(e,t,n,r,i){let o=t.aggregation?void 0:Et(e,t,n,r);if(o)return o;if(D(e.key,e.salt,i)*100>=t.rollout_pct)return e.early_exit?w("out_of_rollout",n):void 0;let s={value:!0,reason:"condition_match",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){let a=St(e,t,i);return s.value=s.variant=a.key,J(s,a.payload,t)}return J(s,e.type==="json"?e.payload:void 0,t)}function We(e){return[...(e.prerequisites??[]).map(t=>t.flag),...e.conditions.flatMap(t=>(t.filters??[]).filter(n=>n.type==="flag").map(n=>n.key))]}function se(e,t){let n=new Map(e.map(s=>[s.key,s])),r={},i=new Map,o=s=>{let a=n.get(s);if(!a||i.has(s))return;i.set(s,1);let u=!1;for(let l of We(a))o(l),(i.get(l)===1||r[l]?.reason==="prerequisite_cycle")&&(u=!0);r[s]=u?w("prerequisite_cycle"):At(a,t,r),i.set(s,2)};for(let s of e)o(s.key);return r}var Ct=4;function At(e,t,n){let r=[];for(let i of We(e))!r.includes(i)&&n[i]?.runtime?.length&&r.length<Ct&&r.push(i);return ie(e,t,n,r)}function ie(e,t,n,r){let[i,...o]=r;if(i===void 0)return Je(e,t,n);let s=ie(e,t,n,o),a=n[i],u=new Set([a.value]),l=[];for(let b of Ye(a)){if(u.has(b.value))continue;u.add(b.value);let k=ie(e,t,{...n,[i]:b},o);Xe(k,s)||l.push({filters:[{type:"flag",key:i,op:"eq",value:b.value}],result:k})}let d=[...l,...s.runtime??[]],{runtime:g,...m}=s;return d.length?{...m,runtime:d}:m}function Ye(e){return(e.runtime??[]).flatMap(t=>{let{runtime:n,...r}=t.result;return[r,...Ye(t.result)]})}function Xe(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let o of i)if(!Xe(n[o],r[o]))return!1;return!0}var ae=e=>e.reason==="requires_server",ce=e=>e.reason!=="app_context_excluded";function le(e,t,n,r){return{key:e,value:t,enabled:t!==void 0&&t!==!1,...typeof t=="string"?{variant:t}:{},...n!==void 0?{payload:n}:{},reason:t===void 0?"not_found":r}}var N=class{constructor(t,n=Date.now){this.ttlMs=t;this.now=n}ttlMs;now;stamp;mark(t){return this.stamp={at:this.now(),id:t}}restore(t){typeof t?.at=="number"&&typeof t.id=="string"&&(this.stamp={at:t.at,id:t.id})}fresh(t){return!!this.ttlMs&&this.ttlMs>0&&!!this.stamp&&this.stamp.id===t&&this.now()-this.stamp.at<this.ttlMs}clear(){this.stamp=void 0}};var $t="lc_preview",ue="lc_preview";function jt(e){let t={};for(let n of(e??"").split(",")){let r=n.indexOf(":");r>0&&r<n.length-1&&(t[n.slice(0,r)]=n.slice(r+1))}return t}function Ze(e){let t=new URL(e).searchParams.get($t),n=null;try{n=sessionStorage.getItem(ue)}catch{}return{forced:jt(t==="off"?null:t??n),persist(){try{t==="off"?sessionStorage.removeItem(ue):t&&sessionStorage.setItem(ue,t)}catch{}}}}var fe=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid"];var de=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];var pe="lc_flag_initial";function Mt(e){try{return e?new URL(e).hostname:""}catch{return""}}function Vt(){let e=new URLSearchParams(location.search),t={$initial_referrer:document.referrer||"$direct",$initial_referring_domain:Mt(document.referrer)||"$direct",$initial_current_url:location.href.split("#")[0]};for(let n of[...de,...fe]){let r=e.get(n);r&&(t[`$initial_${n}`]=r)}return t}function ze(e,t){if(typeof location>"u")return{};let n=e.get(pe);if(n)try{return JSON.parse(n)}catch{}let r=Vt();return t(()=>{e.get(pe)||e.set(pe,JSON.stringify(r))}),r}function Tt(){let e=navigator.userAgent,t=/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":/Firefox\//.test(e)?"Firefox":/Chrome\/|CriOS/.test(e)?"Chrome":/Safari\//.test(e)?"Safari":"Other",n=/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"Mac OS X":/CrOS/.test(e)?"Chrome OS":/Linux/.test(e)?"Linux":"Other";return{browser:t,os:n}}function Qe(){if(typeof location>"u"||typeof navigator>"u")return{};let e={},t=new URLSearchParams(location.search);for(let i of[...de,...fe]){let o=t.get(i);o&&(e[`$${i}`]=o)}let{browser:n,os:r}=Tt();return e.$browser=n,e.$os=r,e.$device_type=String(ge().$device_type??"Desktop"),e}function ge(){if(typeof window>"u")return{};let e=window.innerWidth;return{$viewport_width:e,$viewport_height:window.innerHeight,$screen_width:screen.width,$screen_height:screen.height,$browser_language:navigator.language,$device_type:e<768?"Mobile":e<1024?"Tablet":"Desktop"}}function me(e){return typeof e=="object"?e.value??e.variant??!!e.enabled:e}function ve(e){let t={value:me(e),reason:e.reason??"remote",condition_index:e.condition_index??-1};return e.variant&&(t.variant=e.variant),e.payload!==void 0&&(t.payload=e.payload),e.runtime?.length&&(t.runtime=e.runtime.map(n=>({filters:n.filters,result:ve(n.result)}))),t}var et="lc_rt_events",tt=e=>!!e?.some(t=>t.conditions.some(n=>n.filters?.some(r=>r.type==="event")));function nt(e,t){let n;try{let s=e.flagStorage.get(et);s&&(n=JSON.parse(s))}catch{}let r=new q(n),i={},o=B(t,i);return{counts:()=>r.counts(e.core.sessionId),setServer(s){i=s,o=B(t,i)},server:()=>i,drop(s){for(let a of s)delete i[a]},resolved(){return re(i,r.counts(e.core.sessionId))},record(s,a,u){r.record(s,e.core.sessionId,a,o),u&&e.whenConsented(()=>e.flagStorage.set(et,JSON.stringify(r.saved())))}}}var rt="lc_flags",ye="lc_flag_overrides_api";function ot(e){try{let t=localStorage.getItem("lc_flag_overrides");return t?JSON.parse(t)[e]:void 0}catch{return}}var kn=e=>{let{core:t,config:n}=e,r={},i={},o={},s,a=!1,u=0,l=new Set,d=new Set,g="",m={},b=()=>Object.keys(m).length>0,k={},y={},R={},P=new Set,A=typeof location>"u"?{forced:{},persist(){}}:Ze(location.href),it=Object.keys(A.forced).length>0,$=()=>({...r,...R}),h=e.config.flagOptions??{},j=new N(h.cacheTtlMs),be=(e.config.flagsApiHost??e.config.apiHost).replace(/\/+$/,""),he=h.keys?.length?new Set(h.keys):void 0,_e=c=>he?Object.fromEntries(Object.entries(c).filter(([f])=>he.has(f))):c,I=(c,f,p=!0)=>{if(r=_e(c),i=_e(f),a=!0,p)for(let v of P)v($())},M=nt(e,n.localFlags),xe=e.flagStorage.get(rt);if(xe)try{let c=JSON.parse(xe);r=c.values,i=c.payloads,o=Object.fromEntries(Object.keys(r).map(f=>[f,"cached"])),c.rt&&M.setServer(c.rt),j.restore(c)}catch{}let ke=e.flagStorage.get(ye);if(ke)try{R=JSON.parse(ke)}catch{}let L=n.bootstrap;if(L?.flags){I({...L.flags},{...L.payloads});for(let c of Object.keys(L.flags))o[c]="bootstrap"}let Re={},we=()=>({...h.autoProperties===!1?{}:Qe(),...ze(t.storage,e.whenConsented),...Object.assign({},...e.flagPersonProps.map(c=>c())),...k}),Fe=h.evaluationContexts?.length?{app_contexts:h.evaluationContexts}:{},W=(c=!0)=>{let f=n.localFlags;if(!f?.length)return!0;let p=n.localFlagsContext,v=se(f,{runtime_events:M.counts(),distinct_id:t.distinctId,...t.groups?{groups:t.groups}:{},...t.deviceId?{device_id:t.deviceId}:{},...b()?{contexts:m}:{},...Fe,...p,person_properties:{...we(),...p?.person_properties},group_properties:{...p?.group_properties,...y}}),_={},x={},V=!1;for(let[T,F]of Object.entries(v))ae(F)?V=!0:ce(F)&&(_[T]=F.value,o[T]=F.reason,F.payload!==void 0&&(x[T]=F.payload));return Re=_,I({...r,..._},{...i,...x},c),V},Se=c=>{let f={...r},p={...i};for(let[v,_]of Object.entries(M.resolved()))f[v]=_.value,o[v]=_.reason,_.payload!==void 0?p[v]=_.payload:delete p[v];I(f,p,c)},Ee=tt(n.localFlags);e.onCapture(c=>{let f=Ee||Object.keys(M.server()).length>0;if(M.record(c.event,c.properties,f),!f)return;let p=JSON.stringify([$(),i]);if(Ee&&W(!1),Se(!1),JSON.stringify([$(),i])!==p)for(let v of P)v($())});let O=(c=!0)=>{let f=++u;return!W()||h.disableRemote||!c&&j.fresh(t.distinctId)?Promise.resolve():new Promise(p=>{e.whenConsented(()=>{if(f!==u)return p();A.persist();let v=new AbortController,_=setTimeout(()=>v.abort(),h.timeoutMs??1e4);e.fetch(`${be}/v1/flags`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",signal:v.signal,body:JSON.stringify({api_key:e.apiKey,...t.distinctId?{distinct_id:t.distinctId}:{},...t.anonDistinctId?{anon_distinct_id:t.anonDistinctId}:{},groups:t.groups??{},person_properties:we(),...Object.keys(y).length?{group_properties:y}:{},device_properties:ge(),...t.deviceId?{device_id:t.deviceId}:{},...b()?{contexts:m}:{},...Fe,...it?{preview:A.forced}:{},...h.keys?.length?{flag_keys:h.keys}:{}})}).then(x=>x.ok?x.json():Promise.reject(new Error(`status ${x.status}`))).then(x=>{if(f!==u)return;if(x.quota_limited)return e.log("flags quota limited; keeping cached values");let V={},T={},F={};for(let[K,S]of Object.entries(x.flags??{}))V[K]=me(S),typeof S=="object"&&S.payload!==void 0&&(T[K]=S.payload),o[K]=typeof S=="object"&&typeof S.reason=="string"?S.reason:"remote",typeof S=="object"&&S.runtime?.length&&(F[K]=ve(S));s=x.request_id,M.setServer(F),I({...Re,...V},T,!1),Se(!0),e.flagStorage.set(rt,JSON.stringify({values:V,payloads:T,rt:F,...j.mark(t.distinctId)})),e.log("flags loaded",V)}).catch(x=>e.log("flags fetch failed",x)).finally(()=>{clearTimeout(_),p()})})})},Oe=c=>R[c]??ot(c)??r[c];e.flags={get(c){let f=Oe(c);if(f===void 0)return;if(c in A.forced||c in R)return f;let p=t.sessionId;p!==g&&(l.clear(),d.clear(),g=p),d.has(c)||(d.add(c),t.capture("$exposure",{$feature_flag:c,$feature_flag_response:f,...typeof f=="string"?{$feature_flag_variant:f}:{},...s?{$feature_flag_request_id:s}:{}}));let v=`${c}:${String(f)}`;return l.has(v)||(l.add(v),t.capture("$feature_flag_called",{$feature_flag:c,$feature_flag_response:f,...s?{$feature_flag_request_id:s}:{}})),f},all:()=>a||Object.keys(r).length||Object.keys(R).length?$():{},payload:c=>i[c],result(c,f){let p=f?.sendExposure===!1?Oe(c):this.get(c),v=c in R||ot(c)!==void 0?"override":c in A.forced?"preview":o[c]??"remote";return le(c,p,i[c],v)},layerParam(c,f){for(let[p,v]of Object.entries(i)){let _=v;if(_?.lc_layer!==c||!_.lc_params||!(f in _.lc_params))continue;let x=this.get(p);if(x!==void 0&&x!==!1)return _.lc_params[f]}},onChange(c){return P.add(c),a&&c($()),()=>{P.delete(c)}},reload:O,update(c,f,p=!0){for(let v of Object.keys(c))o[v]="pushed";M.drop(Object.keys(c)),I(p?{...r,...c}:{...c},p?{...i,...f}:{...f})},override(c,f){R=c?{...c}:{},c?f?.persist&&e.whenConsented(()=>e.flagStorage.set(ye,JSON.stringify(R))):e.flagStorage.remove(ye);for(let p of P)p($())},setPersonProperties(c,f=!0){j.clear(),k={...k,...c},f&&O()},resetPersonProperties(){k={}},setGroupProperties(c,f=!0){j.clear();for(let[p,v]of Object.entries(c))y[p]={...y[p],...v};f&&O()},resetGroupProperties(){y={}},setContext(c,f,p){j.clear(),m={...m,[c]:{key:f,properties:p??{}}},O()},clearContext(c){j.clear();let{[c]:f,...p}=m;m=p,O()}},t.onChange(c=>{c==="reset"&&(m={},k={},y={}),(c==="identify"||c==="reset"||c==="group")&&O()}),n.disableFlagsOnFirstLoad?W():O(!1);let H=n.flagStream,Pe;H&&!h.disableRemote&&e.whenConsented(()=>{Pe=Y({apiHost:be,apiKey:e.apiKey,fetch:e.fetch,reload:()=>{O()},visibility:{hidden:()=>document.visibilityState==="hidden",subscribe:c=>(document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c))},...typeof H=="object"&&H.pollMs!==void 0?{pollMs:H.pollMs}:{},log:e.log})});let Ce=h.refreshMs&&h.refreshMs>0&&!h.disableRemote?setInterval(()=>document.visibilityState!=="hidden"&&void O(!1),h.refreshMs):void 0;return()=>{Pe?.(),Ce&&clearInterval(Ce)}};export{kn as flags};
3
+ `),id:s})}}}var J=class{constructor(t){this.o=t}o;ctl;stopped=!0;timer;start(){this.stopped&&(this.stopped=!1,this.loop())}stop(){this.stopped=!0,this.ctl?.abort(),this.timer&&clearTimeout(this.timer),this.o.onState?.(!1)}async loop(){let t=0;for(;!this.stopped;){try{await this.connectOnce()&&(t=0)}catch(r){this.stopped||this.o.log?.("flag stream error",r)}if(this.o.onState?.(!1),this.stopped)return;let n=Ve(t++,this.o.backoff);await new Promise(r=>{this.timer=setTimeout(r,n),this.timer.unref?.()})}}async connectOnce(){this.ctl=new AbortController;let t=await this.o.fetch(this.o.url,{headers:{Authorization:`Bearer ${this.o.secretKey}`,Accept:"text/event-stream"},signal:this.ctl.signal});if(!t.ok||!t.body)throw new Error(`stream status ${t.status}`);this.o.onState?.(!0);let n=ut(i=>{if(i.event==="definitions")try{this.o.onChange(JSON.parse(i.data).etag)}catch{this.o.onChange(void 0)}}),r=t.body.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:i,value:o}=await r.read();if(i)return!0;n(o)}}};function ee(e){let t=!1,n,r=new J({url:`${e.apiHost}/v1/flags/stream`,secretKey:e.apiKey,fetch:e.fetch,...e.backoff?{backoff:e.backoff}:{},...e.log?{log:e.log}:{},onState:l=>t=l,onChange:l=>{l!==void 0&&l===n||(n=l,e.reload())}}),i=()=>e.visibility?.hidden()??!1,o=e.pollMs??6e4,s=o>0?setInterval(()=>!t&&!i()&&e.reload(),o):void 0,a=()=>{i()?r.stop():(r.start(),e.reload())};i()||r.start();let u=e.visibility?.subscribe(a);return()=>{r.stop(),u?.(),s&&clearInterval(s)}}var ft=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),C=(e,t)=>e>>>t|e<<32-t;function qe(e){let t=new TextEncoder().encode(e),n=t.length+9+63>>6<<6,r=new Uint8Array(n);r.set(t),r[t.length]=128;let i=new DataView(r.buffer);i.setUint32(n-8,Math.floor(t.length*8/2**32)),i.setUint32(n-4,t.length*8>>>0);let o=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],s=new Uint32Array(64);for(let a=0;a<n;a+=64){for(let l=0;l<16;l++)s[l]=i.getUint32(a+l*4);for(let l=16;l<64;l++){let d=s[l-15],g=s[l-2],h=C(d,7)^C(d,18)^d>>>3,y=C(g,17)^C(g,19)^g>>>10;s[l]=s[l-16]+h+s[l-7]+y|0}let u=o.slice();for(let l=0;l<64;l++){let[d,g,h,,y,x,v,S]=u,_=S+(C(y,6)^C(y,11)^C(y,25))+(y&x^~y&v)+ft[l]+s[l]|0,k=(C(d,2)^C(d,13)^C(d,22))+(d&g^d&h^g&h)|0;u.pop(),u.unshift(_+k|0),u[4]=u[4]+_|0}for(let l=0;l<8;l++)o[l]=o[l]+u[l]|0}return o.map(a=>(a>>>0).toString(16).padStart(8,"0")).join("")}var dt=/^(0|[1-9]\d{0,2})$/,pt=/^[0-9a-fA-F]{1,4}$/,gt=/^(0|[1-9]\d*)$/;function Ie(e){let t=e.split(".");if(t.length!==4)return;let n=[];for(let r of t){if(!dt.test(r)||Number(r)>255)return;n.push(Number(r))}return n}function mt(e){if(e.includes("%"))return;let t=e,n=e.lastIndexOf(":"),r=e.slice(n+1);if(r.includes(".")){let d=Ie(r);if(!d)return;t=`${e.slice(0,n+1)}${(d[0]<<8|d[1]).toString(16)}:${(d[2]<<8|d[3]).toString(16)}`}let i=t.split("::");if(i.length>2)return;let o=d=>{if(d==="")return[];let g=[];for(let h of d.split(":")){if(!pt.test(h))return;g.push(parseInt(h,16))}return g},s=o(i[0]),a=i.length===2?o(i[1]):[];if(!s||!a)return;let u=s.length+a.length;return(i.length===2?u>7:u!==8)?void 0:[...s,...Array(8-u).fill(0),...a].flatMap(d=>[d>>8,d&255])}function De(e){return e.includes(":")?mt(e):Ie(e)}var vt=e=>e.length===16&&e.slice(0,10).every(t=>t===0)&&e[10]===255&&e[11]===255;function Ne(e){if(typeof e!="string")return;let t=De(e.trim());return t&&vt(t)?t.slice(12):t}function yt(e){let t=typeof e=="string"?[e]:Array.isArray(e)?e:[],n=[];for(let r of t){if(typeof r!="string")continue;let i=r.trim(),o=i.indexOf("/");if(o<0){let u=Ne(i);u&&n.push({bytes:u,bits:u.length*8});continue}let s=De(i.slice(0,o)),a=i.slice(o+1);!s||!gt.test(a)||Number(a)>s.length*8||n.push({bytes:s,bits:Number(a)})}return n}function bt(e,t){if(e.bytes.length!==t.length)return!1;for(let n=0;n<e.bits;n+=8){let i=255<<8-Math.min(8,e.bits-n)&255,o=n/8;if((e.bytes[o]&i)!==(t[o]&i))return!1}return!0}function Le(e,t,n,r){switch(e){case"array_contains_any":case"array_contains_all":case"array_contains_none":{if(!Array.isArray(t)||!Array.isArray(n))return!1;let i=n.filter(o=>t.some(s=>r(s,o))).length;return e==="array_contains_any"?i>0:e==="array_contains_all"?i===n.length:i===0}case"ip_in_cidr":case"ip_not_in_cidr":{let i=Ne(t),o=yt(n);return!i||!o.length?!1:o.some(s=>bt(s,i))===(e==="ip_in_cidr")}}return!1}var _t=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,He=/^\d{4}-\d{2}-\d{2}$/,ht=/^-?(\d{1,6})([hdwmy])$/,xt={h:3600,d:86400,w:604800,m:2592e3,y:31536e3};function kt(e){let t=ht.exec(e.trim());return t?Number(t[1])*xt[t[2]]:void 0}function Ke(e,t,n){if(typeof e=="number")return e*1e3;if(typeof e!="string")return;let r=e.trim();if(n){let o=kt(r);if(o!==void 0)return t-o*1e3}if(!_t.test(r)&&!He.test(r))return;let i=Date.parse(He.test(r)?`${r}T00:00:00Z`:r);return Number.isNaN(i)?void 0:i}function Be(e,t){for(let n=0;n<Math.max(e.length,t.length);n++){let r=e[n]??0,i=t[n]??0;if(r!==i)return r<i?-1:1}return 0}function Rt(e,t,n){if(typeof t!="string")return;let r=t.trim().replace(/^v/,"").split(".");if(e==="semver_wildcard"){let l=r[r.length-1];if(l!=="*"&&l!=="x"&&l!=="X")return;if(r.length===1)return[[0],[2**30]];let d=n.parseVersion(r.slice(0,-1).join("."));if(!d)return;let g=[...d];return g[g.length-1]=g[g.length-1]+1,[d,g]}let i=n.parseVersion(t);if(!i)return;for(;i.length<3;)i.push(0);let[o,s,a]=i,u;return e==="semver_tilde"&&r.length===1?u=[o+1,0,0]:e==="semver_tilde"||o===0&&s>0?u=[o,s+1,0]:o>0?u=[o+1,0,0]:u=[0,0,a+1],[i,u]}function Ue(e,t,n,r,i){switch(e){case"icontains":case"not_icontains":case"starts_with":case"not_starts_with":case"ends_with":case"not_ends_with":return typeof t!="string"||typeof n!="string"?!1:e.endsWith("icontains")?t.toLowerCase().includes(n.toLowerCase())===(e==="icontains"):e.endsWith("starts_with")?t.startsWith(n)===(e==="starts_with"):t.endsWith(n)===(e==="ends_with");case"between":case"not_between":{let o=i.toFloat(t);if(!Array.isArray(n)||n.length!==2||o===void 0)return!1;let[s,a]=n;return typeof s!="number"||typeof a!="number"?!1:(o>=s&&o<=a)==(e==="between")}case"is_date_before":case"is_date_after":{let o=Ke(t,r,!1),s=Ke(n,r,!0);return o===void 0||s===void 0?!1:e==="is_date_before"?o<s:o>s}case"semver_eq":case"semver_neq":case"semver_gt":case"semver_gte":case"semver_lt":case"semver_lte":{let o=i.cmpVersion(t,n);if(o===void 0)return!1;let s=e.slice(7);return s==="eq"?o===0:s==="neq"?o!==0:s==="gt"?o>0:s==="gte"?o>=0:s==="lt"?o<0:o<=0}case"semver_tilde":case"semver_caret":case"semver_wildcard":{let o=i.parseVersion(t),s=Rt(e,n,i);return!!o&&!!s&&Be(o,s[0])>=0&&Be(o,s[1])<0}}return!1}var wt=/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;function te(e){if(typeof e=="number")return e;if(typeof e=="string"&&wt.test(e.trim()))return Number(e.trim())}function ne(e,t){let n=typeof e=="number",r=typeof t=="number";return n||r?n&&r&&e===t:e===t}function oe(e){if(typeof e!="string")return;let t=e.trim().replace(/^v/,""),n=t.search(/[-+]/);n>=0&&(t=t.slice(0,n));let r=[];for(let i of t.split(".")){if(!/^[+-]?\d+$/.test(i))return;let o=parseInt(i,10);if(o<0)return;r.push(o)}return r}function re(e,t){let n=oe(e),r=oe(t);if(!(!n||!r)){for(let i=0;i<Math.max(n.length,r.length);i++){let o=n[i]??0,s=r[i]??0;if(o!==s)return o<s?-1:1}return 0}}var St=(e,t)=>e<t?-1:e>t?1:0;function V(e,t,n,r,i,o=Date.now()){let s=n&&t!==null&&t!==void 0;if(e==="is_set")return s;if(e==="is_not_set")return!s;if(!s)return!1;switch(e){case"eq":case"neq":{let a;if(i){let u=re(t,r);if(u===void 0)return!1;a=u===0}else a=ne(t,r);return a===(e==="eq")}case"contains":case"ncontains":case"regex":case"nregex":{if(typeof t!="string"||typeof r!="string")return!1;if(e==="contains"||e==="ncontains")return t.includes(r)===(e==="contains");let a;try{a=new RegExp(r)}catch{return!1}return a.test(t)===(e==="regex")}case"gt":case"gte":case"lt":case"lte":{let a;if(i)a=re(t,r);else{let u=te(t),l=te(r);a=u===void 0||l===void 0?void 0:St(u,l)}return a===void 0?!1:e==="gt"?a>0:e==="gte"?a>=0:e==="lt"?a<0:a<=0}case"in":case"not_in":return Array.isArray(r)?r.some(a=>ne(t,a))===(e==="in"):!1}return e.startsWith("array_")||e.startsWith("ip_")?Le(e,t,r,ne):Ue(e,t,r,o,{toFloat:te,parseVersion:oe,cmpVersion:re})}function se(e){return e.properties?.length?`${e.key}|${JSON.stringify(e.properties.map(t=>[t.key,t.op,t.value??null]))}`:e.key}function We(e,t,n=Date.now()){return(e.properties??[]).every(r=>V(r.op,t[r.key],Object.hasOwn(t,r.key),r.value,!1,n))}function ae(e,t){let n=t[e.scope??"session"]?.[se(e)]??0;return e.op==="is_set"?n>0:e.op==="is_not_set"?n===0:V(e.op,n,!0,e.value,!1)}var Ge=e=>(e??[]).filter(t=>t.type==="event");function Je(e,t,n){for(let o of e.runtime??[])if(o.filters.every(a=>{if(a.type!=="flag")return ae(a,t);let u=n(a.key);return!!u&&V(a.op,u.value,!0,a.value,!1)}))return Je(o.result,t,n);if(!e.runtime)return e;let{runtime:r,...i}=e;return i}function ce(e,t){let n={},r=new Map,i=o=>{if(r.get(o)===2)return n[o];let s=e[o];if(!s||r.get(o)===1)return;r.set(o,1);let a=Je(s,t,i);return n[o]=a,r.set(o,2),a};for(let o of Object.keys(e))i(o);return n}function Y(e,t){let n=[],r=o=>{o.type==="event"&&o.properties?.length&&n.push(o)};for(let o of e??[])for(let s of o.conditions)for(let a of s.filters??[])r(a);let i=o=>{for(let s of o.runtime??[])s.filters.forEach(r),i(s.result)};return Object.values(t).forEach(i),n}var ie=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function X(e,t){if(!ie(t))return t;let n=ie(e)?{...e}:{};for(let[r,i]of Object.entries(t))i===null?delete n[r]:n[r]=X(n[r],i);return n}var L=class{session={};page={};sid="";constructor(t){if(t&&typeof t.sid=="string"&&ie(t.session)){this.sid=t.sid;for(let[n,r]of Object.entries(t.session))typeof r=="number"&&r>0&&(this.session[n]=r)}}record(t,n,r={},i=[]){n!==this.sid&&(this.sid=n,this.session={},this.page={}),t==="$pageview"&&(this.page={});let o=new Set([t]);for(let s of i)s.type==="event"&&s.key===t&&s.properties?.length&&We(s,r)&&o.add(se(s));for(let s of o)this.session[s]=(this.session[s]??0)+1,this.page[s]=(this.page[s]??0)+1}counts(t){return t===this.sid?{session:{...this.session},page:{...this.page}}:{session:{},page:{}}}saved(){return{sid:this.sid,session:{...this.session}}}};function Ye(e,t){let n=t?e.contexts?.[t]:void 0;if(n)return n;if(t==="user")return{key:e.bucketing_key||e.distinct_id,properties:e.person_properties};if(t==="device")return{key:e.device_id,properties:e.device_properties}}var Ft=["user","device","org"],Et=16**13;function H(e,t,n,r=!1){let i=r?`${e}.${t}.variant.${n}`:`${e}.${t}.${n}`;return parseInt(qe(i).slice(0,13),16)/Et}var F=(e,t=-1)=>({value:!1,reason:e,condition_index:t});function Ot(e,t){return typeof t=="boolean"?typeof e=="boolean"?e===t:t:e===t}function Pt(e,t,n){let r=t.now?Date.parse(t.now):NaN,i=Number.isNaN(r)?Date.now():r,o;switch(e.type){case"person":o=t.person_properties;break;case"group":o=t.group_properties?.[e.group_type??""];break;case"device":o=t.device_properties;break;case"geo":o=t.geo_properties;break;case"context":if(!Ft.includes(e.context_kind??""))return!1;o=Ye(t,e.context_kind)?.properties;break;case"app_version":return V(e.op,t.app_version,!!t.app_version,e.value,!0,i);case"flag":{let s=n[e.key];return!!s&&V(e.op,s.value,!0,e.value,!1,i)}default:return!1}return V(e.op,o?.[e.key],!!o&&Object.hasOwn(o,e.key),e.value,!1,i)}function Ct(e,t,n){let r=e.variants;if(t.variant_override){let s=r.find(a=>a.key===t.variant_override);if(s)return s}let i=H(e.key,e.salt,n,!0)*100,o=0;for(let s of r)if(o+=s.rollout_pct,i<o)return s;return r[r.length-1]}function Xe(e,t){return Ze(e.aggregation,t)}function Ze(e,t){return e.kind==="group"?t.groups?.[e.group_type??""]:e.kind==="device"?t.device_id:e.kind==="context"?Ye(t,e.context_kind)?.key:t.bucketing_key||t.distinct_id}function At(e,t,n,r){let i=e.sticky?r.sticky_assignments?.[e.key]:void 0;if(i===void 0)return;let o={value:!0,reason:"sticky_bucket",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){if(e.variants.some(a=>a.key===t.variant_override))return;let s=e.variants.find(a=>a.key===i);return s?(o.value=o.variant=s.key,z(o,s.payload,t)):void 0}if(i===!0)return z(o,e.type==="json"?e.payload:void 0,t)}function z(e,t,n){let r=n.payload_patch===void 0||n.payload_patch===null?t:X(t,n.payload_patch);return r!==void 0&&(e.payload=r),e}var le=(e,t)=>t.length?{...e,runtime:t}:e;function $t(e,t){return!e.app_contexts?.length||!t.app_contexts?.length?!0:e.app_contexts.some(n=>t.app_contexts?.includes(n))}function ze(e,t,n={}){if(!$t(e,t))return F("app_context_excluded");if(!e.active)return F("inactive");if(e.kill_switch)return F("kill_switch");let r=!1;for(let u of e.prerequisites??[]){let l=n[u.flag];if(!l)return F("prerequisite_missing");if(l.reason==="requires_server")r=!0;else if(l.reason==="prerequisite_cycle"||!Ot(l.value,u.value))return F("prerequisite_failed")}if(r)return F("requires_server");let i=Xe(e,t),o=e.conditions.some(u=>u.aggregation);if(!i&&(!o||e.holdout||e.namespace))return F("no_bucketing_key");if(e.holdout&&H("holdout",e.holdout.salt,i??"")*100<e.holdout.percentage)return F("holdout");if(e.namespace&&e.namespace.total>0){let u=Math.floor(H("namespace",e.namespace.salt,i??"")*e.namespace.total);if(u<e.namespace.start||u>=e.namespace.end)return F("namespace_excluded")}let s=0,a=[];for(let[u,l]of e.conditions.entries()){let d=l.aggregation?Ze(l.aggregation,t):i;if(!d){s++;continue}let g=!1,h=!0,y=!1;for(let v of l.filters??[]){if(v.type==="event"){if(t.runtime_events===void 0)y=!0;else if(!ae(v,t.runtime_events)){h=!1;break}continue}let S=v.type==="cohort"?t.cohorts?.[v.key]:void 0;if(S!==void 0){if(S===(v.op==="not_in"||v.op==="neq")){h=!1;break}}else if(v.type==="cohort"||v.type==="flag"&&n[v.key]?.reason==="requires_server")g=!0;else if(!Pt(v,t,n)){h=!1;break}}if(!h)continue;if(g)return le(F("requires_server",u),a);let x=jt(e,l,u,t,d);if(x)if(y)a.push({filters:Ge(l.filters),result:x});else return le(x,a)}return le(F(s>0&&s===e.conditions.length?"no_bucketing_key":"no_condition_match"),a)}function jt(e,t,n,r,i){let o=t.aggregation?void 0:At(e,t,n,r);if(o)return o;if(H(e.key,e.salt,i)*100>=t.rollout_pct)return e.early_exit?F("out_of_rollout",n):void 0;let s={value:!0,reason:"condition_match",condition_index:n};if(e.type==="multivariate"&&e.variants?.length){let a=Ct(e,t,i);return s.value=s.variant=a.key,z(s,a.payload,t)}return z(s,e.type==="json"?e.payload:void 0,t)}function Qe(e){return[...(e.prerequisites??[]).map(t=>t.flag),...e.conditions.flatMap(t=>(t.filters??[]).filter(n=>n.type==="flag").map(n=>n.key))]}function ue(e,t){let n=new Map(e.map(s=>[s.key,s])),r={},i=new Map,o=s=>{let a=n.get(s);if(!a||i.has(s))return;i.set(s,1);let u=!1;for(let l of Qe(a))o(l),(i.get(l)===1||r[l]?.reason==="prerequisite_cycle")&&(u=!0);r[s]=u?F("prerequisite_cycle"):Mt(a,t,r),i.set(s,2)};for(let s of e)o(s.key);return r}function Mt(e,t,n){return Z(e,t,n,[],new Set)}function Z(e,t,n,r,i){let[o,...s]=r;if(o===void 0){let x=new Set,v=new Proxy(n,{get:(k,A)=>(x.add(String(A)),k[A])}),S=ze(e,t,v),_=[];for(let k of Qe(e))x.has(k)&&!i.has(k)&&!_.includes(k)&&n[k]?.runtime?.length&&_.push(k);return _.length?Z(e,t,n,_,new Set([...i,..._])):S}let a=Z(e,t,n,s,i),u=n[o],l=new Set([u.value]),d=[];for(let x of et(u)){if(l.has(x.value))continue;l.add(x.value);let v=Z(e,t,{...n,[o]:x},s,i);tt(v,a)||d.push({filters:[{type:"flag",key:o,op:"eq",value:x.value}],result:v})}let g=[...d,...a.runtime??[]],{runtime:h,...y}=a;return g.length?{...y,runtime:g}:y}function et(e){return(e.runtime??[]).flatMap(t=>{let{runtime:n,...r}=t.result;return[r,...et(t.result)]})}function tt(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;let n=e,r=t,i=new Set([...Object.keys(n),...Object.keys(r)]);for(let o of i)if(!tt(n[o],r[o]))return!1;return!0}var fe=e=>e.reason==="requires_server",de=e=>e.reason!=="app_context_excluded";function pe(e,t,n,r){return{key:e,value:t,enabled:t!==void 0&&t!==!1,...typeof t=="string"?{variant:t}:{},...n!==void 0?{payload:n}:{},reason:t===void 0?"not_found":r}}var K=class{constructor(t,n=Date.now){this.ttlMs=t;this.now=n}ttlMs;now;stamp;mark(t){return this.stamp={at:this.now(),id:t}}restore(t){typeof t?.at=="number"&&typeof t.id=="string"&&(this.stamp={at:t.at,id:t.id})}fresh(t){return!!this.ttlMs&&this.ttlMs>0&&!!this.stamp&&this.stamp.id===t&&this.now()-this.stamp.at<this.ttlMs}clear(){this.stamp=void 0}};var Tt="lc_preview",ge="lc_preview";function Vt(e){let t={};for(let n of(e??"").split(",")){let r=n.indexOf(":");r>0&&r<n.length-1&&(t[n.slice(0,r)]=n.slice(r+1))}return t}function nt(e){let t=new URL(e).searchParams.get(Tt),n=null;try{n=sessionStorage.getItem(ge)}catch{}return{forced:Vt(t==="off"?null:t??n),persist(){try{t==="off"?sessionStorage.removeItem(ge):t&&sessionStorage.setItem(ge,t)}catch{}}}}var me=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"];var ve=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];var ye="lc_flag_initial";function qt(e){try{return e?new URL(e).hostname:""}catch{return""}}function It(){let e=new URLSearchParams(location.search),t={$initial_referrer:document.referrer||"$direct",$initial_referring_domain:qt(document.referrer)||"$direct",$initial_current_url:location.href.split("#")[0]};for(let n of[...ve,...me]){let r=e.get(n);r&&(t[`$initial_${n}`]=r)}return t}function rt(e,t){if(typeof location>"u")return{};let n=e.get(ye);if(n)try{return JSON.parse(n)}catch{}let r=It();return t(()=>{e.get(ye)||e.set(ye,JSON.stringify(r))}),r}function Dt(){let e=navigator.userAgent,t=/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":/Firefox\//.test(e)?"Firefox":/Chrome\/|CriOS/.test(e)?"Chrome":/Safari\//.test(e)?"Safari":"Other",n=/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/iPhone|iPad|iPod/.test(e)?"iOS":/Mac OS X/.test(e)?"Mac OS X":/CrOS/.test(e)?"Chrome OS":/Linux/.test(e)?"Linux":"Other";return{browser:t,os:n}}function ot(){if(typeof location>"u"||typeof navigator>"u")return{};let e={},t=new URLSearchParams(location.search);for(let i of[...ve,...me]){let o=t.get(i);o&&(e[`$${i}`]=o)}let{browser:n,os:r}=Dt();return e.$browser=n,e.$os=r,e.$device_type=String(be().$device_type??"Desktop"),e}function be(){if(typeof window>"u")return{};let e=window.innerWidth;return{$viewport_width:e,$viewport_height:window.innerHeight,$screen_width:screen.width,$screen_height:screen.height,$browser_language:navigator.language,$device_type:Nt(e)}}function Nt(e,t=navigator){let n=t.userAgent??"";return/iPad|Tablet|PlayBook|Silk|Kindle/i.test(n)||/Macintosh/.test(n)&&(t.maxTouchPoints??0)>1?"Tablet":/Android/i.test(n)?/Mobile/i.test(n)?"Mobile":"Tablet":/iPhone|iPod|Mobile|Windows Phone|BlackBerry|Opera Mini/i.test(n)||t.userAgentData?.mobile?"Mobile":/Windows|Macintosh|X11|CrOS|Linux/i.test(n)?"Desktop":e<768?"Mobile":e<1024?"Tablet":"Desktop"}function _e(e){return typeof e=="object"?e.value??e.variant??!!e.enabled:e}function he(e){let t={value:_e(e),reason:e.reason??"remote",condition_index:e.condition_index??-1};return e.variant&&(t.variant=e.variant),e.payload!==void 0&&(t.payload=e.payload),e.runtime?.length&&(t.runtime=e.runtime.map(n=>({filters:n.filters,result:he(n.result)}))),t}var it="lc_rt_events",st=e=>!!e?.some(t=>t.conditions.some(n=>n.filters?.some(r=>r.type==="event")));function at(e,t){let n;try{let s=e.flagStorage.get(it);s&&(n=JSON.parse(s))}catch{}let r=new L(n),i={},o=Y(t,i);return{counts:()=>r.counts(e.core.sessionId),setServer(s){i=s,o=Y(t,i)},server:()=>i,drop(s){for(let a of s)delete i[a]},resolved(){return ce(i,r.counts(e.core.sessionId))},record(s,a,u){r.record(s,e.core.sessionId,a,o),u&&e.whenConsented(()=>e.flagStorage.set(it,JSON.stringify(r.saved())))}}}var xe="lc_flags",ke="lc_flag_overrides_api";function ct(e){try{let t=localStorage.getItem("lc_flag_overrides");return t?JSON.parse(t)[e]:void 0}catch{return}}var Fn=e=>{let{core:t,config:n}=e,r={},i={},o={},s,a,u=!1,l=0,d=new Set,g=new Set,h="",y={},x=()=>Object.keys(y).length>0,v={},S={},_={},k=new Set,A=typeof location>"u"?{forced:{},persist(){}}:nt(location.href),lt=Object.keys(A.forced).length>0,$=()=>({...r,..._}),R=e.config.flagOptions??{},j=new K(R.cacheTtlMs),Re=(e.config.flagsApiHost??e.config.apiHost).replace(/\/+$/,""),we=R.keys?.length?new Set(R.keys):void 0,Se=c=>we?Object.fromEntries(Object.entries(c).filter(([f])=>we.has(f))):c,q=(c,f,p=!0)=>{if(r=Se(c),i=Se(f),u=!0,p)for(let m of k)m($())},M=at(e,n.localFlags),Q=!1,I=()=>{Q||(Q=!0,queueMicrotask(()=>{Q=!1,N()}))},Fe=e.flagStorage.get(xe);if(Fe)try{let c=JSON.parse(Fe);r=c.values,i=c.payloads,o=Object.fromEntries(Object.keys(r).map(f=>[f,"cached"])),c.rt&&M.setServer(c.rt),j.restore(c),u=Object.keys(r).length>0}catch{}let Ee=e.flagStorage.get(ke);if(Ee)try{_=JSON.parse(Ee)}catch{}let D=n.bootstrap;if(D?.flags||D?.payloads){let c={...D.flags};for(let f of Object.keys(D.payloads??{}))c[f]??=!0;q({...r,...c},{...i,...D.payloads});for(let f of Object.keys(c))o[f]="bootstrap"}let Oe={},Pe=()=>({...R.autoProperties===!1?{}:ot(),...rt(t.storage,e.whenConsented),...Object.assign({},...e.flagPersonProps.map(c=>c())),...v}),Ce=R.evaluationContexts?.length?{app_contexts:R.evaluationContexts}:{},B=(c=!0)=>{let f=n.localFlags;if(!f?.length)return!0;let p=n.localFlagsContext,m=ue(f,{runtime_events:M.counts(),distinct_id:t.distinctId,...t.groups?{groups:t.groups}:{},...t.deviceId?{device_id:t.deviceId}:{},...x()?{contexts:y}:{},...Ce,...p,person_properties:{...Pe(),...p?.person_properties},group_properties:{...p?.group_properties,...S}}),w={},b={},E=!1;for(let[T,O]of Object.entries(m))fe(O)?E=!0:de(O)&&(w[T]=O.value,o[T]=O.reason,O.payload!==void 0&&(b[T]=O.payload));return Oe=w,q({...r,...w},{...i,...b},c),E},Ae=c=>{let f={...r},p={...i};for(let[m,w]of Object.entries(M.resolved()))f[m]=w.value,o[m]=w.reason,w.payload!==void 0?p[m]=w.payload:delete p[m];q(f,p,c)},$e=st(n.localFlags);e.onCapture(c=>{let f=$e||Object.keys(M.server()).length>0;if(M.record(c.event,c.properties,f),!f)return;let p=JSON.stringify([$(),i]);if($e&&B(!1),Ae(!1),JSON.stringify([$(),i])!==p)for(let m of k)m($())});let N=(c=!0)=>{let f=++l;return!B()||R.disableRemote||!c&&j.fresh(t.distinctId)?Promise.resolve():new Promise(p=>{e.whenConsented(()=>{if(f!==l)return p();A.persist();let m=new AbortController,w=setTimeout(()=>m.abort(),R.timeoutMs??1e4);e.fetch(`${Re}/v1/flags`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",signal:m.signal,body:JSON.stringify({api_key:e.apiKey,...t.distinctId?{distinct_id:t.distinctId}:{},...t.anonDistinctId?{anon_distinct_id:t.anonDistinctId}:{},groups:t.groups??{},person_properties:Pe(),...Object.keys(S).length?{group_properties:S}:{},device_properties:be(),...t.deviceId?{device_id:t.deviceId}:{},...x()?{contexts:y}:{},...Ce,...lt?{preview:A.forced}:{},...R.keys?.length?{flag_keys:R.keys}:{}})}).then(b=>b.ok?b.json():Promise.reject(new Error(`status ${b.status}`))).then(b=>{if(f!==l)return;if(b.quota_limited)return a="quota_limited",e.log("flags quota limited; keeping cached values");a=b.errors_while_computing_flags?"errors_while_computing_flags":void 0;let E={},T={},O={};for(let[G,P]of Object.entries(b.flags??{}))E[G]=_e(P),typeof P=="object"&&P.payload!==void 0&&(T[G]=P.payload),o[G]=typeof P=="object"&&typeof P.reason=="string"?P.reason:"remote",typeof P=="object"&&P.runtime?.length&&(O[G]=he(P));s=b.request_id,M.setServer(O);let W=b.errors_while_computing_flags;q({...Oe,...W?r:{},...E},W?{...i,...T}:T,!1),Ae(!0),e.flagStorage.set(xe,JSON.stringify({values:{...W?r:{},...E},payloads:{...W?i:{},...T},rt:O,...j.mark(t.distinctId)})),e.log("flags loaded",E)}).catch(b=>{let E=/^status (\d+)/.exec(String(b?.message))?.[1];f===l&&(a=m.signal.aborted?"timeout":E?`api_error_${E}`:"connection_error"),e.log("flags fetch failed",b)}).finally(()=>{clearTimeout(w),p()})})})},je=c=>_[c]??ct(c)??r[c];e.flags={get(c){let f=je(c);if(f===void 0)return;if(c in A.forced||c in _)return f;let p=t.sessionId;p!==h&&(d.clear(),g.clear(),h=p),g.has(c)||(g.add(c),t.capture("$exposure",{$feature_flag:c,$feature_flag_response:f,...typeof f=="string"?{$feature_flag_variant:f}:{},...s?{$feature_flag_request_id:s}:{}}));let m=`${c}:${String(f)}`;return d.has(m)||(d.add(m),t.capture("$feature_flag_called",{$feature_flag:c,$feature_flag_response:f,...s?{$feature_flag_request_id:s}:{},...o[c]?{$feature_flag_reason:o[c]}:{},...o[c]==="bootstrap"?{$used_bootstrap_value:!0}:{},...a?{$feature_flag_error:a}:{}})),f},all:()=>u||Object.keys(r).length||Object.keys(_).length?$():{},payload:c=>i[c],result(c,f){let p=f?.sendExposure===!1?je(c):this.get(c),m=c in _||ct(c)!==void 0?"override":c in A.forced?"preview":o[c]??"remote";return pe(c,p,i[c],m)},layerParam(c,f){for(let[p,m]of Object.entries(i)){let w=m;if(w?.lc_layer!==c||!w.lc_params||!(f in w.lc_params))continue;let b=this.get(p);if(b!==void 0&&b!==!1)return w.lc_params[f]}},onChange(c){return k.add(c),u&&c($()),()=>{k.delete(c)}},reload:N,update(c,f,p=!0){for(let m of Object.keys(c))o[m]="pushed";M.drop(Object.keys(c)),q(p?{...r,...c}:{...c},p?{...i,...f}:{...f})},override(c,f){_=c?{...c}:{},c?f?.persist&&e.whenConsented(()=>e.flagStorage.set(ke,JSON.stringify(_))):e.flagStorage.remove(ke);for(let p of k)p($())},setPersonProperties(c,f=!0){j.clear(),v={...v,...c},f&&I()},resetPersonProperties(){v={}},setGroupProperties(c,f=!0){j.clear();for(let[p,m]of Object.entries(c))S[p]={...S[p],...m};f&&I()},resetGroupProperties(){S={}},setContext(c,f,p){j.clear(),y={...y,[c]:{key:f,properties:p??{}}},I()},clearContext(c){j.clear();let{[c]:f,...p}=y;y=p,I()}},t.onChange(c=>{if(c==="reset"){y={},v={},S={},d.clear(),g.clear(),r={},i={},o={},s=void 0,a=void 0,M.setServer({}),j.clear(),e.flagStorage.remove(xe),B(!1);for(let f of k)f($())}(c==="identify"||c==="reset"||c==="group")&&I()}),n.disableFlagsOnFirstLoad?B():N(!1);let U=n.flagStream,Me;U&&!R.disableRemote&&e.whenConsented(()=>{Me=ee({apiHost:Re,apiKey:e.apiKey,fetch:e.fetch,reload:()=>{N()},visibility:{hidden:()=>document.visibilityState==="hidden",subscribe:c=>(document.addEventListener("visibilitychange",c),()=>document.removeEventListener("visibilitychange",c))},...typeof U=="object"&&U.pollMs!==void 0?{pollMs:U.pollMs}:{},log:e.log})});let Te=R.refreshMs&&R.refreshMs>0&&!R.disableRemote?setInterval(()=>document.visibilityState!=="hidden"&&void N(!1),R.refreshMs):void 0;return()=>{Me?.(),Te&&clearInterval(Te)}};export{Fn as flags};
@@ -1 +1 @@
1
- var C=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),f=(r,o)=>r>>>o|r<<32-o;function d(r){let o=new TextEncoder().encode(r),a=o.length+9+63>>6<<6,u=new Uint8Array(a);u.set(o),u[o.length]=128;let p=new DataView(u.buffer);p.setUint32(a-8,Math.floor(o.length*8/2**32)),p.setUint32(a-4,o.length*8>>>0);let x=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c=new Uint32Array(64);for(let l=0;l<a;l+=64){for(let e=0;e<16;e++)c[e]=p.getUint32(l+e*4);for(let e=16;e<64;e++){let t=c[e-15],n=c[e-2],i=f(t,7)^f(t,18)^t>>>3,s=f(n,17)^f(n,19)^n>>>10;c[e]=c[e-16]+i+c[e-7]+s|0}let m=x.slice();for(let e=0;e<64;e++){let[t,n,i,,s,y,v,A]=m,b=A+(f(s,6)^f(s,11)^f(s,25))+(s&y^~s&v)+C[e]+c[e]|0,h=(f(t,2)^f(t,13)^f(t,22))+(t&n^t&i^n&i)|0;m.pop(),m.unshift(b+h|0),m[4]=m[4]+b|0}for(let e=0;e<8;e++)x[e]=x[e]+m[e]|0}return x.map(l=>(l>>>0).toString(16).padStart(8,"0")).join("")}var g="[data-lc-ignore]",E="input,select,textarea";function S(r){let o=r,a=o.labels?.[0]?.textContent?.trim()??r.getAttribute("aria-label")??"";return d(`${o.name??""}|${r.id}|${a}`).slice(0,12)}function F(r){let o="";try{o=new URL(r.action||location.href,location.href).pathname}catch{}let a=Array.from(document.forms).indexOf(r);return d(`${r.id}|${r.getAttribute("name")??""}|${o}|${a}`).slice(0,12)}function T(r){if(r.getAttribute("aria-invalid")==="true")return!0;try{return r.matches(":invalid")}catch{return!1}}var I=r=>{let o=new WeakMap,a=new Set,u=new Map,p=e=>{let t=e.target;if(!(t instanceof Element)||!t.matches(E)||t.closest(g))return;let n=t.form;return n?{el:t,form:n}:void 0},x=e=>{let t=o.get(e);return t||(t={id:F(e),startedAt:Date.now(),submitted:!1,touched:new Set},o.set(e,t),a.add(t),r.client.capture("$form_start",{form:t.id,$form_field_count:e.querySelectorAll(E).length})),t},c=e=>{let t=p(e);if(!t)return;let n=x(t.form),i=S(t.el),s=u.get(n.id+i);u.set(n.id+i,{n:(s?.n??0)+1,since:Date.now()}),n.last=i,n.touched.add(i)},l=e=>{let t=p(e),n=t&&o.get(t.form);if(!t||!n)return;let i=S(t.el),s=u.get(n.id+i);s&&r.client.capture("$form_field_interact",{form:n.id,field:i,$field_type:t.el.tagName==="INPUT"?t.el.type:t.el.tagName.toLowerCase(),interaction_ms:Date.now()-s.since,refill_count:s.n-1,error:T(t.el)})},m=e=>{let t=e.target;if(!(t instanceof HTMLFormElement)||t.closest(g))return;let n=x(t);n.submitted=!0,a.delete(n),r.client.capture("$form_submit",{form:n.id,$duration_ms:Date.now()-n.startedAt,$fields_touched:n.touched.size})};return document.addEventListener("focusin",c,!0),document.addEventListener("focusout",l,!0),document.addEventListener("submit",m,!0),r.onUnload(()=>{for(let e of a)e.submitted||r.client.capture("$form_abandon",{form:e.id,last_field:e.last,$fields_touched:e.touched.size,$duration_ms:Date.now()-e.startedAt});a.clear()}),()=>{document.removeEventListener("focusin",c,!0),document.removeEventListener("focusout",l,!0),document.removeEventListener("submit",m,!0)}};export{S as fieldId,I as forms};
1
+ var C=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),f=(r,o)=>r>>>o|r<<32-o;function d(r){let o=new TextEncoder().encode(r),a=o.length+9+63>>6<<6,u=new Uint8Array(a);u.set(o),u[o.length]=128;let p=new DataView(u.buffer);p.setUint32(a-8,Math.floor(o.length*8/2**32)),p.setUint32(a-4,o.length*8>>>0);let x=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],c=new Uint32Array(64);for(let l=0;l<a;l+=64){for(let e=0;e<16;e++)c[e]=p.getUint32(l+e*4);for(let e=16;e<64;e++){let t=c[e-15],n=c[e-2],i=f(t,7)^f(t,18)^t>>>3,s=f(n,17)^f(n,19)^n>>>10;c[e]=c[e-16]+i+c[e-7]+s|0}let m=x.slice();for(let e=0;e<64;e++){let[t,n,i,,s,y,v,A]=m,b=A+(f(s,6)^f(s,11)^f(s,25))+(s&y^~s&v)+C[e]+c[e]|0,h=(f(t,2)^f(t,13)^f(t,22))+(t&n^t&i^n&i)|0;m.pop(),m.unshift(b+h|0),m[4]=m[4]+b|0}for(let e=0;e<8;e++)x[e]=x[e]+m[e]|0}return x.map(l=>(l>>>0).toString(16).padStart(8,"0")).join("")}var g="[data-lc-ignore]",S="input,select,textarea";function E(r){let o=r,a=o.labels?.[0]?.textContent?.trim()??r.getAttribute("aria-label")??"";return d(`${o.name??""}|${r.id}|${a}`).slice(0,12)}function F(r){let o="";try{o=new URL(r.action||location.href,location.href).pathname}catch{}let a=Array.from(document.forms).indexOf(r);return d(`${r.id}|${r.getAttribute("name")??""}|${o}|${a}`).slice(0,12)}function T(r){if(r.getAttribute("aria-invalid")==="true")return!0;try{return r.matches(":invalid")}catch{return!1}}var I=r=>{let o=new WeakMap,a=new Set,u=new Map,p=e=>{let t=e.target;if(!(t instanceof Element)||!t.matches(S)||t.closest(g))return;let n=t.form;return n?{el:t,form:n}:void 0},x=e=>{let t=o.get(e);return t||(t={id:F(e),startedAt:Date.now(),submitted:!1,touched:new Set},o.set(e,t),a.add(t),r.client.capture("$form_start",{form:t.id,$form_field_count:e.querySelectorAll(S).length})),t},c=e=>{let t=p(e);if(!t)return;let n=x(t.form),i=E(t.el),s=u.get(n.id+i);u.set(n.id+i,{n:(s?.n??0)+1,since:Date.now()}),n.last=i,n.touched.add(i)},l=e=>{let t=p(e),n=t&&o.get(t.form);if(!t||!n)return;let i=E(t.el),s=u.get(n.id+i);s&&r.client.capture("$form_field_interact",{form:n.id,field:i,$field_type:t.el.tagName==="INPUT"?t.el.type:t.el.tagName.toLowerCase(),interaction_ms:Date.now()-s.since,refill_count:s.n-1,error:T(t.el)})},m=e=>{let t=e.target;if(!(t instanceof HTMLFormElement)||t.closest(g))return;let n=x(t);n.submitted=!0,a.delete(n),r.client.capture("$form_submit",{form:n.id,$duration_ms:Date.now()-n.startedAt,$fields_touched:n.touched.size})};return document.addEventListener("focusin",c,!0),document.addEventListener("focusout",l,!0),document.addEventListener("submit",m,!0),r.onUnload(()=>{for(let e of a)e.submitted||r.client.capture("$form_abandon",{form:e.id,last_field:e.last,$fields_touched:e.touched.size,$duration_ms:Date.now()-e.startedAt});a.clear()}),()=>{document.removeEventListener("focusin",c,!0),document.removeEventListener("focusout",l,!0),document.removeEventListener("submit",m,!0)}};export{E as fieldId,I as forms};
@@ -1 +1 @@
1
- import{a as I}from"./chunk-AWIQCFGN.js";import{a as ee,c as Ge,d as $e,e as C,f as Ee,h as te,i as ne,k as x}from"./chunk-MCWQHOEV.js";function ie(t,n){let o=2166136261;for(let r of`${n}:${t}`)o=Math.imul(o^r.codePointAt(0),16777619);return o^=o>>>16,o=Math.imul(o,2246822507),o^=o>>>13,o=Math.imul(o,3266489909),o^=o>>>16,(o>>>0)/2**32}function oe(t,n,o){let r=t.conditions.ab_group;if(!r)return t;let s=n.filter(i=>i.conditions.ab_group===r).sort((i,a)=>i.id<a.id?-1:1),u=s.reduce((i,a)=>i+(a.conditions.ab_weight??1),0),c=ie(o,`ab:${r}`)*u;for(let i of s)if(c-=i.conditions.ab_weight??1,c<0)return i;return s[s.length-1]}function se(t,n){let o=t.conditions,r=o.holdout_pct??0,s=o.holdout_scope==="variant"?t.id:o.ab_group??t.id;return r>0&&ie(n,`holdout:${s}`)*100<r}function re(t,n,o,r){let s=t.filter(i=>i.kind==="banner"&&i.steps[0]);if(!s.length)return;let u={id:"changelog",name:"What's new",kind:"resource_center",steps:s.map(i=>({id:i.id,title:i.steps[0].title??i.name,...i.steps[0].body?{body:i.steps[0].body}:{}})),conditions:{}},c=()=>{};return x(u,{shown:n,step:c,completed:c,dismissed:c,event:c},o,r?{nonce:r}:{})}function Me(t,n){for(let o of t){let r=o?.toLowerCase().replace("_","-");if(!r)continue;if(n.has(r))return r;let s=r.split("-")[0];if(n.has(s))return s}}function de(t,n){let o=new Set;for(let c of t.steps)for(let i of Object.keys(c.i18n??{}))o.add(i.toLowerCase());for(let c of Object.keys(t.appearance?.i18n??{}))o.add(c.toLowerCase());let r=Me(n,o);if(!r)return t;let s=c=>{let i=Object.keys(c??{}).find(a=>a.toLowerCase()===r);return i===void 0?void 0:c[i]},u=t.steps.map((c,i)=>{let a=s(c.i18n);if(!a)return c;let m=a.buttons,h=m&&(c.buttons??te(t.kind,i===t.steps.length-1)).map((g,l)=>({...g,label:m[l]??g.label}));return{...c,...a.title!==void 0?{title:a.title}:{},...a.body!==void 0?{body:a.body}:{},...h?{buttons:h}:{}}});return{...t,name:s(t.appearance?.i18n)?.name??t.name,steps:u}}function ce(t){let n=(r,s)=>{try{return JSON.parse(t.get(r)??"null")??s}catch{return s}},o=r=>({get:s=>n(r,{})[s],set(s,u){let c=n(r,{});u===void 0?delete c[s]:c[s]=u,t.set(r,JSON.stringify(c))}});return{views:o("lc_guide_views"),tour:o("lc_guide_progress"),checked:o("lc_guide_checked"),dismissed:o("lc_guide_dismissed"),held:o("lc_guide_holdout"),snoozed:o("lc_guide_snoozed")}}var O="lc_guide_seen",le=["lc_guide_views","lc_guide_progress","lc_guide_checked","lc_guide_dismissed","lc_guide_holdout","lc_guide_snoozed"],F=[O,...le],Oe=2e3,N=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},ae=t=>Array.isArray(t)?t:[],D=(t,n)=>[...new Set([...ae(t),...ae(n)])];function Ae(t,n){let o={[O]:D(t[O],n[O])};for(let r of le){let s=N(t[r]),u=N(n[r]),c={};for(let i of new Set([...Object.keys(s),...Object.keys(u)]))r==="lc_guide_checked"?c[i]=D(s[i],u[i]):r==="lc_guide_views"?c[i]=D(s[i],u[i]).sort((a,m)=>a-m).slice(-50):r==="lc_guide_progress"?c[i]=s[i]??u[i]:c[i]=Math.max(Number(s[i])||0,Number(u[i])||0);o[r]=c}return o}var ue=t=>Object.fromEntries(F.map(n=>{try{return[n,JSON.parse(t.get(n)??"null")]}catch{return[n,null]}}));function fe(t,n){let{core:o}=t,r,s=!1,u=async a=>{let m=await t.fetch(`${t.config.apiHost}/v1/guide-state`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,distinct_id:o.distinctId,...a?{state:a}:{}})});if(!m.ok)throw new Error(`status ${m.status}`);return N((await m.json()).state)},c=()=>t.config.guides?.syncState!==!1&&!!o.distinctId&&o.hasConsent("analytics"),i=()=>{r=void 0,c()&&u(ue(n)).catch(a=>t.log("guide state push failed",a))};return{async pull(){if(c())try{let a=Ae(ue(n),await u());for(let[m,h]of Object.entries(a))n.set(m,JSON.stringify(h));s=!0,i()}catch(a){t.log("guide state pull failed",a)}},touch(){s&&!r&&(r=setTimeout(i,Oe))},stop(){r&&clearTimeout(r)}}}var z="lc_guide";function pe(t,n,o,r){let{core:s}=t;return{async ask(u){try{let c=await t.fetch(`${t.config.apiHost}/v1/guides/answer?api_key=${encodeURIComponent(t.apiKey)}`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,query:u.slice(0,500),distinct_id:s.distinctId||s.sessionId,url:location.href.slice(0,2e3),...r?{locale:r.slice(0,35)}:{}})});if(c.status===503)return"unavailable";if(!c.ok)return null;let i=await c.json();return{answer:typeof i.answer=="string"?i.answer:"",citations:Array.isArray(i.citations)?i.citations.filter(a=>a&&typeof a.url=="string"):[],guide_ids:Array.isArray(i.guide_ids)?i.guide_ids.filter(a=>typeof a=="string"):[]}}catch(c){return t.log("guide answer failed",c),null}},searched({query:u,results:c,answered:i,feedback:a}){s.capture("$guide_search",{$guide_id:n.id,guide_id:n.id,query_length:u.length,results:c,answered:i,...a?{feedback:a}:{},...o()?{query:u.slice(0,500)}:{}})}}}function ge(){if(typeof location>"u"||typeof history>"u")return null;try{let t=new URL(location.href),n=t.searchParams.get(z);return n?(t.searchParams.delete(z),history.replaceState(history.state,"",t.toString()),n.slice(0,100)):null}catch{return null}}var q="lc:guide",me=["shown","step","completed","dismissed","event","progress","snoozed","targetMissing"],K=new Set(["tooltip","modal","banner","tour","checklist","resource_center","announcement","slideout","carousel"]),ye=t=>!!t&&typeof t=="object"&&t.lc===q&&typeof t.key=="string",xe=t=>{if(!t)return null;let n=t.getBoundingClientRect();return{x:n.left,y:n.top,width:n.width,height:n.height}};function he(){try{return window.top!==window}catch{return!0}}var Te=0;function ke(t,n,o,r,s){let u=window.top,c=`${Date.now().toString(36)}-${++Te}`,i=!1,a=y=>{try{u?.postMessage({...y,lc:q,key:c},s)}catch{}},m=t.steps.filter(y=>y.selector||y.fallback_selectors?.length),h=()=>{let y={};for(let _ of m)y[_.id]=xe(ne(_));a({op:"rects",rects:y})},g=y=>{if(y.source!==u||y.origin!==s||!ye(y.data)||y.data.key!==c)return;let _=y.data;if(_.op==="closed")return R(!1);if(_.op!=="hook"||!me.includes(_.name)||!Array.isArray(_.args))return;let A=n[_.name];if(A?.(..._.args),_.name==="step"){let E=t.steps.find(G=>G.id===_.args[1]);E?.automation&&r.automate!==!1&&n.automated?.(E.id,C(E.automation))}};addEventListener("message",g);let l=m.length?setInterval(h,200):void 0;addEventListener("scroll",h,!0),addEventListener("resize",h);let R=y=>{i||(i=!0,l&&clearInterval(l),removeEventListener("message",g),removeEventListener("scroll",h,!0),removeEventListener("resize",h),y&&a({op:"close"}),o())};return a({op:"render",guide:t,...r.start?{start:r.start}:{},...r.checked?{checked:r.checked}:{}}),m.length&&h(),Object.assign(()=>R(!0),{markDone:y=>a({op:"mark",stepId:y})})}function Pe(t){for(let n of document.querySelectorAll("iframe"))if(n.contentWindow===t)return n;return null}function He(t,n){let o=()=>{let s=t.getBoundingClientRect();return new DOMRect(s.left+t.clientLeft+n.x,s.top+t.clientTop+n.y,n.width,n.height)},r=()=>{};return{getBoundingClientRect:o,addEventListener:r,removeEventListener:r}}function _e(t,n){let o=new Set(t.map(u=>u.replace(/\/+$/,""))),r=new Map,s=u=>{if(!o.has(u.origin)||!ye(u.data))return;let c=Pe(u.source);if(!c)return;let i=u.data,a=`${u.origin}|${i.key}`,m=g=>{try{u.source.postMessage({...g,lc:q,key:i.key},u.origin)}catch{}},h=r.get(a);if(i.op==="rects"&&h)h.rects=i.rects&&typeof i.rects=="object"?i.rects:{};else if(i.op==="close")h?.handle();else if(i.op==="mark")h?.handle.markDone(String(i.stepId));else if(i.op==="render"&&!h){let g=i.guide;if(!g||typeof g.id!="string"||typeof g.name!="string"||!Array.isArray(g.steps)||!K.has(g.kind))return;let l=g.kind==="banner"?()=>{}:I();if(!l)return m({op:"closed"});let R=G=>(...v)=>m({op:"hook",name:G,args:v}),y=Object.fromEntries(me.map(G=>[G,R(G)])),_={rects:{},release:l,handle:void 0};r.set(a,_);let E={resolveTarget:G=>{let v=_.rects[G.id];return v&&typeof v.x=="number"?He(c,v):null},automate:!1,...n?{nonce:n}:{},...typeof i.start=="number"?{start:i.start}:{},...Array.isArray(i.checked)?{checked:i.checked}:{}};_.handle=x(g,y,()=>{r.delete(a),l(),m({op:"closed"})},E)}};return addEventListener("message",s),()=>{removeEventListener("message",s);for(let u of[...r.values()])u.handle()}}var we="lc_guide_last",ve=new Set(["hotspot","beacon","badge","launcher"]),Ie=()=>{try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t?`&tz=${encodeURIComponent(t)}`:""}catch{return""}},J=new Set([...ve,"form_validation"]),U=t=>J.has(t.kind)||t.kind==="inline",Le=new Set(["tour","checklist"]),je=30*6e4,Ce=()=>{let t=innerWidth;return t<640?"mobile":t<1024?"tablet":"desktop"},dt=t=>{let{core:n}=t,o=[],r=!1,s=new Set,u=new Map,c=ge(),i=!1,a={get:e=>n.storage.get(e),set(e,d){n.storage.set(e,d),F.includes(e)&&m.touch()},remove:e=>n.storage.remove(e)},m=fe(t,n.storage),h=()=>JSON.parse(a.get(O)??"[]"),g=new Set(h()),l=ce(a),R=new Set,y=[],_=t.config.localFlagsContext,A={..._?.person_properties},E={..._?.group_properties},G=e=>{let d=t.flags?.get(e);return d!==void 0&&d!==!1},v=(e,d={})=>({$guide_id:e.id,$guide_kind:e.kind,...d}),Y=()=>n.distinctId||n.sessionId,B=new Set,P=(e,d=!1)=>{if(e.preview){let f=()=>{};return{shown:f,step:f,completed:f,dismissed:f,event:f}}let k=J.has(e.kind),w=f=>({guide_id:e.id,step_id:f,$guide_step_id:f}),S=()=>{l.tour.set(e.id,void 0),l.checked.set(e.id,void 0),k&&l.dismissed.set(e.id,Date.now())};return{shown(){let f=Date.now(),p=l.views.get(e.id)??[],b=k&&(p.at(-1)??0)>f-je;g.add(e.id),l.snoozed.get(e.id)&&l.snoozed.set(e.id,void 0),a.set(O,JSON.stringify([...g])),n.storage.set(we,String(f)),e.kind==="checklist"&&!l.checked.get(e.id)&&l.checked.set(e.id,[]),!(b||d)&&(l.views.set(e.id,[...p,f].slice(-50)),n.capture("$guide_shown",v(e)))},step:(f,p)=>{e.kind==="checklist"&&l.checked.set(e.id,[...new Set([...l.checked.get(e.id)??[],p])]),n.capture("$guide_step",v(e,{$guide_step_id:p,$guide_step_index:f}))},progress:f=>e.kind==="tour"&&l.tour.set(e.id,f),completed:()=>(S(),n.capture("$guide_completed",v(e))),dismissed:(f,p,b)=>{b!=="snooze"&&S(),n.capture("$guide_dismissed",v(e,{$guide_step_id:p,$guide_step_index:f,...b?{reason:b}:{}}))},event:f=>t.client.capture(f,{$guide_id:e.id}),snoozed:(f,p)=>l.snoozed.set(e.id,Date.now()+p*36e5),targetMissing:(f,p)=>n.capture("$guide_target_missing",v(e,{...w(f),selector:p})),validationFailed:(f,p)=>n.capture("$guide_validation_failed",v(e,{...w(f),rule:p})),automated:(f,p)=>p!=="done"&&t.log(`guide ${e.id} step ${f}: automation ${p}`)}},T=(e,d=0)=>{let k=ve.has(e.kind),w=U(e)?()=>{}:I();if(!w)return void s.delete(e.id);let S=de(e,[t.config.guides?.locale,A.locale,navigator.language]),f=H=>{let L=o.find(Re=>Re.id===H);L&&!s.has(L.id)&&(s.add(L.id),T(L))},p={start:d,person:A,checked:l.checked.get(e.id)??[],library:o,launch:f,flag:G,...t.config.nonce?{nonce:t.config.nonce}:{},...e.kind==="resource_center"&&!e.preview?{assist:pe(t,e,()=>i,t.config.guides?.locale??navigator.language)}:{}},b=d>0||e.kind==="checklist"&&l.checked.get(e.id)!==void 0,$=()=>{R.delete(M),u.delete(e.id),w(),s.delete(e.id)},M=()=>{};if(k){import("./persistent-XLGNSZQR.js").then(H=>{M=H.renderPersistent(S,P(e,b),$,p),r?M():R.add(M)});return}if(e.kind==="form_validation"){import("./validation-ENITEP6V.js").then(H=>{M=H.renderValidation(S,P(e,b),$,p),r?M():R.add(M)});return}let Z=t.config.guides?.renderInTop,X=Z&&K.has(e.kind)&&he()?ke(S,P(e,b),$,p,Z):x(S,P(e,b),$,p);M=X,u.set(e.id,X),R.add(M)},j=(e,d=!1)=>{let k=J.has(e.kind),w=e.conditions,S=e.steps[0]?.selector;if(e.kind==="inline"&&!(S&&document.querySelector(S)))return!1;if(e.preview)return!B.has(e.id)&&(B.add(e.id),!0);let f=l.views.get(e.id)??[],p=l.snoozed.get(e.id);if(!d&&p&&p>Date.now()||!d&&(k?l.dismissed.get(e.id):g.has(e.id)&&!w.frequency&&!p))return!1;let b={url:location.href,flags:G,flagValue:$=>t.flags?.get($),lastShownMs:e.queued?void 0:Number(n.storage.get(we))||void 0,nowMs:Date.now(),random:e.queued?()=>0:Math.random,person:A,groups:E,device:Ce(),seen:$=>g.has($),views:k?[]:f};return!ee(e,b)||oe(e,o,Y())!==e?!1:e.held_out||se(e,Y())?(l.held.get(e.id)||(l.held.set(e.id,Date.now()),n.capture("$guide_holdout",v(e,w.ab_group?{$guide_group:w.ab_group}:{}))),!1):!0},Se=()=>{let e=c?o.find(d=>d.id===c):void 0;c=null,!(!e||s.has(e.id)||t.config.guides?.render===!1||!j(e,!0))&&(s.add(e.id),T(e))},V=()=>{if(!(t.config.guides?.render===!1||typeof document>"u")){for(let e of o){if(s.has(e.id)||!Le.has(e.kind))continue;let d=e.kind==="tour"?e.steps.findIndex(w=>w.id===l.tour.get(e.id)):l.checked.get(e.id)?0:-1,k=e.steps[d];if(!(d<0||!k||k.url&&!location.href.includes(k.url)))return s.add(e.id),T(e,d)}for(let e of o)s.has(e.id)||!U(e)||!j(e)||(s.add(e.id),T(e));for(let e of[...o.filter(d=>d.queued),...o.filter(d=>!d.queued)])if(!(s.has(e.id)||U(e)||!j(e))){s.add(e.id),y.push(setTimeout(()=>T(e),e.queued?0:(e.conditions.delay_seconds??0)*1e3));return}}},be=e=>{for(let d of o)if(!(d.kind!=="checklist"||!s.has(d.id)&&!l.checked.get(d.id)))for(let[k,w]of d.steps.entries()){let S=w.complete_on;if(!S||S.event!==e.event||!Object.entries(S.props??{}).every(([b,$])=>e.properties[b]===$))continue;let f=l.checked.get(d.id)??[];if(f.includes(w.id))continue;let p=u.get(d.id);p?p.markDone(w.id):(l.checked.set(d.id,[...f,w.id]),n.capture("$guide_step",v(d,{$guide_step_id:w.id,$guide_step_index:k,$guide_auto:!0})),f.length+1>=d.steps.length&&P(d).completed())}},W=()=>{let e=t.fetch(`${t.config.apiHost}/v1/guides?api_key=${encodeURIComponent(t.apiKey)}${n.distinctId?`&distinct_id=${encodeURIComponent(n.distinctId)}`:""}${Ie()}&url=${encodeURIComponent(location.origin+location.pathname)}`,{credentials:"omit"}).then(d=>d.ok?d.json():Promise.reject(new Error(`status ${d.status}`)));Promise.all([e,m.pull()]).then(([d])=>{for(let k of h())g.add(k);o=d.guides??[],i=d.settings?.guide_search_capture_query===!0,Se(),V()}).catch(d=>t.log("guides fetch failed",d))};t.guides={showChangelog(){if(typeof document>"u")return 0;let e=I();if(!e)return 0;let d=re(o,()=>n.capture("$changelog_viewed"),()=>(R.delete(d),e()),t.config.nonce);return d?(R.add(d),o.filter(k=>k.kind==="banner").length):(e(),0)},show(e){let d=o.find(k=>k.id===e);return!d||s.has(d.id)||typeof document>"u"||t.config.guides?.render===!1?!1:(s.add(d.id),T(d),s.has(d.id))},reset(e){g.delete(e),a.set(O,JSON.stringify([...g]));for(let d of[l.views,l.dismissed,l.tour,l.checked,l.held])d.set(e,void 0)}},t.whenConsented(W);let Q=t.config.guides?.frameOrigins;return Q?.length&&typeof document<"u"&&R.add(_e(Q,t.config.nonce)),t.onCapture(e=>{if(e.event==="$identify"&&W(),e.$set&&Object.assign(A,e.$set),e.event==="$groupidentify"){let d=String(e.properties.$group_type);E[d]={...E[d],...e.properties.$group_set}}e.event==="$pageview"?V():e.event.startsWith("$guide_")||be(e)}),()=>{r=!0,m.stop();for(let e of y)clearTimeout(e);for(let e of[...R])e()}};export{z as PERMALINK_PARAM,Ge as branchOk,dt as guides,x as renderGuide,Ee as resolveTokens,C as runAutomation,$e as sensitive};
1
+ import{a as I}from"./chunk-AWIQCFGN.js";import{a as ee,c as Ge,d as $e,e as C,f as Ee,h as te,i as ne,k as A}from"./chunk-FUE3SDQU.js";function ie(t,i){let n=2166136261;for(let s of`${i}:${t}`)n=Math.imul(n^s.codePointAt(0),16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,(n>>>0)/2**32}function oe(t,i,n){let s=t.conditions.ab_group;if(!s)return t;let r=i.filter(o=>o.conditions.ab_group===s).sort((o,a)=>o.id<a.id?-1:1),u=r.reduce((o,a)=>o+(a.conditions.ab_weight??1),0),c=ie(n,`ab:${s}`)*u;for(let o of r)if(c-=o.conditions.ab_weight??1,c<0)return o;return r[r.length-1]}function se(t,i){let n=t.conditions,s=n.holdout_pct??0,r=n.holdout_scope==="variant"?t.id:n.ab_group??t.id;return s>0&&ie(i,`holdout:${r}`)*100<s}function re(t,i,n,s){let r=t.filter(o=>o.kind==="banner"&&o.steps[0]);if(!r.length)return;let u={id:"changelog",name:"What's new",kind:"resource_center",steps:r.map(o=>({id:o.id,title:o.steps[0].title??o.name,...o.steps[0].body?{body:o.steps[0].body}:{}})),conditions:{}},c=()=>{};return A(u,{shown:i,step:c,completed:c,dismissed:c,event:c},n,s?{nonce:s}:{})}function xe(t,i){for(let n of t){let s=n?.toLowerCase().replace("_","-");if(!s)continue;if(i.has(s))return s;let r=s.split("-")[0];if(i.has(r))return r}}function de(t,i){let n=new Set;for(let c of t.steps)for(let o of Object.keys(c.i18n??{}))n.add(o.toLowerCase());for(let c of Object.keys(t.appearance?.i18n??{}))n.add(c.toLowerCase());let s=xe(i,n);if(!s)return t;let r=c=>{let o=Object.keys(c??{}).find(a=>a.toLowerCase()===s);return o===void 0?void 0:c[o]},u=t.steps.map((c,o)=>{let a=r(c.i18n);if(!a)return c;let h=a.buttons,v=h&&(c.buttons??te(t.kind,o===t.steps.length-1)).map((g,l)=>({...g,label:h[l]??g.label}));return{...c,...a.title!==void 0?{title:a.title}:{},...a.body!==void 0?{body:a.body}:{},...v?{buttons:v}:{}}});return{...t,name:r(t.appearance?.i18n)?.name??t.name,steps:u}}function ce(t){let i=(s,r)=>{try{return JSON.parse(t.get(s)??"null")??r}catch{return r}},n=s=>({get:r=>i(s,{})[r],set(r,u){let c=i(s,{});u===void 0?delete c[r]:c[r]=u,t.set(s,JSON.stringify(c))}});return{views:n("lc_guide_views"),tour:n("lc_guide_progress"),checked:n("lc_guide_checked"),dismissed:n("lc_guide_dismissed"),held:n("lc_guide_holdout"),snoozed:n("lc_guide_snoozed")}}var M="lc_guide_seen",le=["lc_guide_views","lc_guide_progress","lc_guide_checked","lc_guide_dismissed","lc_guide_holdout","lc_guide_snoozed"],F=[M,...le],Me=2e3,N=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},ae=t=>Array.isArray(t)?t:[],D=(t,i)=>[...new Set([...ae(t),...ae(i)])];function Oe(t,i){let n={[M]:D(t[M],i[M])};for(let s of le){let r=N(t[s]),u=N(i[s]),c={};for(let o of new Set([...Object.keys(r),...Object.keys(u)]))s==="lc_guide_checked"?c[o]=D(r[o],u[o]):s==="lc_guide_views"?c[o]=D(r[o],u[o]).sort((a,h)=>a-h).slice(-50):s==="lc_guide_progress"?c[o]=r[o]??u[o]:c[o]=Math.max(Number(r[o])||0,Number(u[o])||0);n[s]=c}return n}var ue=t=>Object.fromEntries(F.map(i=>{try{return[i,JSON.parse(t.get(i)??"null")]}catch{return[i,null]}}));function fe(t,i){let{core:n}=t,s,r=!1,u=async a=>{let h=await t.fetch(`${t.config.apiHost}/v1/guide-state`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,distinct_id:n.distinctId,...a?{state:a}:{}})});if(!h.ok)throw new Error(`status ${h.status}`);return N((await h.json()).state)},c=()=>t.config.guides?.syncState!==!1&&!!n.distinctId&&n.hasConsent("analytics"),o=()=>{s=void 0,c()&&u(ue(i)).catch(a=>t.log("guide state push failed",a))};return{async pull(){if(c())try{let a=Oe(ue(i),await u());for(let[h,v]of Object.entries(a))i.set(h,JSON.stringify(v));r=!0,o()}catch(a){t.log("guide state pull failed",a)}},touch(){r&&!s&&(s=setTimeout(o,Me))},stop(){s&&clearTimeout(s)}}}var z="lc_guide";function pe(t,i,n,s){let{core:r}=t;return{async ask(u){try{let c=await t.fetch(`${t.config.apiHost}/v1/guides/answer?api_key=${encodeURIComponent(t.apiKey)}`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,query:u.slice(0,500),distinct_id:r.distinctId||r.sessionId,url:location.href.slice(0,2e3),...s?{locale:s.slice(0,35)}:{}})});if(c.status===503)return"unavailable";if(!c.ok)return null;let o=await c.json();return{answer:typeof o.answer=="string"?o.answer:"",citations:Array.isArray(o.citations)?o.citations.filter(a=>a&&typeof a.url=="string"):[],guide_ids:Array.isArray(o.guide_ids)?o.guide_ids.filter(a=>typeof a=="string"):[]}}catch(c){return t.log("guide answer failed",c),null}},searched({query:u,results:c,answered:o,feedback:a}){r.capture("$guide_search",{$guide_id:i.id,guide_id:i.id,query_length:u.length,results:c,answered:o,...a?{feedback:a}:{},...n()?{query:u.slice(0,500)}:{}})}}}function ge(){if(typeof location>"u"||typeof history>"u")return null;try{let t=new URL(location.href),i=t.searchParams.get(z);return i?(t.searchParams.delete(z),history.replaceState(history.state,"",t.toString()),i.slice(0,100)):null}catch{return null}}var q="lc:guide",me=["shown","step","completed","dismissed","event","progress","snoozed","targetMissing"],K=new Set(["tooltip","modal","banner","tour","checklist","resource_center","announcement","slideout","carousel"]),ye=t=>!!t&&typeof t=="object"&&t.lc===q&&typeof t.key=="string",Ae=t=>{if(!t)return null;let i=t.getBoundingClientRect();return{x:i.left,y:i.top,width:i.width,height:i.height}};function he(){try{return window.top!==window}catch{return!0}}function Te(){let t=0,i=0,n=window;for(;n.parent!==window.top&&n.parent!==n;){let s;try{s=n.frameElement}catch{return null}if(!s)return null;let r=s.getBoundingClientRect();t+=r.left+s.clientLeft,i+=r.top+s.clientTop,n=n.parent}return{x:t,y:i}}var Pe=0;function ke(t,i,n,s,r){let u=window.top,c=`${Date.now().toString(36)}-${++Pe}`,o=!1,a=m=>{try{u?.postMessage({...m,lc:q,key:c},r)}catch{}},h=t.steps.filter(m=>m.selector||m.fallback_selectors?.length),v=[...new Set(t.steps.flatMap(m=>(m.branch??[]).filter(y=>y.op==="element_present"||y.op==="element_absent").map(y=>String(y.value))))],g=()=>{let m={},y=Te();for(let k of h){let _=y?Ae(ne(k)):null;m[k.id]=_&&y?{..._,x:_.x+y.x,y:_.y+y.y}:null}let $={};for(let k of v)try{$[k]=!!document.querySelector(k)}catch{$[k]=!1}a({op:"rects",rects:m,present:$})},l=m=>{if(m.source!==u||m.origin!==r||!ye(m.data)||m.data.key!==c)return;let y=m.data;if(y.op==="closed")return O(!1);if(y.op!=="hook"||!me.includes(y.name)||!Array.isArray(y.args))return;let $=i[y.name];if($?.(...y.args),y.name==="step"){let k=t.steps.find(_=>_.id===y.args[1]);k?.automation&&s.automate!==!1&&i.automated?.(k.id,C(k.automation))}};addEventListener("message",l);let G=h.length||v.length?setInterval(g,200):void 0;addEventListener("scroll",g,!0),addEventListener("resize",g);let O=m=>{o||(o=!0,G&&clearInterval(G),removeEventListener("message",l),removeEventListener("scroll",g,!0),removeEventListener("resize",g),m&&a({op:"close"}),n())};return a({op:"render",guide:t,...s.start?{start:s.start}:{},...s.checked?{checked:s.checked}:{}}),(h.length||v.length)&&g(),Object.assign(()=>O(!0),{markDone:m=>a({op:"mark",stepId:m})})}function He(t){let i=[...document.querySelectorAll("iframe")];for(let n=t;n;n=n.parent===n?null:n.parent){let s=i.find(r=>r.contentWindow===n);if(s)return s}return null}function Ie(t,i){let n=()=>{let r=t.getBoundingClientRect();return new DOMRect(r.left+t.clientLeft+i.x,r.top+t.clientTop+i.y,i.width,i.height)},s=()=>{};return{getBoundingClientRect:n,addEventListener:s,removeEventListener:s}}function _e(t,i){let n=new Set(t.map(u=>u.replace(/\/+$/,""))),s=new Map,r=u=>{if(!n.has(u.origin)||!ye(u.data))return;let c=He(u.source);if(!c)return;let o=u.data,a=`${u.origin}|${o.key}`,h=g=>{try{u.source.postMessage({...g,lc:q,key:o.key},u.origin)}catch{}},v=s.get(a);if(o.op==="rects"&&v)v.rects=o.rects&&typeof o.rects=="object"?o.rects:{},v.present=o.present&&typeof o.present=="object"?o.present:{};else if(o.op==="close")v?.handle();else if(o.op==="mark")v?.handle.markDone(String(o.stepId));else if(o.op==="render"&&!v){let g=o.guide;if(!g||typeof g.id!="string"||typeof g.name!="string"||!Array.isArray(g.steps)||!K.has(g.kind))return;let l=g.kind==="banner"?()=>{}:I();if(!l)return h({op:"closed"});let G=k=>(..._)=>h({op:"hook",name:k,args:_}),O=Object.fromEntries(me.map(k=>[k,G(k)])),m={rects:{},present:{},release:l,handle:void 0};s.set(a,m);let $={resolveTarget:k=>{let _=m.rects[k.id];return _&&typeof _.x=="number"?Ie(c,_):null},present:k=>m.present[k]===!0,automate:!1,...i?{nonce:i}:{},...typeof o.start=="number"?{start:o.start}:{},...Array.isArray(o.checked)?{checked:o.checked}:{}};m.handle=A(g,O,()=>{s.delete(a),l(),h({op:"closed"})},$)}};return addEventListener("message",r),()=>{removeEventListener("message",r);for(let u of[...s.values()])u.handle()}}var we="lc_guide_last",ve=new Set(["hotspot","beacon","badge","launcher"]),Le=()=>{try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t?`&tz=${encodeURIComponent(t)}`:""}catch{return""}},J=new Set([...ve,"form_validation"]),U=t=>J.has(t.kind)||t.kind==="inline",je=new Set(["tour","checklist"]),Ce=30*6e4,De=()=>{let t=innerWidth;return t<640?"mobile":t<1024?"tablet":"desktop"},ct=t=>{let{core:i}=t,n=[],s=!1,r=new Set,u=new Map,c=ge(),o=!1,a={get:e=>i.storage.get(e),set(e,d){i.storage.set(e,d),F.includes(e)&&h.touch()},remove:e=>i.storage.remove(e)},h=fe(t,i.storage),v=()=>JSON.parse(a.get(M)??"[]"),g=new Set(v()),l=ce(a),G=new Set,O=[],m=t.config.localFlagsContext,y={...m?.person_properties},$={...m?.group_properties},k=e=>{let d=t.flags?.get(e);return d!==void 0&&d!==!1},_=(e,d={})=>({$guide_id:e.id,$guide_kind:e.kind,...d}),W=()=>i.distinctId||i.sessionId,B=new Set,P=(e,d=!1)=>{if(e.preview){let f=()=>{};return{shown:f,step:f,completed:f,dismissed:f,event:f}}let w=J.has(e.kind),b=f=>({guide_id:e.id,step_id:f,$guide_step_id:f}),S=()=>{l.tour.set(e.id,void 0),l.checked.set(e.id,void 0),w&&l.dismissed.set(e.id,Date.now())};return{shown(){let f=Date.now(),p=l.views.get(e.id)??[],R=w&&(p.at(-1)??0)>f-Ce;g.add(e.id),l.snoozed.get(e.id)&&l.snoozed.set(e.id,void 0),a.set(M,JSON.stringify([...g])),i.storage.set(we,String(f)),e.kind==="checklist"&&!l.checked.get(e.id)&&l.checked.set(e.id,[]),!(R||d)&&(l.views.set(e.id,[...p,f].slice(-50)),i.capture("$guide_shown",_(e)))},step:(f,p)=>{e.kind==="checklist"&&l.checked.set(e.id,[...new Set([...l.checked.get(e.id)??[],p])]),i.capture("$guide_step",_(e,{$guide_step_id:p,$guide_step_index:f}))},progress:f=>e.kind==="tour"&&l.tour.set(e.id,f),completed:()=>(S(),i.capture("$guide_completed",_(e))),dismissed:(f,p,R)=>{R!=="snooze"&&S(),i.capture("$guide_dismissed",_(e,{$guide_step_id:p,$guide_step_index:f,...R?{reason:R}:{}}))},event:f=>t.client.capture(f,{$guide_id:e.id}),snoozed:(f,p)=>l.snoozed.set(e.id,Date.now()+p*36e5),targetMissing:(f,p)=>i.capture("$guide_target_missing",_(e,{...b(f),selector:p})),validationFailed:(f,p)=>i.capture("$guide_validation_failed",_(e,{...b(f),rule:p})),automated:(f,p)=>p!=="done"&&t.log(`guide ${e.id} step ${f}: automation ${p}`)}},T=(e,d=0)=>{let w=ve.has(e.kind),b=U(e)?()=>{}:I();if(!b)return void r.delete(e.id);let S=de(e,[t.config.guides?.locale,y.locale,navigator.language]),f=H=>{let L=n.find(Re=>Re.id===H);L&&!r.has(L.id)&&(r.add(L.id),T(L))},p={start:d,person:y,checked:l.checked.get(e.id)??[],library:n,launch:f,flag:k,...t.config.nonce?{nonce:t.config.nonce}:{},...e.kind==="resource_center"&&!e.preview?{assist:pe(t,e,()=>o,t.config.guides?.locale??navigator.language)}:{}},R=d>0||e.kind==="checklist"&&l.checked.get(e.id)!==void 0,E=()=>{G.delete(x),u.delete(e.id),b(),r.delete(e.id)},x=()=>{};if(w){import("./persistent-SLVINN5A.js").then(H=>{x=H.renderPersistent(S,P(e,R),E,p),s?x():G.add(x)});return}if(e.kind==="form_validation"){import("./validation-HGJXZ553.js").then(H=>{x=H.renderValidation(S,P(e,R),E,p),s?x():G.add(x)});return}let Z=t.config.guides?.renderInTop,X=Z&&K.has(e.kind)&&he()?ke(S,P(e,R),E,p,Z):A(S,P(e,R),E,p);x=X,u.set(e.id,X),G.add(x)},j=(e,d=!1)=>{let w=J.has(e.kind),b=e.conditions,S=e.steps[0]?.selector;if(e.kind==="inline"&&!(S&&document.querySelector(S)))return!1;if(e.preview)return!B.has(e.id)&&(B.add(e.id),!0);let f=l.views.get(e.id)??[],p=l.snoozed.get(e.id);if(!d&&p&&p>Date.now()||!d&&(w?l.dismissed.get(e.id):g.has(e.id)&&!b.frequency&&!p))return!1;let R={url:location.href,flags:k,flagValue:E=>t.flags?.get(E),lastShownMs:e.queued?void 0:Number(i.storage.get(we))||void 0,nowMs:Date.now(),random:e.queued?()=>0:Math.random,person:y,groups:$,device:De(),seen:E=>g.has(E),views:w?[]:f};return!ee(e,R)||oe(e,n,W())!==e?!1:e.held_out||se(e,W())?(l.held.get(e.id)||(l.held.set(e.id,Date.now()),i.capture("$guide_holdout",_(e,b.ab_group?{$guide_group:b.ab_group}:{}))),!1):!0},be=()=>{let e=c?n.find(d=>d.id===c):void 0;c=null,!(!e||r.has(e.id)||t.config.guides?.render===!1||!j(e,!0))&&(r.add(e.id),T(e))},Y=()=>{if(!(t.config.guides?.render===!1||typeof document>"u")){for(let e of n){if(r.has(e.id)||!je.has(e.kind))continue;let d=e.kind==="tour"?e.steps.findIndex(b=>b.id===l.tour.get(e.id)):l.checked.get(e.id)?0:-1,w=e.steps[d];if(!(d<0||!w||w.url&&!location.href.includes(w.url)))return r.add(e.id),T(e,d)}for(let e of n)r.has(e.id)||!U(e)||!j(e)||(r.add(e.id),T(e));for(let e of[...n.filter(d=>d.queued),...n.filter(d=>!d.queued)])if(!(r.has(e.id)||U(e)||!j(e))){r.add(e.id),O.push(setTimeout(()=>T(e),e.queued?0:(e.conditions.delay_seconds??0)*1e3));return}}},Se=e=>{for(let d of n)if(!(d.kind!=="checklist"||!r.has(d.id)&&!l.checked.get(d.id)))for(let[w,b]of d.steps.entries()){let S=b.complete_on;if(!S||S.event!==e.event||!Object.entries(S.props??{}).every(([R,E])=>e.properties[R]===E))continue;let f=l.checked.get(d.id)??[];if(f.includes(b.id))continue;let p=u.get(d.id);p?p.markDone(b.id):(l.checked.set(d.id,[...f,b.id]),i.capture("$guide_step",_(d,{$guide_step_id:b.id,$guide_step_index:w,$guide_auto:!0})),f.length+1>=d.steps.length&&P(d).completed())}},V=()=>{let e=t.fetch(`${t.config.apiHost}/v1/guides?api_key=${encodeURIComponent(t.apiKey)}${i.distinctId?`&distinct_id=${encodeURIComponent(i.distinctId)}`:""}${Le()}&url=${encodeURIComponent(location.origin+location.pathname)}`,{credentials:"omit"}).then(d=>d.ok?d.json():Promise.reject(new Error(`status ${d.status}`)));Promise.all([e,h.pull()]).then(([d])=>{for(let w of v())g.add(w);n=d.guides??[],o=d.settings?.guide_search_capture_query===!0,be(),Y()}).catch(d=>t.log("guides fetch failed",d))};t.guides={showChangelog(){if(typeof document>"u")return 0;let e=I();if(!e)return 0;let d=re(n,()=>i.capture("$changelog_viewed"),()=>(G.delete(d),e()),t.config.nonce);return d?(G.add(d),n.filter(w=>w.kind==="banner").length):(e(),0)},show(e){let d=n.find(w=>w.id===e);return!d||r.has(d.id)||typeof document>"u"||t.config.guides?.render===!1?!1:(r.add(d.id),T(d),r.has(d.id))},reset(e){g.delete(e),a.set(M,JSON.stringify([...g]));for(let d of[l.views,l.dismissed,l.tour,l.checked,l.held])d.set(e,void 0)}},t.whenConsented(V);let Q=t.config.guides?.frameOrigins;return Q?.length&&typeof document<"u"&&G.add(_e(Q,t.config.nonce)),t.onCapture(e=>{if(e.event==="$identify"&&V(),e.$set&&Object.assign(y,e.$set),e.event==="$groupidentify"){let d=String(e.properties.$group_type);$[d]={...$[d],...e.properties.$group_set}}e.event==="$pageview"?Y():e.event.startsWith("$guide_")||Se(e)}),()=>{s=!0,h.stop();for(let e of O)clearTimeout(e);for(let e of[...G])e()}};export{z as PERMALINK_PARAM,Ge as branchOk,ct as guides,A as renderGuide,Ee as resolveTokens,C as runAutomation,$e as sensitive};