@syntrologie/runtime-sdk 2.8.0-canary.129 → 2.8.0-canary.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-QO3T63LM.js → chunk-SC5B3YCG.js} +2 -2
- package/dist/{chunk-QO3T63LM.js.map → chunk-SC5B3YCG.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/smart-canvas.esm.js +2 -2
- package/dist/smart-canvas.esm.js.map +1 -1
- package/dist/smart-canvas.js +2 -2
- package/dist/smart-canvas.js.map +1 -1
- package/dist/smart-canvas.min.js +2 -2
- package/dist/smart-canvas.min.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/smart-canvas.esm.js
CHANGED
|
@@ -561,7 +561,7 @@ Please report this to https://github.com/markedjs/marked.`,n){let r="<p>An error
|
|
|
561
561
|
.themeConfig=${this.themeConfig}
|
|
562
562
|
@drawer-close=${this._onDrawerClose}
|
|
563
563
|
></syntro-drawer>
|
|
564
|
-
`}};Da.properties={isOpen:{type:Boolean},tiles:{attribute:!1},isLoading:{type:Boolean},error:{type:String},canvasTitle:{type:String},displayMode:{type:String},runtimeRef:{attribute:!1},telemetry:{attribute:!1},themeConfig:{attribute:!1},launcherAnimate:{type:Boolean}};customElements.define("syntro-canvas-overlay",Da);function Ha(n,e,t="merge"){return t==="first-match"?nE(n,e):rE(n,e)}function nE(n,e){for(let t of e){let r=n.getFeatureValue?.(t,null);if(!r||typeof r!="object")continue;let i=r,s=i.tiles&&i.tiles.length>0,o=i.actions&&i.actions.length>0;if(s||o)return av([i])}return null}function rE(n,e){let t=[];for(let r of e){let i=n.getFeatureValue?.(r,null);if(!i||typeof i!="object")continue;let s=i,o=s.tiles&&s.tiles.length>0,a=s.actions&&s.actions.length>0;(o||a)&&t.push(s)}return t.length===0?null:av(t)}function av(n){let e=[],t=[],r,i,s,o,a,l,c;for(let u of n)u.tiles&&e.push(...u.tiles),u.actions&&t.push(...u.actions),r??(r=u.fetchedAt),i??(i=u.schemaVersion),s??(s=u.configVersion),o??(o=u.canvasTitle),a??(a=u.theme),l??(l=u.launcher),c??(c=u.meta);return{tiles:e,actions:t,fetchedAt:r??new Date().toISOString(),...i&&{schemaVersion:i},...s&&{configVersion:s},...o&&{canvasTitle:o},...a&&{theme:a},...l&&{launcher:l},...c&&{meta:c}}}var Au=!1;function lv(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Ru(n){if(lv()){Au=!0;return}Au=n??!1}function iE(){return lv()?!0:Au}function K(n,e,t){iE()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function Qe(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function Ba(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var Tu="2.8.0-canary.129";var En="2.0";var sE=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function oE(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] Config URI must use HTTPS:",n),!1):sE.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] Config URI host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid config URI:",n),!1}}function aE(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var cv="syntro_config_cache",lE=1440*60*1e3;function uv(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function cE(n,e){if(uv())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(cv,JSON.stringify(t))}catch{}}function uE(n){if(!uv())return null;try{let e=localStorage.getItem(cv);if(!e)return null;let t=JSON.parse(e);return!t.config||typeof t.timestamp!="number"||!t.sdkVersion||t.sdkVersion!==n||Date.now()-t.timestamp>lE?null:t.config}catch{return null}}var Iu=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function dE(n,e,t){if(e){let r=n.getFeatureValue?.(e,null);if(r&&typeof r=="object"){let i=r.variant_flags;if(i&&i.length>0)return i}}if(n.getAllFeatures){let r=n.getAllFeatures();return t?Object.keys(r).filter(i=>i.startsWith(t)):Object.keys(r)}return[]}var hi=({configUri:n,experiments:e,featureKey:t,credentials:r,configFeatureKey:i,manifestKey:s,variantFlagPrefix:o,sdkVersion:a})=>async()=>{if(e&&i){let u=e.getFeatureValue?.(i,null);if(u&&typeof u=="object")return K("SmartCanvas Config","Resolved config directly from feature flag",u),u}if(e&&(s||o||e.getAllFeatures)){let u=dE(e,s,o);if(u.length>0){let d=Ha(e,u);if(d)return K("SmartCanvas Config","Resolved config from variant flags",d),d}}let l=Iu({configUri:n,experiments:e,featureKey:t});if(!l)return K("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!oE(l))throw new Error(`SmartCanvas: config URI not allowed: ${l}`);let c=r??(aE(l)?"include":"omit");try{let u=await fetch(l,{credentials:c,headers:{"X-SDK-Version":Tu,"X-SDK-Schema-Version":En}});if(!u.ok)throw new Error(`SmartCanvas: failed to fetch config (${u.status})`);let d=await u.json();return K("SmartCanvas Config","Fetched config from URI",d),a&&cE(d,a),d}catch(u){if(a){let d=uE(a);if(d)return K("SmartCanvas Config","Serving config from offline cache"),d}throw u}};var $u=class{constructor(e){this.listeners=new Set;let t=e?.open??!1;if(e?.open===void 0)try{let r=sessionStorage?.getItem("syntro:editor:panel-open");r!==null&&(t=JSON.parse(r))}catch{}this.state={open:t}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){if(this.state.open!==e){this.state={...this.state,open:e};try{sessionStorage?.setItem("syntro:editor:panel-open",JSON.stringify(e))}catch{}this.emit()}}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},dv=n=>new $u(n);function se(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}var iO={colorPrimary:ie[3],colorPrimaryHover:ie[4],colorPrimaryMuted:ie[0],colorBackground:se(S[1],.95),colorBackgroundElevated:se(S[3],.95),colorBackgroundSubtle:se(S[0],.2),colorSurface:se(S[4],.8),colorSurfaceHover:se(S[5],.8),colorText:at.primary,colorTextSecondary:at.secondary,colorTextMuted:at.tertiary,colorTextInverse:S[1],colorBorder:Ac.primary,colorBorderSubtle:Ac.secondary,colorSuccess:be[4],colorSuccessMuted:be[0],colorWarning:Be[4],colorWarningMuted:Be[0],colorError:Te[4],colorErrorMuted:Te[0],colorInfo:Ze[4],colorInfoMuted:Ze[0],colorNotification:ie[4],colorNotificationMuted:se(ie[4],.4),glassBackground:se(S[1],.6),glassBackgroundHover:se(S[1],.7),glassBorder:"rgba(255, 255, 255, 0.08)",glassBlur:"blur(24px)",glassSaturate:"saturate(1.2)",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'SF Mono', 'Fira Code', Consolas, monospace",fontSizeXs:"0.7rem",fontSizeSm:"0.8rem",fontSizeMd:"0.9rem",fontSizeLg:"1rem",fontSizeXl:"1.25rem",fontSizeXxl:"1.5rem",fontWeightNormal:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightNormal:"1.5",lineHeightRelaxed:"1.75",spacingXs:"0.25rem",spacingSm:"0.5rem",spacingMd:"0.75rem",spacingLg:"1rem",spacingXl:"1.5rem",borderRadiusSm:"6px",borderRadiusMd:"10px",borderRadiusLg:"14px",borderRadiusXl:"20px",borderRadiusFull:"9999px",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.2)",shadowMd:"0 2px 12px rgba(0, 0, 0, 0.3)",shadowLg:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowXl:"0 16px 48px rgba(0, 0, 0, 0.5)",backdropBlur:"blur(20px)",backdropSaturate:"saturate(180%)",transitionFast:"0.1s ease",transitionNormal:"0.25s ease",transitionSlow:"0.4s ease"},sO={colorPrimary:ie[3],colorPrimaryHover:ie[2],colorPrimaryMuted:se(ie[5],.1),colorBackground:se(S[12],.95),colorBackgroundElevated:se(S[11],.95),colorBackgroundSubtle:se(S[0],.02),colorSurface:se(S[11],.6),colorSurfaceHover:se(S[10],.6),colorText:S[1],colorTextSecondary:S[6],colorTextMuted:S[8],colorTextInverse:S[12],colorBorder:se(S[0],.12),colorBorderSubtle:se(S[0],.06),colorSuccess:be[4],colorSuccessMuted:se(be[4],.12),colorWarning:Be[4],colorWarningMuted:se(Be[4],.12),colorError:Te[4],colorErrorMuted:se(Te[4],.12),colorInfo:Ze[4],colorInfoMuted:se(Ze[4],.12),colorNotification:ie[3],colorNotificationMuted:se(ie[3],.4),glassBackground:se(S[12],.7),glassBackgroundHover:se(S[12],.8),glassBorder:"rgba(0, 0, 0, 0.06)",glassBlur:"blur(24px)",glassSaturate:"saturate(1.2)",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'SF Mono', 'Fira Code', Consolas, monospace",fontSizeXs:"0.7rem",fontSizeSm:"0.8rem",fontSizeMd:"0.9rem",fontSizeLg:"1rem",fontSizeXl:"1.25rem",fontSizeXxl:"1.5rem",fontWeightNormal:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightNormal:"1.5",lineHeightRelaxed:"1.75",spacingXs:"0.25rem",spacingSm:"0.5rem",spacingMd:"0.75rem",spacingLg:"1rem",spacingXl:"1.5rem",borderRadiusSm:"6px",borderRadiusMd:"10px",borderRadiusLg:"14px",borderRadiusXl:"20px",borderRadiusFull:"9999px",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.08)",shadowMd:"0 2px 12px rgba(0, 0, 0, 0.12)",shadowLg:"0 8px 24px rgba(0, 0, 0, 0.16)",shadowXl:"0 16px 48px rgba(0, 0, 0, 0.2)",backdropBlur:"blur(20px)",backdropSaturate:"saturate(180%)",transitionFast:"0.1s ease",transitionNormal:"0.25s ease",transitionSlow:"0.4s ease"};function pE(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var pv={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ie[3],colorPrimaryHover:ie[4],borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:se(S[1],.6),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%"},launcher:{background:Xo.primary.backgroundDefault,backgroundHover:Xo.primary.backgroundHover,color:Xo.primary.icon,size:"56px",shadow:`0 8px 32px ${se(S[0],.6)}`,borderRadius:"9999px"},tile:{background:se(S[1],.6),backgroundHover:se(S[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:at.primary,textColor:at.secondary,iconBackground:`linear-gradient(135deg, ${ie[3]} 0%, ${ie[3]}cc 100%)`,iconShadow:`0 2px 8px ${ie[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:se(S[1],.6),textColor:at.primary,titleColor:at.primary,arrowColor:se(S[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ie[3]}`},notification:{background:se(S[0],.95),textColor:at.primary,textSecondaryColor:at.secondary,border:`1px solid ${S[5]}`,borderRadius:"12px",successColor:be[4],warningColor:Be[4],errorColor:Te[4],iconBackground:se(ie[3],.15),progressGradient:`linear-gradient(90deg, ${ie[3]}, ${ie[4]})`},content:{background:se(S[3],.8),backgroundHover:se(S[5],.6),border:`1px solid ${se(S[5],.5)}`,borderRadius:"8px",textColor:at.primary,textSecondaryColor:at.secondary,itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:se(S[3],.8),searchColor:at.primary,chevronColor:"currentColor"}},hv={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ie[3],colorPrimaryHover:ie[2],borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:se(S[12],.7),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%"},launcher:{background:ie[3],backgroundHover:ie[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:se(S[12],.7),backgroundHover:se(S[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:S[1],textColor:S[6],iconBackground:`linear-gradient(135deg, ${ie[3]} 0%, ${ie[3]}cc 100%)`,iconShadow:`0 2px 8px ${ie[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:se(S[12],.7),textColor:S[1],titleColor:S[1],arrowColor:se(S[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ie[3]}`},notification:{background:se(S[12],.95),textColor:S[1],textSecondaryColor:S[6],border:`1px solid ${se(S[0],.12)}`,borderRadius:"12px",successColor:be[4],warningColor:Be[4],errorColor:Te[4],iconBackground:se(ie[3],.1),progressGradient:`linear-gradient(90deg, ${ie[3]}, ${ie[2]})`},content:{background:se(S[12],.8),backgroundHover:se(S[11],.6),border:`1px solid ${S[11]}`,borderRadius:"8px",textColor:S[1],textSecondaryColor:S[6],itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:S[12],searchColor:S[1],chevronColor:"currentColor"}};function fv(n){let e=n.mode==="light"?hv:pv;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,borderRadius:n.borderRadius??e.borderRadius,canvas:{...e.canvas,...n.canvas},launcher:{...e.launcher,...n.launcher},tile:{...e.tile,...n.tile},overlay:{...e.overlay,...n.overlay},notification:{...e.notification,...n.notification},content:{...e.content,...n.content}}}function gv(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?hv:pv;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,borderRadius:e.borderRadius??n.borderRadius??r.borderRadius,canvas:{...r.canvas,...n.canvas,...e.canvas},launcher:{...r.launcher,...n.launcher,...e.launcher},tile:{...r.tile,...n.tile,...e.tile},overlay:{...r.overlay,...n.overlay,...e.overlay},notification:{...r.notification,...n.notification,...e.notification},content:{...r.content,...n.content,...e.content}}}var hE=["canvas","launcher","tile","overlay","notification","content"];function mv(n){let e={};n.fontFamily&&(e["--sc-font-family"]=n.fontFamily),n.colorPrimary&&(e["--sc-color-primary"]=n.colorPrimary),n.colorPrimaryHover&&(e["--sc-color-primary-hover"]=n.colorPrimaryHover),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of hE){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&(e[`--sc-${t}-${pE(i)}`]=s)}return e}var Cn,hr,fr,tn,nn,Mu,Va,Ns=class{constructor(e,t,r){ee(this,nn);ee(this,Cn);ee(this,hr);ee(this,fr);ee(this,tn);Z(this,Cn,e),Z(this,hr,t??{}),Z(this,fr,r),Z(this,tn,te(this,nn,Mu).call(this)),e.addController(this)}get config(){return I(this,tn).config}get mode(){return I(this,tn).mode}get cssVariables(){return I(this,tn).cssVariables}hostConnected(){te(this,nn,Va).call(this)}hostDisconnected(){}hostUpdated(){te(this,nn,Va).call(this)}setThemeConfig(e,t){Z(this,hr,e),Z(this,fr,t),Z(this,tn,te(this,nn,Mu).call(this)),te(this,nn,Va).call(this),I(this,Cn).requestUpdate()}};Cn=new WeakMap,hr=new WeakMap,fr=new WeakMap,tn=new WeakMap,nn=new WeakSet,Mu=function(){let e=I(this,fr)?gv(I(this,fr),I(this,hr)):fv(I(this,hr)),t=mv(e);return{config:e,mode:e.mode,cssVariables:t}},Va=function(){let e=I(this,Cn).shadowRoot??("renderRoot"in I(this,Cn)?I(this,Cn).renderRoot:null);if(!e||!(e instanceof ShadowRoot))return;let t=e.querySelector("#sc-theme-vars");t||(t=document.createElement("style"),t.id="sc-theme-vars",e.insertBefore(t,e.firstChild));let r=Object.entries(I(this,tn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
564
|
+
`}};Da.properties={isOpen:{type:Boolean},tiles:{attribute:!1},isLoading:{type:Boolean},error:{type:String},canvasTitle:{type:String},displayMode:{type:String},runtimeRef:{attribute:!1},telemetry:{attribute:!1},themeConfig:{attribute:!1},launcherAnimate:{type:Boolean}};customElements.define("syntro-canvas-overlay",Da);function Ha(n,e,t="merge"){return t==="first-match"?nE(n,e):rE(n,e)}function nE(n,e){for(let t of e){let r=n.getFeatureValue?.(t,null);if(!r||typeof r!="object")continue;let i=r,s=i.tiles&&i.tiles.length>0,o=i.actions&&i.actions.length>0;if(s||o)return av([i])}return null}function rE(n,e){let t=[];for(let r of e){let i=n.getFeatureValue?.(r,null);if(!i||typeof i!="object")continue;let s=i,o=s.tiles&&s.tiles.length>0,a=s.actions&&s.actions.length>0;(o||a)&&t.push(s)}return t.length===0?null:av(t)}function av(n){let e=[],t=[],r,i,s,o,a,l,c;for(let u of n)u.tiles&&e.push(...u.tiles),u.actions&&t.push(...u.actions),r??(r=u.fetchedAt),i??(i=u.schemaVersion),s??(s=u.configVersion),o??(o=u.canvasTitle),a??(a=u.theme),l??(l=u.launcher),c??(c=u.meta);return{tiles:e,actions:t,fetchedAt:r??new Date().toISOString(),...i&&{schemaVersion:i},...s&&{configVersion:s},...o&&{canvasTitle:o},...a&&{theme:a},...l&&{launcher:l},...c&&{meta:c}}}var Au=!1;function lv(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Ru(n){if(lv()){Au=!0;return}Au=n??!1}function iE(){return lv()?!0:Au}function K(n,e,t){iE()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function Qe(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function Ba(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var Tu="2.8.0-canary.130";var En="2.0";var sE=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function oE(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] Config URI must use HTTPS:",n),!1):sE.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] Config URI host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid config URI:",n),!1}}function aE(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var cv="syntro_config_cache",lE=1440*60*1e3;function uv(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function cE(n,e){if(uv())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(cv,JSON.stringify(t))}catch{}}function uE(n){if(!uv())return null;try{let e=localStorage.getItem(cv);if(!e)return null;let t=JSON.parse(e);return!t.config||typeof t.timestamp!="number"||!t.sdkVersion||t.sdkVersion!==n||Date.now()-t.timestamp>lE?null:t.config}catch{return null}}var Iu=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function dE(n,e,t){if(e){let r=n.getFeatureValue?.(e,null);if(r&&typeof r=="object"){let i=r.variant_flags;if(i&&i.length>0)return i}}if(n.getAllFeatures){let r=n.getAllFeatures();return t?Object.keys(r).filter(i=>i.startsWith(t)):Object.keys(r)}return[]}var hi=({configUri:n,experiments:e,featureKey:t,credentials:r,configFeatureKey:i,manifestKey:s,variantFlagPrefix:o,sdkVersion:a})=>async()=>{if(e&&i){let u=e.getFeatureValue?.(i,null);if(u&&typeof u=="object")return K("SmartCanvas Config","Resolved config directly from feature flag",u),u}if(e&&(s||o||e.getAllFeatures)){let u=dE(e,s,o);if(u.length>0){let d=Ha(e,u);if(d)return K("SmartCanvas Config","Resolved config from variant flags",d),d}}let l=Iu({configUri:n,experiments:e,featureKey:t});if(!l)return K("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!oE(l))throw new Error(`SmartCanvas: config URI not allowed: ${l}`);let c=r??(aE(l)?"include":"omit");try{let u=await fetch(l,{credentials:c,headers:{"X-SDK-Version":Tu,"X-SDK-Schema-Version":En}});if(!u.ok)throw new Error(`SmartCanvas: failed to fetch config (${u.status})`);let d=await u.json();return K("SmartCanvas Config","Fetched config from URI",d),a&&cE(d,a),d}catch(u){if(a){let d=uE(a);if(d)return K("SmartCanvas Config","Serving config from offline cache"),d}throw u}};var $u=class{constructor(e){this.listeners=new Set;let t=e?.open??!1;if(e?.open===void 0)try{let r=sessionStorage?.getItem("syntro:editor:panel-open");r!==null&&(t=JSON.parse(r))}catch{}this.state={open:t}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){if(this.state.open!==e){this.state={...this.state,open:e};try{sessionStorage?.setItem("syntro:editor:panel-open",JSON.stringify(e))}catch{}this.emit()}}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},dv=n=>new $u(n);function se(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}var iO={colorPrimary:ie[3],colorPrimaryHover:ie[4],colorPrimaryMuted:ie[0],colorBackground:se(S[1],.95),colorBackgroundElevated:se(S[3],.95),colorBackgroundSubtle:se(S[0],.2),colorSurface:se(S[4],.8),colorSurfaceHover:se(S[5],.8),colorText:at.primary,colorTextSecondary:at.secondary,colorTextMuted:at.tertiary,colorTextInverse:S[1],colorBorder:Ac.primary,colorBorderSubtle:Ac.secondary,colorSuccess:be[4],colorSuccessMuted:be[0],colorWarning:Be[4],colorWarningMuted:Be[0],colorError:Te[4],colorErrorMuted:Te[0],colorInfo:Ze[4],colorInfoMuted:Ze[0],colorNotification:ie[4],colorNotificationMuted:se(ie[4],.4),glassBackground:se(S[1],.6),glassBackgroundHover:se(S[1],.7),glassBorder:"rgba(255, 255, 255, 0.08)",glassBlur:"blur(24px)",glassSaturate:"saturate(1.2)",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'SF Mono', 'Fira Code', Consolas, monospace",fontSizeXs:"0.7rem",fontSizeSm:"0.8rem",fontSizeMd:"0.9rem",fontSizeLg:"1rem",fontSizeXl:"1.25rem",fontSizeXxl:"1.5rem",fontWeightNormal:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightNormal:"1.5",lineHeightRelaxed:"1.75",spacingXs:"0.25rem",spacingSm:"0.5rem",spacingMd:"0.75rem",spacingLg:"1rem",spacingXl:"1.5rem",borderRadiusSm:"6px",borderRadiusMd:"10px",borderRadiusLg:"14px",borderRadiusXl:"20px",borderRadiusFull:"9999px",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.2)",shadowMd:"0 2px 12px rgba(0, 0, 0, 0.3)",shadowLg:"0 8px 24px rgba(0, 0, 0, 0.4)",shadowXl:"0 16px 48px rgba(0, 0, 0, 0.5)",backdropBlur:"blur(20px)",backdropSaturate:"saturate(180%)",transitionFast:"0.1s ease",transitionNormal:"0.25s ease",transitionSlow:"0.4s ease"},sO={colorPrimary:ie[3],colorPrimaryHover:ie[2],colorPrimaryMuted:se(ie[5],.1),colorBackground:se(S[12],.95),colorBackgroundElevated:se(S[11],.95),colorBackgroundSubtle:se(S[0],.02),colorSurface:se(S[11],.6),colorSurfaceHover:se(S[10],.6),colorText:S[1],colorTextSecondary:S[6],colorTextMuted:S[8],colorTextInverse:S[12],colorBorder:se(S[0],.12),colorBorderSubtle:se(S[0],.06),colorSuccess:be[4],colorSuccessMuted:se(be[4],.12),colorWarning:Be[4],colorWarningMuted:se(Be[4],.12),colorError:Te[4],colorErrorMuted:se(Te[4],.12),colorInfo:Ze[4],colorInfoMuted:se(Ze[4],.12),colorNotification:ie[3],colorNotificationMuted:se(ie[3],.4),glassBackground:se(S[12],.7),glassBackgroundHover:se(S[12],.8),glassBorder:"rgba(0, 0, 0, 0.06)",glassBlur:"blur(24px)",glassSaturate:"saturate(1.2)",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",fontFamilyMono:"'SF Mono', 'Fira Code', Consolas, monospace",fontSizeXs:"0.7rem",fontSizeSm:"0.8rem",fontSizeMd:"0.9rem",fontSizeLg:"1rem",fontSizeXl:"1.25rem",fontSizeXxl:"1.5rem",fontWeightNormal:"400",fontWeightMedium:"500",fontWeightSemibold:"600",fontWeightBold:"700",lineHeightTight:"1.25",lineHeightNormal:"1.5",lineHeightRelaxed:"1.75",spacingXs:"0.25rem",spacingSm:"0.5rem",spacingMd:"0.75rem",spacingLg:"1rem",spacingXl:"1.5rem",borderRadiusSm:"6px",borderRadiusMd:"10px",borderRadiusLg:"14px",borderRadiusXl:"20px",borderRadiusFull:"9999px",shadowSm:"0 1px 2px rgba(0, 0, 0, 0.08)",shadowMd:"0 2px 12px rgba(0, 0, 0, 0.12)",shadowLg:"0 8px 24px rgba(0, 0, 0, 0.16)",shadowXl:"0 16px 48px rgba(0, 0, 0, 0.2)",backdropBlur:"blur(20px)",backdropSaturate:"saturate(180%)",transitionFast:"0.1s ease",transitionNormal:"0.25s ease",transitionSlow:"0.4s ease"};function pE(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var pv={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ie[3],colorPrimaryHover:ie[4],borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:se(S[1],.6),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%"},launcher:{background:Xo.primary.backgroundDefault,backgroundHover:Xo.primary.backgroundHover,color:Xo.primary.icon,size:"56px",shadow:`0 8px 32px ${se(S[0],.6)}`,borderRadius:"9999px"},tile:{background:se(S[1],.6),backgroundHover:se(S[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:at.primary,textColor:at.secondary,iconBackground:`linear-gradient(135deg, ${ie[3]} 0%, ${ie[3]}cc 100%)`,iconShadow:`0 2px 8px ${ie[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:se(S[1],.6),textColor:at.primary,titleColor:at.primary,arrowColor:se(S[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ie[3]}`},notification:{background:se(S[0],.95),textColor:at.primary,textSecondaryColor:at.secondary,border:`1px solid ${S[5]}`,borderRadius:"12px",successColor:be[4],warningColor:Be[4],errorColor:Te[4],iconBackground:se(ie[3],.15),progressGradient:`linear-gradient(90deg, ${ie[3]}, ${ie[4]})`},content:{background:se(S[3],.8),backgroundHover:se(S[5],.6),border:`1px solid ${se(S[5],.5)}`,borderRadius:"8px",textColor:at.primary,textSecondaryColor:at.secondary,itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:se(S[3],.8),searchColor:at.primary,chevronColor:"currentColor"}},hv={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ie[3],colorPrimaryHover:ie[2],borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:se(S[12],.7),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%"},launcher:{background:ie[3],backgroundHover:ie[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:se(S[12],.7),backgroundHover:se(S[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:S[1],textColor:S[6],iconBackground:`linear-gradient(135deg, ${ie[3]} 0%, ${ie[3]}cc 100%)`,iconShadow:`0 2px 8px ${ie[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:se(S[12],.7),textColor:S[1],titleColor:S[1],arrowColor:se(S[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ie[3]}`},notification:{background:se(S[12],.95),textColor:S[1],textSecondaryColor:S[6],border:`1px solid ${se(S[0],.12)}`,borderRadius:"12px",successColor:be[4],warningColor:Be[4],errorColor:Te[4],iconBackground:se(ie[3],.1),progressGradient:`linear-gradient(90deg, ${ie[3]}, ${ie[2]})`},content:{background:se(S[12],.8),backgroundHover:se(S[11],.6),border:`1px solid ${S[11]}`,borderRadius:"8px",textColor:S[1],textSecondaryColor:S[6],itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:S[12],searchColor:S[1],chevronColor:"currentColor"}};function fv(n){let e=n.mode==="light"?hv:pv;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,borderRadius:n.borderRadius??e.borderRadius,canvas:{...e.canvas,...n.canvas},launcher:{...e.launcher,...n.launcher},tile:{...e.tile,...n.tile},overlay:{...e.overlay,...n.overlay},notification:{...e.notification,...n.notification},content:{...e.content,...n.content}}}function gv(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?hv:pv;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,borderRadius:e.borderRadius??n.borderRadius??r.borderRadius,canvas:{...r.canvas,...n.canvas,...e.canvas},launcher:{...r.launcher,...n.launcher,...e.launcher},tile:{...r.tile,...n.tile,...e.tile},overlay:{...r.overlay,...n.overlay,...e.overlay},notification:{...r.notification,...n.notification,...e.notification},content:{...r.content,...n.content,...e.content}}}var hE=["canvas","launcher","tile","overlay","notification","content"];function mv(n){let e={};n.fontFamily&&(e["--sc-font-family"]=n.fontFamily),n.colorPrimary&&(e["--sc-color-primary"]=n.colorPrimary),n.colorPrimaryHover&&(e["--sc-color-primary-hover"]=n.colorPrimaryHover),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of hE){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&(e[`--sc-${t}-${pE(i)}`]=s)}return e}var Cn,hr,fr,tn,nn,Mu,Va,Ns=class{constructor(e,t,r){ee(this,nn);ee(this,Cn);ee(this,hr);ee(this,fr);ee(this,tn);Z(this,Cn,e),Z(this,hr,t??{}),Z(this,fr,r),Z(this,tn,te(this,nn,Mu).call(this)),e.addController(this)}get config(){return I(this,tn).config}get mode(){return I(this,tn).mode}get cssVariables(){return I(this,tn).cssVariables}hostConnected(){te(this,nn,Va).call(this)}hostDisconnected(){}hostUpdated(){te(this,nn,Va).call(this)}setThemeConfig(e,t){Z(this,hr,e),Z(this,fr,t),Z(this,tn,te(this,nn,Mu).call(this)),te(this,nn,Va).call(this),I(this,Cn).requestUpdate()}};Cn=new WeakMap,hr=new WeakMap,fr=new WeakMap,tn=new WeakMap,nn=new WeakSet,Mu=function(){let e=I(this,fr)?gv(I(this,fr),I(this,hr)):fv(I(this,hr)),t=mv(e);return{config:e,mode:e.mode,cssVariables:t}},Va=function(){let e=I(this,Cn).shadowRoot??("renderRoot"in I(this,Cn)?I(this,Cn).renderRoot:null);if(!e||!(e instanceof ShadowRoot))return;let t=e.querySelector("#sc-theme-vars");t||(t=document.createElement("style"),t.id="sc-theme-vars",e.insertBefore(t,e.firstChild));let r=Object.entries(I(this,tn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
565
565
|
`);t.textContent=`:host {
|
|
566
566
|
${r}
|
|
567
567
|
}`};var fE=new Set(["tag_name","$el_text"]);function gE(n){return fE.has(n)||n.startsWith("attr__")}function vv(n,e){return n.equals!==void 0?e===n.equals:n.contains!==void 0?typeof e=="string"&&e.includes(n.contains):!1}function mE(n){let{events:e,match:t}=n;return r=>{if(!e.includes(r.name))return!1;if(t){for(let[i,s]of Object.entries(t))if(gE(i)){let o=r.props?.elements;if(!o||!o.some(l=>vv(s,l[i])))return!1}else if(!vv(s,r.props?.[i]))return!1}return!0}}function yv(n,e){for(let t of n.rules)for(let r of t.conditions)if(r.type==="event_count"&&r.key){let i=r.counter,s=i?mE(i):()=>!0,o=typeof r.withinMs=="number";e.register(r.key,s,o)}}function fi(n,e,t){for(let r of n){let i=r.props;if(!i)continue;let s=i.actions;if(s)for(let o of s)o.triggerWhen?.type==="rules"&&yv(o.triggerWhen,e)}if(t)for(let r of t){let i=r;i.triggerWhen?.type==="rules"&&yv(i.triggerWhen,e)}}var An,gi,Ls,Pu,Wa=class extends ge{constructor(){super(...arguments);ee(this,Ls);this.component=null;this.props={};ee(this,An,null);ee(this,gi,null)}createRenderRoot(){return this}render(){return D`<div></div>`}firstUpdated(){Z(this,gi,this.querySelector("div")),te(this,Ls,Pu).call(this)}updated(t){te(this,Ls,Pu).call(this)}disconnectedCallback(){super.disconnectedCallback(),I(this,An)?.unmount(),Z(this,An,null)}};An=new WeakMap,gi=new WeakMap,Ls=new WeakSet,Pu=function(){if(!I(this,gi)||!this.component)return;let t=window.SynOS;if(!t?.React||!t?.ReactDOM?.createRoot)return;let r=t.React,{createRoot:i}=t.ReactDOM;I(this,An)||Z(this,An,i(I(this,gi))),I(this,An).render(r.createElement(this.component,this.props))},Wa.properties={component:{attribute:!1},props:{attribute:!1}};customElements.define("react-bridge",Wa);var vE="syntro-runtime",bv="smart-canvas",_v=n=>[...n].sort((e,t)=>(t.priority??0)-(e.priority??0));function xv(n){let e=typeof window<"u"?window.SynOS?.interventionTracker:null;if(e)for(let t of n)e.trackTriggered(t.id,t.widget??"unknown")}var et,vi,Nt,mt,Lt,gr,Fs,Ds,Hs,mr,vr,Rn,Tn,In,yr,$n,yi,bi,Bs,xe,wv,kv,_i,Ou,Sv,Nu,Lu,Fu,Ev,Du,ja,Cv,mi=class extends ge{constructor(){super();ee(this,xe);this.fetcher=void 0;this.configUri=void 0;this.configUriFeatureKey=void 0;this.configFeatureKey=void 0;this.fetchCredentials="include";this.experiments=void 0;this.telemetry=void 0;this.runtime=void 0;this.launcherLabel=void 0;this.initialBatchHandle=null;this.workspaceTheme=void 0;this._tiles=[];this._configActions=[];this._isLoading=!0;this._error=void 0;this._theme=void 0;this._launcher=void 0;this._canvasTitle=void 0;this._displayMode="standard";this._isOpen=!1;this._pageUrl=typeof window<"u"?window.location.href:"/";ee(this,et);ee(this,vi,null);ee(this,Nt,null);ee(this,mt,null);ee(this,Lt,null);ee(this,gr);ee(this,Fs,0);ee(this,Ds,null);ee(this,Hs,"[]");ee(this,mr,null);ee(this,vr,null);ee(this,Rn,null);ee(this,Tn,null);ee(this,In,null);ee(this,yr,()=>{this._pageUrl=window.location.href});ee(this,$n,null);ee(this,yi,null);ee(this,bi);ee(this,Bs);ee(this,_i,0);ee(this,ja,t=>{I(this,et).toggle()});Z(this,et,dv()),Z(this,gr,!1),Z(this,bi,new Ns(this)),Z(this,Bs,new pi(this,{context:vE,initialValue:null}))}connectedCallback(){super.connectedCallback(),this.style.setProperty("font-family","inherit"),Z(this,vi,I(this,et).subscribe(t=>{this._isOpen=t.open})),this._isOpen=I(this,et).getState().open,Z(this,Nt,document.createElement("div")),I(this,Nt).id="overlayContainer",Object.assign(I(this,Nt).style,{position:"fixed",inset:"0",zIndex:"2147483645",pointerEvents:"none"}),this.shadowRoot.appendChild(I(this,Nt)),Z(this,mt,document.createElement("div")),I(this,mt).id="portalRoot",this.shadowRoot.appendChild(I(this,mt)),te(this,xe,Nu).call(this),te(this,xe,Du).call(this),te(this,xe,Fu).call(this)}disconnectedCallback(){var t,r,i,s,o;super.disconnectedCallback(),(t=I(this,vi))==null||t.call(this),Z(this,vi,null),(r=I(this,vr))==null||r.call(this),Z(this,vr,null),(i=I(this,Rn))==null||i.call(this),Z(this,Rn,null),(s=I(this,Tn))==null||s.call(this),Z(this,Tn,null),(o=I(this,In))==null||o.call(this),Z(this,In,null),te(this,xe,Lu).call(this),I(this,Lt)&&(I(this,Lt).revertAll().catch(a=>{console.error("[SmartCanvasElementLit] Failed to revert actions on disconnect:",a)}),Z(this,Lt,null)),I(this,$n)?.unmount(),Z(this,$n,null),I(this,Nt)?.remove(),Z(this,Nt,null),I(this,mt)?.remove(),Z(this,mt,null)}updated(t){var i;t.has("runtime")&&(I(this,Bs).setValue(this.runtime??null),te(this,xe,Ev).call(this),te(this,xe,Fu).call(this),te(this,xe,Du).call(this),te(this,xe,Lu).call(this),te(this,xe,Nu).call(this));let r=t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("configFeatureKey")||t.has("fetchCredentials")||t.has("experiments");if(r&&(te(this,xe,wv).call(this),(i=I(this,vr))==null||i.call(this),this.experiments?.onFeaturesChanged&&Z(this,vr,this.experiments.onFeaturesChanged(()=>this._loadConfig()))),(r||t.has("_pageUrl"))&&this._loadConfig(),(t.has("_theme")||t.has("workspaceTheme"))&&I(this,bi).setThemeConfig(this._theme??{},this.workspaceTheme),(t.has("_configActions")||t.has("_pageUrl"))&&te(this,xe,Sv).call(this),t.has("_tiles")||t.has("_isLoading")||t.has("_error")){let s=this._tiles.length>0&&!this._error;!this._isLoading&&!s&&I(this,et).getState().open&&I(this,et).setOpen(!1)}t.has("initialBatchHandle")&&this.initialBatchHandle&&(Z(this,Lt,this.initialBatchHandle),Z(this,gr,!0))}render(){let t=this._tiles.length>0&&!this._error;return this._isLoading||t?D`
|
|
@@ -1159,7 +1159,7 @@ Actions:`,w.map((N,z)=>` [${z}] ${N.kind} ${N.anchorId?`anchor="${N.anchorId.se
|
|
|
1159
1159
|
`,t=document.createElement("style");t.setAttribute("data-syntro","base-overlay"),t.textContent=e,n.appendChild(t),Ay=!0}var Ed=async(n={})=>{if(typeof window>"u"||typeof document>"u")throw new Error("SmartCanvas can only be created in a browser-like environment");let e=null;if(n.antiFlicker){let m=typeof n.antiFlicker=="object"?n.antiFlicker:{};e=ky(m)}let t=null,r=null,i=null,{runtime:s}=n;async function o(m){!s?.actions||m.length===0||(i?.isApplied()&&await i.revertAll(),i=await s.actions.applyBatch(m))}async function a(){i?.isApplied()&&(await i.revertAll(),i=null)}if(n.fetcher)try{r=n.fetcher,console.log("[SmartCanvas] Fetching initial config...");let m=await n.fetcher();t=m,console.log("[SmartCanvas] Config fetched:",`tiles=${m.tiles?.length??0},`,`actions=${m.actions?.length??0},`,`theme=${m.theme?.mode??"default"}`),m.actions?.length&&console.log("[SmartCanvas] Actions to apply:",m.actions.map((y,k)=>`[${k}] ${y.kind}${y.anchorId?` anchor="${y.anchorId.selector}"`:""}${y.label?` "${y.label}"`:""}`).join(", ")),m.actions&&m.actions.length>0&&s?.actions&&(await o(m.actions),console.log("[SmartCanvas] Initial actions applied successfully")),m.tiles&&s?.accumulator&&fi(m.tiles,s.accumulator,m.actions)}catch(m){console.error("[SmartCanvas] Error fetching/applying initial config:",m)}e&&e();let l=al();Ua();let c=document.createElement("smart-canvas");if(n.tokens)for(let[m,y]of Object.entries(n.tokens))c.style.setProperty(m,y);let u=n.integrations?.experiments,d=n.integrations?.telemetry,h=n.fetcher??hi({configUri:n.configUri,experiments:u,featureKey:n.configUriFeatureKey,credentials:n.fetchCredentials});r||(r=h);let g={fetcher:h,configUri:n.configUri,configUriFeatureKey:n.configUriFeatureKey,fetchCredentials:n.fetchCredentials,experiments:u,telemetry:d,runtime:s,initialBatchHandle:i,workspaceTheme:n.workspaceTheme};c.mountLitApp(g),n.defaultOpen&&c.open();let v=()=>{let m=n.target??document.body;if(m){m.appendChild(c);let y=c.getOverlayContainer();y&&Ry(y)}};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0}),(l||n.editorUrl)&&(console.log(`[SmartCanvas] Loading editor SDK for ${l??"config"} mode`),Cy(n.editorUrl).catch(console.error));let f={el:c,open:()=>c.open(),close:()=>c.close(),destroy:()=>{a(),c.remove()},setTokens:m=>{for(let[y,k]of Object.entries(m))c.style.setProperty(y,k)},getConfig:async()=>{if(r)try{let m=await r();return t=m,m}catch(m){console.error("[SmartCanvas] Error fetching config:",m)}return t??{tiles:[],actions:[],fetchedAt:""}},setEnabled:async m=>{m?t&&await o(t.actions):await a()},setOverrideFetcher:m=>{r=m,c.setOverrideFetcher(m),s?.accumulator&&m().then(y=>{y?.tiles&&fi(y.tiles,s.accumulator,y.actions)}).catch(()=>{})},registerTelemetryProperties:m=>{d?.register?.(m)},getSessionId:()=>d?.getSessionId?.(),startSessionRecording:()=>{d?.startSessionRecording?.()},track:(m,y)=>d?.track?(d.track(m,y),!0):!1,runtime:s};if(typeof window<"u"){let m=window.SynOS;m&&(m.handle=f)}return f};typeof window<"u"&&(window.SmartCanvas={async create(n){return Ed(n)}});var Cd="syn_";function no(n){if(!n.startsWith(Cd))throw new Error("Invalid Syntro token: must start with 'syn_'");let t=n.slice(Cd.length).replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),i=JSON.parse(r);if(i.v!==1)throw new Error(`Unsupported token version: ${i.v}`);return i}function Ad(n){let e=JSON.stringify(n),t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return Cd+t}function wt(n){if(typeof process<"u"&&process.env)return process.env[n];if(typeof import.meta.env<"u"&&import.meta.env)return import.meta.env[n]}var $y="syntro_segment_attributes";function My(){if(typeof window>"u")return{};try{let n=localStorage.getItem($y);if(n){let e=JSON.parse(n);return K("Syntro Bootstrap","Loaded cached segment attributes:",e),e}}catch(n){Qe("Syntro Bootstrap","Failed to load cached segment attributes:",n)}return{}}function Py(n){if(!(typeof window>"u"))try{localStorage.setItem($y,JSON.stringify(n)),K("Syntro Bootstrap","Cached segment attributes:",n)}catch(e){Qe("Syntro Bootstrap","Failed to cache segment attributes:",e)}}function Oy(n){if(!n)return{};let e={};for(let[t,r]of Object.entries(n))t.startsWith("in_segment_")&&(e[t]=r===!0);return e}function Rd(){if(typeof window>"u")return{};let n={};try{let e=new URLSearchParams(window.location.search);for(let t of["utm_source","utm_medium","utm_campaign","utm_content","utm_term"]){let r=e.get(t);r&&(n[t]=r)}}catch{}try{navigator.language&&(n.browser_language=navigator.language),navigator.languages?.length&&(n.browser_languages=[...navigator.languages])}catch{}try{let e=window.innerWidth;n.device_type=e<768?"mobile":e<1024?"tablet":"desktop"}catch{}try{if(document.referrer){n.referrer=document.referrer;try{n.referrer_hostname=new URL(document.referrer).hostname}catch{}}}catch{}try{let e=navigator.userAgent;e.includes("Edg/")?n.browser="Edge":e.includes("OPR/")||e.includes("Opera")?n.browser="Opera":e.includes("Chrome/")&&!e.includes("Chromium")?n.browser="Chrome":e.includes("Safari/")&&!e.includes("Chrome")?n.browser="Safari":e.includes("Firefox/")&&(n.browser="Firefox"),e.includes("Windows")?n.os="Windows":e.includes("iPhone")||e.includes("iPad")?n.os="iOS":e.includes("Mac OS X")||e.includes("Macintosh")?n.os="macOS":e.includes("Android")?n.os="Android":e.includes("Linux")&&(n.os="Linux")}catch{}try{n.page_url=window.location.href,n.page_path=window.location.pathname,n.page_host=window.location.hostname,window.location.search&&(n.page_query=window.location.search)}catch{}try{let e=window.Telegram?.WebApp;e?(n.surface_type="telegram",n.surface_host=e.platform||"unknown"):(n.surface_type="web",n.surface_host="web")}catch{n.surface_type="web",n.surface_host="web"}return n}var Iy="syntro_geo",Ny="https://geo.syntrologie.com";async function Td(n){if(typeof window>"u")return{};try{let e=localStorage.getItem(Iy);if(e){let t=JSON.parse(e);return K("Syntro Bootstrap","Geo: using cached data:",t),t}}catch{}try{let e=await fetch(n,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json(),r={};for(let[i,s]of Object.entries(t))typeof s=="string"&&s&&(r[i]=s);try{localStorage.setItem(Iy,JSON.stringify(r))}catch{}return K("Syntro Bootstrap","Geo: fetched from worker:",r),r}}catch{}return{}}var Ly="app:",iC="syntro:",sC=/^[a-z][a-z0-9_]*$/;function Id(n){if(!n)return{valid:!1,reason:"Event name cannot be empty"};if(n.startsWith(iC))return{valid:!1,reason:'"syntro:" prefix is reserved for internal SDK events'};if(!n.startsWith(Ly))return{valid:!1,reason:`Custom events must start with "app:" prefix. Got: "${n}"`};let e=n.slice(Ly.length).split(":");if(e.length<2)return{valid:!1,reason:`Event name must have at least 2 segments after "app:" (app:{category}:{action}). Got: "${n}"`};for(let t of e)if(!sC.test(t))return{valid:!1,reason:`Segment "${t}" must be lowercase alphanumeric + underscores. Got: "${n}"`};return{valid:!0}}function oC(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null}function Fy(n,e,t=0){if(t>=e)return!1;for(let r of Object.values(n))if(r!==null&&typeof r=="object"&&!Array.isArray(r)&&!Fy(r,e,t+1))return!1;return!0}function $d(n){if(n===void 0)return{valid:!0};if(n===null||typeof n!="object"||Array.isArray(n))return{valid:!1,reason:"Props must be a plain object"};if(!Fy(n,2))return{valid:!1,reason:"Props nesting depth exceeds 2 levels"};let e=[];for(let[t,r]of Object.entries(n))r!==null&&typeof r=="object"||oC(r)||e.push(t);return e.length>0?{valid:!0,stripped:e}:{valid:!0}}function ll(n,e){return e?!(e.names&&e.names.length>0&&!e.names.includes(n.name)||e.patterns&&e.patterns.length>0&&!e.patterns.some(r=>{try{return new RegExp(r).test(n.name)}catch{return!1}})||e.sources&&e.sources.length>0&&!e.sources.includes(n.source)):!0}var cl=class{constructor(e={}){this.subscriptions=new Set;this.history=[];this.maxHistorySize=e.maxHistorySize??100,this.debug=e.debug??!1,this.emitHistory=e.history??null,this.posthogCapture=e.posthogCapture??null,this.testMode=e.testMode??!1}subscribe(e,t){let r,i;typeof e=="function"?(r=void 0,i=e):(r=e,i=t);let s={filter:r,callback:i};return this.subscriptions.add(s),()=>{this.subscriptions.delete(s)}}publish(e,t,r="canvas"){let i={ts:Date.now(),name:e,source:r,props:t,schemaVersion:$e};this.publishEvent(i)}publishEvent(e){this.history.push(e),this.history.length>this.maxHistorySize&&this.history.shift();for(let t of this.subscriptions)if(ll(e,t.filter))try{t.callback(e)}catch(r){console.error("[EventBus] Subscriber error:",r)}}emit(e,t){let r=Id(e);if(!r.valid)return console.warn(`[EventBus] emit() rejected: ${r.reason}`),this.debug?{delivered:!1,matchedRules:[],posthogCaptured:!1,listenersNotified:0}:void 0;let i=$d(t);if(!i.valid)return console.warn(`[EventBus] emit() rejected props: ${i.reason}`),this.debug?{delivered:!1,matchedRules:[],posthogCaptured:!1,listenersNotified:0}:void 0;let s={ts:Date.now(),name:e,source:"custom",props:t,schemaVersion:$e};this.history.push(s),this.history.length>this.maxHistorySize&&this.history.shift();let o=0;for(let l of this.subscriptions)if(ll(s,l.filter))try{l.callback(s),o++}catch(c){console.error("[EventBus] Subscriber error:",c),o++}let a=!1;if(this.posthogCapture&&!this.testMode)try{this.posthogCapture(e,t),a=!0}catch(l){console.error("[EventBus] PostHog capture error:",l)}if(this.emitHistory&&this.emitHistory.record({name:e,props:t,source:"custom",timestamp:s.ts,matchedRules:[]}),this.debug)return console.debug("[EventBus] emit()",{name:e,props:t,listenersNotified:o,posthogCaptured:a}),{delivered:!0,matchedRules:[],posthogCaptured:a,listenersNotified:o}}setPosthogCapture(e){this.posthogCapture=e}getRecent(e,t){let r=this.history;return e&&(r=r.filter(i=>ll(i,e))),t&&t>0&&(r=r.slice(-t)),r}hasRecentEvent(e,t,r){let i=Date.now()-t;return this.history.some(s=>s.name===e&&s.ts>=i&&(r===void 0||s.source===r))}countRecentEvents(e,t){let r=this.history.filter(i=>ll(i,e));if(t!==void 0){let i=Date.now()-t;r=r.filter(s=>s.ts>=i)}return r.length}clearHistory(){this.history=[]}getSubscriberCount(){return this.subscriptions.size}};function ro(n={}){return new cl(n)}var io=class{constructor(e=100){this.entries=[];this.maxSize=e}record(e){this.entries.push(e),this.maxSize>0&&this.entries.length>this.maxSize&&this.entries.shift()}getAll(){return[...this.entries]}clear(){this.entries=[]}};var Hy={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function By(){return Hy}function Md(n){let e=2166136261,t=n.length;for(let r=0;r<t;r++)e^=n.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function so(n,e,t){return t===2?Md(Md(n+e)+"")%1e4/1e4:t===1?Md(e+n)%1e3/1e3:null}function aC(n){return n<=0?[]:new Array(n).fill(1/n)}function ul(n,e){return n>=e[0]&&n<e[1]}function Vy(n,e){let t=so("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function Wy(n,e){for(let t=0;t<e.length;t++)if(ul(n,e[t]))return t;return-1}function Od(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function dl(n,e){if(!e.length)return!1;let t=!1,r=!1;for(let i=0;i<e.length;i++){let s=uC(n,e[i].type,e[i].pattern);if(e[i].include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function lC(n,e,t){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(n)}catch{return!1}}function cC(n,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[n.host,t.host,!1],[n.pathname,t.pathname,!0]];return t.hash&&r.push([n.hash,t.hash,!1]),t.searchParams.forEach((i,s)=>{r.push([n.searchParams.get(s)||"",i,!1])}),!r.some(i=>!lC(i[0],i[1],i[2]))}catch{return!1}}function uC(n,e,t){try{let r=new URL(n,"https://_");if(e==="regex"){let i=Od(t);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return cC(r,t);return!1}catch{return!1}}function jy(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=aC(n);t=t||r,t.length!==n&&(t=r);let i=t.reduce((o,a)=>a+o,0);(i<.99||i>1.01)&&(t=r);let s=0;return t.map(o=>{let a=s;return s+=o,[a,a+e*o]})}function Uy(n,e,t){if(!e)return null;let r=e.split("?")[1];if(!r)return null;let i=r.replace(/#.*/,"").split("&").map(s=>s.split("=",2)).filter(([s])=>s===n).map(([,s])=>parseInt(s));return i.length>0&&i[0]>=0&&i[0]<t?i[0]:null}function zy(n){try{return n()}catch(e){return console.error(e),!1}}var Pd=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0));async function Nr(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||Hy.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",Pd(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:Pd(i)},r,Pd(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function oo(n){return typeof n=="string"?n:JSON.stringify(n)}function ut(n){typeof n=="number"&&(n=n+""),(!n||typeof n!="string")&&(n="0");let e=n.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function qy(){let n;try{n="1.6.4"}catch{n=""}return n}function Zy(n,e){let t,r;try{t=new URL(n),r=new URL(e)}catch(i){return console.error(`Unable to merge query strings: ${i}`),e}return t.searchParams.forEach((i,s)=>{r.searchParams.has(s)||r.searchParams.set(s,i)}),r.toString()}function Dy(n){return typeof n=="object"&&n!==null}function pl(n){return n.urlPatterns&&n.variations.some(e=>Dy(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>Dy(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function hl(n,e){return new Promise(t=>{let r=!1,i,s=o=>{r||(r=!0,i&&clearTimeout(i),t(o||null))};e&&(i=setTimeout(()=>s(),e)),n.then(o=>s(o)).catch(()=>s())})}var Ke={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Zt=By(),Ti={fetchFeaturesCall:({host:n,clientKey:e,headers:t})=>Zt.fetch(`${n}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:n,clientKey:e,payload:t,headers:r})=>{let i={method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)};return Zt.fetch(`${n}/api/eval/${e}`,i)},eventSourceCall:({host:n,clientKey:e,headers:t})=>t?new Zt.EventSource(`${n}/sub/${e}`,{headers:t}):new Zt.EventSource(`${n}/sub/${e}`),startIdleListener:()=>{let n;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(n),hC()):document.visibilityState==="hidden"&&(n=window.setTimeout(pC,Ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Zt.localStorage=globalThis.localStorage)}catch{}var Ii=new Map,Gy=!1,un=new Map,fl=new Map,$i=new Map,Mi=new Set;function Yy(n){Object.assign(Ke,n),Ke.backgroundSync||Bd()}async function Xy({instance:n,timeout:e,skipCache:t,allowStale:r,backgroundSync:i}){return i||(Ke.backgroundSync=!1),fC({instance:n,allowStale:r,timeout:e,skipCache:t})}function dC(n){let e=ao(n),t=Ii.get(e)||new Set;t.add(n),Ii.set(e,t)}function Jy(n){Ii.forEach(e=>e.delete(n))}function pC(){$i.forEach(n=>{n&&(n.state="idle",Dd(n))})}function hC(){$i.forEach(n=>{n&&n.state==="idle"&&Hd(n)})}async function Ky(){try{if(!Zt.localStorage)return;await Zt.localStorage.setItem(Ke.cacheKey,JSON.stringify(Array.from(un.entries())))}catch{}}async function fC({instance:n,allowStale:e,timeout:t,skipCache:r}){let i=ao(n),s=Ld(n),o=new Date,a=new Date(o.getTime()-Ke.maxAge+Ke.staleTTL);await gC();let l=!Ke.disableCache&&!r?un.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Mi.add(i),l.staleAt<o?Nd(n):Fd(n),{data:l.data,success:!0,source:"cache"}):await hl(Nd(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ao(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function Ld(n){let e=ao(n);if(!("isRemoteEval"in n)||!n.isRemoteEval())return e;let t=n.getAttributes(),r=n.getCacheKeyAttributes()||Object.keys(n.getAttributes()),i={};r.forEach(a=>{i[a]=t[a]});let s=n.getForcedVariations(),o=n.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}async function gC(){if(!Gy){Gy=!0;try{if(Zt.localStorage){let n=await Zt.localStorage.getItem(Ke.cacheKey);if(!Ke.disableCache&&n){let e=JSON.parse(n);e&&Array.isArray(e)&&e.forEach(([t,r])=>{un.set(t,{...r,staleAt:new Date(r.staleAt)})}),Qy()}}}catch{}if(!Ke.disableIdleStreams){let n=Ti.startIdleListener();n&&(Ti.stopIdleListener=n)}}}function Qy(){let n=Array.from(un.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,un.size-Ke.maxEntries),un.size);for(let t=0;t<e;t++)un.delete(n[t].key)}function eb(n,e,t){let r=t.dateUpdated||"",i=new Date(Date.now()+Ke.staleTTL),s=Ke.disableCache?void 0:un.get(e);if(s&&r&&s.version===r){s.staleAt=i,Ky();return}Ke.disableCache||(un.set(e,{data:t,version:r,staleAt:i,sse:Mi.has(n)}),Qy()),Ky();let o=Ii.get(n);o&&o.forEach(a=>mC(a,t))}async function mC(n,e){await n.setPayload(e||n.getPayload())}async function Nd(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),r=n.getClientKey(),i="isRemoteEval"in n&&n.isRemoteEval(),s=ao(n),o=Ld(n),a=fl.get(o);return a||(a=(i?Ti.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):Ti.fetchFeaturesCall({host:e,clientKey:r,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&Mi.add(s),c.json()}).then(c=>(eb(s,o,c),Fd(n),fl.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(fl.delete(o),{data:null,source:"error",success:!1,error:c})),fl.set(o,a)),a}function Fd(n,e=!1){let t=ao(n),r=Ld(n),{streamingHost:i,streamingHostRequestHeaders:s}=n.getApiHosts(),o=n.getClientKey();if(e&&Mi.add(t),Ke.backgroundSync&&Mi.has(t)&&Zt.EventSource){if($i.has(t))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=Ii.get(t);c&&c.forEach(u=>{Nd(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);eb(t,r,c)}a.errors=0}catch{tb(a)}},errors:0,state:"active"};$i.set(t,a),Hd(a)}}function tb(n){if(n.state!=="idle"&&(n.errors++,n.errors>3||n.src&&n.src.readyState===2)){let e=Math.pow(3,n.errors-3)*(1e3+Math.random()*1e3);Dd(n),setTimeout(()=>{["idle","active"].includes(n.state)||Hd(n)},Math.min(e,3e5))}}function Dd(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function Hd(n){n.src=Ti.eventSourceCall({host:n.host,clientKey:n.clientKey,headers:n.headers}),n.state="active",n.src.addEventListener("features",n.cb),n.src.addEventListener("features-updated",n.cb),n.src.onerror=()=>tb(n),n.src.onopen=()=>{n.errors=0}}function vC(n,e){Dd(n),$i.delete(e)}function Bd(){Mi.clear(),$i.forEach(vC),Ii.clear(),Ti.stopIdleListener()}function gl(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Fd(n,!0),dC(n)}}var yC=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,jd={revert:function(){}},bl=new Map,Ud=new Set;function bC(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function _l(n){var e=bl.get(n);return e||(e={element:n,attributes:{}},bl.set(n,e)),e}function xl(n,e,t,r,i){var s=t(n),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:n,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(n);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,i(o))}}),mutationRunner:i,setValue:r,getCurrentValue:t};return e==="position"&&n.parentNode?o.observer.observe(n.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(n,bC(e)),o}function wl(n,e){var t=e.getCurrentValue(e.el);e.virtualValue=n,n&&typeof n!="string"?(!t||n.parentNode!==t.parentNode||n.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,nb()):n!==t&&(e.isDirty=!0,nb())}function _C(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),wl(OC(e),n)}function xC(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),wl(Array.from(e).filter(Boolean).join(" "),n)}function wC(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),wl(e,n)}function kC(n){var e=n.parentSelector,t=n.insertBeforeSelector,r=document.querySelector(e);if(!r)return null;var i=t?document.querySelector(t):null;return t&&!i?null:{parentNode:r,insertBeforeNode:i}}function SC(n){var e=n.originalValue;n.mutations.forEach(function(t){var r=t.mutate(),i=kC(r);e=i||e}),wl(e,n)}var EC=function(e){return e.innerHTML},CC=function(e,t){return e.innerHTML=t};function ib(n){var e=_l(n);return e.html||(e.html=xl(n,"html",EC,CC,_C)),e.html}var AC=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},RC=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};function sb(n){var e=_l(n);return e.position||(e.position=xl(n,"position",AC,RC,SC)),e.position}var TC=function(e,t){return t?e.className=t:e.removeAttribute("class")},IC=function(e){return e.className};function ob(n){var e=_l(n);return e.classes||(e.classes=xl(n,"class",IC,TC,xC)),e.classes}var $C=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},MC=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};function ab(n,e){var t=_l(n);return t.attributes[e]||(t.attributes[e]=xl(n,e,$C(e),MC(e),wC)),t.attributes[e]}function PC(n,e){var t=bl.get(n);if(t)if(e==="html"){var r,i;(r=t.html)==null||(i=r.observer)==null||i.disconnect(),delete t.html}else if(e==="class"){var s,o;(s=t.classes)==null||(o=s.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,d;(c=t.attributes)==null||(u=c[e])==null||(d=u.observer)==null||d.disconnect(),delete t.attributes[e]}}var ml;function OC(n){return ml||(ml=document.createElement("div")),ml.innerHTML=n,ml.innerHTML}function vl(n,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||PC(n,e),t.setValue(n,r)}}function NC(n,e){n.html&&vl(e,"html",n.html),n.classes&&vl(e,"class",n.classes),n.position&&vl(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){vl(e,t,n.attributes[t])})}function nb(){bl.forEach(NC)}function LC(n,e){var t=null;n.kind==="html"?t=ib(e):n.kind==="class"?t=ob(e):n.kind==="attribute"?t=ab(e,n.attribute):n.kind==="position"&&(t=sb(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function FC(n,e){var t=null;if(n.kind==="html"?t=ib(e):n.kind==="class"?t=ob(e):n.kind==="attribute"?t=ab(e,n.attribute):n.kind==="position"&&(t=sb(e)),!!t){var r=t.mutations.indexOf(n);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function lb(n){if(!(n.kind==="position"&&n.elements.size===1)){var e=new Set(n.elements),t=document.querySelectorAll(n.selector);t.forEach(function(r){e.has(r)||(n.elements.add(r),LC(n,r))})}}function DC(n){n.elements.forEach(function(e){return FC(n,e)}),n.elements.clear(),Ud.delete(n)}function rb(){Ud.forEach(lb)}var Vd;function HC(){typeof document>"u"||(Vd||(Vd=new MutationObserver(function(){rb()})),rb(),Vd.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}HC();function kl(n){return typeof document>"u"?jd:(Ud.add(n),lb(n),{revert:function(){DC(n)}})}function Wd(n,e){return kl({kind:"html",elements:new Set,mutate:e,selector:n})}function cb(n,e){return kl({kind:"position",elements:new Set,mutate:e,selector:n})}function lo(n,e){return kl({kind:"class",elements:new Set,mutate:e,selector:n})}function yl(n,e,t){return yC.test(e)?e==="class"||e==="className"?lo(n,function(r){var i=t(Array.from(r).join(" "));r.clear(),i&&i.split(/\s+/g).filter(Boolean).forEach(function(s){return r.add(s)})}):kl({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):jd}function BC(n){var e=n.selector,t=n.action,r=n.value,i=n.attribute,s=n.parentSelector,o=n.insertBeforeSelector;if(i==="html"){if(t==="append")return Wd(e,function(a){return a+(r??"")});if(t==="set")return Wd(e,function(){return r??""})}else if(i==="class"){if(t==="append")return lo(e,function(a){r&&a.add(r)});if(t==="remove")return lo(e,function(a){r&&a.delete(r)});if(t==="set")return lo(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(t==="set"&&s)return cb(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(t==="append")return yl(e,i,function(a){return a!==null?a+(r??""):r??""});if(t==="set")return yl(e,i,function(){return r??""});if(t==="remove")return yl(e,i,function(){return null})}return jd}var VC={html:Wd,classes:lo,attribute:yl,position:cb,declarative:BC},ub=VC;var zd={};function Hn(n,e,t){t=t||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!hb(n,i,t))return!1;break;case"$nor":if(hb(n,i,t))return!1;break;case"$and":if(!qC(n,i,t))return!1;break;case"$not":if(Hn(n,i,t))return!1;break;default:if(!co(i,WC(n,r),t))return!1}return!0}function WC(n,e){let t=e.split("."),r=n;for(let i=0;i<t.length;i++)if(r&&typeof r=="object"&&t[i]in r)r=r[t[i]];else return null;return r}function db(n,e=!1){let t=`${n}${e?"/i":""}`;return zd[t]||(zd[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),zd[t]}function co(n,e,t,r=!1){if(typeof n=="string")return r?String(e).toLowerCase()===n.toLowerCase():e+""===n;if(typeof n=="number")return e*1===n;if(typeof n=="boolean")return e!==null&&!!e===n;if(n===null)return e===null;if(Array.isArray(n)||!fb(n))return JSON.stringify(e)===JSON.stringify(n);for(let i in n)if(!zC(i,e,n[i],t))return!1;return!0}function fb(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function jC(n){if(n===null)return"null";if(Array.isArray(n))return"array";let e=typeof n;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function UC(n,e,t){if(!Array.isArray(n))return!1;let r=fb(e)?i=>co(e,i,t):i=>Hn(i,e,t);for(let i=0;i<n.length;i++)if(n[i]&&r(n[i]))return!0;return!1}function Pi(n,e,t=!1){if(t){let r=i=>typeof i=="string"?i.toLowerCase():i;return Array.isArray(n)?n.some(i=>e.some(s=>r(i)===r(s))):e.some(i=>r(n)===r(i))}return Array.isArray(n)?n.some(r=>e.includes(r)):e.includes(n)}function pb(n,e,t,r=!1){if(!Array.isArray(n))return!1;for(let i=0;i<e.length;i++){let s=!1;for(let o=0;o<n.length;o++)if(co(e[i],n[o],t,r)){s=!0;break}if(!s)return!1}return!0}function zC(n,e,t,r){switch(n){case"$veq":return ut(e)===ut(t);case"$vne":return ut(e)!==ut(t);case"$vgt":return ut(e)>ut(t);case"$vgte":return ut(e)>=ut(t);case"$vlt":return ut(e)<ut(t);case"$vlte":return ut(e)<=ut(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?Pi(e,t):!1;case"$ini":return Array.isArray(t)?Pi(e,t,!0):!1;case"$inGroup":return Pi(e,r[t]||[]);case"$notInGroup":return!Pi(e,r[t]||[]);case"$nin":return Array.isArray(t)?!Pi(e,t):!1;case"$nini":return Array.isArray(t)?!Pi(e,t,!0):!1;case"$not":return!co(t,e,r);case"$size":return Array.isArray(e)?co(t,e.length,r):!1;case"$elemMatch":return UC(e,t,r);case"$all":return Array.isArray(t)?pb(e,t,r):!1;case"$alli":return Array.isArray(t)?pb(e,t,r,!0):!1;case"$regex":try{return db(t).test(e)}catch{return!1}case"$regexi":try{return db(t,!0).test(e)}catch{return!1}case"$type":return jC(e)===t;default:return console.error("Unknown operator: "+n),!1}}function hb(n,e,t){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(Hn(n,e[r],t))return!0;return!1}function qC(n,e,t){for(let r=0;r<e.length;r++)if(!Hn(n,e[r],t))return!1;return!0}var ZC="Feature Evaluated",GC="Experiment Viewed";function KC(n){let e=new Map;return n.global.forcedFeatureValues&&n.global.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),n.user.forcedFeatureValues&&n.user.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),e}function YC(n){return n.global.forcedVariations&&n.user.forcedVariations?{...n.global.forcedVariations,...n.user.forcedVariations}:n.global.forcedVariations?n.global.forcedVariations:n.user.forcedVariations?n.user.forcedVariations:{}}async function Oi(n){try{await n()}catch{}}function gb(n,e,t){if(n.user.trackedExperiments){let i=Cl(e,t);if(n.user.trackedExperiments.has(i))return[];n.user.trackedExperiments.add(i)}n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let r=[];if(n.global.trackingCallback){let i=n.global.trackingCallback;r.push(Oi(()=>i(e,t,n.user)))}if(n.user.trackingCallback){let i=n.user.trackingCallback;r.push(Oi(()=>i(e,t)))}if(n.global.eventLogger){let i=n.global.eventLogger;r.push(Oi(()=>i(GC,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return r}function XC(n,e,t){if(n.user.trackedFeatureUsage){let r=JSON.stringify(t.value);if(n.user.trackedFeatureUsage[e]===r)return;n.user.trackedFeatureUsage[e]=r,n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(n.global.onFeatureUsage){let r=n.global.onFeatureUsage;Oi(()=>r(e,t,n.user))}if(n.user.onFeatureUsage){let r=n.user.onFeatureUsage;Oi(()=>r(e,t))}if(n.global.eventLogger){let r=n.global.eventLogger;Oi(()=>r(ZC,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function Sl(n,e){if(e.stack.evaluatedFeatures.has(n))return Bn(e,n,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(n),e.stack.id=n;let t=KC(e);if(t.has(n))return Bn(e,n,t.get(n),"override");if(!e.global.features||!e.global.features[n])return Bn(e,n,null,"unknownFeature");let r=e.global.features[n];if(r.rules){let i=new Set(e.stack.evaluatedFeatures);e:for(let s of r.rules){if(s.parentConditions)for(let l of s.parentConditions){e.stack.evaluatedFeatures=new Set(i);let c=Sl(l.id,e);if(c.source==="cyclicPrerequisite")return Bn(e,n,null,"cyclicPrerequisite");let u={value:c.value};if(!Hn(u,l.condition||{})){if(l.gate)return Bn(e,n,null,"prerequisite");continue e}}if(s.filters&&yb(s.filters,e))continue;if("force"in s){if(s.condition&&!vb(s.condition,e)||!JC(e,s.seed||n,s.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0,s.range,s.coverage,s.hashVersion))continue;return s.tracks&&s.tracks.forEach(l=>{!gb(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Bn(e,n,s.force,"force",s.id)}if(!s.variations)continue;let o={variations:s.variations,key:s.key||n};"coverage"in s&&(o.coverage=s.coverage),s.weights&&(o.weights=s.weights),s.hashAttribute&&(o.hashAttribute=s.hashAttribute),s.fallbackAttribute&&(o.fallbackAttribute=s.fallbackAttribute),s.disableStickyBucketing&&(o.disableStickyBucketing=s.disableStickyBucketing),s.bucketVersion!==void 0&&(o.bucketVersion=s.bucketVersion),s.minBucketVersion!==void 0&&(o.minBucketVersion=s.minBucketVersion),s.namespace&&(o.namespace=s.namespace),s.meta&&(o.meta=s.meta),s.ranges&&(o.ranges=s.ranges),s.name&&(o.name=s.name),s.phase&&(o.phase=s.phase),s.seed&&(o.seed=s.seed),s.hashVersion&&(o.hashVersion=s.hashVersion),s.filters&&(o.filters=s.filters),s.condition&&(o.condition=s.condition);let{result:a}=El(o,n,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Bn(e,n,a.value,"experiment",s.id,o,a)}}return Bn(e,n,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function El(n,e,t){let r=n.key,i=n.variations.length;if(i<2)return{result:Ae(t,n,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:Ae(t,n,-1,!1,e)};if(n=QC(n,t),n.urlPatterns&&!dl(t.user.url||"",n.urlPatterns))return{result:Ae(t,n,-1,!1,e)};let s=Uy(r,t.user.url||"",i);if(s!==null)return{result:Ae(t,n,s,!1,e)};let o=YC(t);if(r in o){let m=o[r];return{result:Ae(t,n,m,!1,e)}}if(n.status==="draft"||n.active===!1)return{result:Ae(t,n,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Lr(t,n.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0);if(!l)return{result:Ae(t,n,-1,!1,e)};let c=-1,u=!1,d=!1;if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=nA({ctx:t,expKey:n.key,expBucketVersion:n.bucketVersion,expHashAttribute:n.hashAttribute,expFallbackAttribute:n.fallbackAttribute,expMinBucketVersion:n.minBucketVersion,expMeta:n.meta});u=m>=0,c=m,d=!!y}if(!u){if(n.filters){if(yb(n.filters,t))return{result:Ae(t,n,-1,!1,e)}}else if(n.namespace&&!Vy(l,n.namespace))return{result:Ae(t,n,-1,!1,e)};if(n.include&&!zy(n.include))return{result:Ae(t,n,-1,!1,e)};if(n.condition&&!vb(n.condition,t))return{result:Ae(t,n,-1,!1,e)};if(n.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let y of n.parentConditions){t.stack.evaluatedFeatures=new Set(m);let k=Sl(y.id,t);if(k.source==="cyclicPrerequisite")return{result:Ae(t,n,-1,!1,e)};let _={value:k.value};if(!Hn(_,y.condition||{}))return{result:Ae(t,n,-1,!1,e)}}}if(n.groups&&!tA(n.groups,t))return{result:Ae(t,n,-1,!1,e)}}if(n.url&&!eA(n.url,t))return{result:Ae(t,n,-1,!1,e)};let h=so(n.seed||r,l,n.hashVersion||1);if(h===null)return{result:Ae(t,n,-1,!1,e)};if(!u){let m=n.ranges||jy(i,n.coverage===void 0?1:n.coverage,n.weights);c=Wy(h,m)}if(d)return{result:Ae(t,n,-1,!1,e,void 0,!0)};if(c<0)return{result:Ae(t,n,-1,!1,e)};if("force"in n)return{result:Ae(t,n,n.force===void 0?-1:n.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:Ae(t,n,-1,!1,e)};if(n.status==="stopped")return{result:Ae(t,n,-1,!1,e)};let g=Ae(t,n,c,!0,e,h,u);if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{changed:m,key:y,doc:k}=iA(t,a,oo(l),{[qd(n.key,n.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=k,t.user.saveStickyBucketAssignmentDoc(k))}let v=gb(t,n,g);v.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:n,result:g});let f=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in n&&n.changeId&&t.global.recordChangeId&&t.global.recordChangeId(n.changeId),{result:g,trackingCall:f}}function Bn(n,e,t,r,i,s,o){let a={value:t,on:!!t,off:!t,source:r,ruleId:i||""};return s&&(a.experiment=s),o&&(a.experimentResult=o),r!=="override"&&XC(n,e,a),a}function mb(n){return{...n.user.attributes,...n.user.attributeOverrides}}function vb(n,e){return Hn(mb(e),n,e.global.savedGroups||{})}function yb(n,e){return n.some(t=>{let{hashValue:r}=Lr(e,t.attribute);if(!r)return!0;let i=so(t.seed,r,t.hashVersion||2);return i===null?!0:!t.ranges.some(s=>ul(i,s))})}function JC(n,e,t,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=Lr(n,t,r);if(!a)return!1;let l=so(e,a,o||1);return l===null?!1:i?ul(l,i):s!==void 0?l<=s:!0}function Ae(n,e,t,r,i,s,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=Lr(n,e.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},d={key:u.key||""+t,featureId:i,inExperiment:a,hashUsed:r,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(d.name=u.name),s!==void 0&&(d.bucket=s),u.passthrough&&(d.passthrough=u.passthrough),d}function QC(n,e){let t=n.key,r=e.global.overrides;return r&&r[t]&&(n=Object.assign({},n,r[t]),typeof n.url=="string"&&(n.url=Od(n.url))),n}function Lr(n,e,t){let r=e||"id",i="",s=mb(n);return s[r]&&(i=s[r]),!i&&t&&(s[t]&&(i=s[t]),i&&(r=t)),{hashAttribute:r,hashValue:i}}function eA(n,e){let t=e.user.url;if(!t)return!1;let r=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(n.test(t)||n.test(r))}function tA(n,e){let t=e.global.groups||{};for(let r=0;r<n.length;r++)if(t[n[r]])return!0;return!1}function nA({ctx:n,expKey:e,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:i,expMinBucketVersion:s,expMeta:o}){t=t||0,s=s||0,r=r||"id",o=o||[];let a=qd(e,t),l=rA(n,r,i);if(s>0)for(let d=0;d<s;d++){let h=qd(e,d);if(l[h]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let u=o.findIndex(d=>d.key===c);return u<0?{variation:-1}:{variation:u}}function qd(n,e){return e=e||0,`${n}__${e}`}function Zd(n,e){return`${n}||${e}`}function rA(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=Lr(n,e),s=Zd(r,oo(i)),{hashAttribute:o,hashValue:a}=Lr(n,t),l=a?Zd(o,oo(a)):null,c={};return l&&n.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[l].assignments||{}),n.user.stickyBucketAssignmentDocs[s]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[s].assignments||{}),c}function iA(n,e,t,r){let i=Zd(e,t),s=n.user.stickyBucketAssignmentDocs&&n.user.stickyBucketAssignmentDocs[i]?n.user.stickyBucketAssignmentDocs[i].assignments||{}:{},o={...s,...r},a=JSON.stringify(s)!==JSON.stringify(o);return{key:i,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function sA(n,e){let t=new Set,r=e&&e.features?e.features:n.global.features||{},i=e&&e.experiments?e.experiments:n.global.experiments||[];return Object.keys(r).forEach(s=>{let o=r[s];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),i.map(s=>{t.add(s.hashAttribute||"id"),s.fallbackAttribute&&t.add(s.fallbackAttribute)}),Array.from(t)}async function bb(n,e,t){let r=Gd(n,t);return e.getAllAssignments(r)}function Gd(n,e){let t={};return sA(n,e).forEach(i=>{let{hashValue:s}=Lr(n,i);t[i]=oo(s)}),t}async function _b(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await Nr(n.encryptedFeatures,e,t))}catch(r){console.error(r)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await Nr(n.encryptedExperiments,e,t))}catch(r){console.error(r)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await Nr(n.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete n.encryptedSavedGroups}return n}function xb(n){let e=n.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(n.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:n.apiHostRequestHeaders,streamingHostRequestHeaders:n.streamingHostRequestHeaders}}function Cl(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var Ni=typeof window<"u"&&typeof document<"u",oA=qy(),uo=class{constructor(e){if(e=e||{},this.version=oA,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=r=>t.saveAssignments(r)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),Ni&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let r=this._options.stickyBucketAssignmentDocs[t];r&&this._options.stickyBucketService.saveAssignments(r).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await _b(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,gl(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Yy(e.cacheSettings),e.payload)return await this.setPayload(e.payload),gl(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return gl(this,e),await this.setPayload(t||{}),r}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return xb(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:r,streaming:i}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Xy({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:r,backgroundSync:i??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,r){let i=await Nr(e,t||this._options.decryptionKey,r);this.setFeatures(JSON.parse(i))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,r){let i=await Nr(e,t||this._options.decryptionKey,r);this.setExperiments(JSON.parse(i))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(r){console.error(r)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Jy(this),e.destroyAllStreams&&Bd(),this.logs=[],Ni&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=El(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(r=>r.key===e).map(r=>this._runAutoExperiment(r)).filter(r=>r!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let r=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!r)return null;let i=this._isAutoExperimentBlockedByContext(e),s,o;i?s=Ae(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=El(e,null,this._getEvalContext()),this._onExperimentEval(e,s));let a=JSON.stringify(s.value);if(!t&&s.inExperiment&&r&&r.valueHash===a)return s;if(r&&this._undoActiveAutoExperiment(e),s.inExperiment){let l=pl(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Zy(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(dl(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),s;this._redirectedUrl=c;let{navigate:u,delay:d}=this._getNavigateFunction();if(u)if(Ni)Promise.all([...o?[hl(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(h=>window.setTimeout(h,this._options.navigateDelay??d))]).then(()=>{try{u(c)}catch(h){console.error(h)}});else try{u(c)}catch(h){console.error(h)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(s.value):this._applyDOMChanges(s.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return s}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],r=new Set(t);this._activeAutoExperiments.forEach((i,s)=>{r.has(s)||(i.undo(),this._activeAutoExperiments.delete(s))});for(let i of t){let s=this._runAutoExperiment(i,e);if(s&&s.inExperiment&&pl(i)==="redirect")break}}_onExperimentEval(e,t){let r=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,r)}_fireSubscriptions(e,t,r){(!r||r.result.inExperiment!==t.inExperiment||r.result.variationId!==t.variationId)&&this._subscriptions.forEach(i=>{try{i(e,t)}catch(s){console.error(s)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let r=this.evalFeature(e).value;return r===null?t:r}feature(e){return this.evalFeature(e)}evalFeature(e){return Sl(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Cl(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(r){console.error(r)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Cl(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Ni?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=pl(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(r=>r.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let r=new URL(this._getContextUrl());for(let i of e.variations){if(!i||!i.urlRedirect)continue;let s=new URL(i.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(s.protocol!==r.protocol||s.host!==r.host))return!0}}catch(r){return this.log("Error parsing current or redirect URL",{id:e.key,error:r}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:Ni?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Ni)return;let t=[];if(e.css){let r=document.createElement("style");r.innerHTML=e.css,document.head.appendChild(r),t.push(()=>r.remove())}if(e.js){let r=document.createElement("script");r.innerHTML=e.js,this._options.jsInjectionNonce&&(r.nonce=this._options.jsInjectionNonce),document.head.appendChild(r),t.push(()=>r.remove())}return e.domMutations&&e.domMutations.forEach(r=>{t.push(ub.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await bb(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=r}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let r=this._getEvalContext(),i=Gd(r,t);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var aA="https://experiment.syntrologie.com",Kd=class{constructor(e={}){this.featureListeners=new Set;if(e.client)this.gb=e.client;else{let t=e.onExperimentViewed?(r,i)=>{e.onExperimentViewed(r.key,i.variationId,typeof i.value=="string"?i.value:`variation_${i.variationId}`)}:void 0;this.gb=new uo({...e,apiHost:e.apiHost??aA,enableDevMode:e.enableDevMode??!0,trackingCallback:t}),e.autoInit&&this.gb.init({streaming:!0})}}get _internal(){return this.gb}async refreshFeatures(){await this.gb.loadFeatures()}setAttributes(e){this.gb.setAttributes({...this.gb.getAttributes(),...e})}setForcedVariations(e){this.gb.setForcedVariations(e)}getFeatureValue(e,t){return this.gb.getFeatureValue(e,t)}getAllFeatures(){let e=this.gb.getFeatures(),t={};for(let r of Object.keys(e))t[r]=this.gb.getFeatureValue(r,null);return t}shouldRenderRectangle(e){return!0}onFeaturesChanged(e){return this.featureListeners.add(e),this.featureListeners.size===1&&this.gb.setRenderer(()=>{for(let t of this.featureListeners)t()}),()=>{this.featureListeners.delete(e),this.featureListeners.size===0&&this.gb.setRenderer(null)}}};function Yd(n={}){return new Kd(n)}var wb={growthbook:n=>Yd({...n,autoInit:!0})};function kb(n,e){let t=wb[n];if(!t)throw new Error(`Unknown experiment provider: ${n}. Supported: ${Object.keys(wb).join(", ")}`);return t(e)}var lA=["cdn.syntrologie.com","localhost","127.0.0.1"];function cA(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] CDN URL must use HTTPS:",n),!1):lA.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] CDN host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid CDN URL:",n),!1}}var Xd=class{constructor(e){this.name="cdn";if(this.url=`${e.baseUrl}/${e.configId}.json`,this.integrity=e.integrity,!cA(this.url))throw new Error(`[SmartCanvas] CDN URL not allowed: ${this.url}`)}async fetch(){let e=performance.now(),t=await fetch(this.url,{credentials:"omit",cache:"default"});if(!t.ok)throw new Error(`[SmartCanvas] Failed to fetch config from CDN (${t.status})`);let r=await t.text();if(this.integrity){let l=await uA(r),c=this.integrity.replace("sha384-","");if(l!==c)throw new Error(`[SmartCanvas] Config integrity check failed. Expected ${c}, got ${l}`)}let i=JSON.parse(r),s=performance.now()-e,o=t.headers.get("cache-control"),a=t.headers.get("age");return{config:i,meta:{source:"cdn",fetchTimeMs:s,cached:o?.includes("public")??!1,cacheAge:a?parseInt(a,10):void 0}}}};async function uA(n){let t=new TextEncoder().encode(n),r=await crypto.subtle.digest("SHA-384",t),i=new Uint8Array(r);return btoa(String.fromCharCode(...i))}function Sb(n){return new Xd(n)}var dA="syntro_exp",pA="syntro_var",Jd=class{constructor(e){this.name="experiments";this.client=e.client,this.featureKey=e.featureKey,this.manifestKey=e.manifestKey,this.variantFlagPrefix=e.variantFlagPrefix}async fetch(){let e=performance.now();if(typeof window<"u"){let i=new URLSearchParams(window.location.search),s=i.get(dA),o=i.get(pA);if(s&&o!==null&&this.client.setForcedVariations){let a=parseInt(o,10);Number.isNaN(a)||(console.log(`[SmartCanvas] Preview mode: forcing "${s}" to variation ${a}`),this.client.setForcedVariations({[s]:a}))}}if(this.manifestKey||this.variantFlagPrefix||this.client.getAllFeatures){let i=this.fetchMultiFlag();if(i){let s=performance.now()-e;return{config:i,meta:{source:"experiments",fetchTimeMs:s,cached:!0}}}}if(!this.featureKey)throw new Error("[SmartCanvas] No featureKey configured and no variant flags found. Ensure at least one config feature flag exists in your experiment platform.");let t=this.client.getFeatureValue?.(this.featureKey,null);if(!t||typeof t!="object")throw new Error(`[SmartCanvas] Feature "${this.featureKey}" not found or invalid. Ensure the feature is configured in your experiment platform.`);let r=performance.now()-e;return{config:t,meta:{source:"experiments",fetchTimeMs:r,cached:!0}}}fetchMultiFlag(){let e=this.getVariantFlagKeys();return!e||e.length===0?null:Ha(this.client,e)}getVariantFlagKeys(){if(this.manifestKey){let e=this.client.getFeatureValue?.(this.manifestKey,null);if(e&&typeof e=="object"){let t=e.variant_flags;if(t&&t.length>0)return t}}if(this.client.getAllFeatures){let e=this.client.getAllFeatures();return this.variantFlagPrefix?Object.keys(e).filter(t=>t.startsWith(this.variantFlagPrefix)):Object.keys(e)}return[]}};function Eb(n){return new Jd(n)}var hA="https://cdn.syntrologie.com/configs",Cb={cdn:n=>{if(!n.configId)throw new Error("CDN fetcher requires 'configId' option");return Sb({baseUrl:n.baseUrl??hA,configId:n.configId,integrity:n.integrity})},experiments:n=>{if(!n.featureKey)throw new Error("Experiments fetcher requires 'featureKey' option");return Eb({featureKey:n.featureKey})}};function Ab(n,e={}){let t=Cb[n];if(!t)throw new Error(`Unknown config fetcher type: ${n}. Supported: ${Object.keys(Cb).join(", ")}`);return t(e)}var Rb="syntro_session_metrics",Al=class{constructor(e={}){this.metrics=new Map;this.subscribers=new Set;this.experiments=e.experiments,this.attributePrefix=e.attributePrefix??"session_",this.onMetricChange=e.onMetricChange,this.loadFromStorage()}increment(e,t=1){let i=(this.metrics.get(e)??0)+t;return this.metrics.set(e,i),this.saveToStorage(),this.updateExperimentAttributes(e,i),this.onMetricChange?.(e,i),this.notifySubscribers(),i}set(e,t){this.metrics.set(e,t),this.saveToStorage(),this.updateExperimentAttributes(e,t),this.onMetricChange?.(e,t),this.notifySubscribers()}get(e){return this.metrics.get(e)??0}meetsThreshold(e,t){return this.get(e)>=t}getAll(){return Object.fromEntries(this.metrics)}reset(e){this.metrics.delete(e),this.saveToStorage(),this.updateExperimentAttributes(e,0),this.onMetricChange?.(e,0),this.notifySubscribers()}resetAll(){let e=Array.from(this.metrics.keys());this.metrics.clear(),this.saveToStorage();let t={};for(let r of e)t[`${this.attributePrefix}${r}`]=0,this.onMetricChange?.(r,0);this.experiments?.setAttributes?.(t),this.notifySubscribers()}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}destroy(){this.subscribers.clear()}setExperiments(e){this.experiments=e,this.syncAllToExperiments()}updateExperimentAttributes(e,t){if(!this.experiments?.setAttributes)return;let r=`${this.attributePrefix}${e}`;this.experiments.setAttributes({[r]:t})}syncAllToExperiments(){if(!this.experiments?.setAttributes)return;let e={};for(let[t,r]of this.metrics)e[`${this.attributePrefix}${t}`]=r;this.experiments.setAttributes(e)}notifySubscribers(){for(let e of this.subscribers)try{e()}catch{}}loadFromStorage(){if(!(typeof window>"u"||typeof sessionStorage>"u"))try{let e=sessionStorage.getItem(Rb);if(e){let t=JSON.parse(e);for(let[r,i]of Object.entries(t))this.metrics.set(r,i.count)}}catch(e){console.warn("[SessionMetricTracker] Failed to load from sessionStorage:",e)}}saveToStorage(){if(!(typeof window>"u"||typeof sessionStorage>"u"))try{let e={};for(let[t,r]of this.metrics)e[t]={count:r,lastUpdated:Date.now()};sessionStorage.setItem(Rb,JSON.stringify(e))}catch(e){console.warn("[SessionMetricTracker] Failed to save to sessionStorage:",e)}}};function Qd(n={}){return new Al(n)}var Rl=class{constructor(e){this.unsubUnload=null;this.unsubLoad=null;this.destroyed=!1;this.adapter=e}activate(){this.destroyed||(this.unsubUnload=this.adapter.onRegionWillUnload(e=>{this.hideContentInSection(e)}),this.unsubLoad=this.adapter.onRegionDidLoad(e=>{this.revealContentInSection(e)}))}destroy(){this.destroyed=!0,this.unsubUnload?.(),this.unsubLoad?.(),this.unsubUnload=null,this.unsubLoad=null}hideContentInSection(e){let t=this.sectionSelector(e),r=document.querySelectorAll(`${t} [data-syntro-action-id]`);for(let i of r)i.style.opacity="0",i.style.transition="none"}revealContentInSection(e){let t=this.sectionSelector(e);requestAnimationFrame(()=>{if(this.destroyed)return;let r=document.querySelectorAll(`${t} [data-syntro-action-id]`);for(let i of r)i.style.transition="opacity 120ms ease-in",i.style.opacity="1"})}sectionSelector(e){let t=typeof CSS<"u"?CSS.escape(e):e;return document.getElementById(`shopify-section-${e}`)?`#shopify-section-${t}`:`.shopify-section[id$="-${t}"]`}};var Tl=class{constructor(e){this.name="shopify";this.loadCallbacks=new Set;this.unloadCallbacks=new Set;this.abortController=null;this.antiFlicker=null;this.initTimeoutMs=e?.initTimeoutMs??3e3}detect(){return typeof window>"u"||typeof document>"u"?!1:!!("Shopify"in window&&window.Shopify!=null||document.querySelector('meta[name="shopify-checkout-api-token"]'))}async onInit(){this.abortController=new AbortController;let{signal:e}=this.abortController;this.attachSectionListeners(e),this.antiFlicker=new Rl(this),this.antiFlicker.activate(),await this.waitForInitialSections(this.initTimeoutMs,e)}onRegionDidLoad(e){return this.loadCallbacks.add(e),()=>{this.loadCallbacks.delete(e)}}onRegionWillUnload(e){return this.unloadCallbacks.add(e),()=>{this.unloadCallbacks.delete(e)}}onRegionMutated(e){}getAnchorScope(e){let t=e.closest(".shopify-section");return t?.id?`#${typeof CSS<"u"?CSS.escape(t.id):t.id} `:""}destroy(){this.antiFlicker?.destroy(),this.antiFlicker=null,this.abortController&&(this.abortController.abort(),this.abortController=null),this.loadCallbacks.clear(),this.unloadCallbacks.clear()}attachSectionListeners(e){document.addEventListener("shopify:section:load",t=>{let r=t.detail?.sectionId;if(r)for(let i of this.loadCallbacks)try{i(r)}catch{}},{signal:e}),document.addEventListener("shopify:section:unload",t=>{let r=t.detail?.sectionId;if(r)for(let i of this.unloadCallbacks)try{i(r)}catch{}},{signal:e})}waitForInitialSections(e,t){return new Promise(r=>{if(document.querySelector(".shopify-section")){r();return}let i=!1,s=()=>{i||(i=!0,r())};document.addEventListener("shopify:section:load",()=>s(),{once:!0,signal:t});let o=setTimeout(s,e);t.addEventListener("abort",()=>{clearTimeout(o),s()},{once:!0})})}};var fA=[()=>new Tl];function Tb(){for(let n of fA){let e=n();if(e.detect())return e}return null}var ep="syntro_experiments";var mA=720*60*60,Il=class{constructor(e){this.context={...e,telemetryHost:e.telemetryHost.replace(/\/$/,"")},this.writeCookie()}updateContext(e){this.context={...e,telemetryHost:e.telemetryHost.replace(/\/$/,"")},this.writeCookie()}destroy(){document.cookie=`${ep}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/; SameSite=Lax`}writeCookie(){let e={version:1,distinct_id:this.context.distinctId,telemetry_host:this.context.telemetryHost,telemetry_key:this.context.telemetryKey},t=encodeURIComponent(JSON.stringify(e)),r=`${ep}=${t}; max-age=${mA}; path=/; SameSite=Lax`;document.cookie=r}};function vA(){let n=Date.now();return{page:{url:typeof window<"u"?window.location.href:"",title:typeof document<"u"?document.title:void 0},session:{sessionId:"",startTs:n,pageHistory:[]},viewport:{width:typeof window<"u"?window.innerWidth:0,height:typeof window<"u"?window.innerHeight:0}}}function tp(n,e){if(!e)return;let t;try{t=new URL(n).pathname}catch{t=n}if(e.exclude){for(let r of e.exclude)if(Ib(t,r))return}if(e.include){for(let r of e.include)if(Ib(t,r))return r;return}return t}function Ib(n,e){let t=n.replace(/\/$/,"")||"/",r=e.replace(/\/$/,"")||"/";if(t===r)return!0;let i=r.replace(/:[^/]+/g,"[^/]+").replace(/\*/g,".*");return new RegExp(`^${i}$`).test(t)}var $l=class{constructor(e){this.listeners=new Set;this.cleanupFns=[];if(this.telemetry=e.telemetry,this.routes=e.routes,this.navigation=e.navigation,this.context=vA(),this.previousContext={...this.context},e.telemetry?.getSessionId){let t=e.telemetry.getSessionId();t&&(this.context.session.sessionId=t)}e.initialPageHistory&&(this.context.session.pageHistory=e.initialPageHistory),this.context.page.routeId=tp(this.context.page.url,this.routes),this.addPageToHistory(this.context.page.url),typeof window<"u"&&this.setupBrowserListeners()}get(){return{...this.context}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setRoutes(e){this.routes=e;let t=tp(this.context.page.url,this.routes);t!==this.context.page.routeId&&this.updateContext({page:{...this.context.page,routeId:t}})}setAnchors(e){this.updateContext({anchors:e})}setSessionId(e){e!==this.context.session.sessionId&&this.updateContext({session:{...this.context.session,sessionId:e}})}destroy(){for(let e of this.cleanupFns)e();this.cleanupFns=[],this.listeners.clear()}setupBrowserListeners(){let e,t=()=>{clearTimeout(e),e=setTimeout(()=>{this.updateViewport()},100)};window.addEventListener("resize",t),this.cleanupFns.push(()=>window.removeEventListener("resize",t));let r=this.navigation.subscribe(()=>this.updatePage());this.cleanupFns.push(r)}updateViewport(){let e={width:window.innerWidth,height:window.innerHeight};(e.width!==this.context.viewport.width||e.height!==this.context.viewport.height)&&this.updateContext({viewport:e})}updatePage(){let e=window.location.href,{title:t}=document,r=tp(e,this.routes),i={url:e,title:t,routeId:r};(i.url!==this.context.page.url||i.title!==this.context.page.title||i.routeId!==this.context.page.routeId)&&(i.url!==this.context.page.url&&this.addPageToHistory(i.url),this.updateContext({page:i}))}addPageToHistory(e){let t={url:e,ts:Date.now()},r=[...this.context.session.pageHistory||[],t];r.length>50&&r.shift(),this.context.session.pageHistory=r}updateContext(e){this.previousContext={...this.context},this.context={...this.context,...e},this.notifyListeners()}notifyListeners(){for(let e of this.listeners)try{e(this.context,this.previousContext)}catch(t){console.error("[ContextManager] Listener error:",t)}}};function np(n){return new $l(n)}function $b(n,e){let{context:t,state:r,events:i}=e;switch(n.type){case"page_url":{let{url:s}=n,o=t.page.url.split("?")[0].split("#")[0],a=s.replace(/\*\*/g,"\0GLOBSTAR\0").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\0GLOBSTAR\0/g,".*");return new RegExp(`^${a}$`).test(o)}case"route":return t.page.routeId===n.routeId;case"anchor_visible":{let s=t.anchors?.find(o=>o.anchorId===n.anchorId);switch(n.state){case"visible":return s?.visible===!0;case"present":return s?.present===!0;case"absent":return!s?.present;default:return!1}}case"event_occurred":{if(!i)return!1;let s=n.withinMs??6e4;return i.hasRecentEvent(n.eventName,s)}case"state_equals":return r?.getValue?r.getValue(n.key)===n.value:!1;case"viewport":{let{width:s,height:o}=t.viewport;return!(n.minWidth!==void 0&&s<n.minWidth||n.maxWidth!==void 0&&s>n.maxWidth||n.minHeight!==void 0&&o<n.minHeight||n.maxHeight!==void 0&&o>n.maxHeight)}case"session_metric":{let s=e.sessionMetrics?e.sessionMetrics.get(n.key):r?.getSessionMetric(n.key);if(s===void 0)return!1;let{operator:o,threshold:a}=n;switch(o){case"gte":return s>=a;case"lte":return s<=a;case"eq":return s===a;case"gt":return s>a;case"lt":return s<a;default:return!1}}case"dismissed":{if(!r)return n.inverted??!1;let s=r.isDismissed(n.key);return n.inverted?!s:s}case"cooldown_active":{if(!r)return n.inverted??!1;let s=r.isCooldownActive(n.key);return n.inverted?!s:s}case"frequency_limit":{if(!r)return n.inverted??!1;let o=r.getFrequencyCount(n.key)>=n.limit;return n.inverted?!o:o}case"event_count":{if(!e.accumulator)return!1;let s=n,o=e.accumulator.getCount(s.key,s.withinMs);switch(s.operator){case"gte":return o>=s.count;case"lte":return o<=s.count;case"eq":return o===s.count;case"gt":return o>s.count;case"lt":return o<s.count;default:return!1}}default:return console.warn("[RuleStrategy] Unknown condition type:",n.type),!1}}function Mb(n,e){let t=[];for(let r of n.conditions){let i=$b(r,e);if(t.push({condition:r,result:i}),!i)return{matched:!1,conditionResults:t}}return{matched:!0,conditionResults:t}}function Ml(n,e){for(let t=0;t<n.rules.length;t++){let r=n.rules[t],{matched:i,conditionResults:s}=Mb(r,e);if(i)return{value:r.value,isFallback:!1,matchInfo:{strategyType:"rules",matchedRuleIndex:t,evaluatedConditions:s}}}return{value:n.default,isFallback:!0,matchInfo:{strategyType:"rules"}}}function Pl(n,e){let{context:t}=e,r=t.augmented?.[n.field];return r===void 0||typeof r!="number"?{value:n.below,isFallback:!0,matchInfo:{strategyType:"score"}}:{value:r>=n.threshold?n.above:n.below,isFallback:!1,matchInfo:{strategyType:"score"}}}function Pb(n,e){let{state:t,events:r,sessionMetrics:i,accumulator:s}=e;return{context:n,state:t?{isDismissed:o=>t.dismissals.isDismissed(o),isCooldownActive:o=>t.cooldowns.isActive(o),getFrequencyCount:o=>t.frequency.count(o),getSessionMetric:o=>i?.get(o)??0,getValue:o=>t.session.get(o)??t.user.get(o)}:void 0,sessionMetrics:i?{get:o=>i.get(o)??0}:void 0,events:r?{hasRecentEvent:(o,a)=>r.hasRecentEvent(o,a)}:void 0,accumulator:s?{getCount:(o,a)=>s.getCount(o,a)}:void 0}}async function Ob(n,e,t={}){let r=Pb(e,t);switch(n.type){case"rules":return Ml(n,r);case"score":return Pl(n,r);case"model":return{value:n.default,isFallback:!0,matchInfo:{strategyType:"model"}};case"external":return{value:n.default,isFallback:!0,matchInfo:{strategyType:"external"}};default:return console.warn("[DecisionEngine] Unknown strategy type:",n.type),{value:void 0,isFallback:!0,matchInfo:{strategyType:n.type}}}}function Nb(n,e,t={}){let r=Pb(e,t);switch(n.type){case"rules":return Ml(n,r);case"score":return Pl(n,r);case"model":case"external":return{value:n.default,isFallback:!0,matchInfo:{strategyType:n.type}};default:return{value:void 0,isFallback:!0,matchInfo:{strategyType:n.type}}}}function rp(n){return{evaluate:(e,t)=>Ob(e,t,n),evaluateSync:(e,t)=>Nb(e,t,n)}}function ip(n){let{eventBus:e,stateStore:t}=n,r=new Map,i=new Set,s=null,o=t.ns("accumulator");function a(c){let u=!1;for(let d of r.values()){if(!d.predicate(c))continue;let h=o.get(d.stateKey)||{count:0};h.count++,d.needsTimestamps&&(h.timestamps||(h.timestamps=[]),h.timestamps.push(c.ts),h.timestamps.length>200&&(h.timestamps=h.timestamps.slice(-200))),o.set(d.stateKey,h),u=!0}if(u)for(let d of i)try{d()}catch(h){console.error("[EventAccumulator] Subscriber error:",h)}}function l(){s||r.size===0||(s=e.subscribe(a))}return{register(c,u,d=!1){let h=`ev:${c}`,g=r.get(h);if(g){d&&!g.needsTimestamps&&(g.needsTimestamps=!0);return}r.set(h,{stateKey:h,needsTimestamps:d,predicate:u}),l()},getCount(c,u){let d=`ev:${c}`,h=o.get(d);if(!h)return 0;if(u===void 0||!h.timestamps)return h.count;let g=Date.now()-u;return h.timestamps.filter(v=>v>=g).length},subscribe(c){return i.add(c),()=>{i.delete(c)}},destroy(){s&&(s(),s=null),r.clear(),i.clear()}}}var po=class{constructor(){this.listeners=new Set;this.destroyed=!1;this.onPopState=()=>{this.notify(window.location.href,"popstate")};this.wasNative=this.isNativeFunction(history.pushState),this.capturedPushState=history.pushState,this.capturedReplaceState=history.replaceState,history.pushState=(...e)=>{this.capturedPushState.call(history,...e),queueMicrotask(()=>this.notify(window.location.href,"pushState"))},history.replaceState=(...e)=>{this.capturedReplaceState.call(history,...e),queueMicrotask(()=>this.notify(window.location.href,"replaceState"))},window.addEventListener("popstate",this.onPopState)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}diagnose(){return{isNative:this.wasNative,subscriberCount:this.listeners.size}}destroy(){this.destroyed||(this.destroyed=!0,history.pushState=this.capturedPushState,history.replaceState=this.capturedReplaceState,window.removeEventListener("popstate",this.onPopState),this.listeners.clear())}notify(e,t){if(!this.destroyed)for(let r of this.listeners)try{r(e,t)}catch{}}isNativeFunction(e){try{return Function.prototype.toString.call(e).includes("[native code]")}catch{return!1}}};var sp="cooldown:";function Lb(n){return{set(e,t){let r=sp+e,i=Date.now()+t;n.set(r,i)},isActive(e){return this.remaining(e)>0},remaining(e){let t=sp+e,r=n.get(t);if(r===void 0)return 0;let i=r-Date.now();return i<=0?(n.remove(t),0):i},clear(e){let t=sp+e;n.remove(t)}}}var ho="dismissed:";function Fb(n,e){return{mark(t,r=!1){let i=ho+t;(r?e:n).set(i,!0)},isDismissed(t){let r=ho+t;return n.has(r)||e.has(r)},clear(t){let r=ho+t;n.remove(r),e.remove(r)},clearAll(){for(let t of n.keys())t.startsWith(ho)&&n.remove(t);for(let t of e.keys())t.startsWith(ho)&&e.remove(t)}}}var op="freq:";function Db(n){function e(t){let r=op+t,i=n.get(r);if(i){if(i.resetAt&&Date.now()>=i.resetAt){n.remove(r);return}return i}}return{increment(t,r){let i=op+t,s=e(t),o=(s?.count??0)+1,a={count:o,resetAt:s?.resetAt??(r?Date.now()+r:void 0)};return n.set(i,a),o},count(t){return e(t)?.count??0},reset(t){let r=op+t;n.remove(r)},hasReachedLimit(t,r){return this.count(t)>=r}}}var yA="syntro";function ap(n,e){let t=`${e}:`;return{get(r){if(n)try{let i=n.getItem(t+r);if(!i)return;let s=JSON.parse(i);if(s.expiresAt&&Date.now()>=s.expiresAt){n.removeItem(t+r);return}return s.value}catch{return}},set(r,i,s){if(n)try{let o={value:i,expiresAt:s?Date.now()+s:void 0};n.setItem(t+r,JSON.stringify(o))}catch(o){console.warn("[StateStore] Failed to save:",o)}},remove(r){n&&n.removeItem(t+r)},has(r){return n?this.get(r)!==void 0:!1},keys(){if(!n)return[];let r=[];for(let i=0;i<n.length;i++){let s=n.key(i);s?.startsWith(t)&&r.push(s.slice(t.length))}return r},clear(){if(!n)return;let r=this.keys();for(let i of r)n.removeItem(t+i)}}}function fo(n){let e=new Map,t=`${n}:`;return{get(r){let i=e.get(t+r);if(i){if(i.expiresAt&&Date.now()>=i.expiresAt){e.delete(t+r);return}return i.value}},set(r,i,s){e.set(t+r,{value:i,expiresAt:s?Date.now()+s:void 0})},remove(r){e.delete(t+r)},has(r){return this.get(r)!==void 0},keys(){let r=[];for(let i of e.keys())i.startsWith(t)&&r.push(i.slice(t.length));return r},clear(){for(let r of e.keys())r.startsWith(t)&&e.delete(r)}}}var Ol=class{constructor(e={}){this.namespacedStorages=new Map;this.namespace=e.namespace??yA;let t=r=>typeof r=="object"&&r!==null&&typeof r.setItem=="function";typeof window<"u"?(this.session=t(window.sessionStorage)?ap(window.sessionStorage,this.namespace):fo(this.namespace),this.user=t(window.localStorage)?ap(window.localStorage,this.namespace):fo(this.namespace)):(this.session=fo(this.namespace),this.user=fo(this.namespace)),this.dismissals=Fb(this.session,this.user),this.cooldowns=Lb(this.user),this.frequency=Db(this.session)}ns(e){let t=`${this.namespace}:${e}`;if(!this.namespacedStorages.has(t)){let r=typeof window<"u"&&typeof sessionStorage<"u"?ap(sessionStorage,t):fo(t);this.namespacedStorages.set(t,r)}return this.namespacedStorages.get(t)}};function lp(n={}){return new Ol(n)}function go(n){return n.startsWith("inline:")?"inline":n.startsWith("adjacent:")?"adjacent":"static"}function Nl(n){return n.startsWith("inline:")?n.slice(7):n.startsWith("adjacent:")?n.slice(9):null}var Hb={drawer_right:{position:"fixed",top:"0",right:"0",bottom:"0",width:"360px",maxWidth:"90vw"},drawer_left:{position:"fixed",top:"0",left:"0",bottom:"0",width:"360px",maxWidth:"90vw"},drawer_bottom:{position:"fixed",left:"0",right:"0",bottom:"0",maxHeight:"50vh"},overlay_center:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",maxWidth:"90vw",maxHeight:"90vh"},overlay_corner_br:{position:"fixed",bottom:"16px",right:"16px",maxWidth:"400px",maxHeight:"80vh"},overlay_corner_bl:{position:"fixed",bottom:"16px",left:"16px",maxWidth:"400px",maxHeight:"80vh"},toast_top:{position:"fixed",top:"16px",left:"50%",transform:"translateX(-50%)",maxWidth:"90vw"},toast_bottom:{position:"fixed",bottom:"16px",left:"50%",transform:"translateX(-50%)",maxWidth:"90vw"}},mo={fade:[{opacity:0},{opacity:1}],slide:[{opacity:0,transform:"translateY(10px)"},{opacity:1,transform:"translateY(0)"}],scale:[{opacity:0,transform:"scale(0.95)"},{opacity:1,transform:"scale(1)"}],none:[]},Bb={duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"forwards"};function cp(n,e,t){let r=Hb[e];Object.assign(n.style,r),t&&(t.maxWidth&&(n.style.maxWidth=t.maxWidth),t.maxHeight&&(n.style.maxHeight=t.maxHeight),t.minWidth&&(n.style.minWidth=t.minWidth),t.minHeight&&(n.style.minHeight=t.minHeight))}function up(n,e,t){let r=t.placement==="auto"?"bottom":t.placement,i=[Gr(t.offset?{mainAxis:t.offset.y,crossAxis:t.offset.x}:8)];return t.flip!==!1&&i.push(Yr()),t.shift!==!1&&i.push(Kr({padding:8})),n.style.position="absolute",n.style.zIndex="2147483646",Zr(e,n,async()=>{let{x:o,y:a,strategy:l}=await Xr(e,n,{placement:r,middleware:i});Object.assign(n.style,{position:l,left:`${o}px`,top:`${a}px`})})}function dp(n,e,t="append"){return n.style.position="relative",n.style.display="inline-block",t==="prepend"?e.insertBefore(n,e.firstChild):e.appendChild(n),()=>{n.remove()}}function pp(n,e){return e==="none"||mo[e].length===0?null:n.animate(mo[e],Bb)}function hp(n,e){if(e==="none"||mo[e].length===0)return Promise.resolve();let t=[...mo[e]].reverse(),r=n.animate(t,Bb);return new Promise(i=>{r.onfinish=()=>i(),r.oncancel=()=>i()})}function fp(n,e){let t=document.createElement("div");return t.setAttribute("data-syntro-surface",n),t.setAttribute("data-syntro-mount-id",e),t.className="syntro-surface",Object.assign(t.style,{pointerEvents:"auto",boxSizing:"border-box",overflow:"auto"}),t}function gp(n){switch(go(n)){case"static":return n.startsWith("drawer")?2147483640:n.startsWith("overlay")?2147483642:n.startsWith("toast")?2147483644:2147483640;case"inline":return 1;case"adjacent":return 2147483638;default:return 2147483640}}function Vb(n){if(typeof window.Sanitizer=="function")try{let l=new window.Sanitizer({}).sanitizeToFragment(n),c=document.createElement("div");return c.append(l),c.innerHTML}catch{}let t=document.createElement("template");t.innerHTML=n;let r=t.content,i=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,null),s=new Set(["b","strong","i","em","u","span","div","p","br","ul","ol","li","code","pre","small","sup","sub","a","button"]),o=[];for(;i.nextNode();){let a=i.currentNode,l=a.tagName.toLowerCase();if(!s.has(l)){o.push(a);continue}for(let c of Array.from(a.attributes)){let u=c.name.toLowerCase(),d=c.value.trim().toLowerCase(),h=u.startsWith("on"),g=(u==="href"||u==="src")&&d.startsWith("javascript:");(h||g)&&a.removeAttribute(c.name)}}for(let a of o){for(;a.firstChild;)a.parentNode?.insertBefore(a.firstChild,a);a.remove()}return t.innerHTML=(r.firstChild,t.innerHTML)}var bA=0;function mp(n){let{overlayRoot:e,eventBus:t,anchorResolver:r,defaultAnimation:i="fade",widgetRegistry:s}=n,o=new Map,a=new Map,l=new Map;function c(){return`mount-${++bA}`}function u(b,x){t&&t.publish(b,x)}function d(b){let x=l.get(b);if(x){let R=m(b);for(let w of x)try{w(R)}catch(E){console.error("[Surfaces] State callback error:",E)}}}let h=new Map;function g(b,x,R){switch(x.type){case"html":b.innerHTML=Vb(x.content);return;case"widget":{if(s?.has(x.widgetId)){let w=s.mount(x.widgetId,b,x.config);return R&&h.set(R,w),()=>{w.unmount(),R&&h.delete(R)}}console.warn(`[Surfaces] Widget not found: ${x.widgetId}`),b.innerHTML=`<div data-widget-id="${x.widgetId}" data-widget-missing="true">Widget: ${x.widgetId}</div>`;return}case"custom":return x.mount(b);case"react":b.innerHTML="<div data-react-component>React Component</div>";return;default:console.warn("[Surfaces] Unknown content type");return}}function v(b,x,R){let w=c(),E=go(b),$=R?.priority??0,P=R?.animation??i,M=R?.exclusive??!0,G=o.get(b);if(G&&M){if(G.options.priority>$)throw new Error(`Slot ${b} is occupied by higher priority content (${G.options.priority} > ${$})`);f(G)}let L=fp(b,w);L.style.zIndex=String(gp(b));let N;if(E==="static")cp(L,b,R?.constraints),e.appendChild(L);else if(E==="inline"){let A=Nl(b);if(!A)throw new Error(`Invalid inline slot: ${b}`);if(!r)throw new Error("Anchor resolver required for inline slots");let F=r({selector:A,route:"**"});if(!F)throw new Error(`Anchor not found for inline slot: ${A}`);N=dp(L,F)}else if(E==="adjacent"){let A=Nl(b);if(!A)throw new Error(`Invalid adjacent slot: ${b}`);if(!r)throw new Error("Anchor resolver required for adjacent slots");let F=r({selector:A,route:"**"});if(!F)throw new Error(`Anchor not found for adjacent slot: ${A}`);e.appendChild(L),N=up(L,F,R?.position??{placement:"bottom"})}let z=g(L,x,w);pp(L,P);let H={id:w,slot:b,content:x,options:{priority:$,exclusive:M,animation:P,position:R?.position??{placement:"auto"},constraints:R?.constraints??{},adaptiveId:R?.adaptiveId,autoUnmountOnRouteChange:R?.autoUnmountOnRouteChange??!0},container:L,cleanup:()=>{N?.(),z?.()},mountedAt:Date.now()};return o.set(b,H),a.set(b,(a.get(b)??0)+1),u("surface.mounted",{slot:b,id:w,adaptiveId:R?.adaptiveId}),d(b),{id:w,update(A){let F=o.get(b);if(!F||F.id!==w)throw new Error("Mount no longer active");let X=h.get(w);if(X){if(A.type==="widget"){X.update(A.config),F.content=A;return}X.unmount(),h.delete(w)}F.container.innerHTML="";let fe=g(F.container,A,w);if(F.content=A,fe){let de=F.cleanup;F.cleanup=()=>{de?.(),fe()}}},setOptions(A){let F=o.get(b);if(!F||F.id!==w)throw new Error("Mount no longer active");A.priority!==void 0&&(F.options.priority=A.priority),A.animation!==void 0&&(F.options.animation=A.animation),A.constraints&&E==="static"&&(A.constraints.maxWidth&&(F.container.style.maxWidth=A.constraints.maxWidth),A.constraints.maxHeight&&(F.container.style.maxHeight=A.constraints.maxHeight),A.constraints.minWidth&&(F.container.style.minWidth=A.constraints.minWidth),A.constraints.minHeight&&(F.container.style.minHeight=A.constraints.minHeight)),d(b)},async unmount(){let A=o.get(b);!A||A.id!==w||await f(A)},isMounted(){return o.get(b)?.id===w},getContainer(){let A=o.get(b);return A?.id===w?A.container:null}}}async function f(b){b.container.isConnected&&await hp(b.container,b.options.animation);try{b.cleanup?.()}catch(x){console.warn("[Surfaces] Cleanup error during unmount, ignoring:",x)}try{b.container.remove()}catch{}o.delete(b.slot),u("surface.unmounted",{slot:b.slot,id:b.id}),d(b.slot)}function m(b){let x=o.get(b);return{slot:b,occupied:!!x,currentPriority:x?.options.priority,currentAdaptiveId:x?.options.adaptiveId,mountCount:a.get(b)??0,currentMountId:x?.id}}function y(b,x){let R=l.get(b);return R||(R=new Set,l.set(b,R)),R.add(x),()=>{R?.delete(x),R?.size===0&&l.delete(b)}}function k(b,x){let R=o.get(b);return R?x!==void 0?x>=R.options.priority:!1:!0}function _(){for(let b of o.values())try{b.cleanup?.(),b.container.remove()}catch(x){console.error("[Surfaces] Error during cleanup:",x)}o.clear(),l.clear()}return{mount:v,getState:m,onStateChange:y,canMount:k,destroy:_}}var Ll=class{constructor(){this.widgets=new Map;this.mountedWidgets=new Map;this.mountIdCounter=0;this.listeners=new Set}bindRuntime(e){this.runtimeRef=e}register(e,t,r="custom",i){if(this.widgets.has(e)){if(this.widgets.get(e).source==="built-in")throw new Error(`Cannot override built-in widget: ${e}`);console.warn(`[WidgetRegistry] Overriding widget: ${e}`)}this.widgets.set(e,{id:e,widget:t,source:r,metadata:i}),this.notify({type:"registered",widgetId:e})}unregister(e){let t=this.widgets.get(e);return t?t.source==="built-in"?(console.warn(`[WidgetRegistry] Cannot unregister built-in widget: ${e}`),!1):(this.widgets.delete(e),this.notify({type:"unregistered",widgetId:e}),!0):!1}unregisterBySource(e){for(let[t,r]of this.widgets.entries())r.source===e&&this.widgets.delete(t)}get(e){return this.widgets.get(e)?.widget}getRegistration(e){return this.widgets.get(e)}has(e){return this.widgets.has(e)}mount(e,t,r){let i=this.widgets.get(e);if(!i)throw new Error(`Widget not found: ${e}`);let s=`widget-mount-${++this.mountIdCounter}`;t.setAttribute("data-widget-mount-id",s),t.setAttribute("data-widget-id",e);let o={...r,runtime:this.runtimeRef},a=i.widget.mount(t,o);return this.mountedWidgets.set(s,{cleanup:a??void 0,container:t}),{widgetId:e,container:t,unmount:()=>{let c=this.mountedWidgets.get(s);c&&(t.isConnected&&c.cleanup?.(),this.mountedWidgets.delete(s),t.removeAttribute("data-widget-mount-id"),t.removeAttribute("data-widget-id"),t.innerHTML="")},update:c=>{if(i.widget.update)i.widget.update(t,c);else{let u=this.mountedWidgets.get(s);if(u){u.cleanup?.(),t.innerHTML="";let d={...c,runtime:this.runtimeRef},h=i.widget.mount(t,d);u.cleanup=h??void 0}}}}}list(){return Array.from(this.widgets.keys())}listRegistrations(){return Array.from(this.widgets.values())}getBySource(e){return Array.from(this.widgets.values()).filter(t=>t.source===e)}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notify(e){for(let t of this.listeners)try{t(e)}catch(r){console.error("[WidgetRegistry] Listener error:",r)}}destroy(){for(let[e,t]of this.mountedWidgets.entries())t.cleanup?.(),t.container.innerHTML="";this.mountedWidgets.clear()}},vp=new Ll;var jb="2.0.0";function _A(n,e){if(!e)return!0;let t;try{t=new URL(n).pathname}catch{t=n}let r=t.replace(/\/$/,"")||"/";if(e.exclude){for(let i of e.exclude)if(yp(r,i))return!1}if(e.include&&e.include.length>0){for(let i of e.include)if(yp(r,i))return!0;return!1}return!0}function yp(n,e){let t=e.replace(/\/$/,"")||"/";if(n===t)return!0;let r=t.replace(/\*\*/g,"\0GLOBSTAR\0").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\0GLOBSTAR\0/g,".*").replace(/:[^/]+/g,"[^/]+");return new RegExp(`^${r}$`).test(n)}function Wb(n){let t=(typeof window<"u"?window.location.pathname:"/").replace(/\/$/,"")||"/";return(Array.isArray(n.route)?n.route:[n.route]).some(i=>{let s=i;if(/^https?:\/\//.test(s))try{s=new URL(s).pathname}catch{}return yp(t,s)})}function bp(n={}){let{telemetry:e,sessionMetrics:t,routes:r,mode:i="production",namespace:s}=n,o=n.widgets??vp,a=n.executors??rn,l=n.apps??ys,c=new po,u=np({telemetry:e,routes:r,navigation:c}),d=n.events??ro(),h=lp({namespace:s}),g=ip({eventBus:d,stateStore:h}),v=rp({state:h,events:d,sessionMetrics:t,accumulator:g}),f=Ty(),m=wd(),y=M=>Wb(M)?m.resolve(M.selector):null,k=async(M,G)=>{if(!Wb(M))return null;try{return await m.waitFor(M.selector,G)}catch{return null}},_=mp({overlayRoot:f,eventBus:d,anchorResolver:y,widgetRegistry:o}),b=id({overlayRoot:f,eventBus:d,surfaces:_,anchorResolver:y,waitForAnchor:k,executorRegistry:a,subscribeNavigation:M=>c.subscribe(M),runtime:{evaluateSync:M=>v.evaluateSync(M,u.get()),context:u,accumulator:g,sessionMetrics:t,events:d?{subscribe:M=>d.subscribe(()=>M())}:void 0}}),x;if(t){let M=t;M.increment("page_views");let G=typeof window<"u"?window.location.pathname:"/";x=c.subscribe((L,N)=>{if(N!=="replaceState")try{let z=new URL(L).pathname;z!==G&&(G=z,M.increment("page_views"),R=0,M.set("time_on_page",0),M.set("scroll_depth",0))}catch{}})}let R=0,w,E;if(t){let M=t;w=setInterval(()=>{R++},1e3),E=setInterval(()=>{M.set("time_on_page",R)},5e3)}let $;if(t&&d){let M=t;$=d.subscribe({names:["ui.scroll"]},G=>{let L=G.props?.scrollPercentage;typeof L=="number"&&L>M.get("scroll_depth")&&M.set("scroll_depth",L)})}let P={telemetry:e,context:u,events:d,state:h,sessionMetrics:t,actions:b,surfaces:_,widgets:o,executors:a,apps:l,accumulator:g,anchorResolver:m,navigation:c,version:jb,mode:i,async evaluate(M){return v.evaluate(M,u.get())},evaluateSync(M){return v.evaluateSync(M,u.get())},async filterTiles(M){let G=u.get().page.url,L=[];for(let N of M){let z=N.activation;if(!z){L.push(N);continue}if(_A(G,z.routes)){if(z.onlyIfPopulated){let H=N.props?.actions??[];if(H.length>0&&!H.some(A=>A.triggerWhen?v.evaluateSync(A.triggerWhen,u.get()).value:!0))continue}L.push(N)}}return L},setRoutes(M){u.setRoutes(M)},destroy(){l.unbind().catch(M=>{console.error("[Runtime] Error unbinding apps registry:",M)}),x?.(),$?.(),w&&clearInterval(w),E&&clearInterval(E),m.destroy(),g.destroy(),c.destroy(),u.destroy(),b.destroy(),_.destroy()}};return l.bind(P),o.bindRuntime(P),P}var vo=class{constructor(e,t){this.seenSet=new Set;this.triggeredSet=new Set;this.telemetry=e,this.variantId=t}trackServed(e,t){this.telemetry.track?.("syntro_config_served",{variant_id:this.variantId,tiles:e,actions:t})}trackSeen(e,t){this.seenSet.has(e)||(this.seenSet.add(e),this.telemetry.track?.("syntro_intervention_seen",{variant_id:this.variantId,intervention_id:e,intervention_kind:t}))}trackTriggered(e,t){this.triggeredSet.has(e)||(this.triggeredSet.add(e),this.telemetry.track?.("syntro_intervention_triggered",{variant_id:this.variantId,intervention_id:e,intervention_kind:t}))}trackInteracted(e,t,r){this.telemetry.track?.("syntro_intervention_interacted",{variant_id:this.variantId,intervention_id:e,intervention_kind:t,interaction_type:r})}resetPage(){this.seenSet.clear(),this.triggeredSet.clear()}};function xA(){let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=n[Math.floor(Math.random()*n.length)];return e}var _p=class{constructor(){this.sessionId=xA(),console.log(`[Syntro Telemetry] Using noop adapter (no telemetry configured). sessionId=${this.sessionId}`)}trackCanvasOpened(e){}trackCanvasClosed(e){}trackRectangleViewed(e,t){}trackAction(e,t,r){}register(e){}getSessionId(){return this.sessionId}startSessionRecording(){}trackExperiment(e,t,r){}setPersonProperties(e){}setPersonPropertiesOnce(e){}getDistinctId(){return"demo-user"}getAllFeatureFlags(){return{}}getSegmentFlags(){return{}}track(e,t){}};function xp(){return new _p}var C=typeof window<"u"?window:void 0,qe=typeof globalThis<"u"?globalThis:C;typeof self>"u"&&(qe.self=qe),typeof File>"u"&&(qe.File=function(){});var H_=Array.prototype,Ub=H_.forEach,zb=H_.indexOf,pt=qe?.navigator,V=qe?.document,ze=qe?.location,Hp=qe?.fetch,Bp=qe!=null&&qe.XMLHttpRequest&&"withCredentials"in new qe.XMLHttpRequest?qe.XMLHttpRequest:void 0,qb=qe?.AbortController,ot=pt?.userAgent,Q=C??{},hn={DEBUG:!1,LIB_VERSION:"1.341.0"};function Zb(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function Bi(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var s=n.apply(e,t);function o(l){Zb(s,r,i,o,a,"next",l)}function a(l){Zb(s,r,i,o,a,"throw",l)}o(void 0)}))}}function U(){return U=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},U.apply(null,arguments)}function B_(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var wA=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Gb=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return wA.concat(e).some((r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1}))},kA=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function ue(n,e){return n.indexOf(e)!==-1}var pc=function(n){return n.trim()},Vp=function(n){return n.replace(/^\$/,"")},SA=Array.isArray,V_=Object.prototype,W_=V_.hasOwnProperty,hc=V_.toString,me=SA||function(n){return hc.call(n)==="[object Array]"},qn=n=>typeof n=="function",Ne=n=>n===Object(n)&&!me(n),Vi=n=>{if(Ne(n)){for(var e in n)if(W_.call(n,e))return!1;return!0}return!1},W=n=>n===void 0,Le=n=>hc.call(n)=="[object String]",Wp=n=>Le(n)&&n.trim().length===0,Dt=n=>n===null,pe=n=>W(n)||Dt(n),bn=n=>hc.call(n)=="[object Number]"&&n==n,Di=n=>bn(n)&&n>0,yn=n=>hc.call(n)==="[object Boolean]",EA=n=>n instanceof FormData,CA=n=>ue(kA,n);function jp(n){return n===null||typeof n!="object"}function Ul(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function j_(n){return!W(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}var AA=[!0,"true",1,"1","yes"],wp=n=>ue(AA,n),RA=[!1,"false",0,"0","no"];function Kt(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),bn(n)?n>t?(r.warn(" cannot be greater than max: "+t+". Using max value instead."),t):n<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):n:(r.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),Kt(i||t,e,t,r))}var Up=class{constructor(e){this.t={},this.i=e.i,this.o=Kt(e.bucketSize,0,100,e.h),this.m=Kt(e.refillRate,0,this.o,e.h),this.$=Kt(e.refillInterval,0,864e5,e.h)}S(e,t){var r=t-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var s=i*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var t,r=Date.now(),i=String(e),s=this.t[i];return s?this.S(s,r):(s={tokens:this.o,lastAccess:r},this.t[i]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((t=this.i)==null||t.call(this,e)),s.tokens===0)}stop(){this.t={}}},kt="Mobile",zl="iOS",vn="Android",Do="Tablet",U_=vn+" "+Do,z_="iPad",q_="Apple",Z_=q_+" Watch",Ho="Safari",zi="BlackBerry",G_="Samsung",K_=G_+"Browser",Y_=G_+" Internet",Br="Chrome",TA=Br+" OS",X_=Br+" "+zl,Jh="Internet Explorer",J_=Jh+" "+kt,Qh="Opera",IA=Qh+" Mini",ef="Edge",Q_="Microsoft "+ef,ji="Firefox",e0=ji+" "+zl,Bo="Nintendo",Vo="PlayStation",Ui="Xbox",t0=vn+" "+kt,n0=kt+" "+Ho,Ao="Windows",zp=Ao+" Phone",Kb="Nokia",qp="Ouya",r0="Generic",$A=r0+" "+kt.toLowerCase(),i0=r0+" "+Do.toLowerCase(),Zp="Konqueror",tt="(\\d+(\\.\\d+)?)",kp=new RegExp("Version/"+tt),MA=new RegExp(Ui,"i"),PA=new RegExp(Vo+" \\w+","i"),OA=new RegExp(Bo+" \\w+","i"),tf=new RegExp(zi+"|PlayBook|BB10","i"),NA={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Fl,Yb,Sp,LA=(n,e)=>e&&ue(e,q_)||(function(t){return ue(t,Ho)&&!ue(t,Br)&&!ue(t,vn)})(n),s0=function(n,e){return e=e||"",ue(n," OPR/")&&ue(n,"Mini")?IA:ue(n," OPR/")?Qh:tf.test(n)?zi:ue(n,"IE"+kt)||ue(n,"WPDesktop")?J_:ue(n,K_)?Y_:ue(n,ef)||ue(n,"Edg/")?Q_:ue(n,"FBIOS")?"Facebook "+kt:ue(n,"UCWEB")||ue(n,"UCBrowser")?"UC Browser":ue(n,"CriOS")?X_:ue(n,"CrMo")||ue(n,Br)?Br:ue(n,vn)&&ue(n,Ho)?t0:ue(n,"FxiOS")?e0:ue(n.toLowerCase(),Zp.toLowerCase())?Zp:LA(n,e)?ue(n,kt)?n0:Ho:ue(n,ji)?ji:ue(n,"MSIE")||ue(n,"Trident/")?Jh:ue(n,"Gecko")?ji:""},FA={[J_]:[new RegExp("rv:"+tt)],[Q_]:[new RegExp(ef+"?\\/"+tt)],[Br]:[new RegExp("("+Br+"|CrMo)\\/"+tt)],[X_]:[new RegExp("CriOS\\/"+tt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+tt)],[Ho]:[kp],[n0]:[kp],[Qh]:[new RegExp("(Opera|OPR)\\/"+tt)],[ji]:[new RegExp(ji+"\\/"+tt)],[e0]:[new RegExp("FxiOS\\/"+tt)],[Zp]:[new RegExp("Konqueror[:/]?"+tt,"i")],[zi]:[new RegExp(zi+" "+tt),kp],[t0]:[new RegExp("android\\s"+tt,"i")],[Y_]:[new RegExp(K_+"\\/"+tt)],[Jh]:[new RegExp("(rv:|MSIE )"+tt)],Mozilla:[new RegExp("rv:"+tt)]},DA=function(n,e){var t=s0(n,e),r=FA[t];if(W(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=n.match(s);if(o)return parseFloat(o[o.length-2])}return null},Xb=[[new RegExp(Ui+"; "+Ui+" (.*?)[);]","i"),n=>[Ui,n&&n[1]||""]],[new RegExp(Bo,"i"),[Bo,""]],[new RegExp(Vo,"i"),[Vo,""]],[tf,[zi,""]],[new RegExp(Ao,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[zp,""];if(new RegExp(kt).test(e)&&!/IEMobile\b/.test(e))return[Ao+" "+kt,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=NA[r]||"";return/arm/i.test(e)&&(i="RT"),[Ao,i]}return[Ao,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[zl,e.join(".")]}return[zl,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=W(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+vn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+vn+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[vn,e.join(".")]}return[vn,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,n=>{var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[TA,""]],[/Linux|debian/i,["Linux",""]]],Jb=function(n){return OA.test(n)?Bo:PA.test(n)?Vo:MA.test(n)?Ui:new RegExp(qp,"i").test(n)?qp:new RegExp("("+zp+"|WPDesktop)","i").test(n)?zp:/iPad/.test(n)?z_:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?Z_:tf.test(n)?zi:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(Kb,"i").test(n)?Kb:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?new RegExp(kt).test(n)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)||/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?vn:U_:new RegExp("(pda|"+kt+")","i").test(n)?$A:new RegExp(Do,"i").test(n)&&!new RegExp(Do+" pc","i").test(n)?i0:""},HA=n=>n instanceof Error;function BA(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Sp&&t.length===Yb||(Yb=t.length,Sp=t.reduce(((r,i)=>{Fl||(Fl={});var s=Fl[i];if(s)r[s[0]]=s[1];else for(var o=n(i),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[i];if(c&&u){r[c]=u,Fl[i]=[c,u];break}}return r}),{})),Sp}}var Gp=class{constructor(e,t,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=t,this.modifiers=r}buildFromUnknown(e,t){t===void 0&&(t={});var r=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,t,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var t=this;return Bi((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&me(r.stacktrace.frames)&&(r.stacktrace.frames=yield t.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),U({},e,{cause:r,stack:i})}applyChunkIds(e,t){return e.map((r=>(r.filename&&t&&(r.chunk_id=t[r.filename]),r)))}applyCoercers(e,t){for(var r of this.coercers)if(r.match(e))return r.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Bi((function*(){var r=e;for(var i of t.modifiers)r=yield i(r);return r}))()}convertToExceptionList(e,t){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=t.type)!==null&&r!==void 0?r:"generic",handled:(i=t.handled)===null||i===void 0||i,synthetic:(s=e.synthetic)!==null&&s!==void 0&&s}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,U({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:BA(this.stackParser)}}buildCoercingContext(e,t,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(s,a)}};return U({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},qi="?";function Kp(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?qi:t,in_app:!0};return W(r)||(s.lineno=r),W(i)||(s.colno=i),s}var o0=(n,e)=>{var t=n.indexOf("safari-extension")!==-1,r=n.indexOf("safari-web-extension")!==-1;return t||r?[n.indexOf("@")!==-1?n.split("@")[0]:qi,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},VA=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,WA=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,jA=/\((\S*)(?::(\d+))(?::(\d+))\)/,UA=(n,e)=>{var t=VA.exec(n);if(t){var[,r,i,s]=t;return Kp(e,r,qi,+i,+s)}var o=WA.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=jA.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=o0(o[1]||qi,o[2]);return Kp(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},zA=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,qA=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ZA=(n,e)=>{var t=zA.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=qA.exec(t[3]);r&&(t[1]=t[1]||"eval",t[3]=r[1],t[4]=r[2],t[5]="")}var i=t[3],s=t[1]||qi;return[s,i]=o0(s,i),Kp(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Qb=/\(error: (.*)\)/,e_=50;function GA(){return(function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(i,s){s===void 0&&(s=0);for(var o=[],a=i.split(`
|
|
1160
1160
|
`),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=Qb.test(c)?c.replace(Qb,"$1"):c;if(!u.match(/\S*Error: /)){for(var d of t){var h=d(u,n);if(h){o.push(h);break}}if(o.length>=e_)break}}}return(function(g){if(!g.length)return[];var v=Array.from(g);return v.reverse(),v.slice(0,e_).map((f=>{return U({},f,{filename:f.filename||(m=v,m[m.length-1]||{}).filename,function:f.function||qi});var m}))})(o)}})("web:javascript",UA,ZA)}var Yp=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=Le(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Ul(e,"DOMException")}isDOMError(e){return Ul(e,"DOMError")}},Xp=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var r=e.message;return r.error&&typeof r.error.message=="string"?String(r.error.message):String(r)}getStack(e){return e.stacktrace||e.stack||void 0}},Jp=class{constructor(){}match(e){return Ul(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var r,i=t.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},KA=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Qp=class{match(e){return typeof e=="string"}coerce(e,t){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var t="Error",r=e,i=e.match(KA);return i&&(t=i[1],r=i[2]),[t,r]}},YA=["fatal","error","warning","log","info","debug"];function a0(n,e){e===void 0&&(e=40);var t=Object.keys(n);if(t.sort(),!t.length)return"[object has no keys]";for(var r=t.length;r>0;r--){var i=t.slice(0,r).join(", ");if(!(i.length>e))return r===t.length||i.length<=e?i:i.slice(0,e)+"..."}return""}var eh=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var r,i=this.getErrorPropertyFromObject(e);return i?t.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return j_(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+a0(e)}isSeverityLevel(e){return Le(e)&&!Wp(e)&&YA.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(HA(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},th=class{match(e){return j_(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+a0(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},nh=class{match(e){return jp(e)}coerce(e,t){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},rh=class{match(e){return Ul(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return jp(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){if(jp(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}},l0=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(C&&(hn.DEBUG||Q.POSTHOG_DEBUG||t)&&!W(C.console)&&C.console){for(var s=("__rrweb_original__"in C.console[i])?C.console[i].__rrweb_original__:C.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(n,...a)}},info:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("log",...s)},warn:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("warn",...s)},error:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("error",...s)},critical:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];console.error(n,...s)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>l0(n+" "+i,s)};return r},j=l0("[PostHog.js]"),Ie=j.createLogger,XA=Ie("[ExternalScriptsLoader]"),t_=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return XA.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=V?.querySelectorAll("script");if(r){for(var i,s=function(){if(r[o].src===e){var l=r[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!V)return t("document not found");var l=V.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=d=>{l.__posthog_loading_callback_fired=!0,t(void 0,d)},l.onerror=d=>t(d),n.config.prepare_external_dependency_script&&(l=n.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(n.config.external_scripts_inject_target==="head")V.head.appendChild(l);else{var c,u=V.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):V.body.appendChild(l)}};V!=null&&V.body?a():V?.addEventListener("DOMContentLoaded",a)};Q.__PosthogExtensions__=Q.__PosthogExtensions__||{},Q.__PosthogExtensions__.loadExternalDependency=(n,e,t)=>{var r="/static/"+e+".js?v="+n.version;if(e==="remote-config"&&(r="/array/"+n.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=n.requestRouter.endpointFor("assets",r);t_(n,s,t)},Q.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);t_(n,r,t)};var ql={};function Zn(n,e,t){if(me(n)){if(Ub&&n.forEach===Ub)n.forEach(e,t);else if("length"in n&&n.length===+n.length){for(var r=0,i=n.length;r<i;r++)if(r in n&&e.call(t,n[r],r)===ql)return}}}function ke(n,e,t){if(!pe(n)){if(me(n))return Zn(n,e,t);if(EA(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===ql)return}else for(var i in n)if(W_.call(n,i)&&e.call(t,n[i],i)===ql)return}}var Me=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Zn(t,(function(i){for(var s in i)i[s]!==void 0&&(n[s]=i[s])})),n},Gi=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return Zn(t,(function(i){Zn(i,(function(s){n.push(s)}))})),n};function Wl(n){for(var e=Object.keys(n),t=e.length,r=new Array(t);t--;)r[t]=[e[t],n[e[t]]];return r}var n_=function(n){try{return n()}catch{return}},JA=function(n){return function(){try{for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.apply(this,t)}catch(i){j.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),j.critical(i)}}},nf=function(n){var e={};return ke(n,(function(t,r){(Le(t)&&t.length>0||bn(t))&&(e[r]=t)})),e};function QA(n,e){return t=n,r=s=>Le(s)&&!Dt(e)?s.slice(0,e):s,i=new Set,(function s(o,a){return o!==Object(o)?r?r(o,a):o:i.has(o)?void 0:(i.add(o),me(o)?(l=[],Zn(o,(c=>{l.push(s(c))}))):(l={},ke(o,((c,u)=>{i.has(c)||(l[u]=s(c,u))}))),l);var l})(t);var t,r,i}var eR=["herokuapp.com","vercel.app","netlify.app"];function tR(n){var e=n?.hostname;if(!Le(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of eR)if(t===r)return!1;return!0}function c0(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function Oe(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var u0="$people_distinct_id",Ro="__alias",To="__timers",r_="$autocapture_disabled_server_side",ih="$heatmaps_enabled_server_side",i_="$exception_capture_enabled_server_side",sh="$error_tracking_suppression_rules",s_="$error_tracking_capture_extension_exceptions",o_="$web_vitals_enabled_server_side",d0="$dead_clicks_enabled_server_side",a_="$product_tours_enabled_server_side",l_="$web_vitals_allowed_metrics",Ep="$session_recording_remote_config",Zl="$sesid",p0="$session_is_sampled",Wi="$enabled_feature_flags",Io="$early_access_features",oh="$feature_flag_details",$o="$stored_person_properties",Hr="$stored_group_properties",ah="$surveys",Gl="$flag_call_reported",fn="$user_state",lh="$client_session_props",ch="$capture_rate_limit",uh="$initial_campaign_params",dh="$initial_referrer_info",Kl="$initial_person_info",Yl="$epp",h0="__POSTHOG_TOOLBAR__",yo="$posthog_cookieless",nR=[u0,Ro,"__cmpns",To,"$session_recording_enabled_server_side",ih,Zl,Wi,sh,fn,Io,oh,Hr,$o,ah,Gl,lh,ch,uh,dh,Yl,Kl,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function c_(n){return n instanceof Element&&(n.id===h0||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function fc(n){return!!n&&n.nodeType===1}function Gn(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function f0(n){return!!n&&n.nodeType===3}function g0(n){return!!n&&n.nodeType===11}function rf(n){return n?pc(n).split(/\s+/):[]}function u_(n){var e=C?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function Xl(n){var e="";switch(typeof n.className){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return rf(e)}function m0(n){return pe(n)?null:pc(n).split(/(\s+)/).filter((e=>Wo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Uo(n){var e="";return ph(n)&&!x0(n)&&n.childNodes&&n.childNodes.length&&ke(n.childNodes,(function(t){var r;f0(t)&&t.textContent&&(e+=(r=m0(t.textContent))!==null&&r!==void 0?r:"")})),pc(e)}function v0(n){return W(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var sf=["a","button","form","input","select","textarea","label"];function y0(n,e){if(W(e))return!0;var t,r=function(s){if(e.some((o=>s.matches(o))))return{v:!0}};for(var i of n)if(t=r(i))return t.v;return!1}function b0(n){var e=n.parentNode;return!(!e||!fc(e))&&e}var rR=["next","previous","prev",">","<"],d_=10,p_=[".ph-no-rageclick",".ph-no-capture"];function iR(n,e){if(!C||of(n))return!1;var t,r,i;if(yn(e)?(t=!!e&&p_,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:p_,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=_0(n,!1);return!(function(o,a){if(o===!1||W(o))return!1;var l;if(o===!0)l=rR;else{if(!me(o))return!1;if(o.length>d_)return j.error("[PostHog] content_ignorelist array cannot exceed "+d_+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:d}=c;return l.some((h=>u.includes(h)||d.includes(h)))}))})(r,s.map((o=>{var a;return{safeText:Uo(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!y0(s,t)}var of=n=>!n||Gn(n,"html")||!fc(n),_0=(n,e)=>{if(!C||of(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!Gn(i,"body");)if(g0(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=b0(i);if(!s)break;if(e||sf.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=C.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function sR(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!C||of(n)||(s=t)!=null&&s.url_allowlist&&!u_(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&u_(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((v=>e.type===v)))return!1}var{parentIsUsefulElement:u,targetElementList:d}=_0(n,r);if(!(function(v,f){var m=f?.element_allowlist;if(W(m))return!0;var y,k=function(b){if(m.some((x=>b.tagName.toLowerCase()===x)))return{v:!0}};for(var _ of v)if(y=k(_))return y.v;return!1})(d,t)||!y0(d,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var h=C.getComputedStyle(n);if(h&&h.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var g=n.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(sf.indexOf(g)>-1||n.getAttribute("contenteditable")==="true")}}function ph(n){for(var e=n;e.parentNode&&!Gn(e,"body");e=e.parentNode){var t=Xl(e);if(ue(t,"ph-sensitive")||ue(t,"ph-no-capture"))return!1}if(ue(Xl(n),"ph-include"))return!0;var r=n.type||"";if(Le(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(Le(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function x0(n){return!!(Gn(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Gn(n,"select")||Gn(n,"textarea")||n.getAttribute("contenteditable")==="true")}var w0="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",oR=new RegExp("^(?:"+w0+")$"),aR=new RegExp(w0),k0="\\d{3}-?\\d{2}-?\\d{4}",lR=new RegExp("^("+k0+")$"),cR=new RegExp("("+k0+")");function Wo(n,e){return e===void 0&&(e=!0),!(pe(n)||Le(n)&&(n=pc(n),(e?oR:aR).test((n||"").replace(/[- ]/g,""))||(e?lR:cR).test(n)))}function S0(n){var e=Uo(n);return Wo(e=(e+" "+E0(n)).trim())?e:""}function E0(n){var e="";return n&&n.childNodes&&n.childNodes.length&&ke(n.childNodes,(function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=Uo(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+E0(t)).trim())}catch(s){j.error("[AutoCapture]",s)}})),e}function uR(n){return(function(e){var t=e.map((r=>{var i,s,o="";if(r.tag_name&&(o+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))o+="."+a.replace(/"/g,"");var l=U({},r.text?{text:r.text}:{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),c={};return Wl(l).sort(((u,d)=>{var[h]=u,[g]=d;return h.localeCompare(g)})).forEach((u=>{var[d,h]=u;return c[h_(d.toString())]=h_(h.toString())})),o+=":",o+=Wl(c).map((u=>{var[d,h]=u;return d+'="'+h+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var r,i,s={text:(r=t.$el_text)==null?void 0:r.slice(0,400),tag_name:t.tag_name,href:(i=t.attr__href)==null?void 0:i.slice(0,2048),attr_class:dR(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Wl(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return s.attributes[a]=l})),s}))})(n))}function h_(n){return n.replace(/"|\\"/g,'\\"')}function dR(n){var e=n.attr__class;return e?me(e)?e:rf(e):void 0}var Jl=class{constructor(e){this.disabled=e===!1;var t=Ne(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}},Ql=n=>{var e=V?.createElement("a");return W(e)?null:(e.href=n,e)},pR=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return ke(n,(function(s,o){W(s)||W(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+t)})),i.join(e)},ec=function(n,e){for(var t,r=((n.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){t=s;break}}if(!me(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{j.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},zo=function(n,e,t){if(!n||!e||!e.length)return n;for(var r=n.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");me(h)&&(e.includes(h[0])?u.push(h[0]+"="+t):u.push(c[d]))}var g=l;return a!=null&&(g+="?"+u.join("&")),s!=null&&(g+="#"+s),g},tc=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Cp="$copy_autocapture",f_=Ie("[AutoCapture]");function Ap(n,e){return e.length>n?e.slice(0,n)+"...":e}function hR(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!fc(e));return e}function fR(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};sf.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=Ap(1024,S0(n)):s.$el_text=Ap(1024,Uo(n)));var o=Xl(n);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),ke(n.attributes,(function(u){var d;if((!x0(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Wo(u.value)&&(d=u.name,!Le(d)||d.substring(0,10)!=="_ngcontent"&&d.substring(0,7)!=="_nghost")){var h=u.value;u.name==="class"&&(h=rf(h).join(" ")),s["attr__"+u.name]=Ap(1024,h)}}));for(var a=1,l=1,c=n;c=hR(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function gR(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!Gn(u,"body");)g0(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var d,h=[],g={},v=!1,f=!1;if(ke(c,(b=>{var x=ph(b);b.tagName.toLowerCase()==="a"&&(v=b.getAttribute("href"),v=x&&v&&Wo(v)&&v),ue(Xl(b),"ph-no-capture")&&(f=!0),h.push(fR(b,s,o,a));var R=(function(w){if(!ph(w))return{};var E={};return ke(w.attributes,(function($){if($.name&&$.name.indexOf("data-ph-capture-attribute")===0){var P=$.name.replace("data-ph-capture-attribute-",""),M=$.value;P&&M&&Wo(M)&&(E[P]=M)}})),E})(b);Me(g,R)})),f)return{props:{},explicitNoCapture:f};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?h[0].$el_text=S0(n):h[0].$el_text=Uo(n)),v){var m,y;h[0].attr__href=v;var k=(m=Ql(v))==null?void 0:m.host,_=C==null||(y=C.location)==null?void 0:y.host;k&&_&&k!==_&&(d=v)}return{props:Me({$event_type:i.type,$ce_version:1},l?{}:{$elements:h},{$elements_chain:uR(h)},(t=h[0])!=null&&t.$el_text?{$el_text:(r=h[0])==null?void 0:r.$el_text}:{},d&&i.type==="click"?{$external_click_url:d}:{},g)}}var hh=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Jl(e.config.rageclick),this.C=null}get R(){var e,t,r=Ne(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map((i=>new RegExp(i))),r.url_ignorelist=(t=r.url_ignorelist)==null?void 0:t.map((i=>new RegExp(i))),r}F(){if(this.isBrowserSupported()){if(C&&V){var e=r=>{r=r||C?.event;try{this.O(r)}catch(i){f_.error("Failed to capture event",i)}};if(Oe(V,"submit",e,{capture:!0}),Oe(V,"change",e,{capture:!0}),Oe(V,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||C?.event,this.O(r,Cp)};Oe(V,"copy",t,{capture:!0}),Oe(V,"cut",t,{capture:!0})}}}else f_.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[r_]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,r=[];return(t=this.C)==null||t.forEach((i=>{var s=V?.querySelectorAll(i);s?.forEach((o=>{e===o&&r.push(i)}))})),r}get isEnabled(){var e,t,r=(e=this.instance.persistence)==null?void 0:e.props[r_],i=this.T;if(Dt(i)&&!yn(r)&&!this.instance.M())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,i=v0(e);f0(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&iR(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===Cp;if(i&&sR(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=gR(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),t===Cp){var c,u=m0(C==null||(c=C.getSelection())==null?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return qn(V?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return bn(n)&&isFinite(n)&&Math.floor(n)===n});var g_="0123456789abcdef",fh=class n{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new n(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+g_.charAt(this.bytes[t]>>>4)+g_.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new n(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(r!==0)return Math.sign(r)}return 0}},gh=class{constructor(){this.A=0,this.j=0,this.D=new mh}generate(){var e=this.generateOrAbort();if(W(e)){this.A=0;var t=this.generateOrAbort();if(W(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return fh.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},m_,C0=n=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<n.length;e++)n[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return n};C&&!W(C.crypto)&&crypto.getRandomValues&&(C0=n=>crypto.getRandomValues(n));var mh=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(C0(this.N),this.U=0),this.N[this.U++]}},zn=()=>mR().toString(),mR=()=>(m_||(m_=new gh)).generate(),bo="",vR=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function yR(n,e){if(e){var t=(function(i,s){if(s===void 0&&(s=V),bo)return bo;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+zn();!bo&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";s.cookie=u+";max-age=3",s.cookie.includes(l)&&(s.cookie=u+";max-age=0",bo=c)}return bo})(n);if(!t){var r=(i=>{var s=i.match(vR);return s?s[0]:""})(n);r!==t&&j.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var Gt={H:()=>!!V,B:function(n){j.error("cookieStore error: "+n)},q:function(n){if(V){try{for(var e=n+"=",t=V.cookie.split(";").filter((s=>s.length)),r=0;r<t.length;r++){for(var i=t[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch{}return null}},W:function(n){var e;try{e=JSON.parse(Gt.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(V)try{var s="",o="",a=yR(V.location.hostname,r);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var c=n+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&j.warn("cookieStore warning: large cookie, len="+c.length),V.cookie=c,c}catch{return}},V:function(n,e){if(V!=null&&V.cookie)try{Gt.G(n,"",-1,e)}catch{return}}},Rp=null,Re={H:function(){if(!Dt(Rp))return Rp;var n=!0;if(W(C))n=!1;else try{var e="__mplssupport__";Re.G(e,"xyz"),Re.q(e)!=='"xyz"'&&(n=!1),Re.V(e)}catch{n=!1}return n||j.error("localStorage unsupported; falling back to cookie store"),Rp=n,n},B:function(n){j.error("localStorage error: "+n)},q:function(n){try{return C?.localStorage.getItem(n)}catch(e){Re.B(e)}return null},W:function(n){try{return JSON.parse(Re.q(n))||{}}catch{}return null},G:function(n,e){try{C?.localStorage.setItem(n,JSON.stringify(e))}catch(t){Re.B(t)}},V:function(n){try{C?.localStorage.removeItem(n)}catch(e){Re.B(e)}}},bR=["$device_id","distinct_id",Zl,p0,Yl,Kl],Dl={},_R={H:function(){return!0},B:function(n){j.error("memoryStorage error: "+n)},q:function(n){return Dl[n]||null},W:function(n){return Dl[n]||null},G:function(n,e){Dl[n]=e},V:function(n){delete Dl[n]}},Fr=null,Ue={H:function(){if(!Dt(Fr))return Fr;if(Fr=!0,W(C))Fr=!1;else try{var n="__support__";Ue.G(n,"xyz"),Ue.q(n)!=='"xyz"'&&(Fr=!1),Ue.V(n)}catch{Fr=!1}return Fr},B:function(n){j.error("sessionStorage error: ",n)},q:function(n){try{return C?.sessionStorage.getItem(n)}catch(e){Ue.B(e)}return null},W:function(n){try{return JSON.parse(Ue.q(n))||null}catch{}return null},G:function(n,e){try{C?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){Ue.B(t)}},V:function(n){try{C?.sessionStorage.removeItem(n)}catch(e){Ue.B(e)}}},gn=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),vh=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?gn.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===gn.DENIED||this.consent===gn.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===gn.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return wp(e)?gn.GRANTED:ue(RA,e)?gn.DENIED:gn.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?Re:Gt;var t=e==="localStorage"?Gt:Re;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(wp(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!c0([pt?.doNotTrack,pt?.msDoNotTrack,Q.doNotTrack],(e=>wp(e)))}},Hl=Ie("[Dead Clicks]"),xR=()=>!0,wR=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(d0)),r=n.instance.config.capture_dead_clicks;return yn(r)?r:!!Ne(r)||t},nc=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,r){this.instance=e,this.isEnabled=t,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[d0]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Hl.error("failed to load script",i):e()}))}et(){var e;if(V){if(!this.tt&&(e=Q.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Ne(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=Q.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(V),Hl.info("starting...")}}else Hl.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Hl.info("stopping..."))}},_o=Ie("[ExceptionAutocapture]"),yh=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(C&&this.isEnabled&&(s=Q.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=Q.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=Q.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=Q.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){_o.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[i_]),this.dt=new Up({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:_o}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ne(e)?t=U({},t,e):(W(e)?this.ht:e)&&(t=U({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(_o.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return _o.error("failed to load script",i);e()}))}ut(){var e,t,r;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[i_]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,r,i=(t=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(i)?_o.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function v_(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return qn(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var bh=class{constructor(e){var t;this._instance=e,this.ct=(C==null||(t=C.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(j.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,j.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(C&&C.history){var r=this;(e=C.history.pushState)!=null&&e.__posthog_wrapped__||v_(C.history,"pushState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")})),(t=C.history.replaceState)!=null&&t.__posthog_wrapped__||v_(C.history,"replaceState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")})),this.bt()}}_t(e){try{var t,r=C==null||(t=C.location)==null?void 0:t.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(i){j.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Oe(C,"popstate",e),this.ft=()=>{C&&C.removeEventListener("popstate",e)}}}},Tp=Ie("[SegmentIntegration]");function kR(n,e){var t=n.config.segment;if(!t)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var c=()=>l.anonymousId()||zn();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(fn,"identified")),i()},a=s.user();"then"in a&&qn(a.then)?a.then(o):o(a)})(n,(()=>{t.register((r=>{Promise&&Promise.resolve||Tp.warn("This browser does not have Promise support, and can not use the segment integration");var i=(s,o)=>{if(!o)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(Tp.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(Tp.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var a=r.calculateEventProperties(o,s.event.properties);return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>i(s,s.event.event),page:s=>i(s,"$pageview"),identify:s=>i(s,"$identify"),screen:s=>i(s,"$screen")}})(n)).then((()=>{e()}))}))}var A0="posthog-js";function R0(n,e){var{organization:t,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,d,h;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var g=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=g,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var v=((l=a.exception)==null?void 0:l.values)||[],f=v.map((y=>U({},y,{stacktrace:y.stacktrace?U({},y.stacktrace,{type:"raw",frames:(y.stacktrace.frames||[]).map((k=>U({},k,{platform:"web:javascript"})))}):void 0}))),m={$exception_message:((c=v[0])==null?void 0:c.value)||a.message,$exception_type:(u=v[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:f,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((d=v[0])==null?void 0:d.value)||a.message,$sentry_exception_type:(h=v[0])==null?void 0:h.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),o&&n.exceptions.sendExceptionEvent(m),a}}var _h=class{constructor(e,t,r,i,s,o){this.name=A0,this.setupOnce=function(a){a(R0(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},SR=C!=null&&C.location?tc(C.location.hash,"__posthog")||tc(location.hash,"state"):null,y_="_postHogToolbarParams",b_=Ie("[Toolbar]"),Un=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(Un||{}),xh=class{constructor(e){this.instance=e}yt(e){Q.ph_toolbar_state=e}wt(){var e;return(e=Q.ph_toolbar_state)!==null&&e!==void 0?e:Un.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),!C||!V)return!1;e=e??C.location,r=r??C.history;try{if(!t){try{C.localStorage.setItem("test","test"),C.localStorage.removeItem("test")}catch{return!1}t=C?.localStorage}var i,s=SR||tc(e.hash,"__posthog")||tc(e.hash,"state"),o=s?n_((()=>JSON.parse(atob(decodeURIComponent(s)))))||n_((()=>JSON.parse(decodeURIComponent(s)))):null;return o&&o.action==="ph_authorize"?((i=o).source="url",i&&Object.keys(i).length>0&&(o.desiredHash?e.hash=o.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(t.getItem(y_)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=Q.ph_load_toolbar||Q.ph_load_editor;!pe(t)&&qn(t)?t(e,this.instance):b_.warn("No toolbar load function found")}loadToolbar(e){var t=!(V==null||!V.getElementById(h0));if(!C||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=U({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(C.localStorage.setItem(y_,JSON.stringify(U({},i,{source:void 0}))),this.wt()===Un.LOADED)this.xt(i);else if(this.wt()===Un.UNINITIALIZED){var s;this.yt(Un.LOADING),(s=Q.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return b_.error("[Toolbar] Failed to load",o),void this.yt(Un.UNINITIALIZED);this.yt(Un.LOADED),this.xt(i)})),Oe(C,"turbolinks:load",(()=>{this.yt(Un.UNINITIALIZED),this.loadToolbar(i)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,r){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,t,r)}},ER=Ie("[TracingHeaders]"),wh=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;W(this.$t)&&((t=Q.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),W(this.St)&&((r=Q.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return ER.error("failed to load script",i);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}},Bl="https?://(.*)",Ki=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],CR=Gi(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ki),qo="<masked>",AR=["li_fat_id"];function T0(n,e,t){if(!V)return{};var r,i=e?Gi([],Ki,t||[]):[],s=I0(zo(V.URL,i,qo),n),o=(r={},ke(AR,(function(a){var l=Gt.q(a);r[a]=l||null})),r);return Me(o,s)}function I0(n,e){var t=CR.concat(e||[]),r={};return ke(t,(function(i){var s=ec(n,i);r[i]=s||null})),r}function $0(n){var e=(function(s){return s?s.search(Bl+"google.([^/?]*)")===0?"google":s.search(Bl+"bing.com")===0?"bing":s.search(Bl+"yahoo.com")===0?"yahoo":s.search(Bl+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",r={};if(!Dt(e)){r.$search_engine=e;var i=V?ec(V.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function __(){return navigator.language||navigator.userLanguage}function M0(){return V?.referrer||"$direct"}function P0(n,e){var t=n?Gi([],Ki,e||[]):[],r=ze?.href.substring(0,1e3);return{r:M0().substring(0,1e3),u:r?zo(r,t,qo):void 0}}function O0(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Ql(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=Ql(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=I0(r);Me(i,o)}if(t){var a=$0(t);Me(i,a)}return i}function N0(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function RR(){try{return new Date().getTimezoneOffset()}catch{return}}function TR(n,e){if(!ot)return{};var t,r,i,s=n?Gi([],Ki,e||[]):[],[o,a]=(function(l){for(var c=0;c<Xb.length;c++){var[u,d]=Xb[c],h=u.exec(l),g=h&&(qn(d)?d(h,l):d);if(g)return g}return["",""]})(ot);return Me(nf({$os:o,$os_version:a,$browser:s0(ot,navigator.vendor),$device:Jb(ot),$device_type:(r=ot,i=Jb(r),i===z_||i===U_||i==="Kobo"||i==="Kindle Fire"||i===i0?Do:i===Bo||i===Ui||i===Vo||i===qp?"Console":i===Z_?"Wearable":i?kt:"Desktop"),$timezone:N0(),$timezone_offset:RR()}),{$current_url:zo(ze?.href,s,qo),$host:ze?.host,$pathname:ze?.pathname,$raw_user_agent:ot.length>1e3?ot.substring(0,997)+"...":ot,$browser_version:DA(ot,navigator.vendor),$browser_language:__(),$browser_language_prefix:(t=__(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:C?.screen.height,$screen_width:C?.screen.width,$viewport_height:C?.innerHeight,$viewport_width:C?.innerWidth,$lib:"web",$lib_version:hn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Vn=Ie("[Web Vitals]"),x_=9e5,kh=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((r,i)=>U({},r,{["$web_vitals_"+i.name+"_event"]:U({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(W(s))Vn.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();W(o)||(pe(r?.name)||pe(r?.value)?Vn.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?Vn.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),W(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=W(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(U({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var r,i,s,o,a=Q.__PosthogExtensions__;W(a)||W(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):Vn.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[o_]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=Ne(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return pe(r)?((t=this._instance.persistence)==null?void 0:t.props[l_])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=Ne(this._instance.config.capture_performance)&&bn(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:x_;return 0<e&&e<=6e4?x_:e}get isEnabled(){var e=ze?.protocol;if(e!=="http:"&&e!=="https:")return Vn.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:yn(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return yn(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Vn.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=Ne(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Ne(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[o_]:t}),this._instance.persistence.register({[l_]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=Q.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,(s=>{s?Vn.error("failed to load script",s):e()}))}}Ct(){var e=C?C.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=t?Gi([],Ki,r||[]):[];return zo(e,i,qo)}Vn.error("Could not determine current URL")}},IR=Ie("[Heatmaps]");function w_(n){return Ne(n)&&"clientX"in n&&"clientY"in n&&bn(n.clientX)&&bn(n.clientY)}var Sh=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[ih]),this.rageclicks=new Jl(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return Ne(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return pe(this.instance.config.capture_heatmaps)?pe(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;IR.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ih]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return e?.visibilityState==="visible"})(V)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){C&&V&&(this.Nt=this.Lt.bind(this),Oe(C,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||C?.event),Oe(V,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||C?.event),Oe(V,"mousemove",this.zt,{capture:!0}),this.Bt=new nc(this.instance,xR,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Oe(V,"visibilitychange",this.qt),this.P=!0)}At(){var e;C&&V&&(this.Nt&&C.removeEventListener("beforeunload",this.Nt),this.Ut&&V.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&V.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&V.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=(function(a,l,c){for(var u=a;u&&fc(u)&&!Gn(u,"body");){if(u===c)return!1;if(ue(l,C?.getComputedStyle(u).position))return!0;u=b0(u)}return!1})(v0(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:t}}Dt(e,t){var r;if(t===void 0&&(t="click"),!c_(e.target)&&w_(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(U({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!c_(e.target)&&w_(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(C){var t=C.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?Gi([],Ki,i||[]):[],o=zo(t,s,qo);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!Vi(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},rc=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(j.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var r,i=this.Qt(e,t);return this.Kt={pathname:(r=C?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var r=this.Kt;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:d}=s;if(!(W(o)||W(a)||W(l)||W(c)||W(u)||W(d))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),d=Math.ceil(d);var h=o<=1?1:Kt(a/o,0,1,j),g=o<=1?1:Kt(l/o,0,1,j),v=c<=1?1:Kt(u/c,0,1,j),f=c<=1?1:Kt(d/c,0,1,j);i=Me(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:f})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}};var mn=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),St=Uint8Array,nt=Uint16Array,Zi=Uint32Array,af=new St([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),lf=new St([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),k_=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),L0=function(n,e){for(var t=new nt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new Zi(t[30]);for(r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return[t,i]},F0=L0(af,2),$R=F0[0],Eh=F0[1];$R[28]=258,Eh[258]=28;for(Ch=L0(lf,0)[1],ic=new nt(32768),Se=0;Se<32768;++Se)Wn=(43690&Se)>>>1|(21845&Se)<<1,Wn=(61680&(Wn=(52428&Wn)>>>2|(13107&Wn)<<2))>>>4|(3855&Wn)<<4,ic[Se]=((65280&Wn)>>>8|(255&Wn)<<8)>>>1;var Wn,Ch,ic,Se,No=function(n,e,t){for(var r=n.length,i=0,s=new nt(e);i<r;++i)++s[n[i]-1];var o,a=new nt(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new nt(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var c=i<<4|n[i],u=e-n[i],d=a[n[i]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[ic[d]>>>l]=c}else for(o=new nt(r),i=0;i<r;++i)o[i]=ic[a[n[i]-1]++]>>>15-n[i];return o},Vr=new St(288);for(Se=0;Se<144;++Se)Vr[Se]=8;for(Se=144;Se<256;++Se)Vr[Se]=9;for(Se=256;Se<280;++Se)Vr[Se]=7;for(Se=280;Se<288;++Se)Vr[Se]=8;var sc=new St(32);for(Se=0;Se<32;++Se)sc[Se]=5;var MR=No(Vr,9,0),PR=No(sc,5,0),D0=function(n){return(n/8>>0)+(7&n&&1)},H0=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof nt?nt:n instanceof Zi?Zi:St)(t-e);return r.set(n.subarray(e,t)),r},dn=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},xo=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},Ip=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return[new St(0),0];if(i==1){var o=new St(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(x,R){return x.f-R.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,d=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=t[t[c].f<t[d].f?c++:d++],l=t[c!=u&&t[c].f<t[d].f?c++:d++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=s[0].s;for(r=1;r<i;++r)s[r].s>h&&(h=s[r].s);var g=new nt(h+1),v=Ah(t[u-1],g,0);if(v>e){r=0;var f=0,m=v-e,y=1<<m;for(s.sort((function(x,R){return g[R.s]-g[x.s]||x.f-R.f}));r<i;++r){var k=s[r].s;if(!(g[k]>e))break;f+=y-(1<<v-g[k]),g[k]=e}for(f>>>=m;f>0;){var _=s[r].s;g[_]<e?f-=1<<e-g[_]++-1:++r}for(;r>=0&&f;--r){var b=s[r].s;g[b]==e&&(--g[b],++f)}v=e}return[new St(g),v]},Ah=function(n,e,t){return n.s==-1?Math.max(Ah(n.l,e,t+1),Ah(n.r,e,t+1)):e[n.s]=t},S_=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new nt(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return[t.subarray(0,r),e]},wo=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},Rh=function(n,e,t){var r=t.length,i=D0(e+2);n[i]=255&r,n[i+1]=r>>>8,n[i+2]=255^n[i],n[i+3]=255^n[i+1];for(var s=0;s<r;++s)n[i+s+4]=t[s];return 8*(i+4+r)},E_=function(n,e,t,r,i,s,o,a,l,c,u){dn(e,u++,t),++i[256];for(var d=Ip(i,15),h=d[0],g=d[1],v=Ip(s,15),f=v[0],m=v[1],y=S_(h),k=y[0],_=y[1],b=S_(f),x=b[0],R=b[1],w=new nt(19),E=0;E<k.length;++E)w[31&k[E]]++;for(E=0;E<x.length;++E)w[31&x[E]]++;for(var $=Ip(w,7),P=$[0],M=$[1],G=19;G>4&&!P[k_[G-1]];--G);var L,N,z,H,oe=c+5<<3,A=wo(i,Vr)+wo(s,sc)+o,F=wo(i,h)+wo(s,f)+o+14+3*G+wo(w,P)+(2*w[16]+3*w[17]+7*w[18]);if(oe<=A&&oe<=F)return Rh(e,u,n.subarray(l,l+c));if(dn(e,u,1+(F<A)),u+=2,F<A){L=No(h,g,0),N=h,z=No(f,m,0),H=f;var X=No(P,M,0);for(dn(e,u,_-257),dn(e,u+5,R-1),dn(e,u+10,G-4),u+=14,E=0;E<G;++E)dn(e,u+3*E,P[k_[E]]);u+=3*G;for(var fe=[k,x],de=0;de<2;++de){var He=fe[de];for(E=0;E<He.length;++E){var Ce=31&He[E];dn(e,u,X[Ce]),u+=P[Ce],Ce>15&&(dn(e,u,He[E]>>>5&127),u+=He[E]>>>12)}}}else L=MR,N=Vr,z=PR,H=sc;for(E=0;E<a;++E)if(r[E]>255){Ce=r[E]>>>18&31,xo(e,u,L[Ce+257]),u+=N[Ce+257],Ce>7&&(dn(e,u,r[E]>>>23&31),u+=af[Ce]);var Et=31&r[E];xo(e,u,z[Et]),u+=H[Et],Et>3&&(xo(e,u,r[E]>>>5&8191),u+=lf[Et])}else xo(e,u,L[r[E]]),u+=N[r[E]];return xo(e,u,L[256]),u+N[256]},OR=new Zi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),NR=(function(){for(var n=new Zi(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),LR=function(n,e,t,r,i){return(function(s,o,a,l,c,u){var d=s.length,h=new St(l+d+5*(1+Math.floor(d/7e3))+c),g=h.subarray(l,h.length-c),v=0;if(!o||d<8)for(var f=0;f<=d;f+=65535){var m=f+65535;m<d?v=Rh(g,v,s.subarray(f,m)):(g[f]=u,v=Rh(g,v,s.subarray(f,d)))}else{for(var y=OR[o-1],k=y>>>13,_=8191&y,b=(1<<a)-1,x=new nt(32768),R=new nt(b+1),w=Math.ceil(a/3),E=2*w,$=function(vc){return(s[vc]^s[vc+1]<<w^s[vc+2]<<E)&b},P=new Zi(25e3),M=new nt(288),G=new nt(32),L=0,N=0,z=(f=0,0),H=0,oe=0;f<d;++f){var A=$(f),F=32767&f,X=R[A];if(x[F]=X,R[A]=F,H<=f){var fe=d-f;if((L>7e3||z>24576)&&fe>423){v=E_(s,g,0,P,M,G,N,z,oe,f-oe,v),z=L=N=0,oe=f;for(var de=0;de<286;++de)M[de]=0;for(de=0;de<30;++de)G[de]=0}var He=2,Ce=0,Et=_,Ct=F-X&32767;if(fe>2&&A==$(f-Ct))for(var gc=Math.min(k,fe)-1,Yi=Math.min(32767,f),Pe=Math.min(258,fe);Ct<=Yi&&--Et&&F!=X;){if(s[f+He]==s[f+He-Ct]){for(var Ht=0;Ht<Pe&&s[f+Ht]==s[f+Ht-Ct];++Ht);if(Ht>He){if(He=Ht,Ce=Ct,Ht>gc)break;var Q0=Math.min(Ct,Ht-2),gf=0;for(de=0;de<Q0;++de){var mc=f-Ct+de+32768&32767,mf=mc-x[mc]+32768&32767;mf>gf&&(gf=mf,X=mc)}}}Ct+=(F=X)-(X=x[F])+32768&32767}if(Ce){P[z++]=268435456|Eh[He]<<18|Ch[Ce];var vf=31&Eh[He],yf=31&Ch[Ce];N+=af[vf]+lf[yf],++M[257+vf],++G[yf],H=f+He,++L}else P[z++]=s[f],++M[s[f]]}}v=E_(s,g,u,P,M,G,N,z,oe,f-oe,v)}return H0(h,0,l+D0(v)+c)})(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,r,!0)},$p=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function FR(n,e){e===void 0&&(e={});var t=(function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=NR[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=n.length;t.p(n);var i,s=LR(n,e,10+((i=e).filename&&i.filename.length+1||0),8),o=s.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&$p(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(s,e),$p(s,o-8,t.d()),$p(s,o-4,r),s}var DR=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
|
|
1161
1161
|
`).replace(/\r/g,`
|
|
1162
|
-
`)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Dt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},HR=!!Bp||!!Hp,C_="text/plain",oc=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=U({},e),a=(r=s?.split("&").map((c=>{var u,[d,h]=c.split("="),g=t&&(u=o[d])!==null&&u!==void 0?u:h;return delete o[d],d+"="+g})))!==null&&r!==void 0?r:[],l=pR(o);return l&&a.push(l),i+"?"+a.join("&")},Mo=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),Mp=n=>{var{data:e,compression:t}=n;if(e){if(t===mn.GZipJS){var r=FR((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var d=new St(l.length+(l.length>>>1)),h=0,g=function(y){d[h++]=y},v=0;v<u;++v){if(h+5>d.length){var f=new St(h+8+(u-v<<1));f.set(d),d=f}var m=l.charCodeAt(v);m<128||c?g(m):m<2048?(g(192|m>>>6),g(128|63&m)):m>55295&&m<57344?(g(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++v))>>>18),g(128|m>>>12&63),g(128|m>>>6&63),g(128|63&m)):(g(224|m>>>12),g(128|m>>>6&63),g(128|63&m))}return H0(d,0,h)})(Mo(e)),{mtime:0}),i=new Blob([r],{type:C_});return{contentType:C_,body:i,estimatedSize:i.size}}if(t===mn.Base64){var s=(function(l){var c,u,d,h,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,m=0,y="",k=[];if(!l)return l;l=DR(l);do c=(g=l.charCodeAt(f++)<<16|l.charCodeAt(f++)<<8|l.charCodeAt(f++))>>18&63,u=g>>12&63,d=g>>6&63,h=63&g,k[m++]=v.charAt(c)+v.charAt(u)+v.charAt(d)+v.charAt(h);while(f<l.length);switch(y=k.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(Mo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Mo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Mo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},jl=[];Hp&&jl.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=Mp(n))!==null&&e!==void 0?e:{},o=new Headers;ke(n.headers,(function(u,d){o.append(d,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(qb){var c=new qb;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}Hp(a,U({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then((u=>u.text().then((d=>{var h={statusCode:u.status,text:d};if(u.status===200)try{h.json=JSON.parse(d)}catch(g){j.error(g)}n.callback==null||n.callback(h)})))).catch((u=>{j.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Bp&&jl.push({transport:"XHR",method:n=>{var e,t=new Bp;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=Mp(n))!==null&&e!==void 0?e:{};ke(n.headers,(function(s,o){t.setRequestHeader(o,s)})),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),pt!=null&&pt.sendBeacon&&jl.push({transport:"sendBeacon",method:n=>{var e=oc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=Mp(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;pt.sendBeacon(e,s)}catch{}}});var ac=function(n,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function A_(n,e,t){return Mo({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var B0={exact:(n,e)=>e.some((t=>n.some((r=>t===r)))),is_not:(n,e)=>e.every((t=>n.every((r=>t!==r)))),regex:(n,e)=>e.some((t=>n.some((r=>ac(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!ac(t,r))))),icontains:(n,e)=>e.map(Vl).some((t=>n.map(Vl).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(Vl).every((t=>n.map(Vl).every((r=>!t.includes(r))))),gt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r>parseFloat(i)))})),lt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r<parseFloat(i)))}))},Vl=n=>n.toLowerCase();function V0(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(W(s)||Dt(s))return!1;var o=[String(s)],a=B0[i.operator];return!!a&&a(i.values,o)}))}var Pp=Ie("[Error tracking]"),Th=class{constructor(e){var t,r;this.Zt=[],this.ti=new Gp([new Yp,new rh,new Jp,new Xp,new th,new eh,new Qp,new nh],GA()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(sh))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[sh]:this.Zt,[s_]:o})}get ii(){var e,t=!!this._instance.get_property(s_),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void Pp.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void Pp.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void Pp.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Le(s)&&s.length>0&&r.$exception_types.push(s),Le(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Zt.some((r=>{var i=r.values.map((s=>{var o,a=B0[s.operator],l=me(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}si(e){return e.flatMap((t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!pe(e)&&me(e)}},dt=Ie("[FeatureFlags]"),ko=Ie("[FeatureFlags]",{debugEnabled:!0}),Op="$active_feature_flags",Li="$override_feature_flags",R_="$feature_flag_payloads",So="$override_feature_flag_payloads",T_="$feature_flag_request_id",I_="$feature_flag_evaluated_at",$_=n=>{var e={};for(var[t,r]of Wl(n||{}))r&&(e[t]=r);return e},BR=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]}))),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload})).map((t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]})))):dt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},VR=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),Ih=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(dt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||dt.error("Invalid evaluation context found:",r,"Expected non-empty string"),i})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(oh),t=this._instance.get_property(Li),r=this._instance.get_property(So);if(!r&&!t)return e||{};var i=Me({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],d=W(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,h=W(u)?c.variant:typeof u=="string"?u:void 0,g=r?.[o],v=U({},c,{enabled:d,variant:d?h??c?.variant:void 0});d!==c?.enabled&&(v.original_enabled=c?.enabled),h!==c?.variant&&(v.original_variant=c?.variant),g&&(v.metadata=U({},c?.metadata,{payload:g,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=v}return this.oi||(dt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(Wi),t=this._instance.get_property(Li);if(!t)return e||{};for(var r=Me({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(dt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(R_),t=this._instance.get_property(So);if(!t)return e||{};for(var r=Me({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(dt.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout((()=>{this.mi()}),5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:U({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property($o)||{}),group_properties:this._instance.get_property(Hr)};Dt(i)||W(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=N0()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:mn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var d,h,g=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),g=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((h=u.json)!==null&&h!==void 0?h:{})),!s.disable_flags||this.hi)if(this.vi=!g,u.json&&(d=u.json.quotaLimited)!=null&&d.includes(VR.FeatureFlags))dt.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var v;s.disable_flags||this.receivedFeatureFlags((v=u.json)!==null&&v!==void 0?v:{},g),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}dt.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(T_)||void 0,c=this._instance.get_property(I_)||void 0,u=this._instance.get_property(Gl)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var d,h,g,v,f,m,y,k,_;me(u[e])?u[e].push(a):u[e]=[a],(d=this._instance.persistence)==null||d.register({[Gl]:u});var b=this.getFeatureFlagDetails(e),x={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((h=this._instance.config.bootstrap)==null||(h=h.featureFlags)==null?void 0:h[e])||null,$feature_flag_bootstrapped_payload:((g=this._instance.config.bootstrap)==null||(g=g.featureFlagPayloads)==null?void 0:g[e])||null,$used_bootstrap_value:!this.vi};W(b==null||(v=b.metadata)==null?void 0:v.version)||(x.$feature_flag_version=b.metadata.version);var R,w=(f=b==null||(m=b.reason)==null?void 0:m.description)!==null&&f!==void 0?f:b==null||(y=b.reason)==null?void 0:y.code;w&&(x.$feature_flag_reason=w),b!=null&&(k=b.metadata)!=null&&k.id&&(x.$feature_flag_id=b.metadata.id),W(b?.original_variant)&&W(b?.original_enabled)||(x.$feature_flag_original_response=W(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(_=b.metadata)!=null&&_.original_payload&&(x.$feature_flag_original_payload=b==null||(R=b.metadata)==null?void 0:R.original_payload),this._instance.capture("$feature_flag_called",x)}if(i){var E=o;if(!W(o))try{E=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:E}}}else dt.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:mn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return W(r)?void 0:!!r}dt.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var d=BR(o),h=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var f=o.requestId,m=o.evaluatedAt;if(me(g)){dt.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(g)for(var k=0;k<g.length;k++)y[g[k]]=!0;a&&a.register({[Op]:g,[Wi]:y})}else{var _=g,b=v,x=h;if(o.errorsWhileComputingFlags)if(h){var R=new Set(Object.keys(h).filter((w=>{var E;return!((E=h[w])!=null&&E.failed)})));_=U({},l,Object.fromEntries(Object.entries(_).filter((w=>{var[E]=w;return R.has(E)})))),b=U({},c,Object.fromEntries(Object.entries(b||{}).filter((w=>{var[E]=w;return R.has(E)})))),x=U({},u,Object.fromEntries(Object.entries(x||{}).filter((w=>{var[E]=w;return R.has(E)}))))}else _=U({},l,_),b=U({},c,b),x=U({},u,x);a&&a.register(U({[Op]:Object.keys($_(_)),[Wi]:_||{},[R_]:b||{},[oh]:x||{}},f?{[T_]:f}:{},m?{[I_]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),dt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return dt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Li),this._instance.persistence.unregister(So),this.wi(),ko.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Li),ko.info("Flag overrides cleared");else if(r.flags){if(me(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[Li]:i})}else this._instance.persistence.register({[Li]:r.flags});ko.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(So),ko.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[So]:r.payloads}),ko.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(Io)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=U({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[Op]:Object.keys($_(l)),[Wi]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Io),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Io),(l=this._instance.persistence)==null||l.register({[Io]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((r=>t[r])),flagVariants:Object.keys(t).filter((r=>t[r])).reduce(((r,i)=>(r[i]=t[i],r)),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach((i=>i(t,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property($o)||{};this._instance.register({[$o]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister($o)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Hr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=U({},r[i],e[i]),delete e[i]})),this._instance.register({[Hr]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Hr)||{};this._instance.register({[Hr]:U({},t,{[e]:{}})})}else this._instance.unregister(Hr)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},WR=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Lo=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.Si(e),this.load(),e.debug&&j.info("Persistence loaded",e.persistence,U({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){WR.indexOf(e.persistence.toLowerCase())===-1&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(i){i===void 0&&(i=[]);var s=[...bR,...i];return U({},Re,{W:function(o){try{var a={};try{a=Gt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Re.q(o)||"{}"));return Re.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,d){try{Re.G(o,a,void 0,void 0,d);var h={};s.forEach((g=>{a[g]&&(h[g]=a[g])})),Object.keys(h).length&&Gt.G(o,h,l,c,u,d)}catch(g){Re.B(g)}},V:function(o,a){try{C?.localStorage.removeItem(o),Gt.V(o,a)}catch(l){Re.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Re.H()?Re:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&Ue.H()?Ue:r==="memory"?_R:r==="cookie"?Gt:t.H()?t:Gt}properties(){var e={};return ke(this.props,(function(t,r){if(r===Wi&&Ne(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(Dt(o=nR)?l:zb&&o.indexOf===zb?o.indexOf(a)!=-1:(ke(o,(function(c){if(l||(l=c===a))return ql})),l))||(e[r]=t);var o,a,l})),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=Me({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(Ne(e)){W(t)&&(t="None"),this.Pi=W(r)?this.Ci:r;var i=!1;if(ke(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(Ne(e)){this.Pi=W(t)?this.Ci:t;var r=!1;if(ke(e,((i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Ei){var e=T0(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Vi(nf(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=V?.referrer)?$0(e):{})}update_referrer_info(){var e;this.register_once({$referrer:M0(),$referring_domain:V!=null&&V.referrer&&((e=Ql(V.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[uh]||this.props[dh]||this.register_once({[Kl]:P0(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ke([dh,uh],(o=>{var a=this.props[o];a&&ke(a,(function(l,c){e["$initial_"+Vp(c)]=l}))}));var t,r,i=this.props[Kl];if(i){var s=(t=O0(i),r={},ke(t,(function(o,a){r["$initial_"+Vp(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return ke(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this.Ci=this.Pi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,d)=>u===c[d]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[To]||{};r[e]=t,this.props[To]=r,this.save()}remove_event_timer(e){var t=(this.props[To]||{})[e];return W(t)||(delete this.props[To][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},M_=Ie("[Product Tours]"),Np="ph_product_tours",$h=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[a_]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(a_)||this.it((()=>this.Oi()))}it(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?M_.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=Q.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=Q.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!me(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[Np];if(me(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return M_.error(a),void e([],{isLoaded:!1,error:a})}var l=me(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[Np]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){pe(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(Np)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},Eo=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),sD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),oD=(function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n})({}),aD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Lp=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),lD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),cD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),uD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),Po=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Fp=(function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n})({}),Mh=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Ie("[Surveys]"),W0="seenSurvey_",jR=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},P_=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(W0,n),UR=[Lp.Popover,Lp.Widget,Lp.API],zR={ignoreConditions:!1,ignoreDelay:!1,displayType:Mh.Popover},jo=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter((r=>r!==t))}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function Fi(n,e,t){if(pe(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var Ph=class{constructor(e){this.Ai=new jo,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!W((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((r,i)=>{this.on(r,i)}))}}register(e){var t,r;if(!W((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.zi)==null||u.add(c?.event||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&s.add(l?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach((i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)}))}qi(e){this.onAction("actionCaptured",(t=>e(t)))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!Fi(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some((a=>Fi(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Fi((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some((c=>Fi(c.text,t.text,t.text_matching||"exact")||Fi(c.$el_text,t.text,t.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(c){for(var u,d=[],h=/(?::|")text="(.*?)"/g;!pe(u=h.exec(c));)d.includes(u[1])||d.push(u[1]);return d})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>Fi(c,o,a))))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||V0(t.properties.reduce(((r,i)=>{var s=me(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r}),{}),e?.properties)}},Oh=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&V0(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach((o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}}))})),r}te(e,t,r){var i=(r===Eo.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie((o=>{s=o.filter((a=>i?.includes(a.id)))})),s.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Qi(l,t)}))}register(e){var t;W((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=e.filter((r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0}));t.length!==0&&(this.se==null&&(this.se=new Ph(this._instance),this.se.init(),this.se.qi((r=>{this.onAction(r)}))),t.forEach((r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}})))})))}ee(e){var t,r=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((s,o)=>{this.onEvent(s,o)})),this.Ki=this.Zi(e,Eo.Activation),this.Yi=this.Zi(e,Eo.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var d=a.indexOf(u);d>=0&&(a.splice(d,1),this.le(a))}}else{if(this.Yi.has(e)){var h=this.te(e,t,Eo.Cancellation);h.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map((v=>v.id))}),h.forEach((v=>{var f=a.indexOf(v.id);f>=0&&a.splice(f,1),this.ue(v.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var g=this.te(e,t,Eo.Activation);this.le(a.concat(g.map((v=>v.id))||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter((o=>!this.he(o)));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},Nh=class extends Oh{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Po.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return we}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Lh=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(pe(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=me(t);this.ve=r?t.length>0:t,we.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(W0)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)we.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)we.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())we.info("Not loading surveys in cookieless mode without consent.");else{var e=Q?.__PosthogExtensions__;if(e){if(!W(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)}))}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else we.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Nh(this._instance),we.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){we.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return we.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(ah);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then((s=>{var{surveys:o,context:a}=s;return e(o,a)})):(typeof Promise<"u"&&(this.pe=new Promise((s=>{r=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;we.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,d=s.json.surveys||[],h=d.filter((v=>(function(f){return!(!f.start_date||f.end_date)})(v)&&((function(f){var m;return!((m=f.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(v)||(function(f){var m;return!((m=f.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(v))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(o=this._instance.persistence)==null||o.register({[ah]:d});var g={isLoaded:!0};e(d,g),r?.({surveys:d,context:g})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){we.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!pe(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);we.warn("init was not called")}be(e){var t=null;return this.getSurveys((r=>{var i;t=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),t}ye(e){if(pe(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(pe(this._surveyManager))return we.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return pe(this._surveyManager)?(we.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var s,o=(s=i.find((l=>l.id===e)))!==null&&s!==void 0?s:null;if(o){var a=this.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,r){var i;if(pe(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(UR.includes(s.type)){var o=V?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(we.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;we.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),we.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);we.warn("Survey element not found")}else we.warn("Surveys of type "+s.type+" cannot be rendered in the app");else we.warn("Survey not found")}}displaySurvey(e,t){var r;if(pe(this._surveyManager))we.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=U({},i,{appearance:U({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Mh.Popover&&t.initialResponses&&we.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void we.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Mh.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){pe(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},pn=Ie("[Conversations]"),Fh=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;pe(t)||(yn(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Q?.__PosthogExtensions__;if(e&&!W(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1}))}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else pn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),pn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else pn.error("Cannot complete initialization: remote config is null")}Se(e,t){pn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():pn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Dt(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return Bi((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(pn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return Bi((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(pn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Bi((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(pn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Bi((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(pn.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Dh=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!pe(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Ie("[logs]"),t=Q?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},O_=Ie("[RateLimiter]"),Hh=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((i=>{O_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void O_.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(ch))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(ch,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},Dr=Ie("[RemoteConfig]"),Bh=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Q._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Dr.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Dr.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Dr.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return Dr.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie((t=>{this.yi(t)}));this.yi(e)}))}catch(e){Dr.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Dr.info("__preview_remote_config is disabled. Logging config instead",e):Dr.error("Failed to fetch remote config from PostHog.")}},Vh=3e3,Wh=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Kt(t?.flush_interval_ms||Vh,250,5e3,j.createLogger("flush interval"),Vh),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter((r=>r.url.indexOf("/e")===0)),...t.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Oe(U({},r,{transport:"sendBeacon"}))}))}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout((()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&me(s.data)&&ke(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Oe(s)};for(var i in t)r()}}),this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return ke(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;W(e[s])&&(e[s]=U({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},qR=["retriesPerformedSoFar"],jh=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!W(C)&&"onLine"in C.navigator&&(this.Ue=C.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Oe(C,"online",this.ze),Oe(C,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=B_(e,qR);Di(t)&&(r.url=oc(r.url,{retry_count:t})),this._instance._send_request(U({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(U({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),j.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout((()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()}),this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter((s=>s.retryAt<e||(t.push(s),!1)));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,W(C)||(this.ze&&(C.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(C.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(U({},e,{transport:"sendBeacon"}))}catch(t){j.error(t)}this.Re=[]}},Uh=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){Oe(C,"scroll",this.Ge,{capture:!0}),Oe(C,"scrollend",this.Ge,{capture:!0}),Oe(C,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return C?.document.documentElement;var e=me(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=C?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return C&&(C.scrollY||C.pageYOffset||C.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return C&&(C.scrollX||C.pageXOffset||C.document.documentElement.scrollLeft)||0}},ZR=n=>P0(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),lc=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[lh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||ZR,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[lh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?O0(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return ke(nf(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Vp(r)]=t})),e}},Dp=Ie("[SessionId]"),cc=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new jo,this.er=(u,d)=>!(!Di(u)||!Di(d))&&Math.abs(u-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||zn,this.ar=r||zn;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Kt(o,60,36e3,Dp.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=Ue.W(this.ur),l=Ue.W(this.hr);a&&!l?this.rr=a:Ue.V(this.ur),Ue.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var d=u.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Dp.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return W(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&Ue.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&Ue.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?Ue.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[Zl]:[t,e,r]}))}_r(){var e=this.Xe.props[Zl];return me(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&C&&(C.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&Ue.V(this.hr)},Oe(C,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=Di(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,d=!u&&!e&&this.er(r,i);u||d||l?(s=this.nr(),a=this.ar(),Dp.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var h=Di(i)&&e&&!l?i:r,g=Di(o)?o:new Date().getTime();return this.pr(a),this.vr(s,h,g),e||this.lr(),c&&this.tr.forEach((v=>v(s,a,c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout((()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},GR=["$set_once","$set"],jn=Ie("[SiteApps]"),zh=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=Q._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,g]of Object.entries(d))c[h]={id:u[h],type:h,properties:g};var{$set_once:v,$set:f}=e;return{event:U({},B_(e,GR),{properties:U({},e.properties,f?{$set:U({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},f)}:{},v?{$set_once:U({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},v)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(jn.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,jn.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(t.processEvent=o),i=!0}catch(a){jn.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){jn.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){jn.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",(c=>this.$r(c)))):void jn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;Q["__$$ph_site_app_"+c]=s._instance,(u=Q.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(d=>{if(d)return jn.error("Error while initializing PostHog app with config id "+c,d)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else jn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},j0=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Gb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Gb(i?.brand,e))))return!0}catch{}return!!n.webdriver},Oo=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),N_="i.posthog.com",qh=class{constructor(e){this.Sr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+N_,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Oo.EU:this.Sr[this.apiHost]=Oo.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Oo.CUSTOM)return this.apiHost+t;var r=N_+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},KR={icontains:(n,e)=>!!C&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!C&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!C&&ac(e.href,n),not_regex:(n,e)=>!!C&&!ac(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Zh=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments((i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);Le(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(pe(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach((t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=ec(e?.search,"__experiment_id"),r=ec(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments((i=>{this.Cr(parseInt(t),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}Cr(e,t,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!pe(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(pe(e.conditions)||pe((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||KR[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return C?.location}static Fr(e){var t;if(pe(e.conditions)||pe((t=e.conditions)==null?void 0:t.utm))return!0;var r=T0();if(r.utm_source){var i,s,o,a,l,c,u,d,h=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,f=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return h&&v&&f&&g}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];j.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach((i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):n.kr("Control variants leave the page unmodified.")}_is_bot(){return pt&&this._instance?j0(pt,this._instance.config.custom_blocked_useragents):void 0}},YR=Ie("[PostHog ExternalIntegrations]"),XR={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Gh=class{constructor(e){this._instance=e}it(e,t){var r;(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return YR.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=Q.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(XR[o],(()=>{var u;(u=Q.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=Q.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=Q.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Kh="[SessionRecording]",Co=Ie(Kh),uc=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw Co.error("started without valid sessionManager"),new Error(Kh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Kh+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(Ep))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return C&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!W(Object.assign)&&!W(Array.from);this.Ar&&r?(this.Dr(e),Co.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(Q!=null&&(t=Q.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=Q.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=Q.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return Co.error("could not load recorder",s);this.Lr(e)})))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(p0)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=pe(a)?null:parseFloat(a);pe(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[Ep]:U({enabled:!!o},o,{networkPayloadCapture:U({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:W(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:Co.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):Co.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Ep);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=Q.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=Q.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},Fo={},Yh=()=>{},Hi="posthog",U0=!HR&&ot?.indexOf("MSIE")===-1&&ot?.indexOf("Mozilla")===-1,L_=n=>{var e;return U({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:tR(V?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Yh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:ze&&Le(ze?.search)&&ze.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(C==null||(e=C.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;j.error(r)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Vh},error_tracking:{},_onCapture:Yh,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},F_=n=>{var e={};W(n.process_person)||(e.person_profiles=n.process_person),W(n.xhr_headers)||(e.request_headers=n.xhr_headers),W(n.cookie_name)||(e.persistence_name=n.cookie_name),W(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),W(n.store_google)||(e.save_campaign_params=n.store_google),W(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return me(n.property_blacklist)&&(W(n.property_denylist)?t.property_denylist=n.property_blacklist:me(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:j.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Xh=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},dc=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Xh,this.Br=!1,this.version=hn.LIB_VERSION,this.qr=new jo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=L_(),this.SentryIntegration=_h,this.sentryIntegration=e=>(function(t,r){var i=R0(t,r);return{name:A0,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new Ih(this),this.toolbar=new xh(this),this.scrollManager=new Uh(this),this.pageViewManager=new rc(this),this.surveys=new Lh(this),this.conversations=new Fh(this),this.logs=new Dh(this),this.experiments=new Zh(this),this.exceptions=new Th(this),this.rateLimiter=new Hh(this),this.requestRouter=new qh(this),this.consent=new vh(this),this.externalIntegrations=new Gh(this),this.people={set:(e,t,r)=>{var i=Le(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Le(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>j.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==Hi){var i,s=(i=Fo[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Fo[r]=s,Fo[Hi][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),W(e)||Wp(e))return j.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Me({},L_(t.defaults),F_(t),{name:r,token:e})),this.config.on_xhr_error&&j.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:mn.GZipJS;var s=this.Qr();this.persistence=new Lo(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Lo(U({},this.config,{persistence:"sessionStorage"}),s);var o=U({},this.persistence.props),a=U({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Wh((k=>this.ts(k)),this.config.request_queue_config),this.es=new jh(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new cc(this),this.sessionPropsManager=new lc(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(j.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(j.info("Initializing extensions synchronously"),this.rs(l)),hn.DEBUG=hn.DEBUG||this.config.debug,hn.DEBUG&&j.info("Starting in debug mode",{this:this,config:t,thisC:U({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,d=this.config.get_device_id(zn()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?d:t.bootstrap.distinctID;this.persistence.set_property(fn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var g,v,f=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlags)||{}).filter((k=>{var _;return!((_=t.bootstrap)==null||(_=_.featureFlags)==null||!_[k])})).reduce(((k,_)=>{var b;return k[_]=((b=t.bootstrap)==null||(b=b.featureFlags)==null?void 0:b[_])||!1,k}),{}),m=Object.keys(((v=t.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((k=>f[k])).reduce(((k,_)=>{var b,x;return(b=t.bootstrap)!=null&&(b=b.featureFlagPayloads)!=null&&b[_]&&(k[_]=(x=t.bootstrap)==null||(x=x.featureFlagPayloads)==null?void 0:x[_]),k}),{});this.featureFlags.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:yo,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(zn());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(fn,"anonymous")}return Oe(C,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?kR(this,(()=>this.ns())):this.ns(),qn(this.config._onCapture)&&this.config._onCapture!==Yh&&(j.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&j.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new bh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new wh(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new zh(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new uc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new hh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new $h(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Sh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new kh(this)})),r.push((()=>{this.exceptionObserver=new yh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new nc(this,wR),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}})),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var r=e.shift();if(r)try{r()}catch(s){j.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&j.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!V||!V.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.yi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=ue(e.supportedCompression,mn.GZipJS)?mn.GZipJS:ue(e.supportedCompression,mn.Base64)?mn.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){j.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&ze!=null&&ze.hostname){var e=ze.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new Bh(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Zn(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(U0?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=oc(e.url,{ip:this.config.ip?1:0}),e.headers=U({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var r,i,s,o=U({},t);o.timeout=o.timeout||6e4,o.url=oc(o.url,{_:new Date().getTime().toString(),ver:hn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=jl.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=c0(l,(u=>u.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(U({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];Zn(e,(a=>{a&&(t=a[0],me(t)?s.push(a):qn(a)?a.call(this):me(a)&&t==="alias"?r.push(a):me(a)&&t.indexOf("capture")!==-1&&qn(this[t])?s.push(a):i.push(a))}));var o=function(a,l){Zn(a,(function(c){if(me(c[0])){var u=l;ke(c,(function(d){u=u[d[0]].apply(u,d.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!W(e)&&Le(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!Le(t?.$current_url)&&(j.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=r?.timestamp||a,c=zn(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var d,h=e!=="$groupidentify",g=this.vs(r?.$set_once,h);if(g&&(u.$set_once=g),(u=QA(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,W(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Po.DISMISSED||e===Po.SENT){var v=t?.[Fp.SURVEY_ID],f=t?.[Fp.SURVEY_ITERATION];d={id:v,current_iteration:f},localStorage.getItem(P_(d))||localStorage.setItem(P_(d),"true"),u.$set=U({},u.$set,{[jR({id:v,current_iteration:f},e===Po.SENT?"responded":"dismissed")]:!0})}else e===Po.SHOWN&&(u.$set=U({},u.$set,{[Fp.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=U({},u.properties.$set,u.$set);if(Vi(m)||this.setPersonPropertiesForFlags(m),!pe(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var k={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(k):this.Zr.enqueue(k),u}j.critical("This capture call is ignored due to client rate limiting.")}}else j.error("No event name provided to posthog.capture")}else j.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=U({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=U({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Le(a.distinct_id)&&!bn(a.distinct_id)||Wp(a.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=TR(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=d,a.$window_id=h}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.es)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===Oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Me(a,c),e==="$pageview"&&V&&(a.title=V.title),!W(o)){var v=r.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}ot&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Me({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),me(this.config.property_denylist)?ke(this.config.property_denylist,(function(y){delete a[y]})):j.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(j.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this.fs();return a.$process_person_profile=m,m&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=Me({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(j.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),Vi(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=U({},i,e),a=U({},s,t),l={};for(var[c,u]of Object.entries(o)){var d=typeof u=="string";l[c]={key:c,enabled:!!d||!!u,variant:d?u:void 0,reason:void 0,metadata:W(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=zR),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(bn(e)&&(e=e.toString(),j.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==yo){if(this.ps("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(Ro)&&(this.unregister(Ro),this.register({distinct_id:e}));var o=(this.persistence.get_property(fn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(fn,"identified"),this.setPersonPropertiesForFlags(U({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=A_(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Gl))}}else j.critical('The string "'+yo+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else j.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=A_(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(U({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):j.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:U({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else j.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(j.info("reset"),!this.__loaded)return j.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(fn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:yo,$device_id:null},"");else{var a=this.config.get_device_id(zn());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,t){return e===this.get_property(u0)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(W(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Ro,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=U({},this.config);if(Ne(e)){var r,i,s,o,a,l,c;Me(this.config,F_(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Lo(U({},this.config,{persistence:"sessionStorage"}),u);var d=this.Kr(this.config.debug);yn(d)&&(this.config.debug=d),yn(this.config.debug)&&(this.config.debug?(hn.DEBUG=!0,Re.H()&&Re.G("ph_debug","true"),j.info("set_config",{config:e,oldConfig:t,newConfig:U({},this.config)})):(hn.DEBUG=!1,Re.H()&&Re.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(U({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Hi;return t!==Hi&&(t=Hi+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(fn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(fn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Vi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Ro])&&((t=this.persistence)==null||(t=t.props)==null||!t[Yl]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(j.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(Yl,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new cc(this),this.pageViewManager=new rc(this),this.persistence&&(this.sessionPropsManager=new lc(this,this.sessionManager,this.persistence)),this.sessionRecording=new uc(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(W(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else j.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:yo,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):j.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===gn.GRANTED?"granted":e===gn.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return pt?j0(pt,this.config.custom_blocked_useragents):void 0}hs(){V&&(V.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:V.title},{send_instantly:!0}),this.Gr&&(V.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Oe(V,"visibilitychange",this.Gr)))}debug(e){e===!1?(C?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(C?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(j.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=j,o=(t="advanced_disable_flags")in(e=l)&&!pe(e[t]),a=r in e&&!pe(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(pe(this.config.before_send))return e;var t=me(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),pe(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return CA(e.event)?j.warn(s+". This can cause unexpected behavior."):j.info(s),null}r.properties&&!Vi(r.properties)||j.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=yn(e)&&!e,r=Re.H()&&Re.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=JA(n.prototype[e[t]])})(dc,["identify"]);var D_;var z0=(D_=Fo[Hi]=new dc,(function(){function n(){n.done||(n.done=!0,U0=!1,ke(Fo,(function(e){e._dom_loaded()})))}V!=null&&V.addEventListener?V.readyState==="complete"?n():Oe(V,"DOMContentLoaded",n,{capture:!1}):C&&j.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),D_);var cf=class{constructor(e={}){this.options=e;if(this.client=e.client,this.featureFlagsCallback=e.onFeatureFlagsLoaded,this.captureCallback=e.onCapture,this.rrwebCallback=e.onRRWebEvent,!this.client&&e.consent&&e.requireExplicitConsent&&typeof window<"u"&&e.apiKey){let t=e.consent;t.getStatus()==="granted"&&this.initPostHog(),t.subscribe(i=>{i==="granted"?this.client?this.client.opt_in_capturing():this.initPostHog():i==="denied"&&this.client&&this.client.opt_out_capturing()});return}!this.client&&typeof window<"u"&&e.apiKey&&this.initPostHog()}initPostHog(){let e=this.options;if(!e.apiKey)return;let t=e.enableFeatureFlags??!0,r=`syntro_${e.apiKey.slice(-6)||"sdk"}`,o={api_host:`${(e.apiHost??"https://telemetry.syntrologie.com").replace(/\/$/,"")}/t/${e.apiKey}`,advanced_disable_feature_flags:!t,advanced_disable_feature_flags_on_first_load:!t,autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??"history_change",capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),opt_out_useragent_filter:!0,session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0},a=z0.init(e.apiKey,o,r);if(a&&(this.client=a),this.captureCallback&&this.client&&this.client.on("eventCaptured",(...l)=>{let c=l[0],u=typeof c=="string"?c:c?.event,d=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,d)}),t&&this.featureFlagsCallback&&this.client){this.client.onFeatureFlags(()=>{let c=this.getAllFeatureFlags();c&&this.featureFlagsCallback&&this.featureFlagsCallback(c)});let l=this.getAllFeatureFlags();l&&Object.keys(l).length>0&&this.featureFlagsCallback(l)}this.rrwebCallback&&this.client&&this.setupRRWebIntercept()}setupRRWebIntercept(e=30){let t=this.client?.sessionRecording;if(!t){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let r=null,i=t;for(let o of Object.getOwnPropertyNames(i)){let a=i[o];if(a&&typeof a=="object"&&typeof a.onRRwebEmit=="function"&&typeof a.start=="function"&&a!==t){r=a;break}}if(!r){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let s=r.onRRwebEmit.bind(r);r.onRRwebEmit=o=>{this.rrwebCallback?.({kind:"rrweb",...o}),s(o)},typeof window<"u"&&(window.__RRWEB_INTERCEPT_READY__=!0)}getAllFeatureFlags(){return this.client?.featureFlags?.getFlagVariants()}getSegmentFlags(){let e=this.getAllFeatureFlags();if(!e)return{};let t={};for(let[r,i]of Object.entries(e))r.startsWith("in_segment_")&&(t[r]=i===!0);return t}identify(e,t){this.client?.identify(e,t)}alias(e,t){this.client?.alias(e,t)}track(e,t){this.client?.capture(e,t)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,t){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:t})}trackAction(e,t,r){this.track("shadow_canvas_action",{action:e,rectangleId:t,surface:r})}register(e){this.client?.register?.(e)}getSessionId(){return this.client?.get_session_id?.()}startSessionRecording(){this.client?.startSessionRecording?.()}trackExperiment(e,t,r){let i=`$experiment_${e}`;this.register({[i]:r??`variation_${t}`,[`${i}_id`]:t}),this.track("$experiment_started",{$experiment_key:e,$experiment_variation_id:t,$experiment_variation_name:r??`variation_${t}`})}setPersonProperties(e){this.client?.capture("$set",{$set:e})}setPersonPropertiesOnce(e){this.client?.capture("$set",{$set_once:e})}getDistinctId(){return this.client?.get_distinct_id?.()}};function uf(n={}){return new cf(n)}var q0={posthog:n=>uf(n),noop:()=>xp()};function Z0(n,e){let t=q0[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(q0).join(", ")}`);return t(e)}async function G0(n){Ru(),K("Syntro Bootstrap","====== INIT ======"),K("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=al();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",to()),console.log("[DIAG] editorConf:",ol()),K("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let A=!!window.__SYNTRO_EDITOR_PARAMS__,F=!!window.__SYNTRO_AUDIT_LEGEND__,X=!!window.__SYNTRO_REVIEW_DATA__;if(A||F||X){let fe=[A&&"__SYNTRO_EDITOR_PARAMS__",F&&"__SYNTRO_AUDIT_LEGEND__",X&&"__SYNTRO_REVIEW_DATA__"].filter(Boolean);console.warn(`[Syntro Bootstrap] \u26A0 Mode detection returned null but mode-specific globals found: ${fe.join(", ")}. This suggests URL params were lost (redirect?) but the service worker injected mode data. Check if replaceState failed or if page JS changed the URL before init().`)}}console.log(`[DIAG] Token resolution: options.token=${n.token?n.token.slice(0,15)+"...":"null"}`);let t=n.token;if(!t&&e){let F=ol()?.syntro_token;F?.startsWith("syn_")&&(t=F,K("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))K("Syntro Bootstrap","Token starts with syn_, decoding..."),r=no(t),Ru(r.d);else if(e)K("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw Ba("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),Ba("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)K("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw Ba("Syntro Bootstrap","\u274C No token provided and NOT in editor/audit/review mode!"),new Error("Syntro token is required (unless in editor, audit, or review mode)");let i=wt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||wt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=wt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||wt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th,o=wt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||wt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||wt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||wt("VITE_SYNTRO_GEO_HOST")||Ny,l=My(),c=Rd(),u=n.appSignalsInit??{},d={...c,...l,...u};K("Syntro Bootstrap","Phase 1: Browser metadata:",c),K("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&K("Syntro Bootstrap","Phase 1: App signals:",u);let h=Td(a),g=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(A=>{let F=setTimeout(()=>{window.removeEventListener("message",X),A(null)},500);function X(fe){let de=fe.data;de?.jsonrpc==="2.0"&&de?.id===1&&de?.result?.hostInfo&&(clearTimeout(F),window.removeEventListener("message",X),A(de.result.hostInfo))}window.addEventListener("message",X);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(F),window.removeEventListener("message",X),A(null)}})})(),v,f=n.debug||n.testMode,m=ro({debug:n.debug,history:f?new io(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let y=ku({elementResolver:typeof window<"u"?(A,F)=>{let X=document.elementFromPoint(A,F);if(!X)return null;let fe={tag_name:X.tagName.toLowerCase()};X.id&&(fe.attr__id=X.id),X.className&&typeof X.className=="string"&&(fe.classes=X.className.split(" ").filter(Boolean));for(let de of X.attributes)de.name.startsWith("data-")&&(fe[`attr__${de.name}`]=de.value);return fe}:void 0});y.onEvent(A=>m.publishEvent(A)),typeof window<"u"&&(setInterval(()=>y.tick(Date.now()),1e3),document.addEventListener("click",A=>{let F=[],X=A.target;for(;X&&X!==document.body;){let fe={tag_name:X.tagName.toLowerCase()};for(let de of X.attributes)(de.name.startsWith("data-")||de.name==="id"||de.name==="class"||de.name==="aria-label")&&(fe[`attr__${de.name}`]=de.value);F.push(fe),X=X.parentElement}y.enrichClickAttributes(Date.now(),F)},!0));let k=Tb(),_,b=A=>{K("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let F=Oy(A);if(K("Syntro Bootstrap","Segment flags from PostHog:",F),Py(F),v){let X=R?.getAll?.()??{},fe={...c,...X,...F,...u};K("Syntro Bootstrap","Updating GrowthBook with attributes:",fe),v.setAttributes?.(fe)}if(_&&x?.getDistinctId){let X=x.getDistinctId();X&&s&&r?.t&&_.updateContext({distinctId:X,telemetryHost:s,telemetryKey:r.t})}},x;if(r?.t){let A=r.t==="noop"?"noop":"posthog";x=Z0(A,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,onFeatureFlagsLoaded:b,onCapture:(X,fe)=>{y.ingest({kind:"posthog",event:X,properties:fe,timestamp:Date.now()})},onRRWebEvent:X=>{y.ingest(X)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${A}) with EventBus wiring`),Object.keys(u).length>0&&(x.track?.("app_signals_init",u),K("Syntro Bootstrap","Tracked app signals event:",u));let F=x;if(m.setPosthogCapture((X,fe)=>{F.track?.(X,fe)}),k?.name==="shopify"&&s)try{_=new Il({distinctId:x.getDistinctId?.()??"",telemetryHost:s,telemetryKey:r.t}),K("Syntro Bootstrap","ShopifyPixelBridge initialized for checkout attribution")}catch(X){Qe("Syntro Bootstrap","ShopifyPixelBridge init failed",X)}}let R;r?.e&&(v=kb("growthbook",{clientKey:r.e,apiHost:i,attributes:d,onExperimentViewed:x?.trackExperiment?(A,F,X)=>{x.trackExperiment(A,F,X)}:void 0})),R=Qd({experiments:v,onMetricChange:(A,F)=>{K("Syntro Bootstrap",`Session metric changed: ${A} = ${F}`)}}),K("Syntro Bootstrap","SessionMetricTracker created");let w="production";e==="editor"?w="editor":e==="audit"?w="audit":wt("NODE_ENV")==="development"&&(w="development");let E=bp({telemetry:x,sessionMetrics:R,mode:w,events:m});K("Syntro Bootstrap","Runtime created:",{version:E.version,mode:E.mode,hasContext:!!E.context,hasEvents:!!E.events,hasState:!!E.state}),K("Syntro Bootstrap","Core app executors already registered");let $=n.cdnBase||wt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||wt("VITE_SYNTRO_CDN_BASE")||"https://cdn.syntrologie.com",P=Xc({cdnBase:$,registry:E.apps,onLoadStart:A=>{K("Syntro Bootstrap",`Loading app from CDN: ${A}`)},onLoadEnd:(A,F,X)=>{F?K("Syntro Bootstrap",`App loaded successfully: ${A}`):Qe("Syntro Bootstrap",`Failed to load app: ${A}`,X)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:E.apps,runtime:E,version:E.version},K("Syntro Bootstrap","Global SynOS object exposed"));let M=E.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${M.length} apps in registry:`,M.map(A=>`${A.manifest.id}(${A.state})`).join(", "));for(let A of M)if(A.state==="registered")try{await E.apps.activate(A.manifest.id),console.log(`[DIAG] Activated: ${A.manifest.id} \u2192 widgets: [${E.widgets.list().join(", ")}]`)}catch(F){console.error(`[DIAG] FAILED to activate: ${A.manifest.id}`,F),Qe("Syntro Bootstrap",`Failed to auto-activate built-in app: ${A.manifest.id}`,F)}if(console.log(`[DIAG] Activation complete. Total widgets: [${E.widgets.list().join(", ")}]`),v?.refreshFeatures)try{await v.refreshFeatures(),K("Syntro Bootstrap","GrowthBook features loaded")}catch(A){Qe("Syntro Bootstrap","Failed to load GrowthBook features:",A)}let G=await h;if(v&&Object.keys(G).length>0){let A={...c,...G,...u};K("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",G),v.setAttributes?.(A)}let L=await g;L&&v&&(c.surface_type="mcp-app",c.surface_host=L.name,v.setAttributes?.({...c,...G}),K("Syntro Bootstrap","MCP App detected:",L.name));let N;if(n.fetcher)N=n.fetcher;else if(r?.f){let A=Ab(r.f,r.o??{});N=async()=>{let F=await A.fetch();return{...F.config,tiles:F.config.tiles??[]}}}else v&&(N=hi({experiments:v}));let z=new Set,H=N?async()=>{let A=await N(),F=A.tiles?.length??0,X=A.actions?.length??0,fe=A.meta?.variant_id;if((F>0||X>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),x&&fe){let Ce=new vo(x,fe);Ce.trackServed(F,X),typeof window<"u"&&(window.SynOS.interventionTracker=Ce),E.navigation.subscribe(()=>{Ce.resetPage()})}console.log("[Syntro Bootstrap] Config fetched:",`tiles=${A.tiles?.length??0},`,`actions=${A.actions?.length??0},`,`theme=${A.theme?.name??"none"}`),A.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",A.actions.map((Ce,Et)=>`[${Et}] ${Ce.kind}${Ce.anchorId?` anchor="${Ce.anchorId.selector}"`:""}${Ce.label?` "${Ce.label}"`:""}`).join(", "));let de=A,He=P.getRequiredApps(de);return He.length>0?console.log("[Syntro Bootstrap] Required external apps:",He.join(", ")):K("Syntro Bootstrap","No external apps required (all executors are built-in)"),He.length>0&&await P.loadAppsForConfig(de).then(async Et=>{let Ct=Et.filter(Pe=>Pe.success),gc=Et.filter(Pe=>!Pe.success);Ct.length>0&&console.log(`[Syntro Bootstrap] Apps loaded from CDN: ${Ct.map(Pe=>Pe.appId).join(", ")}`);let Yi=gc.filter(Pe=>!z.has(Pe.appId));Yi.length>0&&(console.error("[Syntro Bootstrap] Apps FAILED to load from CDN:",Yi.map(Pe=>`${Pe.appId} (${Pe.error})`).join(", ")),Yi.forEach(Pe=>z.add(Pe.appId)));for(let Pe of He)if(E.apps.has(Pe))try{await E.apps.activate(Pe),console.log(`[Syntro Bootstrap] App activated: ${Pe}`)}catch(Ht){console.error(`[Syntro Bootstrap] Failed to activate app: ${Pe}`,Ht)}else console.error(`[Syntro Bootstrap] App "${Pe}" required by config but NOT registered.`,`Available apps: [${Array.from(E.apps.list?.()??[]).join(", ")}]`)}),A}:void 0;if(k){K("Syntro Bootstrap",`Detected platform: ${k.name}`);try{await k.onInit(),K("Syntro Bootstrap",`Platform adapter initialized: ${k.name}`)}catch(A){Qe("Syntro Bootstrap",`Platform adapter init failed: ${k.name}`,A)}}return{canvas:await Ed({...n.canvas,fetcher:H,integrations:{experiments:v,telemetry:x},editorUrl:o,runtime:E,platformAdapter:k??void 0}),runtime:E,experiments:v,telemetry:x,sessionMetrics:R,appLoader:P}}async function JR(n){try{return await G0(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function QR(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}var K0={init:JR,encodeToken:Ad,decodeToken:no,events:{emit:QR}};typeof window<"u"&&(window.Syntro=K0);function Zo(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function VD(n){let e=[],t=[];if(!n||typeof n!="object")return{valid:!1,errors:["Config must be an object"],warnings:e};let r=n;if(r.tiles||t.push("Config missing required field: tiles"),r.actions||t.push("Config missing required field: actions"),r.fetchedAt||t.push("Config missing required field: fetchedAt"),t.length>0)return{valid:!1,errors:t,warnings:e};let i=r.schemaVersion||"1.0",s=Zo(i),o=Zo(En);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${En}. Some features may not work. Update SDK to latest version.`),s.major<o.major||!r.schemaVersion?(e.push(`Config schema v${i} is older than SDK v${En}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:eT(r,i)}):{valid:!0,warnings:e,errors:t}}function eT(n,e){let t={...n};return Zo(e).major===1&&(t=tT(t)),t.schemaVersion=En,t}function tT(n){let e={schemaVersion:"2.0",tiles:[],actions:n.actions||[],fetchedAt:n.fetchedAt||new Date().toISOString()};return n.tiles&&Array.isArray(n.tiles)&&(e.tiles=n.tiles.map(t=>{let r={...t};return t.experiment&&delete r.experiment,r})),n.configVersion&&(e.configVersion=n.configVersion),n.canvasTitle&&(e.canvasTitle=n.canvasTitle),n.theme&&(e.theme=n.theme),n.launcher&&(e.launcher=n.launcher),e}function WD(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Zo(t),i=Zo(En);return r.major<i.major||!e.schemaVersion}var nT=p.object({url:p.string(),routeId:p.string().optional(),title:p.string().optional(),locale:p.string().optional()}),rT=p.object({url:p.string(),ts:p.number()}),iT=p.object({sessionId:p.string(),startTs:p.number(),pageHistory:p.array(rT).optional()}),sT=p.object({width:p.number(),height:p.number()}),oT=p.object({x:p.number(),y:p.number(),w:p.number(),h:p.number()}),aT=p.object({anchorId:p.string(),present:p.boolean(),visible:p.boolean().optional(),boundingBox:oT.optional()}),lT=p.record(p.string(),p.union([p.number(),p.string(),p.boolean(),p.undefined()])),cT=p.object({page:nT,session:iT,viewport:sT,anchors:p.array(aT).optional(),augmented:lT.optional()});function zD(n){return cT.safeParse(n)}var df=class{constructor(e,t,r,i){this._isFallback=!0;this._isLoading=!0;this._cancelled=!1;this._host=e,this._runtime=t,this._strategy=r,this._defaultValue=i,this._value=i,e.addController(this)}get value(){return this._value}get isFallback(){return this._isFallback}get isLoading(){return this._isLoading}hostConnected(){this._evaluate()}hostDisconnected(){this._cancelled=!0}setStrategy(e){this._strategy=e,this._evaluate()}_evaluate(){if(this._cancelled=!1,!this._runtime||!this._strategy){this._value=this._defaultValue,this._isFallback=!0,this._isLoading=!1,this._host.requestUpdate();return}this._isLoading=!0,this._host.requestUpdate();let e=this._strategy;this._runtime.evaluate(e).then(t=>{this._cancelled||(this._value=t.value,this._isFallback=t.isFallback,this._isLoading=!1,this._host.requestUpdate())})}};var pf=class{constructor(e,t){this._unsubscribe=null;this.host=e,this._runtime=t,this._context=t.context.get(),e.addController(this)}hostConnected(){this._context=this._runtime.context.get(),this._unsubscribe=this._runtime.context.subscribe(e=>{this._context=e,this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}get runtime(){return this._runtime}get context(){return this._context}get page(){return this._context?.page??null}get session(){return this._context?.session??null}get viewport(){return this._context?.viewport??null}};var hf=class{constructor(e,t,r,i){this._host=e,this._runtime=t,this._filter=r,this._callback=i,e.addController(this)}hostConnected(){this._subscribe()}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0}setFilter(e){this._filter=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}setCallback(e){this._callback=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}_subscribe(){this._runtime&&(this._unsubscribe=this._filter?this._runtime.events.subscribe(this._filter,this._callback):this._runtime.events.subscribe(this._callback))}};var Y0=p.enum(["posthog","canvas","derived"]),uT=p.object({ts:p.number(),name:p.string(),source:Y0,props:p.record(p.string(),p.unknown()).optional(),schemaVersion:p.string()}),dT=p.object({names:p.array(p.string()).optional(),patterns:p.array(p.string()).optional(),sources:p.array(Y0).optional()});function g4(n){return uT.safeParse(n)}function m4(n){return dT.safeParse(n)}var X0=p.union([p.object({type:p.literal("data"),key:p.string(),value:p.string().optional()}),p.object({type:p.literal("css"),value:p.string()}),p.object({type:p.literal("aria"),role:p.string().optional(),label:p.string().optional()}),p.object({type:p.literal("shadow-css"),value:p.string()}),p.object({type:p.literal("ref"),el:p.any()})]),pT=p.object({kind:p.literal("tooltip"),id:p.string(),anchor:X0,content:p.object({title:p.string().optional(),body:p.string()}),placement:p.enum(["top","bottom","left","right","auto"]).optional(),offsetPx:p.number().optional(),blocking:p.boolean().optional(),trigger:p.enum(["immediate","hover","click"]).optional(),dismiss:p.object({onEsc:p.boolean().optional(),closeButton:p.boolean().optional(),timeoutMs:p.number().optional()}).optional()}),hT=p.object({kind:p.literal("highlight"),id:p.string(),anchor:X0,copy:p.string().optional(),ring:p.object({paddingPx:p.number().optional(),radiusPx:p.number().optional()}).optional(),scrim:p.object({opacity:p.number().optional()}).optional(),ringColor:p.string().optional(),blocking:p.boolean().optional(),dismiss:p.object({onClickOutside:p.boolean().optional(),onEsc:p.boolean().optional(),timeoutMs:p.number().optional()}).optional()}),ff=p.object({id:p.string(),version:p.number(),routes:p.array(p.string()).optional(),steps:p.array(p.union([pT,hT]))});function $4(n){return ff.parse(n)}var N4=({configUri:n,experiments:e,featureKey:t="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=Iu({configUri:n,experiments:e,featureKey:t});if(!i)throw new Error("SmartCanvas overlays: recipe URI missing (env + feature unset).");let s=await fetch(i,{credentials:r});if(!s.ok)throw new Error(`SmartCanvas overlays: failed to fetch recipe (${s.status})`);let o=await s.json();return ff.parse(o)};var fT=p.object({value:p.unknown(),expiresAt:p.number().optional()}),gT=p.object({count:p.number(),resetAt:p.number().optional()});function D4(n){return fT.safeParse(n)}function H4(n){return gT.safeParse(n)}var J0="2026-04-25T05:54:57.098Z (4d142d719fa)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${J0} (Lit)`);let n=window.SynOS,e=n?.appRegistry||ys;window.SynOS={...n,appRegistry:e,_runtimeBuild:J0,_renderer:"lit"},Ua(),tv(e)}export{mo as ANIMATION_KEYFRAMES,il as ActivationConfigZ,oy as AddClassZ,xt as AnchorIdZ,aT as AnchorStateZ,ud as AnchorVisibleConditionZ,vs as AppRegistry,lT as AugmentationZ,Kv as BadgePositionZ,py as BadgeZ,oT as BoundingBoxZ,Os as CanvasEvents,ff as CanvasRecipeZ,Ln as ConditionZ,$l as ContextManager,md as CooldownActiveConditionZ,Zs as CounterDefZ,xd as CtaButtonZ,Eu as DEFAULT_COOLDOWN,df as DecisionController,Qs as DecisionStrategyZ,gd as DismissedConditionZ,$e as EVENT_SCHEMA_VERSION,cl as EventBus,yd as EventCountConditionZ,dT as EventFilterZ,io as EventHistory,dd as EventOccurredConditionZ,Y0 as EventSourceZ,Ga as ExecutorRegistry,Js as ExternalStrategyZ,gT as FrequencyEntryZ,vd as FrequencyLimitConditionZ,hT as HighlightStepZ,Gv as HighlightStyleZ,uy as HighlightZ,cy as InsertHtmlZ,Qv as InsertPositionZ,vo as InterventionTracker,Su as MAX_VISIBLE_TOASTS,qs as MatchOpZ,Jv as ModalContentZ,fy as ModalZ,Xs as ModelStrategyZ,vy as MountWidgetZ,my as NavigateZ,po as NavigationMonitor,uT as NormalizedEventZ,Ps as NotificationsController,nT as PageContextZ,rT as PageHistoryEntryZ,ld as PageUrlConditionZ,_y as ParallelZ,Yv as PlacementZ,dy as PulseZ,J0 as RUNTIME_SDK_BUILD,jb as RUNTIME_VERSION,ay as RemoveClassZ,cd as RouteConditionZ,Zv as RouteFilterZ,Ks as RuleStrategyZ,Gs as RuleZ,cT as RuntimeContextZ,pf as RuntimeController,hf as RuntimeEventsController,En as SDK_SCHEMA_VERSION,Tu as SDK_VERSION,Hb as STATIC_SLOT_STYLES,Ys as ScoreStrategyZ,ry as ScrollBehaviorZ,_d as ScrollLogicalPositionZ,gy as ScrollToZ,X0 as SelectorZ,by as SequenceZ,iT as SessionContextZ,fd as SessionMetricConditionZ,Al as SessionMetricTracker,sy as SetAttrZ,ly as SetStyleZ,iy as SetTextZ,$u as SmartCanvasController,mi as SmartCanvasElementLit,We as StandardEvents,pd as StateEqualsConditionZ,Ol as StateStore,fT as StoredValueZ,K0 as Syntro,Ns as ThemeController,Xv as TooltipContentZ,pT as TooltipStepZ,ey as TooltipTriggerZ,hy as TooltipZ,ny as TourStepForSchemaZ,xy as TourZ,rl as TriggerWhenZ,hd as ViewportConditionZ,sT as ViewportContextZ,yy as WaitZ,ty as WidgetConfigZ,Ll as WidgetRegistry,cp as applyStaticSlotStyles,X1 as coreActionStepSchemas,id as createActionEngine,wd as createAnchorResolver,hi as createCanvasConfigFetcher,np as createContextManager,rp as createDecisionEngine,ip as createEventAccumulator,ro as createEventBus,Yd as createGrowthBookClient,xp as createNoopClient,N4 as createOverlayRecipeFetcher,uf as createPostHogClient,sv as createPostHogNormalizer,Qd as createSessionMetricTracker,Ed as createSmartCanvas,dv as createSmartCanvasController,bp as createSmartCanvasRuntime,lp as createStateStore,fp as createSurfaceContainer,mp as createSurfaces,UN as decisionSchemas,no as decodeToken,Ad as encodeToken,Ob as evaluate,$b as evaluateCondition,Mb as evaluateRule,Ml as evaluateRuleStrategy,Pl as evaluateScoreStrategy,Nb as evaluateSync,rn as executorRegistry,J1 as getAntiFlickerSnippet,CE as getExecutor,Nl as getSlotAnchorId,go as getSlotType,gp as getSlotZIndex,Wu as hasExecutor,WD as needsMigration,$s as normalizePostHogEvent,Zo as parseVersion,pp as playEnterAnimation,hp as playExitAnimation,fi as registerConfigPredicates,Ua as registerSmartCanvasElement,Iu as resolveConfigUri,vE as runtimeContext,up as setupAdjacentPositioning,dp as setupInlinePositioning,Ms as shouldNormalizeEvent,Wt as validateAction,Xa as validateActions,jN as validateActivationConfig,VN as validateCondition,VD as validateConfig,m4 as validateEventFilter,Id as validateEventName,H4 as validateFrequencyEntry,g4 as validateNormalizedEvent,$d as validateProps,$4 as validateRecipe,zD as validateRuntimeContext,D4 as validateStoredValue,WN as validateStrategy,vp as widgetRegistry};
|
|
1162
|
+
`)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Dt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},HR=!!Bp||!!Hp,C_="text/plain",oc=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=U({},e),a=(r=s?.split("&").map((c=>{var u,[d,h]=c.split("="),g=t&&(u=o[d])!==null&&u!==void 0?u:h;return delete o[d],d+"="+g})))!==null&&r!==void 0?r:[],l=pR(o);return l&&a.push(l),i+"?"+a.join("&")},Mo=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),Mp=n=>{var{data:e,compression:t}=n;if(e){if(t===mn.GZipJS){var r=FR((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var d=new St(l.length+(l.length>>>1)),h=0,g=function(y){d[h++]=y},v=0;v<u;++v){if(h+5>d.length){var f=new St(h+8+(u-v<<1));f.set(d),d=f}var m=l.charCodeAt(v);m<128||c?g(m):m<2048?(g(192|m>>>6),g(128|63&m)):m>55295&&m<57344?(g(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++v))>>>18),g(128|m>>>12&63),g(128|m>>>6&63),g(128|63&m)):(g(224|m>>>12),g(128|m>>>6&63),g(128|63&m))}return H0(d,0,h)})(Mo(e)),{mtime:0}),i=new Blob([r],{type:C_});return{contentType:C_,body:i,estimatedSize:i.size}}if(t===mn.Base64){var s=(function(l){var c,u,d,h,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,m=0,y="",k=[];if(!l)return l;l=DR(l);do c=(g=l.charCodeAt(f++)<<16|l.charCodeAt(f++)<<8|l.charCodeAt(f++))>>18&63,u=g>>12&63,d=g>>6&63,h=63&g,k[m++]=v.charAt(c)+v.charAt(u)+v.charAt(d)+v.charAt(h);while(f<l.length);switch(y=k.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(Mo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Mo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Mo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},jl=[];Hp&&jl.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=Mp(n))!==null&&e!==void 0?e:{},o=new Headers;ke(n.headers,(function(u,d){o.append(d,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(qb){var c=new qb;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}Hp(a,U({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then((u=>u.text().then((d=>{var h={statusCode:u.status,text:d};if(u.status===200)try{h.json=JSON.parse(d)}catch(g){j.error(g)}n.callback==null||n.callback(h)})))).catch((u=>{j.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Bp&&jl.push({transport:"XHR",method:n=>{var e,t=new Bp;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=Mp(n))!==null&&e!==void 0?e:{};ke(n.headers,(function(s,o){t.setRequestHeader(o,s)})),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),pt!=null&&pt.sendBeacon&&jl.push({transport:"sendBeacon",method:n=>{var e=oc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=Mp(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;pt.sendBeacon(e,s)}catch{}}});var ac=function(n,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function A_(n,e,t){return Mo({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var B0={exact:(n,e)=>e.some((t=>n.some((r=>t===r)))),is_not:(n,e)=>e.every((t=>n.every((r=>t!==r)))),regex:(n,e)=>e.some((t=>n.some((r=>ac(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!ac(t,r))))),icontains:(n,e)=>e.map(Vl).some((t=>n.map(Vl).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(Vl).every((t=>n.map(Vl).every((r=>!t.includes(r))))),gt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r>parseFloat(i)))})),lt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r<parseFloat(i)))}))},Vl=n=>n.toLowerCase();function V0(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(W(s)||Dt(s))return!1;var o=[String(s)],a=B0[i.operator];return!!a&&a(i.values,o)}))}var Pp=Ie("[Error tracking]"),Th=class{constructor(e){var t,r;this.Zt=[],this.ti=new Gp([new Yp,new rh,new Jp,new Xp,new th,new eh,new Qp,new nh],GA()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(sh))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[sh]:this.Zt,[s_]:o})}get ii(){var e,t=!!this._instance.get_property(s_),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void Pp.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void Pp.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void Pp.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Le(s)&&s.length>0&&r.$exception_types.push(s),Le(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Zt.some((r=>{var i=r.values.map((s=>{var o,a=B0[s.operator],l=me(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}si(e){return e.flatMap((t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!pe(e)&&me(e)}},dt=Ie("[FeatureFlags]"),ko=Ie("[FeatureFlags]",{debugEnabled:!0}),Op="$active_feature_flags",Li="$override_feature_flags",R_="$feature_flag_payloads",So="$override_feature_flag_payloads",T_="$feature_flag_request_id",I_="$feature_flag_evaluated_at",$_=n=>{var e={};for(var[t,r]of Wl(n||{}))r&&(e[t]=r);return e},BR=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]}))),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload})).map((t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]})))):dt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},VR=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),Ih=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(dt.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||dt.error("Invalid evaluation context found:",r,"Expected non-empty string"),i})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(oh),t=this._instance.get_property(Li),r=this._instance.get_property(So);if(!r&&!t)return e||{};var i=Me({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],d=W(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,h=W(u)?c.variant:typeof u=="string"?u:void 0,g=r?.[o],v=U({},c,{enabled:d,variant:d?h??c?.variant:void 0});d!==c?.enabled&&(v.original_enabled=c?.enabled),h!==c?.variant&&(v.original_variant=c?.variant),g&&(v.metadata=U({},c?.metadata,{payload:g,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=v}return this.oi||(dt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(Wi),t=this._instance.get_property(Li);if(!t)return e||{};for(var r=Me({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(dt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(R_),t=this._instance.get_property(So);if(!t)return e||{};for(var r=Me({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(dt.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout((()=>{this.mi()}),5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:U({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property($o)||{}),group_properties:this._instance.get_property(Hr)};Dt(i)||W(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=N0()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:mn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var d,h,g=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),g=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((h=u.json)!==null&&h!==void 0?h:{})),!s.disable_flags||this.hi)if(this.vi=!g,u.json&&(d=u.json.quotaLimited)!=null&&d.includes(VR.FeatureFlags))dt.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var v;s.disable_flags||this.receivedFeatureFlags((v=u.json)!==null&&v!==void 0?v:{},g),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}dt.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(T_)||void 0,c=this._instance.get_property(I_)||void 0,u=this._instance.get_property(Gl)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var d,h,g,v,f,m,y,k,_;me(u[e])?u[e].push(a):u[e]=[a],(d=this._instance.persistence)==null||d.register({[Gl]:u});var b=this.getFeatureFlagDetails(e),x={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((h=this._instance.config.bootstrap)==null||(h=h.featureFlags)==null?void 0:h[e])||null,$feature_flag_bootstrapped_payload:((g=this._instance.config.bootstrap)==null||(g=g.featureFlagPayloads)==null?void 0:g[e])||null,$used_bootstrap_value:!this.vi};W(b==null||(v=b.metadata)==null?void 0:v.version)||(x.$feature_flag_version=b.metadata.version);var R,w=(f=b==null||(m=b.reason)==null?void 0:m.description)!==null&&f!==void 0?f:b==null||(y=b.reason)==null?void 0:y.code;w&&(x.$feature_flag_reason=w),b!=null&&(k=b.metadata)!=null&&k.id&&(x.$feature_flag_id=b.metadata.id),W(b?.original_variant)&&W(b?.original_enabled)||(x.$feature_flag_original_response=W(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(_=b.metadata)!=null&&_.original_payload&&(x.$feature_flag_original_payload=b==null||(R=b.metadata)==null?void 0:R.original_payload),this._instance.capture("$feature_flag_called",x)}if(i){var E=o;if(!W(o))try{E=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:E}}}else dt.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:mn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return W(r)?void 0:!!r}dt.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var d=BR(o),h=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var f=o.requestId,m=o.evaluatedAt;if(me(g)){dt.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(g)for(var k=0;k<g.length;k++)y[g[k]]=!0;a&&a.register({[Op]:g,[Wi]:y})}else{var _=g,b=v,x=h;if(o.errorsWhileComputingFlags)if(h){var R=new Set(Object.keys(h).filter((w=>{var E;return!((E=h[w])!=null&&E.failed)})));_=U({},l,Object.fromEntries(Object.entries(_).filter((w=>{var[E]=w;return R.has(E)})))),b=U({},c,Object.fromEntries(Object.entries(b||{}).filter((w=>{var[E]=w;return R.has(E)})))),x=U({},u,Object.fromEntries(Object.entries(x||{}).filter((w=>{var[E]=w;return R.has(E)}))))}else _=U({},l,_),b=U({},c,b),x=U({},u,x);a&&a.register(U({[Op]:Object.keys($_(_)),[Wi]:_||{},[R_]:b||{},[oh]:x||{}},f?{[T_]:f}:{},m?{[I_]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),dt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return dt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Li),this._instance.persistence.unregister(So),this.wi(),ko.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Li),ko.info("Flag overrides cleared");else if(r.flags){if(me(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[Li]:i})}else this._instance.persistence.register({[Li]:r.flags});ko.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(So),ko.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[So]:r.payloads}),ko.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(Io)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=U({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[Op]:Object.keys($_(l)),[Wi]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Io),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Io),(l=this._instance.persistence)==null||l.register({[Io]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((r=>t[r])),flagVariants:Object.keys(t).filter((r=>t[r])).reduce(((r,i)=>(r[i]=t[i],r)),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach((i=>i(t,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property($o)||{};this._instance.register({[$o]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister($o)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Hr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=U({},r[i],e[i]),delete e[i]})),this._instance.register({[Hr]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Hr)||{};this._instance.register({[Hr]:U({},t,{[e]:{}})})}else this._instance.unregister(Hr)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},WR=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Lo=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.Si(e),this.load(),e.debug&&j.info("Persistence loaded",e.persistence,U({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){WR.indexOf(e.persistence.toLowerCase())===-1&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(i){i===void 0&&(i=[]);var s=[...bR,...i];return U({},Re,{W:function(o){try{var a={};try{a=Gt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Re.q(o)||"{}"));return Re.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,d){try{Re.G(o,a,void 0,void 0,d);var h={};s.forEach((g=>{a[g]&&(h[g]=a[g])})),Object.keys(h).length&&Gt.G(o,h,l,c,u,d)}catch(g){Re.B(g)}},V:function(o,a){try{C?.localStorage.removeItem(o),Gt.V(o,a)}catch(l){Re.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Re.H()?Re:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&Ue.H()?Ue:r==="memory"?_R:r==="cookie"?Gt:t.H()?t:Gt}properties(){var e={};return ke(this.props,(function(t,r){if(r===Wi&&Ne(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(Dt(o=nR)?l:zb&&o.indexOf===zb?o.indexOf(a)!=-1:(ke(o,(function(c){if(l||(l=c===a))return ql})),l))||(e[r]=t);var o,a,l})),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=Me({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(Ne(e)){W(t)&&(t="None"),this.Pi=W(r)?this.Ci:r;var i=!1;if(ke(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(Ne(e)){this.Pi=W(t)?this.Ci:t;var r=!1;if(ke(e,((i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Ei){var e=T0(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Vi(nf(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=V?.referrer)?$0(e):{})}update_referrer_info(){var e;this.register_once({$referrer:M0(),$referring_domain:V!=null&&V.referrer&&((e=Ql(V.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[uh]||this.props[dh]||this.register_once({[Kl]:P0(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ke([dh,uh],(o=>{var a=this.props[o];a&&ke(a,(function(l,c){e["$initial_"+Vp(c)]=l}))}));var t,r,i=this.props[Kl];if(i){var s=(t=O0(i),r={},ke(t,(function(o,a){r["$initial_"+Vp(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return ke(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this.Ci=this.Pi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,d)=>u===c[d]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[To]||{};r[e]=t,this.props[To]=r,this.save()}remove_event_timer(e){var t=(this.props[To]||{})[e];return W(t)||(delete this.props[To][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},M_=Ie("[Product Tours]"),Np="ph_product_tours",$h=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[a_]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(a_)||this.it((()=>this.Oi()))}it(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?M_.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=Q.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=Q.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!me(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[Np];if(me(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return M_.error(a),void e([],{isLoaded:!1,error:a})}var l=me(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[Np]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){pe(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(Np)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},Eo=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),sD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),oD=(function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n})({}),aD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Lp=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),lD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),cD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),uD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),Po=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Fp=(function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n})({}),Mh=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Ie("[Surveys]"),W0="seenSurvey_",jR=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},P_=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(W0,n),UR=[Lp.Popover,Lp.Widget,Lp.API],zR={ignoreConditions:!1,ignoreDelay:!1,displayType:Mh.Popover},jo=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter((r=>r!==t))}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function Fi(n,e,t){if(pe(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var Ph=class{constructor(e){this.Ai=new jo,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!W((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((r,i)=>{this.on(r,i)}))}}register(e){var t,r;if(!W((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.zi)==null||u.add(c?.event||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&s.add(l?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach((i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)}))}qi(e){this.onAction("actionCaptured",(t=>e(t)))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!Fi(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some((a=>Fi(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Fi((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some((c=>Fi(c.text,t.text,t.text_matching||"exact")||Fi(c.$el_text,t.text,t.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(c){for(var u,d=[],h=/(?::|")text="(.*?)"/g;!pe(u=h.exec(c));)d.includes(u[1])||d.push(u[1]);return d})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>Fi(c,o,a))))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||V0(t.properties.reduce(((r,i)=>{var s=me(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r}),{}),e?.properties)}},Oh=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&V0(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach((o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}}))})),r}te(e,t,r){var i=(r===Eo.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie((o=>{s=o.filter((a=>i?.includes(a.id)))})),s.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Qi(l,t)}))}register(e){var t;W((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=e.filter((r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0}));t.length!==0&&(this.se==null&&(this.se=new Ph(this._instance),this.se.init(),this.se.qi((r=>{this.onAction(r)}))),t.forEach((r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}})))})))}ee(e){var t,r=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((s,o)=>{this.onEvent(s,o)})),this.Ki=this.Zi(e,Eo.Activation),this.Yi=this.Zi(e,Eo.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var d=a.indexOf(u);d>=0&&(a.splice(d,1),this.le(a))}}else{if(this.Yi.has(e)){var h=this.te(e,t,Eo.Cancellation);h.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map((v=>v.id))}),h.forEach((v=>{var f=a.indexOf(v.id);f>=0&&a.splice(f,1),this.ue(v.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var g=this.te(e,t,Eo.Activation);this.le(a.concat(g.map((v=>v.id))||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter((o=>!this.he(o)));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},Nh=class extends Oh{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Po.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return we}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Lh=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(pe(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=me(t);this.ve=r?t.length>0:t,we.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(W0)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)we.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)we.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())we.info("Not loading surveys in cookieless mode without consent.");else{var e=Q?.__PosthogExtensions__;if(e){if(!W(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)}))}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else we.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Nh(this._instance),we.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){we.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return we.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(ah);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then((s=>{var{surveys:o,context:a}=s;return e(o,a)})):(typeof Promise<"u"&&(this.pe=new Promise((s=>{r=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;we.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,d=s.json.surveys||[],h=d.filter((v=>(function(f){return!(!f.start_date||f.end_date)})(v)&&((function(f){var m;return!((m=f.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(v)||(function(f){var m;return!((m=f.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(v))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(o=this._instance.persistence)==null||o.register({[ah]:d});var g={isLoaded:!0};e(d,g),r?.({surveys:d,context:g})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){we.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!pe(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);we.warn("init was not called")}be(e){var t=null;return this.getSurveys((r=>{var i;t=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),t}ye(e){if(pe(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(pe(this._surveyManager))return we.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return pe(this._surveyManager)?(we.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var s,o=(s=i.find((l=>l.id===e)))!==null&&s!==void 0?s:null;if(o){var a=this.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,r){var i;if(pe(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(UR.includes(s.type)){var o=V?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(we.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;we.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),we.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);we.warn("Survey element not found")}else we.warn("Surveys of type "+s.type+" cannot be rendered in the app");else we.warn("Survey not found")}}displaySurvey(e,t){var r;if(pe(this._surveyManager))we.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=U({},i,{appearance:U({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Mh.Popover&&t.initialResponses&&we.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void we.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Mh.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){pe(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},pn=Ie("[Conversations]"),Fh=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;pe(t)||(yn(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=Q?.__PosthogExtensions__;if(e&&!W(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1}))}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else pn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),pn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else pn.error("Cannot complete initialization: remote config is null")}Se(e,t){pn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():pn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Dt(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return Bi((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(pn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return Bi((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(pn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Bi((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(pn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Bi((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(pn.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},Dh=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!pe(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Ie("[logs]"),t=Q?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},O_=Ie("[RateLimiter]"),Hh=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((i=>{O_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void O_.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(ch))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(ch,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},Dr=Ie("[RemoteConfig]"),Bh=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=Q._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=Q.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Dr.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Dr.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Dr.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return Dr.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie((t=>{this.yi(t)}));this.yi(e)}))}catch(e){Dr.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Dr.info("__preview_remote_config is disabled. Logging config instead",e):Dr.error("Failed to fetch remote config from PostHog.")}},Vh=3e3,Wh=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Kt(t?.flush_interval_ms||Vh,250,5e3,j.createLogger("flush interval"),Vh),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter((r=>r.url.indexOf("/e")===0)),...t.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Oe(U({},r,{transport:"sendBeacon"}))}))}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout((()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&me(s.data)&&ke(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Oe(s)};for(var i in t)r()}}),this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return ke(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;W(e[s])&&(e[s]=U({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},qR=["retriesPerformedSoFar"],jh=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!W(C)&&"onLine"in C.navigator&&(this.Ue=C.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Oe(C,"online",this.ze),Oe(C,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=B_(e,qR);Di(t)&&(r.url=oc(r.url,{retry_count:t})),this._instance._send_request(U({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(U({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),j.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout((()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()}),this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter((s=>s.retryAt<e||(t.push(s),!1)));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,W(C)||(this.ze&&(C.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(C.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(U({},e,{transport:"sendBeacon"}))}catch(t){j.error(t)}this.Re=[]}},Uh=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){Oe(C,"scroll",this.Ge,{capture:!0}),Oe(C,"scrollend",this.Ge,{capture:!0}),Oe(C,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return C?.document.documentElement;var e=me(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=C?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return C&&(C.scrollY||C.pageYOffset||C.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return C&&(C.scrollX||C.pageXOffset||C.document.documentElement.scrollLeft)||0}},ZR=n=>P0(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),lc=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[lh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||ZR,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[lh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?O0(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return ke(nf(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Vp(r)]=t})),e}},Dp=Ie("[SessionId]"),cc=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new jo,this.er=(u,d)=>!(!Di(u)||!Di(d))&&Math.abs(u-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||zn,this.ar=r||zn;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Kt(o,60,36e3,Dp.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=Ue.W(this.ur),l=Ue.W(this.hr);a&&!l?this.rr=a:Ue.V(this.ur),Ue.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var d=u.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Dp.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return W(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&Ue.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&Ue.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?Ue.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[Zl]:[t,e,r]}))}_r(){var e=this.Xe.props[Zl];return me(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&C&&(C.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&Ue.V(this.hr)},Oe(C,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=Di(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,d=!u&&!e&&this.er(r,i);u||d||l?(s=this.nr(),a=this.ar(),Dp.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var h=Di(i)&&e&&!l?i:r,g=Di(o)?o:new Date().getTime();return this.pr(a),this.vr(s,h,g),e||this.lr(),c&&this.tr.forEach((v=>v(s,a,c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:d,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout((()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},GR=["$set_once","$set"],jn=Ie("[SiteApps]"),zh=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=Q._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,g]of Object.entries(d))c[h]={id:u[h],type:h,properties:g};var{$set_once:v,$set:f}=e;return{event:U({},B_(e,GR),{properties:U({},e.properties,f?{$set:U({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},f)}:{},v?{$set_once:U({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},v)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(jn.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,jn.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(t.processEvent=o),i=!0}catch(a){jn.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){jn.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){jn.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",(c=>this.$r(c)))):void jn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;Q["__$$ph_site_app_"+c]=s._instance,(u=Q.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(d=>{if(d)return jn.error("Error while initializing PostHog app with config id "+c,d)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else jn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},j0=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Gb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Gb(i?.brand,e))))return!0}catch{}return!!n.webdriver},Oo=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),N_="i.posthog.com",qh=class{constructor(e){this.Sr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+N_,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Oo.EU:this.Sr[this.apiHost]=Oo.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===Oo.CUSTOM)return this.apiHost+t;var r=N_+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},KR={icontains:(n,e)=>!!C&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!C&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!C&&ac(e.href,n),not_regex:(n,e)=>!!C&&!ac(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Zh=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments((i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);Le(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(pe(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach((t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=ec(e?.search,"__experiment_id"),r=ec(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments((i=>{this.Cr(parseInt(t),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}Cr(e,t,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!pe(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(pe(e.conditions)||pe((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||KR[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return C?.location}static Fr(e){var t;if(pe(e.conditions)||pe((t=e.conditions)==null?void 0:t.utm))return!0;var r=T0();if(r.utm_source){var i,s,o,a,l,c,u,d,h=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,f=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return h&&v&&f&&g}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];j.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach((i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):n.kr("Control variants leave the page unmodified.")}_is_bot(){return pt&&this._instance?j0(pt,this._instance.config.custom_blocked_useragents):void 0}},YR=Ie("[PostHog ExternalIntegrations]"),XR={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Gh=class{constructor(e){this._instance=e}it(e,t){var r;(r=Q.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return YR.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=Q.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(XR[o],(()=>{var u;(u=Q.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=Q.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=Q.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Kh="[SessionRecording]",Co=Ie(Kh),uc=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw Co.error("started without valid sessionManager"),new Error(Kh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Kh+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(Ep))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return C&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!W(Object.assign)&&!W(Array.from);this.Ar&&r?(this.Dr(e),Co.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(Q!=null&&(t=Q.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=Q.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=Q.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return Co.error("could not load recorder",s);this.Lr(e)})))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(p0)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=pe(a)?null:parseFloat(a);pe(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[Ep]:U({enabled:!!o},o,{networkPayloadCapture:U({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:W(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:Co.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):Co.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Ep);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=Q.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=Q.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},Fo={},Yh=()=>{},Hi="posthog",U0=!HR&&ot?.indexOf("MSIE")===-1&&ot?.indexOf("Mozilla")===-1,L_=n=>{var e;return U({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:tR(V?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Yh,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:ze&&Le(ze?.search)&&ze.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(C==null||(e=C.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;j.error(r)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Vh},error_tracking:{},_onCapture:Yh,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},F_=n=>{var e={};W(n.process_person)||(e.person_profiles=n.process_person),W(n.xhr_headers)||(e.request_headers=n.xhr_headers),W(n.cookie_name)||(e.persistence_name=n.cookie_name),W(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),W(n.store_google)||(e.save_campaign_params=n.store_google),W(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return me(n.property_blacklist)&&(W(n.property_denylist)?t.property_denylist=n.property_blacklist:me(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:j.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Xh=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},dc=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Xh,this.Br=!1,this.version=hn.LIB_VERSION,this.qr=new jo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=L_(),this.SentryIntegration=_h,this.sentryIntegration=e=>(function(t,r){var i=R0(t,r);return{name:A0,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new Ih(this),this.toolbar=new xh(this),this.scrollManager=new Uh(this),this.pageViewManager=new rc(this),this.surveys=new Lh(this),this.conversations=new Fh(this),this.logs=new Dh(this),this.experiments=new Zh(this),this.exceptions=new Th(this),this.rateLimiter=new Hh(this),this.requestRouter=new qh(this),this.consent=new vh(this),this.externalIntegrations=new Gh(this),this.people={set:(e,t,r)=>{var i=Le(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Le(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>j.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==Hi){var i,s=(i=Fo[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Fo[r]=s,Fo[Hi][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),W(e)||Wp(e))return j.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Me({},L_(t.defaults),F_(t),{name:r,token:e})),this.config.on_xhr_error&&j.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:mn.GZipJS;var s=this.Qr();this.persistence=new Lo(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Lo(U({},this.config,{persistence:"sessionStorage"}),s);var o=U({},this.persistence.props),a=U({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Wh((k=>this.ts(k)),this.config.request_queue_config),this.es=new jh(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new cc(this),this.sessionPropsManager=new lc(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(j.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(j.info("Initializing extensions synchronously"),this.rs(l)),hn.DEBUG=hn.DEBUG||this.config.debug,hn.DEBUG&&j.info("Starting in debug mode",{this:this,config:t,thisC:U({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,d=this.config.get_device_id(zn()),h=(c=t.bootstrap)!=null&&c.isIdentifiedID?d:t.bootstrap.distinctID;this.persistence.set_property(fn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this.ss()){var g,v,f=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlags)||{}).filter((k=>{var _;return!((_=t.bootstrap)==null||(_=_.featureFlags)==null||!_[k])})).reduce(((k,_)=>{var b;return k[_]=((b=t.bootstrap)==null||(b=b.featureFlags)==null?void 0:b[_])||!1,k}),{}),m=Object.keys(((v=t.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((k=>f[k])).reduce(((k,_)=>{var b,x;return(b=t.bootstrap)!=null&&(b=b.featureFlagPayloads)!=null&&b[_]&&(k[_]=(x=t.bootstrap)==null||(x=x.featureFlagPayloads)==null?void 0:x[_]),k}),{});this.featureFlags.receivedFeatureFlags({featureFlags:f,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:yo,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(zn());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(fn,"anonymous")}return Oe(C,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?kR(this,(()=>this.ns())):this.ns(),qn(this.config._onCapture)&&this.config._onCapture!==Yh&&(j.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&j.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new bh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new wh(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new zh(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new uc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new hh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new $h(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Sh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new kh(this)})),r.push((()=>{this.exceptionObserver=new yh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new nc(this,wR),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}})),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var r=e.shift();if(r)try{r()}catch(s){j.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&j.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!V||!V.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.yi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=ue(e.supportedCompression,mn.GZipJS)?mn.GZipJS:ue(e.supportedCompression,mn.Base64)?mn.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){j.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&ze!=null&&ze.hostname){var e=ze.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new Bh(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Zn(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(U0?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=oc(e.url,{ip:this.config.ip?1:0}),e.headers=U({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var r,i,s,o=U({},t);o.timeout=o.timeout||6e4,o.url=oc(o.url,{_:new Date().getTime().toString(),ver:hn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=jl.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=c0(l,(u=>u.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(U({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];Zn(e,(a=>{a&&(t=a[0],me(t)?s.push(a):qn(a)?a.call(this):me(a)&&t==="alias"?r.push(a):me(a)&&t.indexOf("capture")!==-1&&qn(this[t])?s.push(a):i.push(a))}));var o=function(a,l){Zn(a,(function(c){if(me(c[0])){var u=l;ke(c,(function(d){u=u[d[0]].apply(u,d.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!W(e)&&Le(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!Le(t?.$current_url)&&(j.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=r?.timestamp||a,c=zn(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var d,h=e!=="$groupidentify",g=this.vs(r?.$set_once,h);if(g&&(u.$set_once=g),(u=QA(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,W(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===Po.DISMISSED||e===Po.SENT){var v=t?.[Fp.SURVEY_ID],f=t?.[Fp.SURVEY_ITERATION];d={id:v,current_iteration:f},localStorage.getItem(P_(d))||localStorage.setItem(P_(d),"true"),u.$set=U({},u.$set,{[jR({id:v,current_iteration:f},e===Po.SENT?"responded":"dismissed")]:!0})}else e===Po.SHOWN&&(u.$set=U({},u.$set,{[Fp.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=U({},u.properties.$set,u.$set);if(Vi(m)||this.setPersonPropertiesForFlags(m),!pe(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var k={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(k):this.Zr.enqueue(k),u}j.critical("This capture call is ignored due to client rate limiting.")}}else j.error("No event name provided to posthog.capture")}else j.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=U({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=U({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Le(a.distinct_id)&&!bn(a.distinct_id)||Wp(a.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=TR(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=d,a.$window_id=h}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.es)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===Oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Me(a,c),e==="$pageview"&&V&&(a.title=V.title),!W(o)){var v=r.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}ot&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Me({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),me(this.config.property_denylist)?ke(this.config.property_denylist,(function(y){delete a[y]})):j.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(j.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this.fs();return a.$process_person_profile=m,m&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=Me({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(j.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),Vi(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=U({},i,e),a=U({},s,t),l={};for(var[c,u]of Object.entries(o)){var d=typeof u=="string";l[c]={key:c,enabled:!!d||!!u,variant:d?u:void 0,reason:void 0,metadata:W(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=zR),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(bn(e)&&(e=e.toString(),j.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==yo){if(this.ps("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(Ro)&&(this.unregister(Ro),this.register({distinct_id:e}));var o=(this.persistence.get_property(fn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(fn,"identified"),this.setPersonPropertiesForFlags(U({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=A_(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Gl))}}else j.critical('The string "'+yo+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else j.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=A_(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(U({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):j.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:U({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else j.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(j.info("reset"),!this.__loaded)return j.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(fn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:yo,$device_id:null},"");else{var a=this.config.get_device_id(zn());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,t){return e===this.get_property(u0)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(W(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Ro,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=U({},this.config);if(Ne(e)){var r,i,s,o,a,l,c;Me(this.config,F_(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Lo(U({},this.config,{persistence:"sessionStorage"}),u);var d=this.Kr(this.config.debug);yn(d)&&(this.config.debug=d),yn(this.config.debug)&&(this.config.debug?(hn.DEBUG=!0,Re.H()&&Re.G("ph_debug","true"),j.info("set_config",{config:e,oldConfig:t,newConfig:U({},this.config)})):(hn.DEBUG=!1,Re.H()&&Re.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(U({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Hi;return t!==Hi&&(t=Hi+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(fn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(fn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Vi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Ro])&&((t=this.persistence)==null||(t=t.props)==null||!t[Yl]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(j.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(Yl,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new cc(this),this.pageViewManager=new rc(this),this.persistence&&(this.sessionPropsManager=new lc(this,this.sessionManager,this.persistence)),this.sessionRecording=new uc(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(W(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else j.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:yo,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):j.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===gn.GRANTED?"granted":e===gn.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return pt?j0(pt,this.config.custom_blocked_useragents):void 0}hs(){V&&(V.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:V.title},{send_instantly:!0}),this.Gr&&(V.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Oe(V,"visibilitychange",this.Gr)))}debug(e){e===!1?(C?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(C?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(j.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=j,o=(t="advanced_disable_flags")in(e=l)&&!pe(e[t]),a=r in e&&!pe(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(pe(this.config.before_send))return e;var t=me(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),pe(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return CA(e.event)?j.warn(s+". This can cause unexpected behavior."):j.info(s),null}r.properties&&!Vi(r.properties)||j.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=yn(e)&&!e,r=Re.H()&&Re.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=JA(n.prototype[e[t]])})(dc,["identify"]);var D_;var z0=(D_=Fo[Hi]=new dc,(function(){function n(){n.done||(n.done=!0,U0=!1,ke(Fo,(function(e){e._dom_loaded()})))}V!=null&&V.addEventListener?V.readyState==="complete"?n():Oe(V,"DOMContentLoaded",n,{capture:!1}):C&&j.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),D_);var cf=class{constructor(e={}){this.options=e;if(this.client=e.client,this.featureFlagsCallback=e.onFeatureFlagsLoaded,this.captureCallback=e.onCapture,this.rrwebCallback=e.onRRWebEvent,!this.client&&e.consent&&e.requireExplicitConsent&&typeof window<"u"&&e.apiKey){let t=e.consent;t.getStatus()==="granted"&&this.initPostHog(),t.subscribe(i=>{i==="granted"?this.client?this.client.opt_in_capturing():this.initPostHog():i==="denied"&&this.client&&this.client.opt_out_capturing()});return}!this.client&&typeof window<"u"&&e.apiKey&&this.initPostHog()}initPostHog(){let e=this.options;if(!e.apiKey)return;let t=e.enableFeatureFlags??!0,r=`syntro_${e.apiKey.slice(-6)||"sdk"}`,o={api_host:`${(e.apiHost??"https://telemetry.syntrologie.com").replace(/\/$/,"")}/t/${e.apiKey}`,advanced_disable_feature_flags:!t,advanced_disable_feature_flags_on_first_load:!t,autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??"history_change",capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),opt_out_useragent_filter:!0,session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0},a=z0.init(e.apiKey,o,r);if(a&&(this.client=a),this.captureCallback&&this.client&&this.client.on("eventCaptured",(...l)=>{let c=l[0],u=typeof c=="string"?c:c?.event,d=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,d)}),t&&this.featureFlagsCallback&&this.client){this.client.onFeatureFlags(()=>{let c=this.getAllFeatureFlags();c&&this.featureFlagsCallback&&this.featureFlagsCallback(c)});let l=this.getAllFeatureFlags();l&&Object.keys(l).length>0&&this.featureFlagsCallback(l)}this.rrwebCallback&&this.client&&this.setupRRWebIntercept()}setupRRWebIntercept(e=30){let t=this.client?.sessionRecording;if(!t){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let r=null,i=t;for(let o of Object.getOwnPropertyNames(i)){let a=i[o];if(a&&typeof a=="object"&&typeof a.onRRwebEmit=="function"&&typeof a.start=="function"&&a!==t){r=a;break}}if(!r){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let s=r.onRRwebEmit.bind(r);r.onRRwebEmit=o=>{this.rrwebCallback?.({kind:"rrweb",...o}),s(o)},typeof window<"u"&&(window.__RRWEB_INTERCEPT_READY__=!0)}getAllFeatureFlags(){return this.client?.featureFlags?.getFlagVariants()}getSegmentFlags(){let e=this.getAllFeatureFlags();if(!e)return{};let t={};for(let[r,i]of Object.entries(e))r.startsWith("in_segment_")&&(t[r]=i===!0);return t}identify(e,t){this.client?.identify(e,t)}alias(e,t){this.client?.alias(e,t)}track(e,t){this.client?.capture(e,t)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,t){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:t})}trackAction(e,t,r){this.track("shadow_canvas_action",{action:e,rectangleId:t,surface:r})}register(e){this.client?.register?.(e)}getSessionId(){return this.client?.get_session_id?.()}startSessionRecording(){this.client?.startSessionRecording?.()}trackExperiment(e,t,r){let i=`$experiment_${e}`;this.register({[i]:r??`variation_${t}`,[`${i}_id`]:t}),this.track("$experiment_started",{$experiment_key:e,$experiment_variation_id:t,$experiment_variation_name:r??`variation_${t}`})}setPersonProperties(e){this.client?.capture("$set",{$set:e})}setPersonPropertiesOnce(e){this.client?.capture("$set",{$set_once:e})}getDistinctId(){return this.client?.get_distinct_id?.()}};function uf(n={}){return new cf(n)}var q0={posthog:n=>uf(n),noop:()=>xp()};function Z0(n,e){let t=q0[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(q0).join(", ")}`);return t(e)}async function G0(n){Ru(),K("Syntro Bootstrap","====== INIT ======"),K("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=al();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",to()),console.log("[DIAG] editorConf:",ol()),K("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let A=!!window.__SYNTRO_EDITOR_PARAMS__,F=!!window.__SYNTRO_AUDIT_LEGEND__,X=!!window.__SYNTRO_REVIEW_DATA__;if(A||F||X){let fe=[A&&"__SYNTRO_EDITOR_PARAMS__",F&&"__SYNTRO_AUDIT_LEGEND__",X&&"__SYNTRO_REVIEW_DATA__"].filter(Boolean);console.warn(`[Syntro Bootstrap] \u26A0 Mode detection returned null but mode-specific globals found: ${fe.join(", ")}. This suggests URL params were lost (redirect?) but the service worker injected mode data. Check if replaceState failed or if page JS changed the URL before init().`)}}console.log(`[DIAG] Token resolution: options.token=${n.token?n.token.slice(0,15)+"...":"null"}`);let t=n.token;if(!t&&e){let F=ol()?.syntro_token;F?.startsWith("syn_")&&(t=F,K("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))K("Syntro Bootstrap","Token starts with syn_, decoding..."),r=no(t),Ru(r.d);else if(e)K("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw Ba("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),Ba("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)K("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw Ba("Syntro Bootstrap","\u274C No token provided and NOT in editor/audit/review mode!"),new Error("Syntro token is required (unless in editor, audit, or review mode)");let i=wt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||wt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=wt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||wt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th,o=wt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||wt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||wt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||wt("VITE_SYNTRO_GEO_HOST")||Ny,l=My(),c=Rd(),u=n.appSignalsInit??{},d={...c,...l,...u};K("Syntro Bootstrap","Phase 1: Browser metadata:",c),K("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&K("Syntro Bootstrap","Phase 1: App signals:",u);let h=Td(a),g=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(A=>{let F=setTimeout(()=>{window.removeEventListener("message",X),A(null)},500);function X(fe){let de=fe.data;de?.jsonrpc==="2.0"&&de?.id===1&&de?.result?.hostInfo&&(clearTimeout(F),window.removeEventListener("message",X),A(de.result.hostInfo))}window.addEventListener("message",X);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(F),window.removeEventListener("message",X),A(null)}})})(),v,f=n.debug||n.testMode,m=ro({debug:n.debug,history:f?new io(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let y=ku({elementResolver:typeof window<"u"?(A,F)=>{let X=document.elementFromPoint(A,F);if(!X)return null;let fe={tag_name:X.tagName.toLowerCase()};X.id&&(fe.attr__id=X.id),X.className&&typeof X.className=="string"&&(fe.classes=X.className.split(" ").filter(Boolean));for(let de of X.attributes)de.name.startsWith("data-")&&(fe[`attr__${de.name}`]=de.value);return fe}:void 0});y.onEvent(A=>m.publishEvent(A)),typeof window<"u"&&(setInterval(()=>y.tick(Date.now()),1e3),document.addEventListener("click",A=>{let F=[],X=A.target;for(;X&&X!==document.body;){let fe={tag_name:X.tagName.toLowerCase()};for(let de of X.attributes)(de.name.startsWith("data-")||de.name==="id"||de.name==="class"||de.name==="aria-label")&&(fe[`attr__${de.name}`]=de.value);F.push(fe),X=X.parentElement}y.enrichClickAttributes(Date.now(),F)},!0));let k=Tb(),_,b=A=>{K("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let F=Oy(A);if(K("Syntro Bootstrap","Segment flags from PostHog:",F),Py(F),v){let X=R?.getAll?.()??{},fe={...c,...X,...F,...u};K("Syntro Bootstrap","Updating GrowthBook with attributes:",fe),v.setAttributes?.(fe)}if(_&&x?.getDistinctId){let X=x.getDistinctId();X&&s&&r?.t&&_.updateContext({distinctId:X,telemetryHost:s,telemetryKey:r.t})}},x;if(r?.t){let A=r.t==="noop"?"noop":"posthog";x=Z0(A,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,onFeatureFlagsLoaded:b,onCapture:(X,fe)=>{y.ingest({kind:"posthog",event:X,properties:fe,timestamp:Date.now()})},onRRWebEvent:X=>{y.ingest(X)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${A}) with EventBus wiring`),Object.keys(u).length>0&&(x.track?.("app_signals_init",u),K("Syntro Bootstrap","Tracked app signals event:",u));let F=x;if(m.setPosthogCapture((X,fe)=>{F.track?.(X,fe)}),k?.name==="shopify"&&s)try{_=new Il({distinctId:x.getDistinctId?.()??"",telemetryHost:s,telemetryKey:r.t}),K("Syntro Bootstrap","ShopifyPixelBridge initialized for checkout attribution")}catch(X){Qe("Syntro Bootstrap","ShopifyPixelBridge init failed",X)}}let R;r?.e&&(v=kb("growthbook",{clientKey:r.e,apiHost:i,attributes:d,onExperimentViewed:x?.trackExperiment?(A,F,X)=>{x.trackExperiment(A,F,X)}:void 0})),R=Qd({experiments:v,onMetricChange:(A,F)=>{K("Syntro Bootstrap",`Session metric changed: ${A} = ${F}`)}}),K("Syntro Bootstrap","SessionMetricTracker created");let w="production";e==="editor"?w="editor":e==="audit"?w="audit":wt("NODE_ENV")==="development"&&(w="development");let E=bp({telemetry:x,sessionMetrics:R,mode:w,events:m});K("Syntro Bootstrap","Runtime created:",{version:E.version,mode:E.mode,hasContext:!!E.context,hasEvents:!!E.events,hasState:!!E.state}),K("Syntro Bootstrap","Core app executors already registered");let $=n.cdnBase||wt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||wt("VITE_SYNTRO_CDN_BASE")||"https://cdn.syntrologie.com",P=Xc({cdnBase:$,registry:E.apps,onLoadStart:A=>{K("Syntro Bootstrap",`Loading app from CDN: ${A}`)},onLoadEnd:(A,F,X)=>{F?K("Syntro Bootstrap",`App loaded successfully: ${A}`):Qe("Syntro Bootstrap",`Failed to load app: ${A}`,X)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:E.apps,runtime:E,version:E.version},K("Syntro Bootstrap","Global SynOS object exposed"));let M=E.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${M.length} apps in registry:`,M.map(A=>`${A.manifest.id}(${A.state})`).join(", "));for(let A of M)if(A.state==="registered")try{await E.apps.activate(A.manifest.id),console.log(`[DIAG] Activated: ${A.manifest.id} \u2192 widgets: [${E.widgets.list().join(", ")}]`)}catch(F){console.error(`[DIAG] FAILED to activate: ${A.manifest.id}`,F),Qe("Syntro Bootstrap",`Failed to auto-activate built-in app: ${A.manifest.id}`,F)}if(console.log(`[DIAG] Activation complete. Total widgets: [${E.widgets.list().join(", ")}]`),v?.refreshFeatures)try{await v.refreshFeatures(),K("Syntro Bootstrap","GrowthBook features loaded")}catch(A){Qe("Syntro Bootstrap","Failed to load GrowthBook features:",A)}let G=await h;if(v&&Object.keys(G).length>0){let A={...c,...G,...u};K("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",G),v.setAttributes?.(A)}let L=await g;L&&v&&(c.surface_type="mcp-app",c.surface_host=L.name,v.setAttributes?.({...c,...G}),K("Syntro Bootstrap","MCP App detected:",L.name));let N;if(n.fetcher)N=n.fetcher;else if(r?.f){let A=Ab(r.f,r.o??{});N=async()=>{let F=await A.fetch();return{...F.config,tiles:F.config.tiles??[]}}}else v&&(N=hi({experiments:v}));let z=new Set,H=N?async()=>{let A=await N(),F=A.tiles?.length??0,X=A.actions?.length??0,fe=A.meta?.variant_id;if((F>0||X>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),x&&fe){let Ce=new vo(x,fe);Ce.trackServed(F,X),typeof window<"u"&&(window.SynOS.interventionTracker=Ce),E.navigation.subscribe(()=>{Ce.resetPage()})}console.log("[Syntro Bootstrap] Config fetched:",`tiles=${A.tiles?.length??0},`,`actions=${A.actions?.length??0},`,`theme=${A.theme?.name??"none"}`),A.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",A.actions.map((Ce,Et)=>`[${Et}] ${Ce.kind}${Ce.anchorId?` anchor="${Ce.anchorId.selector}"`:""}${Ce.label?` "${Ce.label}"`:""}`).join(", "));let de=A,He=P.getRequiredApps(de);return He.length>0?console.log("[Syntro Bootstrap] Required external apps:",He.join(", ")):K("Syntro Bootstrap","No external apps required (all executors are built-in)"),He.length>0&&await P.loadAppsForConfig(de).then(async Et=>{let Ct=Et.filter(Pe=>Pe.success),gc=Et.filter(Pe=>!Pe.success);Ct.length>0&&console.log(`[Syntro Bootstrap] Apps loaded from CDN: ${Ct.map(Pe=>Pe.appId).join(", ")}`);let Yi=gc.filter(Pe=>!z.has(Pe.appId));Yi.length>0&&(console.error("[Syntro Bootstrap] Apps FAILED to load from CDN:",Yi.map(Pe=>`${Pe.appId} (${Pe.error})`).join(", ")),Yi.forEach(Pe=>z.add(Pe.appId)));for(let Pe of He)if(E.apps.has(Pe))try{await E.apps.activate(Pe),console.log(`[Syntro Bootstrap] App activated: ${Pe}`)}catch(Ht){console.error(`[Syntro Bootstrap] Failed to activate app: ${Pe}`,Ht)}else console.error(`[Syntro Bootstrap] App "${Pe}" required by config but NOT registered.`,`Available apps: [${Array.from(E.apps.list?.()??[]).join(", ")}]`)}),A}:void 0;if(k){K("Syntro Bootstrap",`Detected platform: ${k.name}`);try{await k.onInit(),K("Syntro Bootstrap",`Platform adapter initialized: ${k.name}`)}catch(A){Qe("Syntro Bootstrap",`Platform adapter init failed: ${k.name}`,A)}}return{canvas:await Ed({...n.canvas,fetcher:H,integrations:{experiments:v,telemetry:x},editorUrl:o,runtime:E,platformAdapter:k??void 0}),runtime:E,experiments:v,telemetry:x,sessionMetrics:R,appLoader:P}}async function JR(n){try{return await G0(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function QR(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}var K0={init:JR,encodeToken:Ad,decodeToken:no,events:{emit:QR}};typeof window<"u"&&(window.Syntro=K0);function Zo(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function VD(n){let e=[],t=[];if(!n||typeof n!="object")return{valid:!1,errors:["Config must be an object"],warnings:e};let r=n;if(r.tiles||t.push("Config missing required field: tiles"),r.actions||t.push("Config missing required field: actions"),r.fetchedAt||t.push("Config missing required field: fetchedAt"),t.length>0)return{valid:!1,errors:t,warnings:e};let i=r.schemaVersion||"1.0",s=Zo(i),o=Zo(En);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${En}. Some features may not work. Update SDK to latest version.`),s.major<o.major||!r.schemaVersion?(e.push(`Config schema v${i} is older than SDK v${En}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:eT(r,i)}):{valid:!0,warnings:e,errors:t}}function eT(n,e){let t={...n};return Zo(e).major===1&&(t=tT(t)),t.schemaVersion=En,t}function tT(n){let e={schemaVersion:"2.0",tiles:[],actions:n.actions||[],fetchedAt:n.fetchedAt||new Date().toISOString()};return n.tiles&&Array.isArray(n.tiles)&&(e.tiles=n.tiles.map(t=>{let r={...t};return t.experiment&&delete r.experiment,r})),n.configVersion&&(e.configVersion=n.configVersion),n.canvasTitle&&(e.canvasTitle=n.canvasTitle),n.theme&&(e.theme=n.theme),n.launcher&&(e.launcher=n.launcher),e}function WD(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Zo(t),i=Zo(En);return r.major<i.major||!e.schemaVersion}var nT=p.object({url:p.string(),routeId:p.string().optional(),title:p.string().optional(),locale:p.string().optional()}),rT=p.object({url:p.string(),ts:p.number()}),iT=p.object({sessionId:p.string(),startTs:p.number(),pageHistory:p.array(rT).optional()}),sT=p.object({width:p.number(),height:p.number()}),oT=p.object({x:p.number(),y:p.number(),w:p.number(),h:p.number()}),aT=p.object({anchorId:p.string(),present:p.boolean(),visible:p.boolean().optional(),boundingBox:oT.optional()}),lT=p.record(p.string(),p.union([p.number(),p.string(),p.boolean(),p.undefined()])),cT=p.object({page:nT,session:iT,viewport:sT,anchors:p.array(aT).optional(),augmented:lT.optional()});function zD(n){return cT.safeParse(n)}var df=class{constructor(e,t,r,i){this._isFallback=!0;this._isLoading=!0;this._cancelled=!1;this._host=e,this._runtime=t,this._strategy=r,this._defaultValue=i,this._value=i,e.addController(this)}get value(){return this._value}get isFallback(){return this._isFallback}get isLoading(){return this._isLoading}hostConnected(){this._evaluate()}hostDisconnected(){this._cancelled=!0}setStrategy(e){this._strategy=e,this._evaluate()}_evaluate(){if(this._cancelled=!1,!this._runtime||!this._strategy){this._value=this._defaultValue,this._isFallback=!0,this._isLoading=!1,this._host.requestUpdate();return}this._isLoading=!0,this._host.requestUpdate();let e=this._strategy;this._runtime.evaluate(e).then(t=>{this._cancelled||(this._value=t.value,this._isFallback=t.isFallback,this._isLoading=!1,this._host.requestUpdate())})}};var pf=class{constructor(e,t){this._unsubscribe=null;this.host=e,this._runtime=t,this._context=t.context.get(),e.addController(this)}hostConnected(){this._context=this._runtime.context.get(),this._unsubscribe=this._runtime.context.subscribe(e=>{this._context=e,this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}get runtime(){return this._runtime}get context(){return this._context}get page(){return this._context?.page??null}get session(){return this._context?.session??null}get viewport(){return this._context?.viewport??null}};var hf=class{constructor(e,t,r,i){this._host=e,this._runtime=t,this._filter=r,this._callback=i,e.addController(this)}hostConnected(){this._subscribe()}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0}setFilter(e){this._filter=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}setCallback(e){this._callback=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}_subscribe(){this._runtime&&(this._unsubscribe=this._filter?this._runtime.events.subscribe(this._filter,this._callback):this._runtime.events.subscribe(this._callback))}};var Y0=p.enum(["posthog","canvas","derived"]),uT=p.object({ts:p.number(),name:p.string(),source:Y0,props:p.record(p.string(),p.unknown()).optional(),schemaVersion:p.string()}),dT=p.object({names:p.array(p.string()).optional(),patterns:p.array(p.string()).optional(),sources:p.array(Y0).optional()});function g4(n){return uT.safeParse(n)}function m4(n){return dT.safeParse(n)}var X0=p.union([p.object({type:p.literal("data"),key:p.string(),value:p.string().optional()}),p.object({type:p.literal("css"),value:p.string()}),p.object({type:p.literal("aria"),role:p.string().optional(),label:p.string().optional()}),p.object({type:p.literal("shadow-css"),value:p.string()}),p.object({type:p.literal("ref"),el:p.any()})]),pT=p.object({kind:p.literal("tooltip"),id:p.string(),anchor:X0,content:p.object({title:p.string().optional(),body:p.string()}),placement:p.enum(["top","bottom","left","right","auto"]).optional(),offsetPx:p.number().optional(),blocking:p.boolean().optional(),trigger:p.enum(["immediate","hover","click"]).optional(),dismiss:p.object({onEsc:p.boolean().optional(),closeButton:p.boolean().optional(),timeoutMs:p.number().optional()}).optional()}),hT=p.object({kind:p.literal("highlight"),id:p.string(),anchor:X0,copy:p.string().optional(),ring:p.object({paddingPx:p.number().optional(),radiusPx:p.number().optional()}).optional(),scrim:p.object({opacity:p.number().optional()}).optional(),ringColor:p.string().optional(),blocking:p.boolean().optional(),dismiss:p.object({onClickOutside:p.boolean().optional(),onEsc:p.boolean().optional(),timeoutMs:p.number().optional()}).optional()}),ff=p.object({id:p.string(),version:p.number(),routes:p.array(p.string()).optional(),steps:p.array(p.union([pT,hT]))});function $4(n){return ff.parse(n)}var N4=({configUri:n,experiments:e,featureKey:t="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=Iu({configUri:n,experiments:e,featureKey:t});if(!i)throw new Error("SmartCanvas overlays: recipe URI missing (env + feature unset).");let s=await fetch(i,{credentials:r});if(!s.ok)throw new Error(`SmartCanvas overlays: failed to fetch recipe (${s.status})`);let o=await s.json();return ff.parse(o)};var fT=p.object({value:p.unknown(),expiresAt:p.number().optional()}),gT=p.object({count:p.number(),resetAt:p.number().optional()});function D4(n){return fT.safeParse(n)}function H4(n){return gT.safeParse(n)}var J0="2026-04-25T08:19:59.191Z (69d7d18cab7)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${J0} (Lit)`);let n=window.SynOS,e=n?.appRegistry||ys;window.SynOS={...n,appRegistry:e,_runtimeBuild:J0,_renderer:"lit"},Ua(),tv(e)}export{mo as ANIMATION_KEYFRAMES,il as ActivationConfigZ,oy as AddClassZ,xt as AnchorIdZ,aT as AnchorStateZ,ud as AnchorVisibleConditionZ,vs as AppRegistry,lT as AugmentationZ,Kv as BadgePositionZ,py as BadgeZ,oT as BoundingBoxZ,Os as CanvasEvents,ff as CanvasRecipeZ,Ln as ConditionZ,$l as ContextManager,md as CooldownActiveConditionZ,Zs as CounterDefZ,xd as CtaButtonZ,Eu as DEFAULT_COOLDOWN,df as DecisionController,Qs as DecisionStrategyZ,gd as DismissedConditionZ,$e as EVENT_SCHEMA_VERSION,cl as EventBus,yd as EventCountConditionZ,dT as EventFilterZ,io as EventHistory,dd as EventOccurredConditionZ,Y0 as EventSourceZ,Ga as ExecutorRegistry,Js as ExternalStrategyZ,gT as FrequencyEntryZ,vd as FrequencyLimitConditionZ,hT as HighlightStepZ,Gv as HighlightStyleZ,uy as HighlightZ,cy as InsertHtmlZ,Qv as InsertPositionZ,vo as InterventionTracker,Su as MAX_VISIBLE_TOASTS,qs as MatchOpZ,Jv as ModalContentZ,fy as ModalZ,Xs as ModelStrategyZ,vy as MountWidgetZ,my as NavigateZ,po as NavigationMonitor,uT as NormalizedEventZ,Ps as NotificationsController,nT as PageContextZ,rT as PageHistoryEntryZ,ld as PageUrlConditionZ,_y as ParallelZ,Yv as PlacementZ,dy as PulseZ,J0 as RUNTIME_SDK_BUILD,jb as RUNTIME_VERSION,ay as RemoveClassZ,cd as RouteConditionZ,Zv as RouteFilterZ,Ks as RuleStrategyZ,Gs as RuleZ,cT as RuntimeContextZ,pf as RuntimeController,hf as RuntimeEventsController,En as SDK_SCHEMA_VERSION,Tu as SDK_VERSION,Hb as STATIC_SLOT_STYLES,Ys as ScoreStrategyZ,ry as ScrollBehaviorZ,_d as ScrollLogicalPositionZ,gy as ScrollToZ,X0 as SelectorZ,by as SequenceZ,iT as SessionContextZ,fd as SessionMetricConditionZ,Al as SessionMetricTracker,sy as SetAttrZ,ly as SetStyleZ,iy as SetTextZ,$u as SmartCanvasController,mi as SmartCanvasElementLit,We as StandardEvents,pd as StateEqualsConditionZ,Ol as StateStore,fT as StoredValueZ,K0 as Syntro,Ns as ThemeController,Xv as TooltipContentZ,pT as TooltipStepZ,ey as TooltipTriggerZ,hy as TooltipZ,ny as TourStepForSchemaZ,xy as TourZ,rl as TriggerWhenZ,hd as ViewportConditionZ,sT as ViewportContextZ,yy as WaitZ,ty as WidgetConfigZ,Ll as WidgetRegistry,cp as applyStaticSlotStyles,X1 as coreActionStepSchemas,id as createActionEngine,wd as createAnchorResolver,hi as createCanvasConfigFetcher,np as createContextManager,rp as createDecisionEngine,ip as createEventAccumulator,ro as createEventBus,Yd as createGrowthBookClient,xp as createNoopClient,N4 as createOverlayRecipeFetcher,uf as createPostHogClient,sv as createPostHogNormalizer,Qd as createSessionMetricTracker,Ed as createSmartCanvas,dv as createSmartCanvasController,bp as createSmartCanvasRuntime,lp as createStateStore,fp as createSurfaceContainer,mp as createSurfaces,UN as decisionSchemas,no as decodeToken,Ad as encodeToken,Ob as evaluate,$b as evaluateCondition,Mb as evaluateRule,Ml as evaluateRuleStrategy,Pl as evaluateScoreStrategy,Nb as evaluateSync,rn as executorRegistry,J1 as getAntiFlickerSnippet,CE as getExecutor,Nl as getSlotAnchorId,go as getSlotType,gp as getSlotZIndex,Wu as hasExecutor,WD as needsMigration,$s as normalizePostHogEvent,Zo as parseVersion,pp as playEnterAnimation,hp as playExitAnimation,fi as registerConfigPredicates,Ua as registerSmartCanvasElement,Iu as resolveConfigUri,vE as runtimeContext,up as setupAdjacentPositioning,dp as setupInlinePositioning,Ms as shouldNormalizeEvent,Wt as validateAction,Xa as validateActions,jN as validateActivationConfig,VN as validateCondition,VD as validateConfig,m4 as validateEventFilter,Id as validateEventName,H4 as validateFrequencyEntry,g4 as validateNormalizedEvent,$d as validateProps,$4 as validateRecipe,zD as validateRuntimeContext,D4 as validateStoredValue,WN as validateStrategy,vp as widgetRegistry};
|
|
1163
1163
|
/*! Bundled license information:
|
|
1164
1164
|
|
|
1165
1165
|
@lit/reactive-element/css-tag.js:
|