@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.min.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
|
-
`}};Qa.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",Qa);function el(n,e,t="merge"){return t==="first-match"?xE(n,e):wE(n,e)}function xE(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 Kv([i])}return null}function wE(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:Kv(t)}function Kv(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 bd=!1;function Yv(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function _d(n){if(Yv()){bd=!0;return}bd=n??!1}function kE(){return Yv()?!0:bd}function K(n,e,t){kE()&&(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 tl(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var nl="2.8.0-canary.129";var nn="2.0";var SE=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function EE(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 CE(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Xv="syntro_config_cache",AE=1440*60*1e3;function Jv(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function RE(n,e){if(Jv())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Xv,JSON.stringify(t))}catch{}}function TE(n){if(!Jv())return null;try{let e=localStorage.getItem(Xv);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>AE?null:t.config}catch{return null}}var rl=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function IE(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 hr=({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=IE(e,s,o);if(u.length>0){let d=el(e,u);if(d)return K("SmartCanvas Config","Resolved config from variant flags",d),d}}let l=rl({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(!EE(l))throw new Error(`SmartCanvas: config URI not allowed: ${l}`);let c=r??(CE(l)?"include":"omit");try{let u=await fetch(l,{credentials:c,headers:{"X-SDK-Version":nl,"X-SDK-Schema-Version":nn}});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&&RE(d,a),d}catch(u){if(a){let d=TE(a);if(d)return K("SmartCanvas Config","Serving config from offline cache"),d}throw u}};var il=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)}},xd=n=>new il(n);function se(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}var bO={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:_u.primary,colorBorderSubtle:_u.secondary,colorSuccess:be[4],colorSuccessMuted:be[0],colorWarning:Ve[4],colorWarningMuted:Ve[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"},_O={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:Ve[4],colorWarningMuted:se(Ve[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 $E(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Qv={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:ua.primary.backgroundDefault,backgroundHover:ua.primary.backgroundHover,color:ua.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:Ve[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"}},ey={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:Ve[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 ty(n){let e=n.mode==="light"?ey:Qv;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 ny(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?ey:Qv;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 ME=["canvas","launcher","tile","overlay","notification","content"];function ry(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 ME){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&(e[`--sc-${t}-${$E(i)}`]=s)}return e}var An,fr,gr,rn,sn,wd,sl,xi=class{constructor(e,t,r){ee(this,sn);ee(this,An);ee(this,fr);ee(this,gr);ee(this,rn);Z(this,An,e),Z(this,fr,t??{}),Z(this,gr,r),Z(this,rn,te(this,sn,wd).call(this)),e.addController(this)}get config(){return I(this,rn).config}get mode(){return I(this,rn).mode}get cssVariables(){return I(this,rn).cssVariables}hostConnected(){te(this,sn,sl).call(this)}hostDisconnected(){}hostUpdated(){te(this,sn,sl).call(this)}setThemeConfig(e,t){Z(this,fr,e),Z(this,gr,t),Z(this,rn,te(this,sn,wd).call(this)),te(this,sn,sl).call(this),I(this,An).requestUpdate()}};An=new WeakMap,fr=new WeakMap,gr=new WeakMap,rn=new WeakMap,sn=new WeakSet,wd=function(){let e=I(this,gr)?ny(I(this,gr),I(this,fr)):ty(I(this,fr)),t=ry(e);return{config:e,mode:e.mode,cssVariables:t}},sl=function(){let e=I(this,An).shadowRoot??("renderRoot"in I(this,An)?I(this,An).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,rn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
564
|
+
`}};Qa.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",Qa);function el(n,e,t="merge"){return t==="first-match"?xE(n,e):wE(n,e)}function xE(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 Kv([i])}return null}function wE(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:Kv(t)}function Kv(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 bd=!1;function Yv(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function _d(n){if(Yv()){bd=!0;return}bd=n??!1}function kE(){return Yv()?!0:bd}function K(n,e,t){kE()&&(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 tl(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var nl="2.8.0-canary.130";var nn="2.0";var SE=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function EE(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 CE(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Xv="syntro_config_cache",AE=1440*60*1e3;function Jv(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function RE(n,e){if(Jv())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Xv,JSON.stringify(t))}catch{}}function TE(n){if(!Jv())return null;try{let e=localStorage.getItem(Xv);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>AE?null:t.config}catch{return null}}var rl=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function IE(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 hr=({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=IE(e,s,o);if(u.length>0){let d=el(e,u);if(d)return K("SmartCanvas Config","Resolved config from variant flags",d),d}}let l=rl({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(!EE(l))throw new Error(`SmartCanvas: config URI not allowed: ${l}`);let c=r??(CE(l)?"include":"omit");try{let u=await fetch(l,{credentials:c,headers:{"X-SDK-Version":nl,"X-SDK-Schema-Version":nn}});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&&RE(d,a),d}catch(u){if(a){let d=TE(a);if(d)return K("SmartCanvas Config","Serving config from offline cache"),d}throw u}};var il=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)}},xd=n=>new il(n);function se(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}var bO={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:_u.primary,colorBorderSubtle:_u.secondary,colorSuccess:be[4],colorSuccessMuted:be[0],colorWarning:Ve[4],colorWarningMuted:Ve[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"},_O={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:Ve[4],colorWarningMuted:se(Ve[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 $E(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Qv={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:ua.primary.backgroundDefault,backgroundHover:ua.primary.backgroundHover,color:ua.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:Ve[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"}},ey={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:Ve[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 ty(n){let e=n.mode==="light"?ey:Qv;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 ny(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?ey:Qv;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 ME=["canvas","launcher","tile","overlay","notification","content"];function ry(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 ME){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&(e[`--sc-${t}-${$E(i)}`]=s)}return e}var An,fr,gr,rn,sn,wd,sl,xi=class{constructor(e,t,r){ee(this,sn);ee(this,An);ee(this,fr);ee(this,gr);ee(this,rn);Z(this,An,e),Z(this,fr,t??{}),Z(this,gr,r),Z(this,rn,te(this,sn,wd).call(this)),e.addController(this)}get config(){return I(this,rn).config}get mode(){return I(this,rn).mode}get cssVariables(){return I(this,rn).cssVariables}hostConnected(){te(this,sn,sl).call(this)}hostDisconnected(){}hostUpdated(){te(this,sn,sl).call(this)}setThemeConfig(e,t){Z(this,fr,e),Z(this,gr,t),Z(this,rn,te(this,sn,wd).call(this)),te(this,sn,sl).call(this),I(this,An).requestUpdate()}};An=new WeakMap,fr=new WeakMap,gr=new WeakMap,rn=new WeakMap,sn=new WeakSet,wd=function(){let e=I(this,gr)?ny(I(this,gr),I(this,fr)):ty(I(this,fr)),t=ry(e);return{config:e,mode:e.mode,cssVariables:t}},sl=function(){let e=I(this,An).shadowRoot??("renderRoot"in I(this,An)?I(this,An).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,rn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
565
565
|
`);t.textContent=`:host {
|
|
566
566
|
${r}
|
|
567
567
|
}`};var PE=new Set(["tag_name","$el_text"]);function OE(n){return PE.has(n)||n.startsWith("attr__")}function iy(n,e){return n.equals!==void 0?e===n.equals:n.contains!==void 0?typeof e=="string"&&e.includes(n.contains):!1}function NE(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(OE(i)){let o=r.props?.elements;if(!o||!o.some(l=>iy(s,l[i])))return!1}else if(!iy(s,r.props?.[i]))return!1}return!0}}function sy(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?NE(i):()=>!0,o=typeof r.withinMs=="number";e.register(r.key,s,o)}}function mr(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"&&sy(o.triggerWhen,e)}if(t)for(let r of t){let i=r;i.triggerWhen?.type==="rules"&&sy(i.triggerWhen,e)}}var Rn,wi,Qs,kd,ol=class extends ge{constructor(){super(...arguments);ee(this,Qs);this.component=null;this.props={};ee(this,Rn,null);ee(this,wi,null)}createRenderRoot(){return this}render(){return D`<div></div>`}firstUpdated(){Z(this,wi,this.querySelector("div")),te(this,Qs,kd).call(this)}updated(t){te(this,Qs,kd).call(this)}disconnectedCallback(){super.disconnectedCallback(),I(this,Rn)?.unmount(),Z(this,Rn,null)}};Rn=new WeakMap,wi=new WeakMap,Qs=new WeakSet,kd=function(){if(!I(this,wi)||!this.component)return;let t=window.SynOS;if(!t?.React||!t?.ReactDOM?.createRoot)return;let r=t.React,{createRoot:i}=t.ReactDOM;I(this,Rn)||Z(this,Rn,i(I(this,wi))),I(this,Rn).render(r.createElement(this.component,this.props))},ol.properties={component:{attribute:!1},props:{attribute:!1}};customElements.define("react-bridge",ol);var cy="syntro-runtime",oy="smart-canvas",ay=n=>[...n].sort((e,t)=>(t.priority??0)-(e.priority??0));function ly(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,ki,Nt,vt,Lt,yr,eo,to,no,br,_r,Tn,In,$n,xr,Mn,Si,Ei,ro,xe,uy,dy,Ci,Sd,py,Ed,Cd,Ad,hy,Rd,al,fy,vr=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,ki,null);ee(this,Nt,null);ee(this,vt,null);ee(this,Lt,null);ee(this,yr);ee(this,eo,0);ee(this,to,null);ee(this,no,"[]");ee(this,br,null);ee(this,_r,null);ee(this,Tn,null);ee(this,In,null);ee(this,$n,null);ee(this,xr,()=>{this._pageUrl=window.location.href});ee(this,Mn,null);ee(this,Si,null);ee(this,Ei);ee(this,ro);ee(this,Ci,0);ee(this,al,t=>{I(this,et).toggle()});Z(this,et,xd()),Z(this,yr,!1),Z(this,Ei,new xi(this)),Z(this,ro,new mi(this,{context:cy,initialValue:null}))}connectedCallback(){super.connectedCallback(),this.style.setProperty("font-family","inherit"),Z(this,ki,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,vt,document.createElement("div")),I(this,vt).id="portalRoot",this.shadowRoot.appendChild(I(this,vt)),te(this,xe,Ed).call(this),te(this,xe,Rd).call(this),te(this,xe,Ad).call(this)}disconnectedCallback(){var t,r,i,s,o;super.disconnectedCallback(),(t=I(this,ki))==null||t.call(this),Z(this,ki,null),(r=I(this,_r))==null||r.call(this),Z(this,_r,null),(i=I(this,Tn))==null||i.call(this),Z(this,Tn,null),(s=I(this,In))==null||s.call(this),Z(this,In,null),(o=I(this,$n))==null||o.call(this),Z(this,$n,null),te(this,xe,Cd).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,Mn)?.unmount(),Z(this,Mn,null),I(this,Nt)?.remove(),Z(this,Nt,null),I(this,vt)?.remove(),Z(this,vt,null)}updated(t){var i;t.has("runtime")&&(I(this,ro).setValue(this.runtime??null),te(this,xe,hy).call(this),te(this,xe,Ad).call(this),te(this,xe,Rd).call(this),te(this,xe,Cd).call(this),te(this,xe,Ed).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,uy).call(this),(i=I(this,_r))==null||i.call(this),this.experiments?.onFeaturesChanged&&Z(this,_r,this.experiments.onFeaturesChanged(()=>this._loadConfig()))),(r||t.has("_pageUrl"))&&this._loadConfig(),(t.has("_theme")||t.has("workspaceTheme"))&&I(this,Ei).setThemeConfig(this._theme??{},this.workspaceTheme),(t.has("_configActions")||t.has("_pageUrl"))&&te(this,xe,py).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,yr,!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),jy=!0}var Fl=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=Dy(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&&mr(m.tiles,s.accumulator,m.actions)}catch(m){console.error("[SmartCanvas] Error fetching/applying initial config:",m)}e&&e();let l=Ll();io();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??hr({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&&Uy(y)}};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0}),(l||n.editorUrl)&&(console.log(`[SmartCanvas] Loading editor SDK for ${l??"config"} mode`),Wy(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&&mr(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 Fl(n)}});var Rp="syn_";function ji(n){if(!n.startsWith(Rp))throw new Error("Invalid Syntro token: must start with 'syn_'");let t=n.slice(Rp.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 Dl(n){let e=JSON.stringify(n),t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return Rp+t}function wt(n){if(typeof process<"u"&&process.env)return process.env[n]}var Zy="syntro_segment_attributes";function Gy(){if(typeof window>"u")return{};try{let n=localStorage.getItem(Zy);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 Ky(n){if(!(typeof window>"u"))try{localStorage.setItem(Zy,JSON.stringify(n)),K("Syntro Bootstrap","Cached segment attributes:",n)}catch(e){Qe("Syntro Bootstrap","Failed to cache segment attributes:",e)}}function Yy(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 Tp(){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 qy="syntro_geo",Xy="https://geo.syntrologie.com";async function Ip(n){if(typeof window>"u")return{};try{let e=localStorage.getItem(qy);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(qy,JSON.stringify(r))}catch{}return K("Syntro Bootstrap","Geo: fetched from worker:",r),r}}catch{}return{}}var Jy="app:",kC="syntro:",SC=/^[a-z][a-z0-9_]*$/;function Hl(n){if(!n)return{valid:!1,reason:"Event name cannot be empty"};if(n.startsWith(kC))return{valid:!1,reason:'"syntro:" prefix is reserved for internal SDK events'};if(!n.startsWith(Jy))return{valid:!1,reason:`Custom events must start with "app:" prefix. Got: "${n}"`};let e=n.slice(Jy.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 EC(n){return typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null}function Qy(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)&&!Qy(r,e,t+1))return!1;return!0}function Bl(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(!Qy(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"||EC(r)||e.push(t);return e.length>0?{valid:!0,stripped:e}:{valid:!0}}function Vl(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 vo=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:Ie};this.publishEvent(i)}publishEvent(e){this.history.push(e),this.history.length>this.maxHistorySize&&this.history.shift();for(let t of this.subscriptions)if(Vl(e,t.filter))try{t.callback(e)}catch(r){console.error("[EventBus] Subscriber error:",r)}}emit(e,t){let r=Hl(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=Bl(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:Ie};this.history.push(s),this.history.length>this.maxHistorySize&&this.history.shift();let o=0;for(let l of this.subscriptions)if(Vl(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=>Vl(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=>Vl(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 Ui(n={}){return new vo(n)}var zi=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 tb={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function nb(){return tb}function $p(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 yo(n,e,t){return t===2?$p($p(n+e)+"")%1e4/1e4:t===1?$p(e+n)%1e3/1e3:null}function CC(n){return n<=0?[]:new Array(n).fill(1/n)}function Wl(n,e){return n>=e[0]&&n<e[1]}function rb(n,e){let t=yo("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function ib(n,e){for(let t=0;t<e.length;t++)if(Wl(n,e[t]))return t;return-1}function Pp(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function jl(n,e){if(!e.length)return!1;let t=!1,r=!1;for(let i=0;i<e.length;i++){let s=TC(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 AC(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 RC(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=>!AC(i[0],i[1],i[2]))}catch{return!1}}function TC(n,e,t){try{let r=new URL(n,"https://_");if(e==="regex"){let i=Pp(t);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return RC(r,t);return!1}catch{return!1}}function sb(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=CC(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 ob(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 ab(n){try{return n()}catch(e){return console.error(e),!1}}var Mp=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0));async function Dr(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||tb.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",Mp(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:Mp(i)},r,Mp(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function bo(n){return typeof n=="string"?n:JSON.stringify(n)}function dt(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 lb(){let n;try{n="1.6.4"}catch{n=""}return n}function cb(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 eb(n){return typeof n=="object"&&n!==null}function Ul(n){return n.urlPatterns&&n.variations.some(e=>eb(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>eb(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function zl(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},Gt=nb(),qi={fetchFeaturesCall:({host:n,clientKey:e,headers:t})=>Gt.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 Gt.fetch(`${n}/api/eval/${e}`,i)},eventSourceCall:({host:n,clientKey:e,headers:t})=>t?new Gt.EventSource(`${n}/sub/${e}`,{headers:t}):new Gt.EventSource(`${n}/sub/${e}`),startIdleListener:()=>{let n;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(n),MC()):document.visibilityState==="hidden"&&(n=window.setTimeout($C,Ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Gt.localStorage=globalThis.localStorage)}catch{}var Zi=new Map,ub=!1,pn=new Map,ql=new Map,Gi=new Map,Ki=new Set;function pb(n){Object.assign(Ke,n),Ke.backgroundSync||Hp()}async function hb({instance:n,timeout:e,skipCache:t,allowStale:r,backgroundSync:i}){return i||(Ke.backgroundSync=!1),PC({instance:n,allowStale:r,timeout:e,skipCache:t})}function IC(n){let e=_o(n),t=Zi.get(e)||new Set;t.add(n),Zi.set(e,t)}function fb(n){Zi.forEach(e=>e.delete(n))}function $C(){Gi.forEach(n=>{n&&(n.state="idle",Fp(n))})}function MC(){Gi.forEach(n=>{n&&n.state==="idle"&&Dp(n)})}async function db(){try{if(!Gt.localStorage)return;await Gt.localStorage.setItem(Ke.cacheKey,JSON.stringify(Array.from(pn.entries())))}catch{}}async function PC({instance:n,allowStale:e,timeout:t,skipCache:r}){let i=_o(n),s=Np(n),o=new Date,a=new Date(o.getTime()-Ke.maxAge+Ke.staleTTL);await OC();let l=!Ke.disableCache&&!r?pn.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ki.add(i),l.staleAt<o?Op(n):Lp(n),{data:l.data,success:!0,source:"cache"}):await zl(Op(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function _o(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function Np(n){let e=_o(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 OC(){if(!ub){ub=!0;try{if(Gt.localStorage){let n=await Gt.localStorage.getItem(Ke.cacheKey);if(!Ke.disableCache&&n){let e=JSON.parse(n);e&&Array.isArray(e)&&e.forEach(([t,r])=>{pn.set(t,{...r,staleAt:new Date(r.staleAt)})}),gb()}}}catch{}if(!Ke.disableIdleStreams){let n=qi.startIdleListener();n&&(qi.stopIdleListener=n)}}}function gb(){let n=Array.from(pn.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,pn.size-Ke.maxEntries),pn.size);for(let t=0;t<e;t++)pn.delete(n[t].key)}function mb(n,e,t){let r=t.dateUpdated||"",i=new Date(Date.now()+Ke.staleTTL),s=Ke.disableCache?void 0:pn.get(e);if(s&&r&&s.version===r){s.staleAt=i,db();return}Ke.disableCache||(pn.set(e,{data:t,version:r,staleAt:i,sse:Ki.has(n)}),gb()),db();let o=Zi.get(n);o&&o.forEach(a=>NC(a,t))}async function NC(n,e){await n.setPayload(e||n.getPayload())}async function Op(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),r=n.getClientKey(),i="isRemoteEval"in n&&n.isRemoteEval(),s=_o(n),o=Np(n),a=ql.get(o);return a||(a=(i?qi.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):qi.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"&&Ki.add(s),c.json()}).then(c=>(mb(s,o,c),Lp(n),ql.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(ql.delete(o),{data:null,source:"error",success:!1,error:c})),ql.set(o,a)),a}function Lp(n,e=!1){let t=_o(n),r=Np(n),{streamingHost:i,streamingHostRequestHeaders:s}=n.getApiHosts(),o=n.getClientKey();if(e&&Ki.add(t),Ke.backgroundSync&&Ki.has(t)&&Gt.EventSource){if(Gi.has(t))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=Zi.get(t);c&&c.forEach(u=>{Op(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);mb(t,r,c)}a.errors=0}catch{vb(a)}},errors:0,state:"active"};Gi.set(t,a),Dp(a)}}function vb(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);Fp(n),setTimeout(()=>{["idle","active"].includes(n.state)||Dp(n)},Math.min(e,3e5))}}function Fp(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function Dp(n){n.src=qi.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=()=>vb(n),n.src.onopen=()=>{n.errors=0}}function LC(n,e){Fp(n),Gi.delete(e)}function Hp(){Ki.clear(),Gi.forEach(LC),Zi.clear(),qi.stopIdleListener()}function Zl(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Lp(n,!0),IC(n)}}var FC=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Wp={revert:function(){}},Xl=new Map,jp=new Set;function DC(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function Jl(n){var e=Xl.get(n);return e||(e={element:n,attributes:{}},Xl.set(n,e)),e}function Ql(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,DC(e)),o}function ec(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,yb()):n!==t&&(e.isDirty=!0,yb())}function HC(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),ec(QC(e),n)}function BC(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),ec(Array.from(e).filter(Boolean).join(" "),n)}function VC(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),ec(e,n)}function WC(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 jC(n){var e=n.originalValue;n.mutations.forEach(function(t){var r=t.mutate(),i=WC(r);e=i||e}),ec(e,n)}var UC=function(e){return e.innerHTML},zC=function(e,t){return e.innerHTML=t};function _b(n){var e=Jl(n);return e.html||(e.html=Ql(n,"html",UC,zC,HC)),e.html}var qC=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},ZC=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};function xb(n){var e=Jl(n);return e.position||(e.position=Ql(n,"position",qC,ZC,jC)),e.position}var GC=function(e,t){return t?e.className=t:e.removeAttribute("class")},KC=function(e){return e.className};function wb(n){var e=Jl(n);return e.classes||(e.classes=Ql(n,"class",KC,GC,BC)),e.classes}var YC=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},XC=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};function kb(n,e){var t=Jl(n);return t.attributes[e]||(t.attributes[e]=Ql(n,e,YC(e),XC(e),VC)),t.attributes[e]}function JC(n,e){var t=Xl.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 Gl;function QC(n){return Gl||(Gl=document.createElement("div")),Gl.innerHTML=n,Gl.innerHTML}function Kl(n,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||JC(n,e),t.setValue(n,r)}}function eA(n,e){n.html&&Kl(e,"html",n.html),n.classes&&Kl(e,"class",n.classes),n.position&&Kl(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){Kl(e,t,n.attributes[t])})}function yb(){Xl.forEach(eA)}function tA(n,e){var t=null;n.kind==="html"?t=_b(e):n.kind==="class"?t=wb(e):n.kind==="attribute"?t=kb(e,n.attribute):n.kind==="position"&&(t=xb(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function nA(n,e){var t=null;if(n.kind==="html"?t=_b(e):n.kind==="class"?t=wb(e):n.kind==="attribute"?t=kb(e,n.attribute):n.kind==="position"&&(t=xb(e)),!!t){var r=t.mutations.indexOf(n);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function Sb(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),tA(n,r))})}}function rA(n){n.elements.forEach(function(e){return nA(n,e)}),n.elements.clear(),jp.delete(n)}function bb(){jp.forEach(Sb)}var Bp;function iA(){typeof document>"u"||(Bp||(Bp=new MutationObserver(function(){bb()})),bb(),Bp.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}iA();function tc(n){return typeof document>"u"?Wp:(jp.add(n),Sb(n),{revert:function(){rA(n)}})}function Vp(n,e){return tc({kind:"html",elements:new Set,mutate:e,selector:n})}function Eb(n,e){return tc({kind:"position",elements:new Set,mutate:e,selector:n})}function xo(n,e){return tc({kind:"class",elements:new Set,mutate:e,selector:n})}function Yl(n,e,t){return FC.test(e)?e==="class"||e==="className"?xo(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)})}):tc({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):Wp}function sA(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 Vp(e,function(a){return a+(r??"")});if(t==="set")return Vp(e,function(){return r??""})}else if(i==="class"){if(t==="append")return xo(e,function(a){r&&a.add(r)});if(t==="remove")return xo(e,function(a){r&&a.delete(r)});if(t==="set")return xo(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(t==="set"&&s)return Eb(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 Wp}var oA={html:Vp,classes:xo,attribute:Yl,position:Eb,declarative:sA},Cb=oA;var Up={};function Hn(n,e,t){t=t||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!Tb(n,i,t))return!1;break;case"$nor":if(Tb(n,i,t))return!1;break;case"$and":if(!dA(n,i,t))return!1;break;case"$not":if(Hn(n,i,t))return!1;break;default:if(!wo(i,aA(n,r),t))return!1}return!0}function aA(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 Ab(n,e=!1){let t=`${n}${e?"/i":""}`;return Up[t]||(Up[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Up[t]}function wo(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)||!Ib(n))return JSON.stringify(e)===JSON.stringify(n);for(let i in n)if(!uA(i,e,n[i],t))return!1;return!0}function Ib(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function lA(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 cA(n,e,t){if(!Array.isArray(n))return!1;let r=Ib(e)?i=>wo(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 Yi(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 Rb(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(wo(e[i],n[o],t,r)){s=!0;break}if(!s)return!1}return!0}function uA(n,e,t,r){switch(n){case"$veq":return dt(e)===dt(t);case"$vne":return dt(e)!==dt(t);case"$vgt":return dt(e)>dt(t);case"$vgte":return dt(e)>=dt(t);case"$vlt":return dt(e)<dt(t);case"$vlte":return dt(e)<=dt(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)?Yi(e,t):!1;case"$ini":return Array.isArray(t)?Yi(e,t,!0):!1;case"$inGroup":return Yi(e,r[t]||[]);case"$notInGroup":return!Yi(e,r[t]||[]);case"$nin":return Array.isArray(t)?!Yi(e,t):!1;case"$nini":return Array.isArray(t)?!Yi(e,t,!0):!1;case"$not":return!wo(t,e,r);case"$size":return Array.isArray(e)?wo(t,e.length,r):!1;case"$elemMatch":return cA(e,t,r);case"$all":return Array.isArray(t)?Rb(e,t,r):!1;case"$alli":return Array.isArray(t)?Rb(e,t,r,!0):!1;case"$regex":try{return Ab(t).test(e)}catch{return!1}case"$regexi":try{return Ab(t,!0).test(e)}catch{return!1}case"$type":return lA(e)===t;default:return console.error("Unknown operator: "+n),!1}}function Tb(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 dA(n,e,t){for(let r=0;r<e.length;r++)if(!Hn(n,e[r],t))return!1;return!0}var pA="Feature Evaluated",hA="Experiment Viewed";function fA(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 gA(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 Xi(n){try{await n()}catch{}}function $b(n,e,t){if(n.user.trackedExperiments){let i=ic(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(Xi(()=>i(e,t,n.user)))}if(n.user.trackingCallback){let i=n.user.trackingCallback;r.push(Xi(()=>i(e,t)))}if(n.global.eventLogger){let i=n.global.eventLogger;r.push(Xi(()=>i(hA,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return r}function mA(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;Xi(()=>r(e,t,n.user))}if(n.user.onFeatureUsage){let r=n.user.onFeatureUsage;Xi(()=>r(e,t))}if(n.global.eventLogger){let r=n.global.eventLogger;Xi(()=>r(pA,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function nc(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=fA(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=nc(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&&Ob(s.filters,e))continue;if("force"in s){if(s.condition&&!Pb(s.condition,e)||!vA(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=>{!$b(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}=rc(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 rc(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=yA(n,t),n.urlPatterns&&!jl(t.user.url||"",n.urlPatterns))return{result:Ae(t,n,-1,!1,e)};let s=ob(r,t.user.url||"",i);if(s!==null)return{result:Ae(t,n,s,!1,e)};let o=gA(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}=Hr(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}=xA({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(Ob(n.filters,t))return{result:Ae(t,n,-1,!1,e)}}else if(n.namespace&&!rb(l,n.namespace))return{result:Ae(t,n,-1,!1,e)};if(n.include&&!ab(n.include))return{result:Ae(t,n,-1,!1,e)};if(n.condition&&!Pb(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=nc(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&&!_A(n.groups,t))return{result:Ae(t,n,-1,!1,e)}}if(n.url&&!bA(n.url,t))return{result:Ae(t,n,-1,!1,e)};let h=yo(n.seed||r,l,n.hashVersion||1);if(h===null)return{result:Ae(t,n,-1,!1,e)};if(!u){let m=n.ranges||sb(i,n.coverage===void 0?1:n.coverage,n.weights);c=ib(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}=kA(t,a,bo(l),{[zp(n.key,n.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=k,t.user.saveStickyBucketAssignmentDoc(k))}let v=$b(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"&&mA(n,e,a),a}function Mb(n){return{...n.user.attributes,...n.user.attributeOverrides}}function Pb(n,e){return Hn(Mb(e),n,e.global.savedGroups||{})}function Ob(n,e){return n.some(t=>{let{hashValue:r}=Hr(e,t.attribute);if(!r)return!0;let i=yo(t.seed,r,t.hashVersion||2);return i===null?!0:!t.ranges.some(s=>Wl(i,s))})}function vA(n,e,t,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=Hr(n,t,r);if(!a)return!1;let l=yo(e,a,o||1);return l===null?!1:i?Wl(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}=Hr(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 yA(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=Pp(n.url))),n}function Hr(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 bA(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 _A(n,e){let t=e.global.groups||{};for(let r=0;r<n.length;r++)if(t[n[r]])return!0;return!1}function xA({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=zp(e,t),l=wA(n,r,i);if(s>0)for(let d=0;d<s;d++){let h=zp(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 zp(n,e){return e=e||0,`${n}__${e}`}function qp(n,e){return`${n}||${e}`}function wA(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=Hr(n,e),s=qp(r,bo(i)),{hashAttribute:o,hashValue:a}=Hr(n,t),l=a?qp(o,bo(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 kA(n,e,t,r){let i=qp(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 Nb(n,e,t){let r=Zp(n,t);return e.getAllAssignments(r)}function Zp(n,e){let t={};return SA(n,e).forEach(i=>{let{hashValue:s}=Hr(n,i);t[i]=bo(s)}),t}async function Lb(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await Dr(n.encryptedFeatures,e,t))}catch(r){console.error(r)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await Dr(n.encryptedExperiments,e,t))}catch(r){console.error(r)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await Dr(n.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete n.encryptedSavedGroups}return n}function Fb(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 ic(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var Ji=typeof window<"u"&&typeof document<"u",EA=lb(),ko=class{constructor(e){if(e=e||{},this.version=EA,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),Ji&&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 Lb(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,Zl(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&pb(e.cacheSettings),e.payload)return await this.setPayload(e.payload),Zl(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return Zl(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 Fb(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 hb({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 Dr(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 Dr(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,fb(this),e.destroyAllStreams&&Hp(),this.logs=[],Ji&&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}=rc(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}=rc(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=Ul(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?cb(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(jl(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(Ji)Promise.all([...o?[zl(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&&Ul(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 nc(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=>[ic(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(ic(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Ji?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=Ul(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}:Ji?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Ji)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(Cb.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await Nb(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=Zp(r,t);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var CA="https://experiment.syntrologie.com",Gp=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 ko({...e,apiHost:e.apiHost??CA,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 sc(n={}){return new Gp(n)}var Db={growthbook:n=>sc({...n,autoInit:!0})};function Hb(n,e){let t=Db[n];if(!t)throw new Error(`Unknown experiment provider: ${n}. Supported: ${Object.keys(Db).join(", ")}`);return t(e)}var AA=["cdn.syntrologie.com","localhost","127.0.0.1"];function RA(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):AA.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 Kp=class{constructor(e){this.name="cdn";if(this.url=`${e.baseUrl}/${e.configId}.json`,this.integrity=e.integrity,!RA(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 TA(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 TA(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 Bb(n){return new Kp(n)}var IA="syntro_exp",$A="syntro_var",Yp=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(IA),o=i.get($A);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:el(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 Vb(n){return new Yp(n)}var MA="https://cdn.syntrologie.com/configs",Wb={cdn:n=>{if(!n.configId)throw new Error("CDN fetcher requires 'configId' option");return Bb({baseUrl:n.baseUrl??MA,configId:n.configId,integrity:n.integrity})},experiments:n=>{if(!n.featureKey)throw new Error("Experiments fetcher requires 'featureKey' option");return Vb({featureKey:n.featureKey})}};function jb(n,e={}){let t=Wb[n];if(!t)throw new Error(`Unknown config fetcher type: ${n}. Supported: ${Object.keys(Wb).join(", ")}`);return t(e)}var Ub="syntro_session_metrics",So=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(Ub);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(Ub,JSON.stringify(e))}catch(e){console.warn("[SessionMetricTracker] Failed to save to sessionStorage:",e)}}};function oc(n={}){return new So(n)}var ac=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 lc=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 ac(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 PA=[()=>new lc];function zb(){for(let n of PA){let e=n();if(e.detect())return e}return null}var Xp="syntro_experiments";var NA=720*60*60,cc=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=`${Xp}=; 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=`${Xp}=${t}; max-age=${NA}; path=/; SameSite=Lax`;document.cookie=r}};function LA(){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 Jp(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(qb(t,r))return}if(e.include){for(let r of e.include)if(qb(t,r))return r;return}return t}function qb(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 Eo=class{constructor(e){this.listeners=new Set;this.cleanupFns=[];if(this.telemetry=e.telemetry,this.routes=e.routes,this.navigation=e.navigation,this.context=LA(),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=Jp(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=Jp(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=Jp(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 uc(n){return new Eo(n)}function Qp(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 eh(n,e){let t=[];for(let r of n.conditions){let i=Qp(r,e);if(t.push({condition:r,result:i}),!i)return{matched:!1,conditionResults:t}}return{matched:!0,conditionResults:t}}function Co(n,e){for(let t=0;t<n.rules.length;t++){let r=n.rules[t],{matched:i,conditionResults:s}=eh(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 Ao(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 Zb(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 th(n,e,t={}){let r=Zb(e,t);switch(n.type){case"rules":return Co(n,r);case"score":return Ao(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 nh(n,e,t={}){let r=Zb(e,t);switch(n.type){case"rules":return Co(n,r);case"score":return Ao(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 dc(n){return{evaluate:(e,t)=>th(e,t,n),evaluateSync:(e,t)=>nh(e,t,n)}}function pc(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 Qi=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 rh="cooldown:";function Gb(n){return{set(e,t){let r=rh+e,i=Date.now()+t;n.set(r,i)},isActive(e){return this.remaining(e)>0},remaining(e){let t=rh+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=rh+e;n.remove(t)}}}var Ro="dismissed:";function Kb(n,e){return{mark(t,r=!1){let i=Ro+t;(r?e:n).set(i,!0)},isDismissed(t){let r=Ro+t;return n.has(r)||e.has(r)},clear(t){let r=Ro+t;n.remove(r),e.remove(r)},clearAll(){for(let t of n.keys())t.startsWith(Ro)&&n.remove(t);for(let t of e.keys())t.startsWith(Ro)&&e.remove(t)}}}var ih="freq:";function Yb(n){function e(t){let r=ih+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=ih+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=ih+t;n.remove(r)},hasReachedLimit(t,r){return this.count(t)>=r}}}var FA="syntro";function sh(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 To(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 Io=class{constructor(e={}){this.namespacedStorages=new Map;this.namespace=e.namespace??FA;let t=r=>typeof r=="object"&&r!==null&&typeof r.setItem=="function";typeof window<"u"?(this.session=t(window.sessionStorage)?sh(window.sessionStorage,this.namespace):To(this.namespace),this.user=t(window.localStorage)?sh(window.localStorage,this.namespace):To(this.namespace)):(this.session=To(this.namespace),this.user=To(this.namespace)),this.dismissals=Kb(this.session,this.user),this.cooldowns=Gb(this.user),this.frequency=Yb(this.session)}ns(e){let t=`${this.namespace}:${e}`;if(!this.namespacedStorages.has(t)){let r=typeof window<"u"&&typeof sessionStorage<"u"?sh(sessionStorage,t):To(t);this.namespacedStorages.set(t,r)}return this.namespacedStorages.get(t)}};function hc(n={}){return new Io(n)}function es(n){return n.startsWith("inline:")?"inline":n.startsWith("adjacent:")?"adjacent":"static"}function $o(n){return n.startsWith("inline:")?n.slice(7):n.startsWith("adjacent:")?n.slice(9):null}var oh={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"}},ts={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:[]},Xb={duration:200,easing:"cubic-bezier(0.16, 1, 0.3, 1)",fill:"forwards"};function fc(n,e,t){let r=oh[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 gc(n,e,t){let r=t.placement==="auto"?"bottom":t.placement,i=[Xr(t.offset?{mainAxis:t.offset.y,crossAxis:t.offset.x}:8)];return t.flip!==!1&&i.push(Qr()),t.shift!==!1&&i.push(Jr({padding:8})),n.style.position="absolute",n.style.zIndex="2147483646",Yr(e,n,async()=>{let{x:o,y:a,strategy:l}=await ei(e,n,{placement:r,middleware:i});Object.assign(n.style,{position:l,left:`${o}px`,top:`${a}px`})})}function mc(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 vc(n,e){return e==="none"||ts[e].length===0?null:n.animate(ts[e],Xb)}function yc(n,e){if(e==="none"||ts[e].length===0)return Promise.resolve();let t=[...ts[e]].reverse(),r=n.animate(t,Xb);return new Promise(i=>{r.onfinish=()=>i(),r.oncancel=()=>i()})}function bc(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 _c(n){switch(es(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 Jb(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 DA=0;function xc(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-${++DA}`}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=Jb(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=es(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=bc(b,w);L.style.zIndex=String(_c(b));let N;if(E==="static")fc(L,b,R?.constraints),e.appendChild(L);else if(E==="inline"){let A=$o(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=mc(L,F)}else if(E==="adjacent"){let A=$o(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=gc(L,F,R?.position??{placement:"bottom"})}let z=g(L,x,w);vc(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 yc(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 Mo=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()}},wc=new Mo;var lh="2.0.0";function HA(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(ah(r,i))return!1}if(e.include&&e.include.length>0){for(let i of e.include)if(ah(r,i))return!0;return!1}return!0}function ah(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 Qb(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 ah(t,s)})}function kc(n={}){let{telemetry:e,sessionMetrics:t,routes:r,mode:i="production",namespace:s}=n,o=n.widgets??wc,a=n.executors??jt,l=n.apps??Bs,c=new Qi,u=uc({telemetry:e,routes:r,navigation:c}),d=n.events??Ui(),h=hc({namespace:s}),g=pc({eventBus:d,stateStore:h}),v=dc({state:h,events:d,sessionMetrics:t,accumulator:g}),f=zy(),m=Pl(),y=M=>Qb(M)?m.resolve(M.selector):null,k=async(M,G)=>{if(!Qb(M))return null;try{return await m.waitFor(M.selector,G)}catch{return null}},_=xc({overlayRoot:f,eventBus:d,anchorResolver:y,widgetRegistry:o}),b=fl({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:lh,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(HA(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 ns=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 BA(){let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=n[Math.floor(Math.random()*n.length)];return e}var ch=class{constructor(){this.sessionId=BA(),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 Sc(){return new ch}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 K_=Array.prototype,e_=K_.forEach,t_=K_.indexOf,ht=qe?.navigator,V=qe?.document,ze=qe?.location,Ah=qe?.fetch,Rh=qe!=null&&qe.XMLHttpRequest&&"withCredentials"in new qe.XMLHttpRequest?qe.XMLHttpRequest:void 0,n_=qe?.AbortController,ot=ht?.userAgent,Q=C??{},gn={DEBUG:!1,LIB_VERSION:"1.341.0"};function r_(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 as(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var s=n.apply(e,t);function o(l){r_(s,r,i,o,a,"next",l)}function a(l){r_(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 Y_(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 VA=["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"],i_=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return VA.concat(e).some((r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1}))},WA=["$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 eu=function(n){return n.trim()},Th=function(n){return n.replace(/^\$/,"")},jA=Array.isArray,X_=Object.prototype,J_=X_.hasOwnProperty,tu=X_.toString,me=jA||function(n){return tu.call(n)==="[object Array]"},qn=n=>typeof n=="function",Ne=n=>n===Object(n)&&!me(n),ls=n=>{if(Ne(n)){for(var e in n)if(J_.call(n,e))return!1;return!0}return!1},W=n=>n===void 0,Le=n=>tu.call(n)=="[object String]",Ih=n=>Le(n)&&n.trim().length===0,Ht=n=>n===null,pe=n=>W(n)||Ht(n),xn=n=>tu.call(n)=="[object Number]"&&n==n,ss=n=>xn(n)&&n>0,_n=n=>tu.call(n)==="[object Boolean]",UA=n=>n instanceof FormData,zA=n=>ue(WA,n);function $h(n){return n===null||typeof n!="object"}function Mc(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function Q_(n){return!W(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}var qA=[!0,"true",1,"1","yes"],uh=n=>ue(qA,n),ZA=[!1,"false",0,"0","no"];function Yt(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),xn(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),Yt(i||t,e,t,r))}var Mh=class{constructor(e){this.t={},this.i=e.i,this.o=Yt(e.bucketSize,0,100,e.h),this.m=Yt(e.refillRate,0,this.o,e.h),this.$=Yt(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",Pc="iOS",bn="Android",Qo="Tablet",e0=bn+" "+Qo,t0="iPad",n0="Apple",r0=n0+" Watch",ea="Safari",ps="BlackBerry",i0="Samsung",s0=i0+"Browser",o0=i0+" Internet",jr="Chrome",GA=jr+" OS",a0=jr+" "+Pc,Vf="Internet Explorer",l0=Vf+" "+kt,Wf="Opera",KA=Wf+" Mini",jf="Edge",c0="Microsoft "+jf,us="Firefox",u0=us+" "+Pc,ta="Nintendo",na="PlayStation",ds="Xbox",d0=bn+" "+kt,p0=kt+" "+ea,Wo="Windows",Ph=Wo+" Phone",s_="Nokia",Oh="Ouya",h0="Generic",YA=h0+" "+kt.toLowerCase(),f0=h0+" "+Qo.toLowerCase(),Nh="Konqueror",tt="(\\d+(\\.\\d+)?)",dh=new RegExp("Version/"+tt),XA=new RegExp(ds,"i"),JA=new RegExp(na+" \\w+","i"),QA=new RegExp(ta+" \\w+","i"),Uf=new RegExp(ps+"|PlayBook|BB10","i"),eR={"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"},Ec,o_,ph,tR=(n,e)=>e&&ue(e,n0)||(function(t){return ue(t,ea)&&!ue(t,jr)&&!ue(t,bn)})(n),g0=function(n,e){return e=e||"",ue(n," OPR/")&&ue(n,"Mini")?KA:ue(n," OPR/")?Wf:Uf.test(n)?ps:ue(n,"IE"+kt)||ue(n,"WPDesktop")?l0:ue(n,s0)?o0:ue(n,jf)||ue(n,"Edg/")?c0:ue(n,"FBIOS")?"Facebook "+kt:ue(n,"UCWEB")||ue(n,"UCBrowser")?"UC Browser":ue(n,"CriOS")?a0:ue(n,"CrMo")||ue(n,jr)?jr:ue(n,bn)&&ue(n,ea)?d0:ue(n,"FxiOS")?u0:ue(n.toLowerCase(),Nh.toLowerCase())?Nh:tR(n,e)?ue(n,kt)?p0:ea:ue(n,us)?us:ue(n,"MSIE")||ue(n,"Trident/")?Vf:ue(n,"Gecko")?us:""},nR={[l0]:[new RegExp("rv:"+tt)],[c0]:[new RegExp(jf+"?\\/"+tt)],[jr]:[new RegExp("("+jr+"|CrMo)\\/"+tt)],[a0]:[new RegExp("CriOS\\/"+tt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+tt)],[ea]:[dh],[p0]:[dh],[Wf]:[new RegExp("(Opera|OPR)\\/"+tt)],[us]:[new RegExp(us+"\\/"+tt)],[u0]:[new RegExp("FxiOS\\/"+tt)],[Nh]:[new RegExp("Konqueror[:/]?"+tt,"i")],[ps]:[new RegExp(ps+" "+tt),dh],[d0]:[new RegExp("android\\s"+tt,"i")],[o0]:[new RegExp(s0+"\\/"+tt)],[Vf]:[new RegExp("(rv:|MSIE )"+tt)],Mozilla:[new RegExp("rv:"+tt)]},rR=function(n,e){var t=g0(n,e),r=nR[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},a_=[[new RegExp(ds+"; "+ds+" (.*?)[);]","i"),n=>[ds,n&&n[1]||""]],[new RegExp(ta,"i"),[ta,""]],[new RegExp(na,"i"),[na,""]],[Uf,[ps,""]],[new RegExp(Wo,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Ph,""];if(new RegExp(kt).test(e)&&!/IEMobile\b/.test(e))return[Wo+" "+kt,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=eR[r]||"";return/arm/i.test(e)&&(i="RT"),[Wo,i]}return[Wo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[Pc,e.join(".")]}return[Pc,""]}],[/(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("("+bn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+bn+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[bn,e.join(".")]}return[bn,""]}],[/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/,[GA,""]],[/Linux|debian/i,["Linux",""]]],l_=function(n){return QA.test(n)?ta:JA.test(n)?na:XA.test(n)?ds:new RegExp(Oh,"i").test(n)?Oh:new RegExp("("+Ph+"|WPDesktop)","i").test(n)?Ph:/iPad/.test(n)?t0:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?r0:Uf.test(n)?ps:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(s_,"i").test(n)?s_:/(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)?bn:e0:new RegExp("(pda|"+kt+")","i").test(n)?YA:new RegExp(Qo,"i").test(n)&&!new RegExp(Qo+" pc","i").test(n)?f0:""},iR=n=>n instanceof Error;function sR(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return ph&&t.length===o_||(o_=t.length,ph=t.reduce(((r,i)=>{Ec||(Ec={});var s=Ec[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,Ec[i]=[c,u];break}}return r}),{})),ph}}var Lh=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 as((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 as((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:sR(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)})}},hs="?";function Fh(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?hs:t,in_app:!0};return W(r)||(s.lineno=r),W(i)||(s.colno=i),s}var m0=(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]:hs,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},oR=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,aR=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,lR=/\((\S*)(?::(\d+))(?::(\d+))\)/,cR=(n,e)=>{var t=oR.exec(n);if(t){var[,r,i,s]=t;return Fh(e,r,hs,+i,+s)}var o=aR.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=lR.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=m0(o[1]||hs,o[2]);return Fh(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},uR=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,dR=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,pR=(n,e)=>{var t=uR.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=dR.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]||hs;return[s,i]=m0(s,i),Fh(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},c_=/\(error: (.*)\)/,u_=50;function hR(){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=c_.test(c)?c.replace(c_,"$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>=u_)break}}}return(function(g){if(!g.length)return[];var v=Array.from(g);return v.reverse(),v.slice(0,u_).map((f=>{return U({},f,{filename:f.filename||(m=v,m[m.length-1]||{}).filename,function:f.function||hs});var m}))})(o)}})("web:javascript",cR,pR)}var Dh=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 Mc(e,"DOMException")}isDOMError(e){return Mc(e,"DOMError")}},Hh=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}},Bh=class{constructor(){}match(e){return Mc(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}}},fR=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Vh=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(fR);return i&&(t=i[1],r=i[2]),[t,r]}},gR=["fatal","error","warning","log","info","debug"];function v0(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 Wh=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 Q_(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: "+v0(e)}isSeverityLevel(e){return Le(e)&&!Ih(e)&&gR.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(iR(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},jh=class{match(e){return Q_(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+v0(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Uh=class{match(e){return $h(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}}},zh=class{match(e){return Mc(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return $h(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($h(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}},y0=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(C&&(gn.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)=>y0(n+" "+i,s)};return r},j=y0("[PostHog.js]"),$e=j.createLogger,mR=$e("[ExternalScriptsLoader]"),d_=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return mR.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);d_(n,s,t)},Q.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);d_(n,r,t)};var Oc={};function Zn(n,e,t){if(me(n)){if(e_&&n.forEach===e_)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)===Oc)return}}}function ke(n,e,t){if(!pe(n)){if(me(n))return Zn(n,e,t);if(UA(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===Oc)return}else for(var i in n)if(J_.call(n,i)&&e.call(t,n[i],i)===Oc)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},gs=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 Ic(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 p_=function(n){try{return n()}catch{return}},vR=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)}}},zf=function(n){var e={};return ke(n,(function(t,r){(Le(t)&&t.length>0||xn(t))&&(e[r]=t)})),e};function yR(n,e){return t=n,r=s=>Le(s)&&!Ht(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 bR=["herokuapp.com","vercel.app","netlify.app"];function _R(n){var e=n?.hostname;if(!Le(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of bR)if(t===r)return!1;return!0}function b0(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 _0="$people_distinct_id",jo="__alias",Uo="__timers",h_="$autocapture_disabled_server_side",qh="$heatmaps_enabled_server_side",f_="$exception_capture_enabled_server_side",Zh="$error_tracking_suppression_rules",g_="$error_tracking_capture_extension_exceptions",m_="$web_vitals_enabled_server_side",x0="$dead_clicks_enabled_server_side",v_="$product_tours_enabled_server_side",y_="$web_vitals_allowed_metrics",hh="$session_recording_remote_config",Nc="$sesid",w0="$session_is_sampled",cs="$enabled_feature_flags",zo="$early_access_features",Gh="$feature_flag_details",qo="$stored_person_properties",Wr="$stored_group_properties",Kh="$surveys",Lc="$flag_call_reported",mn="$user_state",Yh="$client_session_props",Xh="$capture_rate_limit",Jh="$initial_campaign_params",Qh="$initial_referrer_info",Fc="$initial_person_info",Dc="$epp",k0="__POSTHOG_TOOLBAR__",Po="$posthog_cookieless",xR=[_0,jo,"__cmpns",Uo,"$session_recording_enabled_server_side",qh,Nc,cs,Zh,mn,zo,Gh,Wr,qo,Kh,Lc,Yh,Xh,Jh,Qh,Dc,Fc,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function b_(n){return n instanceof Element&&(n.id===k0||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function nu(n){return!!n&&n.nodeType===1}function Gn(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function S0(n){return!!n&&n.nodeType===3}function E0(n){return!!n&&n.nodeType===11}function qf(n){return n?eu(n).split(/\s+/):[]}function __(n){var e=C?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function Hc(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 qf(e)}function C0(n){return pe(n)?null:eu(n).split(/(\s+)/).filter((e=>ra(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function sa(n){var e="";return ef(n)&&!$0(n)&&n.childNodes&&n.childNodes.length&&ke(n.childNodes,(function(t){var r;S0(t)&&t.textContent&&(e+=(r=C0(t.textContent))!==null&&r!==void 0?r:"")})),eu(e)}function A0(n){return W(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Zf=["a","button","form","input","select","textarea","label"];function R0(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 T0(n){var e=n.parentNode;return!(!e||!nu(e))&&e}var wR=["next","previous","prev",">","<"],x_=10,w_=[".ph-no-rageclick",".ph-no-capture"];function kR(n,e){if(!C||Gf(n))return!1;var t,r,i;if(_n(e)?(t=!!e&&w_,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:w_,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=I0(n,!1);return!(function(o,a){if(o===!1||W(o))return!1;var l;if(o===!0)l=wR;else{if(!me(o))return!1;if(o.length>x_)return j.error("[PostHog] content_ignorelist array cannot exceed "+x_+" 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:sa(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!R0(s,t)}var Gf=n=>!n||Gn(n,"html")||!nu(n),I0=(n,e)=>{if(!C||Gf(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!Gn(i,"body");)if(E0(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=T0(i);if(!s)break;if(e||Zf.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||Gf(n)||(s=t)!=null&&s.url_allowlist&&!__(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&__(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}=I0(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)||!R0(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&&(Zf.indexOf(g)>-1||n.getAttribute("contenteditable")==="true")}}function ef(n){for(var e=n;e.parentNode&&!Gn(e,"body");e=e.parentNode){var t=Hc(e);if(ue(t,"ph-sensitive")||ue(t,"ph-no-capture"))return!1}if(ue(Hc(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 $0(n){return!!(Gn(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||Gn(n,"select")||Gn(n,"textarea")||n.getAttribute("contenteditable")==="true")}var M0="(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})",ER=new RegExp("^(?:"+M0+")$"),CR=new RegExp(M0),P0="\\d{3}-?\\d{2}-?\\d{4}",AR=new RegExp("^("+P0+")$"),RR=new RegExp("("+P0+")");function ra(n,e){return e===void 0&&(e=!0),!(pe(n)||Le(n)&&(n=eu(n),(e?ER:CR).test((n||"").replace(/[- ]/g,""))||(e?AR:RR).test(n)))}function O0(n){var e=sa(n);return ra(e=(e+" "+N0(n)).trim())?e:""}function N0(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=sa(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+N0(t)).trim())}catch(s){j.error("[AutoCapture]",s)}})),e}function TR(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 Ic(l).sort(((u,d)=>{var[h]=u,[g]=d;return h.localeCompare(g)})).forEach((u=>{var[d,h]=u;return c[k_(d.toString())]=k_(h.toString())})),o+=":",o+=Ic(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:IR(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ic(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 k_(n){return n.replace(/"|\\"/g,'\\"')}function IR(n){var e=n.attr__class;return e?me(e)?e:qf(e):void 0}var Bc=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}},Vc=n=>{var e=V?.createElement("a");return W(e)?null:(e.href=n,e)},$R=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)},Wc=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," ")},oa=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},jc=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},fh="$copy_autocapture",S_=$e("[AutoCapture]");function gh(n,e){return e.length>n?e.slice(0,n)+"...":e}function MR(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!nu(e));return e}function PR(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Zf.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=gh(1024,O0(n)):s.$el_text=gh(1024,sa(n)));var o=Hc(n);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),ke(n.attributes,(function(u){var d;if((!$0(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&ra(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=qf(h).join(" ")),s["attr__"+u.name]=gh(1024,h)}}));for(var a=1,l=1,c=n;c=MR(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function OR(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");)E0(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=ef(b);b.tagName.toLowerCase()==="a"&&(v=b.getAttribute("href"),v=x&&v&&ra(v)&&v),ue(Hc(b),"ph-no-capture")&&(f=!0),h.push(PR(b,s,o,a));var R=(function(w){if(!ef(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&&ra(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=O0(n):h[0].$el_text=sa(n)),v){var m,y;h[0].attr__href=v;var k=(m=Vc(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:TR(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 tf=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Bc(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){S_.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,fh)};Oe(V,"copy",t,{capture:!0}),Oe(V,"cut",t,{capture:!0})}}}else S_.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({[h_]:!!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[h_],i=this.T;if(Ht(i)&&!_n(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=A0(e);S0(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())&&kR(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===fh;if(i&&SR(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=OR(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===fh){var c,u=C0(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 xn(n)&&isFinite(n)&&Math.floor(n)===n});var E_="0123456789abcdef",nf=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+E_.charAt(this.bytes[t]>>>4)+E_.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}},rf=class{constructor(){this.A=0,this.j=0,this.D=new sf}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 nf.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())}},C_,L0=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&&(L0=n=>crypto.getRandomValues(n));var sf=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(L0(this.N),this.U=0),this.N[this.U++]}},zn=()=>NR().toString(),NR=()=>(C_||(C_=new rf)).generate(),Oo="",LR=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function FR(n,e){if(e){var t=(function(i,s){if(s===void 0&&(s=V),Oo)return Oo;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();!Oo&&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",Oo=c)}return Oo})(n);if(!t){var r=(i=>{var s=i.match(LR);return s?s[0]:""})(n);r!==t&&j.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var Kt={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(Kt.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(V)try{var s="",o="",a=FR(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{Kt.G(n,"",-1,e)}catch{return}}},mh=null,Re={H:function(){if(!Ht(mh))return mh;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"),mh=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)}}},DR=["$device_id","distinct_id",Nc,w0,Dc,Fc],Cc={},HR={H:function(){return!0},B:function(n){j.error("memoryStorage error: "+n)},q:function(n){return Cc[n]||null},W:function(n){return Cc[n]||null},G:function(n,e){Cc[n]=e},V:function(n){delete Cc[n]}},Br=null,Ue={H:function(){if(!Ht(Br))return Br;if(Br=!0,W(C))Br=!1;else try{var n="__support__";Ue.G(n,"xyz"),Ue.q(n)!=='"xyz"'&&(Br=!1),Ue.V(n)}catch{Br=!1}return Br},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)}}},vn=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),of=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?vn.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===vn.DENIED||this.consent===vn.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===vn.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 uh(e)?vn.GRANTED:ue(ZA,e)?vn.DENIED:vn.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?Re:Kt;var t=e==="localStorage"?Kt:Re;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(uh(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!b0([ht?.doNotTrack,ht?.msDoNotTrack,Q.doNotTrack],(e=>uh(e)))}},Ac=$e("[Dead Clicks]"),BR=()=>!0,VR=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(x0)),r=n.instance.config.capture_dead_clicks;return _n(r)?r:!!Ne(r)||t},Uc=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({[x0]: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?Ac.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),Ac.info("starting...")}}else Ac.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Ac.info("stopping..."))}},No=$e("[ExceptionAutocapture]"),af=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){No.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[f_]),this.dt=new Mh({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:No}),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?(No.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 No.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({[f_]: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)?No.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function A_(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 lf=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__||A_(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__||A_(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)}}}},vh=$e("[SegmentIntegration]");function WR(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(mn,"identified")),i()},a=s.user();"then"in a&&qn(a.then)?a.then(o):o(a)})(n,(()=>{t.register((r=>{Promise&&Promise.resolve||vh.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()||(vh.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(vh.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 F0="posthog-js";function D0(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 cf=class{constructor(e,t,r,i,s,o){this.name=F0,this.setupOnce=function(a){a(D0(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},jR=C!=null&&C.location?jc(C.location.hash,"__posthog")||jc(location.hash,"state"):null,R_="_postHogToolbarParams",T_=$e("[Toolbar]"),Un=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(Un||{}),uf=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=jR||jc(e.hash,"__posthog")||jc(e.hash,"state"),o=s?p_((()=>JSON.parse(atob(decodeURIComponent(s)))))||p_((()=>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(R_)||"{}")).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):T_.warn("No toolbar load function found")}loadToolbar(e){var t=!(V==null||!V.getElementById(k0));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(R_,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 T_.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)}},UR=$e("[TracingHeaders]"),df=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 UR.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)}},Rc="https?://(.*)",ms=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],zR=gs(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],ms),aa="<masked>",qR=["li_fat_id"];function H0(n,e,t){if(!V)return{};var r,i=e?gs([],ms,t||[]):[],s=B0(oa(V.URL,i,aa),n),o=(r={},ke(qR,(function(a){var l=Kt.q(a);r[a]=l||null})),r);return Me(o,s)}function B0(n,e){var t=zR.concat(e||[]),r={};return ke(t,(function(i){var s=Wc(n,i);r[i]=s||null})),r}function V0(n){var e=(function(s){return s?s.search(Rc+"google.([^/?]*)")===0?"google":s.search(Rc+"bing.com")===0?"bing":s.search(Rc+"yahoo.com")===0?"yahoo":s.search(Rc+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",r={};if(!Ht(e)){r.$search_engine=e;var i=V?Wc(V.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function I_(){return navigator.language||navigator.userLanguage}function W0(){return V?.referrer||"$direct"}function j0(n,e){var t=n?gs([],ms,e||[]):[],r=ze?.href.substring(0,1e3);return{r:W0().substring(0,1e3),u:r?oa(r,t,aa):void 0}}function U0(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Vc(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=Vc(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=B0(r);Me(i,o)}if(t){var a=V0(t);Me(i,a)}return i}function z0(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function ZR(){try{return new Date().getTimezoneOffset()}catch{return}}function GR(n,e){if(!ot)return{};var t,r,i,s=n?gs([],ms,e||[]):[],[o,a]=(function(l){for(var c=0;c<a_.length;c++){var[u,d]=a_[c],h=u.exec(l),g=h&&(qn(d)?d(h,l):d);if(g)return g}return["",""]})(ot);return Me(zf({$os:o,$os_version:a,$browser:g0(ot,navigator.vendor),$device:l_(ot),$device_type:(r=ot,i=l_(r),i===t0||i===e0||i==="Kobo"||i==="Kindle Fire"||i===f0?Qo:i===ta||i===ds||i===na||i===Oh?"Console":i===r0?"Wearable":i?kt:"Desktop"),$timezone:z0(),$timezone_offset:ZR()}),{$current_url:oa(ze?.href,s,aa),$host:ze?.host,$pathname:ze?.pathname,$raw_user_agent:ot.length>1e3?ot.substring(0,997)+"...":ot,$browser_version:rR(ot,navigator.vendor),$browser_language:I_(),$browser_language_prefix:(t=I_(),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:gn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Vn=$e("[Web Vitals]"),$_=9e5,pf=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[m_]),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[y_])||["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)&&xn(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:$_;return 0<e&&e<=6e4?$_: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:_n(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return _n(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({[m_]:t}),this._instance.persistence.register({[y_]: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?gs([],ms,r||[]):[];return oa(e,i,aa)}Vn.error("Could not determine current URL")}},KR=$e("[Heatmaps]");function M_(n){return Ne(n)&&"clientX"in n&&"clientY"in n&&xn(n.clientX)&&xn(n.clientY)}var hf=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[qh]),this.rageclicks=new Bc(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;KR.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({[qh]: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 Uc(this.instance,BR,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&&nu(u)&&!Gn(u,"body");){if(u===c)return!1;if(ue(l,C?.getComputedStyle(u).position))return!0;u=T0(u)}return!1})(A0(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"),!b_(e.target)&&M_(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){!b_(e.target)&&M_(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?gs([],ms,i||[]):[],o=oa(t,s,aa);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!ls(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},zc=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:Yt(a/o,0,1,j),g=o<=1?1:Yt(l/o,0,1,j),v=c<=1?1:Yt(u/c,0,1,j),f=c<=1?1:Yt(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 yn=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),St=Uint8Array,nt=Uint16Array,fs=Uint32Array,Kf=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]),Yf=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]),P_=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),q0=function(n,e){for(var t=new nt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new fs(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]},Z0=q0(Kf,2),YR=Z0[0],ff=Z0[1];YR[28]=258,ff[258]=28;for(gf=q0(Yf,0)[1],qc=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,qc[Se]=((65280&Wn)>>>8|(255&Wn)<<8)>>>1;var Wn,gf,qc,Se,Yo=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[qc[d]>>>l]=c}else for(o=new nt(r),i=0;i<r;++i)o[i]=qc[a[n[i]-1]++]>>>15-n[i];return o},Ur=new St(288);for(Se=0;Se<144;++Se)Ur[Se]=8;for(Se=144;Se<256;++Se)Ur[Se]=9;for(Se=256;Se<280;++Se)Ur[Se]=7;for(Se=280;Se<288;++Se)Ur[Se]=8;var Zc=new St(32);for(Se=0;Se<32;++Se)Zc[Se]=5;var XR=Yo(Ur,9,0),JR=Yo(Zc,5,0),G0=function(n){return(n/8>>0)+(7&n&&1)},K0=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof nt?nt:n instanceof fs?fs:St)(t-e);return r.set(n.subarray(e,t)),r},hn=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},Lo=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},yh=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=mf(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]},mf=function(n,e,t){return n.s==-1?Math.max(mf(n.l,e,t+1),mf(n.r,e,t+1)):e[n.s]=t},O_=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]},Fo=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},vf=function(n,e,t){var r=t.length,i=G0(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)},N_=function(n,e,t,r,i,s,o,a,l,c,u){hn(e,u++,t),++i[256];for(var d=yh(i,15),h=d[0],g=d[1],v=yh(s,15),f=v[0],m=v[1],y=O_(h),k=y[0],_=y[1],b=O_(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 $=yh(w,7),P=$[0],M=$[1],G=19;G>4&&!P[P_[G-1]];--G);var L,N,z,H,oe=c+5<<3,A=Fo(i,Ur)+Fo(s,Zc)+o,F=Fo(i,h)+Fo(s,f)+o+14+3*G+Fo(w,P)+(2*w[16]+3*w[17]+7*w[18]);if(oe<=A&&oe<=F)return vf(e,u,n.subarray(l,l+c));if(hn(e,u,1+(F<A)),u+=2,F<A){L=Yo(h,g,0),N=h,z=Yo(f,m,0),H=f;var X=Yo(P,M,0);for(hn(e,u,_-257),hn(e,u+5,R-1),hn(e,u+10,G-4),u+=14,E=0;E<G;++E)hn(e,u+3*E,P[P_[E]]);u+=3*G;for(var fe=[k,x],de=0;de<2;++de){var Be=fe[de];for(E=0;E<Be.length;++E){var Ce=31&Be[E];hn(e,u,X[Ce]),u+=P[Ce],Ce>15&&(hn(e,u,Be[E]>>>5&127),u+=Be[E]>>>12)}}}else L=XR,N=Ur,z=JR,H=Zc;for(E=0;E<a;++E)if(r[E]>255){Ce=r[E]>>>18&31,Lo(e,u,L[Ce+257]),u+=N[Ce+257],Ce>7&&(hn(e,u,r[E]>>>23&31),u+=Kf[Ce]);var Et=31&r[E];Lo(e,u,z[Et]),u+=H[Et],Et>3&&(Lo(e,u,r[E]>>>5&8191),u+=Yf[Et])}else Lo(e,u,L[r[E]]),u+=N[r[E]];return Lo(e,u,L[256]),u+N[256]},QR=new fs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),eT=(function(){for(var n=new fs(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),tT=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=vf(g,v,s.subarray(f,m)):(g[f]=u,v=vf(g,v,s.subarray(f,d)))}else{for(var y=QR[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(uu){return(s[uu]^s[uu+1]<<w^s[uu+2]<<E)&b},P=new fs(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=N_(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 Be=2,Ce=0,Et=_,Ct=F-X&32767;if(fe>2&&A==$(f-Ct))for(var lu=Math.min(k,fe)-1,ys=Math.min(32767,f),Pe=Math.min(258,fe);Ct<=ys&&--Et&&F!=X;){if(s[f+Be]==s[f+Be-Ct]){for(var Bt=0;Bt<Pe&&s[f+Bt]==s[f+Bt-Ct];++Bt);if(Bt>Be){if(Be=Bt,Ce=Ct,Bt>lu)break;var bx=Math.min(Ct,Bt-2),ng=0;for(de=0;de<bx;++de){var cu=f-Ct+de+32768&32767,rg=cu-x[cu]+32768&32767;rg>ng&&(ng=rg,X=cu)}}}Ct+=(F=X)-(X=x[F])+32768&32767}if(Ce){P[z++]=268435456|ff[Be]<<18|gf[Ce];var ig=31&ff[Be],sg=31&gf[Ce];N+=Kf[ig]+Yf[sg],++M[257+ig],++G[sg],H=f+Be,++L}else P[z++]=s[f],++M[s[f]]}}v=N_(s,g,u,P,M,G,N,z,oe,f-oe,v)}return K0(h,0,l+G0(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)},bh=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function nT(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=eT[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=n.length;t.p(n);var i,s=tT(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&&bh(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),bh(s,o-8,t.d()),bh(s,o-4,r),s}var rT=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),Ht(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},iT=!!Rh||!!Ah,L_="text/plain",Gc=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=$R(o);return l&&a.push(l),i+"?"+a.join("&")},Zo=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),_h=n=>{var{data:e,compression:t}=n;if(e){if(t===yn.GZipJS){var r=nT((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 K0(d,0,h)})(Zo(e)),{mtime:0}),i=new Blob([r],{type:L_});return{contentType:L_,body:i,estimatedSize:i.size}}if(t===yn.Base64){var s=(function(l){var c,u,d,h,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,m=0,y="",k=[];if(!l)return l;l=rT(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})(Zo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Zo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Zo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},$c=[];Ah&&$c.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=_h(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(n_){var c=new n_;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}Ah(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))}}),Rh&&$c.push({transport:"XHR",method:n=>{var e,t=new Rh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=_h(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)}}),ht!=null&&ht.sendBeacon&&$c.push({transport:"sendBeacon",method:n=>{var e=Gc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=_h(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var Kc=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 F_(n,e,t){return Zo({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Y0={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=>Kc(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Kc(t,r))))),icontains:(n,e)=>e.map(Tc).some((t=>n.map(Tc).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(Tc).every((t=>n.map(Tc).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)))}))},Tc=n=>n.toLowerCase();function X0(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(W(s)||Ht(s))return!1;var o=[String(s)],a=Y0[i.operator];return!!a&&a(i.values,o)}))}var xh=$e("[Error tracking]"),yf=class{constructor(e){var t,r;this.Zt=[],this.ti=new Lh([new Dh,new zh,new Bh,new Hh,new jh,new Wh,new Vh,new Uh],hR()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Zh))!==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({[Zh]:this.Zt,[g_]:o})}get ii(){var e,t=!!this._instance.get_property(g_),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 xh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void xh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void xh.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=Y0[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)}},pt=$e("[FeatureFlags]"),Do=$e("[FeatureFlags]",{debugEnabled:!0}),wh="$active_feature_flags",rs="$override_feature_flags",D_="$feature_flag_payloads",Ho="$override_feature_flag_payloads",H_="$feature_flag_request_id",B_="$feature_flag_evaluated_at",V_=n=>{var e={};for(var[t,r]of Ic(n||{}))r&&(e[t]=r);return e},sT=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]})))):pt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},oT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),bf=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||(pt.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||pt.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(Gh),t=this._instance.get_property(rs),r=this._instance.get_property(Ho);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||(pt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(cs),t=this._instance.get_property(rs);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||(pt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(D_),t=this._instance.get_property(Ho);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||(pt.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(qo)||{}),group_properties:this._instance.get_property(Wr)};Ht(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=z0()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:yn.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(oT.FeatureFlags))pt.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}pt.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(H_)||void 0,c=this._instance.get_property(B_)||void 0,u=this._instance.get_property(Lc)||{};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({[Lc]: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 pt.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:yn.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}pt.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=sT(o),h=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var f=o.requestId,m=o.evaluatedAt;if(me(g)){pt.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({[wh]:g,[cs]: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({[wh]:Object.keys(V_(_)),[cs]:_||{},[D_]:b||{},[Gh]:x||{}},f?{[H_]:f}:{},m?{[B_]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),pt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return pt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(rs),this._instance.persistence.unregister(Ho),this.wi(),Do.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(rs),Do.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({[rs]:i})}else this._instance.persistence.register({[rs]:r.flags});Do.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Ho),Do.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Ho]:r.payloads}),Do.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(zo)||[]).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({[wh]:Object.keys(V_(l)),[cs]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(zo),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(zo),(l=this._instance.persistence)==null||l.register({[zo]: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(qo)||{};this._instance.register({[qo]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(qo)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Wr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=U({},r[i],e[i]),delete e[i]})),this._instance.register({[Wr]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Wr)||{};this._instance.register({[Wr]:U({},t,{[e]:{}})})}else this._instance.unregister(Wr)}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}},aT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Xo=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){aT.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=[...DR,...i];return U({},Re,{W:function(o){try{var a={};try{a=Kt.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&&Kt.G(o,h,l,c,u,d)}catch(g){Re.B(g)}},V:function(o,a){try{C?.localStorage.removeItem(o),Kt.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"?HR:r==="cookie"?Kt:t.H()?t:Kt}properties(){var e={};return ke(this.props,(function(t,r){if(r===cs&&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,(Ht(o=xR)?l:t_&&o.indexOf===t_?o.indexOf(a)!=-1:(ke(o,(function(c){if(l||(l=c===a))return Oc})),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=H0(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ls(zf(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=V?.referrer)?V0(e):{})}update_referrer_info(){var e;this.register_once({$referrer:W0(),$referring_domain:V!=null&&V.referrer&&((e=Vc(V.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Jh]||this.props[Qh]||this.register_once({[Fc]:j0(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ke([Qh,Jh],(o=>{var a=this.props[o];a&&ke(a,(function(l,c){e["$initial_"+Th(c)]=l}))}));var t,r,i=this.props[Fc];if(i){var s=(t=U0(i),r={},ke(t,(function(o,a){r["$initial_"+Th(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[Uo]||{};r[e]=t,this.props[Uo]=r,this.save()}remove_event_timer(e){var t=(this.props[Uo]||{})[e];return W(t)||(delete this.props[Uo][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},W_=$e("[Product Tours]"),kh="ph_product_tours",_f=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[v_]:!(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(v_)||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?W_.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[kh];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 W_.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({[kh]: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(kh)}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)}},Bo=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),mD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),vD=(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})({}),yD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Sh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),bD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),_D=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),xD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),Go=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Eh=(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})({}),xf=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=$e("[Surveys]"),J0="seenSurvey_",lT=(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},j_=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(J0,n),cT=[Sh.Popover,Sh.Widget,Sh.API],uT={ignoreConditions:!1,ignoreDelay:!1,displayType:xf.Popover},ia=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 is(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 wf=class{constructor(e){this.Ai=new ia,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"||!is(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=>is(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&is((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=>is(c.text,t.text,t.text_matching||"exact")||is(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=>is(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||X0(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)}},kf=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&X0(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===Bo.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 wf(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,Bo.Activation),this.Yi=this.Zi(e,Bo.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,Bo.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,Bo.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}},Sf=class extends kf{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Go.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()}},Ef=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(J0)||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 Sf(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(Kh);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({[Kh]: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(cT.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!==xf.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!==xf.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()}},fn=$e("[Conversations]"),Cf=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)||(_n(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 fn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),fn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else fn.error("Cannot complete initialization: remote config is null")}Se(e,t){fn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():fn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Ht(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 as((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(fn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return as((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(fn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return as((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(fn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return as((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(fn.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}},Af=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=$e("[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.")}}},U_=$e("[RateLimiter]"),Rf=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=>{U_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void U_.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(Xh))!==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(Xh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},Vr=$e("[RemoteConfig]"),Tf=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))):(Vr.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 Vr.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Vr.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return Vr.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){Vr.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()):Vr.info("__preview_remote_config is disabled. Logging config instead",e):Vr.error("Failed to fetch remote config from PostHog.")}},If=3e3,$f=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Yt(t?.flush_interval_ms||If,250,5e3,j.createLogger("flush interval"),If),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}},dT=["retriesPerformedSoFar"],Mf=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=Y_(e,dT);ss(t)&&(r.url=Gc(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=[]}},Pf=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}},pT=n=>j0(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Yc=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({[Yh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||pT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Yh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?U0(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(zf(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Th(r)]=t})),e}},Ch=$e("[SessionId]"),Xc=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 ia,this.er=(u,d)=>!(!ss(u)||!ss(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*Yt(o,60,36e3,Ch.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){Ch.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({[Nc]:[t,e,r]}))}_r(){var e=this.Xe.props[Nc];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=ss(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(),Ch.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=ss(i)&&e&&!l?i:r,g=ss(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)}},hT=["$set_once","$set"],jn=$e("[SiteApps]"),Of=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({},Y_(e,hT),{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.')}},Q0=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&i_(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>i_(i?.brand,e))))return!0}catch{}return!!n.webdriver},Ko=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),z_="i.posthog.com",Nf=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("."+z_,".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]=Ko.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ko.EU:this.Sr[this.apiHost]=Ko.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===Ko.CUSTOM)return this.apiHost+t;var r=z_+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},fT={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&&Kc(e.href,n),not_regex:(n,e)=>!!C&&!Kc(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Lf=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=Wc(e?.search,"__experiment_id"),r=Wc(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||fT[(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=H0();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 ht&&this._instance?Q0(ht,this._instance.config.custom_blocked_useragents):void 0}},gT=$e("[PostHog ExternalIntegrations]"),mT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ff=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 gT.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(mT[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)}}},Df="[SessionRecording]",Vo=$e(Df),Jc=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 Vo.error("started without valid sessionManager"),new Error(Df+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Df+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(hh))==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),Vo.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 Vo.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(w0)}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({[hh]: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:Vo.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):Vo.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(hh);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))}},Jo={},Hf=()=>{},os="posthog",ex=!iT&&ot?.indexOf("MSIE")===-1&&ot?.indexOf("Mozilla")===-1,q_=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:_R(V?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Hf,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:If},error_tracking:{},_onCapture:Hf,__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))},Z_=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},Bf=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}},Qc=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 Bf,this.Br=!1,this.version=gn.LIB_VERSION,this.qr=new ia,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=q_(),this.SentryIntegration=cf,this.sentryIntegration=e=>(function(t,r){var i=D0(t,r);return{name:F0,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 bf(this),this.toolbar=new uf(this),this.scrollManager=new Pf(this),this.pageViewManager=new zc(this),this.surveys=new Ef(this),this.conversations=new Cf(this),this.logs=new Af(this),this.experiments=new Lf(this),this.exceptions=new yf(this),this.rateLimiter=new Rf(this),this.requestRouter=new Nf(this),this.consent=new of(this),this.externalIntegrations=new Ff(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!==os){var i,s=(i=Jo[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Jo[r]=s,Jo[os][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),W(e)||Ih(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({},q_(t.defaults),Z_(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:yn.GZipJS;var s=this.Qr();this.persistence=new Xo(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xo(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 $f((k=>this.ts(k)),this.config.request_queue_config),this.es=new Mf(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 Xc(this),this.sessionPropsManager=new Yc(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)),gn.DEBUG=gn.DEBUG||this.config.debug,gn.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(mn,(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:Po,$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(mn,"anonymous")}return Oe(C,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?WR(this,(()=>this.ns())):this.ns(),qn(this.config._onCapture)&&this.config._onCapture!==Hf&&(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 lf(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new df(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new Of(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Jc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new tf(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new _f(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new hf(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new pf(this)})),r.push((()=>{this.exceptionObserver=new af(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new Uc(this,VR),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,yn.GZipJS)?yn.GZipJS:ue(e.supportedCompression,yn.Base64)?yn.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 Tf(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&&(ex?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Gc(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=Gc(o.url,{_:new Date().getTime().toString(),ver:gn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=$c.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=b0(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=yR(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===Go.DISMISSED||e===Go.SENT){var v=t?.[Eh.SURVEY_ID],f=t?.[Eh.SURVEY_ITERATION];d={id:v,current_iteration:f},localStorage.getItem(j_(d))||localStorage.setItem(j_(d),"true"),u.$set=U({},u.$set,{[lT({id:v,current_iteration:f},e===Go.SENT?"responded":"dismissed")]:!0})}else e===Go.SHOWN&&(u.$set=U({},u.$set,{[Eh.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=U({},u.properties.$set,u.$set);if(ls(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)&&!xn(a.distinct_id)||Ih(a.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=GR(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===Ko.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),ls(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=uT),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(xn(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!==Po){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(jo)&&(this.unregister(jo),this.register({distinct_id:e}));var o=(this.persistence.get_property(mn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(mn,"identified"),this.setPersonPropertiesForFlags(U({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=F_(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Lc))}}else j.critical('The string "'+Po+'" 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=F_(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(mn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Po,$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(_0)?(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(jo,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,Z_(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 Xo(U({},this.config,{persistence:"sessionStorage"}),u);var d=this.Kr(this.config.debug);_n(d)&&(this.config.debug=d),_n(this.config.debug)&&(this.config.debug?(gn.DEBUG=!0,Re.H()&&Re.G("ph_debug","true"),j.info("set_config",{config:e,oldConfig:t,newConfig:U({},this.config)})):(gn.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:os;return t!==os&&(t=os+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(mn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(mn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ls(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[jo])&&((t=this.persistence)==null||(t=t.props)==null||!t[Dc]))}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(Dc,!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 Xc(this),this.pageViewManager=new zc(this),this.persistence&&(this.sessionPropsManager=new Yc(this,this.sessionManager,this.persistence)),this.sessionRecording=new Jc(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:Po,$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===vn.GRANTED?"granted":e===vn.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 ht?Q0(ht,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 zA(e.event)?j.warn(s+". This can cause unexpected behavior."):j.info(s),null}r.properties&&!ls(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=_n(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]]=vR(n.prototype[e[t]])})(Qc,["identify"]);var G_;var tx=(G_=Jo[os]=new Qc,(function(){function n(){n.done||(n.done=!0,ex=!1,ke(Jo,(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")})(),G_);var Xf=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=tx.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 ru(n={}){return new Xf(n)}var nx={posthog:n=>ru(n),noop:()=>Sc()};function rx(n,e){let t=nx[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(nx).join(", ")}`);return t(e)}async function ix(n){_d(),K("Syntro Bootstrap","====== INIT ======"),K("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Ll();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",mo()),console.log("[DIAG] editorConf:",Nl()),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=Nl()?.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=ji(t),_d(r.d);else if(e)K("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw tl("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),tl("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 tl("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")||Xy,l=Gy(),c=Tp(),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=Ip(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=Ui({debug:n.debug,history:f?new zi(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let y=vd({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=zb(),_,b=A=>{K("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let F=Yy(A);if(K("Syntro Bootstrap","Segment flags from PostHog:",F),Ky(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=rx(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 cc({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=Hb("growthbook",{clientKey:r.e,apiHost:i,attributes:d,onExperimentViewed:x?.trackExperiment?(A,F,X)=>{x.trackExperiment(A,F,X)}:void 0})),R=oc({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=kc({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=Uu({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=jb(r.f,r.o??{});N=async()=>{let F=await A.fetch();return{...F.config,tiles:F.config.tiles??[]}}}else v&&(N=hr({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 ns(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,Be=P.getRequiredApps(de);return Be.length>0?console.log("[Syntro Bootstrap] Required external apps:",Be.join(", ")):K("Syntro Bootstrap","No external apps required (all executors are built-in)"),Be.length>0&&await P.loadAppsForConfig(de).then(async Et=>{let Ct=Et.filter(Pe=>Pe.success),lu=Et.filter(Pe=>!Pe.success);Ct.length>0&&console.log(`[Syntro Bootstrap] Apps loaded from CDN: ${Ct.map(Pe=>Pe.appId).join(", ")}`);let ys=lu.filter(Pe=>!z.has(Pe.appId));ys.length>0&&(console.error("[Syntro Bootstrap] Apps FAILED to load from CDN:",ys.map(Pe=>`${Pe.appId} (${Pe.error})`).join(", ")),ys.forEach(Pe=>z.add(Pe.appId)));for(let Pe of Be)if(E.apps.has(Pe))try{await E.apps.activate(Pe),console.log(`[Syntro Bootstrap] App activated: ${Pe}`)}catch(Bt){console.error(`[Syntro Bootstrap] Failed to activate app: ${Pe}`,Bt)}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 Fl({...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 vT(n){try{return await ix(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 yT(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 Jf={init:vT,encodeToken:Dl,decodeToken:ji,events:{emit:yT}};typeof window<"u"&&(window.Syntro=Jf);function vs(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function bT(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=vs(i),o=vs(nn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${nn}. 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${nn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:_T(r,i)}):{valid:!0,warnings:e,errors:t}}function _T(n,e){let t={...n};return vs(e).major===1&&(t=xT(t)),t.schemaVersion=nn,t}function xT(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 wT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=vs(t),i=vs(nn);return r.major<i.major||!e.schemaVersion}var sx=p.object({url:p.string(),routeId:p.string().optional(),title:p.string().optional(),locale:p.string().optional()}),ox=p.object({url:p.string(),ts:p.number()}),ax=p.object({sessionId:p.string(),startTs:p.number(),pageHistory:p.array(ox).optional()}),lx=p.object({width:p.number(),height:p.number()}),cx=p.object({x:p.number(),y:p.number(),w:p.number(),h:p.number()}),ux=p.object({anchorId:p.string(),present:p.boolean(),visible:p.boolean().optional(),boundingBox:cx.optional()}),dx=p.record(p.string(),p.union([p.number(),p.string(),p.boolean(),p.undefined()])),px=p.object({page:sx,session:ax,viewport:lx,anchors:p.array(ux).optional(),augmented:dx.optional()});function kT(n){return px.safeParse(n)}var iu=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 su=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 ou=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 Qf=p.enum(["posthog","canvas","derived"]),hx=p.object({ts:p.number(),name:p.string(),source:Qf,props:p.record(p.string(),p.unknown()).optional(),schemaVersion:p.string()}),fx=p.object({names:p.array(p.string()).optional(),patterns:p.array(p.string()).optional(),sources:p.array(Qf).optional()});function ST(n){return hx.safeParse(n)}function ET(n){return fx.safeParse(n)}var eg=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()})]),gx=p.object({kind:p.literal("tooltip"),id:p.string(),anchor:eg,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()}),mx=p.object({kind:p.literal("highlight"),id:p.string(),anchor:eg,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()}),au=p.object({id:p.string(),version:p.number(),routes:p.array(p.string()).optional(),steps:p.array(p.union([gx,mx]))});function CT(n){return au.parse(n)}var AT=({configUri:n,experiments:e,featureKey:t="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=rl({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 au.parse(o)};var vx=p.object({value:p.unknown(),expiresAt:p.number().optional()}),yx=p.object({count:p.number(),resetAt:p.number().optional()});function RT(n){return vx.safeParse(n)}function TT(n){return yx.safeParse(n)}var tg="2026-04-25T05:54:57.098Z (4d142d719fa)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${tg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||Bs;window.SynOS={...n,appRegistry:e,_runtimeBuild:tg,_renderer:"lit"},io(),Uv(e)}return Cx(IT);})();
|
|
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),Ht(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},iT=!!Rh||!!Ah,L_="text/plain",Gc=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=$R(o);return l&&a.push(l),i+"?"+a.join("&")},Zo=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),_h=n=>{var{data:e,compression:t}=n;if(e){if(t===yn.GZipJS){var r=nT((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 K0(d,0,h)})(Zo(e)),{mtime:0}),i=new Blob([r],{type:L_});return{contentType:L_,body:i,estimatedSize:i.size}}if(t===yn.Base64){var s=(function(l){var c,u,d,h,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,m=0,y="",k=[];if(!l)return l;l=rT(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})(Zo(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Zo(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=Zo(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},$c=[];Ah&&$c.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=_h(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(n_){var c=new n_;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}Ah(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))}}),Rh&&$c.push({transport:"XHR",method:n=>{var e,t=new Rh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=_h(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)}}),ht!=null&&ht.sendBeacon&&$c.push({transport:"sendBeacon",method:n=>{var e=Gc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=_h(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var Kc=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 F_(n,e,t){return Zo({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Y0={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=>Kc(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Kc(t,r))))),icontains:(n,e)=>e.map(Tc).some((t=>n.map(Tc).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(Tc).every((t=>n.map(Tc).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)))}))},Tc=n=>n.toLowerCase();function X0(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(W(s)||Ht(s))return!1;var o=[String(s)],a=Y0[i.operator];return!!a&&a(i.values,o)}))}var xh=$e("[Error tracking]"),yf=class{constructor(e){var t,r;this.Zt=[],this.ti=new Lh([new Dh,new zh,new Bh,new Hh,new jh,new Wh,new Vh,new Uh],hR()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Zh))!==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({[Zh]:this.Zt,[g_]:o})}get ii(){var e,t=!!this._instance.get_property(g_),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 xh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void xh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void xh.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=Y0[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)}},pt=$e("[FeatureFlags]"),Do=$e("[FeatureFlags]",{debugEnabled:!0}),wh="$active_feature_flags",rs="$override_feature_flags",D_="$feature_flag_payloads",Ho="$override_feature_flag_payloads",H_="$feature_flag_request_id",B_="$feature_flag_evaluated_at",V_=n=>{var e={};for(var[t,r]of Ic(n||{}))r&&(e[t]=r);return e},sT=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]})))):pt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},oT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),bf=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||(pt.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||pt.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(Gh),t=this._instance.get_property(rs),r=this._instance.get_property(Ho);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||(pt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(cs),t=this._instance.get_property(rs);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||(pt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(D_),t=this._instance.get_property(Ho);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||(pt.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(qo)||{}),group_properties:this._instance.get_property(Wr)};Ht(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=z0()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:yn.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(oT.FeatureFlags))pt.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}pt.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(H_)||void 0,c=this._instance.get_property(B_)||void 0,u=this._instance.get_property(Lc)||{};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({[Lc]: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 pt.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:yn.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}pt.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=sT(o),h=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var f=o.requestId,m=o.evaluatedAt;if(me(g)){pt.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({[wh]:g,[cs]: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({[wh]:Object.keys(V_(_)),[cs]:_||{},[D_]:b||{},[Gh]:x||{}},f?{[H_]:f}:{},m?{[B_]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),pt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return pt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(rs),this._instance.persistence.unregister(Ho),this.wi(),Do.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(rs),Do.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({[rs]:i})}else this._instance.persistence.register({[rs]:r.flags});Do.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Ho),Do.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Ho]:r.payloads}),Do.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(zo)||[]).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({[wh]:Object.keys(V_(l)),[cs]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(zo),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(zo),(l=this._instance.persistence)==null||l.register({[zo]: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(qo)||{};this._instance.register({[qo]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(qo)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(Wr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=U({},r[i],e[i]),delete e[i]})),this._instance.register({[Wr]:U({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Wr)||{};this._instance.register({[Wr]:U({},t,{[e]:{}})})}else this._instance.unregister(Wr)}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}},aT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Xo=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){aT.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=[...DR,...i];return U({},Re,{W:function(o){try{var a={};try{a=Kt.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&&Kt.G(o,h,l,c,u,d)}catch(g){Re.B(g)}},V:function(o,a){try{C?.localStorage.removeItem(o),Kt.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"?HR:r==="cookie"?Kt:t.H()?t:Kt}properties(){var e={};return ke(this.props,(function(t,r){if(r===cs&&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,(Ht(o=xR)?l:t_&&o.indexOf===t_?o.indexOf(a)!=-1:(ke(o,(function(c){if(l||(l=c===a))return Oc})),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=H0(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ls(zf(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=V?.referrer)?V0(e):{})}update_referrer_info(){var e;this.register_once({$referrer:W0(),$referring_domain:V!=null&&V.referrer&&((e=Vc(V.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Jh]||this.props[Qh]||this.register_once({[Fc]:j0(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ke([Qh,Jh],(o=>{var a=this.props[o];a&&ke(a,(function(l,c){e["$initial_"+Th(c)]=l}))}));var t,r,i=this.props[Fc];if(i){var s=(t=U0(i),r={},ke(t,(function(o,a){r["$initial_"+Th(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[Uo]||{};r[e]=t,this.props[Uo]=r,this.save()}remove_event_timer(e){var t=(this.props[Uo]||{})[e];return W(t)||(delete this.props[Uo][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},W_=$e("[Product Tours]"),kh="ph_product_tours",_f=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[v_]:!(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(v_)||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?W_.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[kh];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 W_.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({[kh]: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(kh)}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)}},Bo=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),mD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),vD=(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})({}),yD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Sh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),bD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),_D=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),xD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),Go=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Eh=(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})({}),xf=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=$e("[Surveys]"),J0="seenSurvey_",lT=(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},j_=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(J0,n),cT=[Sh.Popover,Sh.Widget,Sh.API],uT={ignoreConditions:!1,ignoreDelay:!1,displayType:xf.Popover},ia=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 is(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 wf=class{constructor(e){this.Ai=new ia,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"||!is(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=>is(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&is((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=>is(c.text,t.text,t.text_matching||"exact")||is(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=>is(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||X0(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)}},kf=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&X0(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===Bo.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 wf(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,Bo.Activation),this.Yi=this.Zi(e,Bo.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,Bo.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,Bo.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}},Sf=class extends kf{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return Go.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()}},Ef=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(J0)||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 Sf(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(Kh);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({[Kh]: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(cT.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!==xf.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!==xf.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()}},fn=$e("[Conversations]"),Cf=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)||(_n(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 fn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),fn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else fn.error("Cannot complete initialization: remote config is null")}Se(e,t){fn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():fn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Ht(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 as((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(fn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return as((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(fn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return as((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(fn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return as((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(fn.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}},Af=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=$e("[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.")}}},U_=$e("[RateLimiter]"),Rf=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=>{U_.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void U_.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(Xh))!==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(Xh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},Vr=$e("[RemoteConfig]"),Tf=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))):(Vr.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 Vr.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void Vr.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return Vr.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){Vr.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()):Vr.info("__preview_remote_config is disabled. Logging config instead",e):Vr.error("Failed to fetch remote config from PostHog.")}},If=3e3,$f=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Yt(t?.flush_interval_ms||If,250,5e3,j.createLogger("flush interval"),If),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}},dT=["retriesPerformedSoFar"],Mf=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=Y_(e,dT);ss(t)&&(r.url=Gc(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=[]}},Pf=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}},pT=n=>j0(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Yc=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({[Yh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||pT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Yh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?U0(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(zf(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Th(r)]=t})),e}},Ch=$e("[SessionId]"),Xc=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 ia,this.er=(u,d)=>!(!ss(u)||!ss(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*Yt(o,60,36e3,Ch.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){Ch.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({[Nc]:[t,e,r]}))}_r(){var e=this.Xe.props[Nc];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=ss(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(),Ch.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=ss(i)&&e&&!l?i:r,g=ss(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)}},hT=["$set_once","$set"],jn=$e("[SiteApps]"),Of=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({},Y_(e,hT),{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.')}},Q0=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&i_(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>i_(i?.brand,e))))return!0}catch{}return!!n.webdriver},Ko=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),z_="i.posthog.com",Nf=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("."+z_,".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]=Ko.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=Ko.EU:this.Sr[this.apiHost]=Ko.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===Ko.CUSTOM)return this.apiHost+t;var r=z_+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},fT={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&&Kc(e.href,n),not_regex:(n,e)=>!!C&&!Kc(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Lf=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=Wc(e?.search,"__experiment_id"),r=Wc(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||fT[(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=H0();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 ht&&this._instance?Q0(ht,this._instance.config.custom_blocked_useragents):void 0}},gT=$e("[PostHog ExternalIntegrations]"),mT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ff=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 gT.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(mT[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)}}},Df="[SessionRecording]",Vo=$e(Df),Jc=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 Vo.error("started without valid sessionManager"),new Error(Df+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Df+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(hh))==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),Vo.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 Vo.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(w0)}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({[hh]: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:Vo.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):Vo.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(hh);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))}},Jo={},Hf=()=>{},os="posthog",ex=!iT&&ot?.indexOf("MSIE")===-1&&ot?.indexOf("Mozilla")===-1,q_=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:_R(V?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Hf,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:If},error_tracking:{},_onCapture:Hf,__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))},Z_=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},Bf=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}},Qc=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 Bf,this.Br=!1,this.version=gn.LIB_VERSION,this.qr=new ia,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=q_(),this.SentryIntegration=cf,this.sentryIntegration=e=>(function(t,r){var i=D0(t,r);return{name:F0,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 bf(this),this.toolbar=new uf(this),this.scrollManager=new Pf(this),this.pageViewManager=new zc(this),this.surveys=new Ef(this),this.conversations=new Cf(this),this.logs=new Af(this),this.experiments=new Lf(this),this.exceptions=new yf(this),this.rateLimiter=new Rf(this),this.requestRouter=new Nf(this),this.consent=new of(this),this.externalIntegrations=new Ff(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!==os){var i,s=(i=Jo[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Jo[r]=s,Jo[os][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),W(e)||Ih(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({},q_(t.defaults),Z_(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:yn.GZipJS;var s=this.Qr();this.persistence=new Xo(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Xo(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 $f((k=>this.ts(k)),this.config.request_queue_config),this.es=new Mf(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 Xc(this),this.sessionPropsManager=new Yc(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)),gn.DEBUG=gn.DEBUG||this.config.debug,gn.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(mn,(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:Po,$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(mn,"anonymous")}return Oe(C,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?WR(this,(()=>this.ns())):this.ns(),qn(this.config._onCapture)&&this.config._onCapture!==Hf&&(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 lf(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new df(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new Of(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Jc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new tf(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new _f(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new hf(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new pf(this)})),r.push((()=>{this.exceptionObserver=new af(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new Uc(this,VR),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,yn.GZipJS)?yn.GZipJS:ue(e.supportedCompression,yn.Base64)?yn.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 Tf(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&&(ex?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Gc(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=Gc(o.url,{_:new Date().getTime().toString(),ver:gn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=$c.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=b0(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=yR(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===Go.DISMISSED||e===Go.SENT){var v=t?.[Eh.SURVEY_ID],f=t?.[Eh.SURVEY_ITERATION];d={id:v,current_iteration:f},localStorage.getItem(j_(d))||localStorage.setItem(j_(d),"true"),u.$set=U({},u.$set,{[lT({id:v,current_iteration:f},e===Go.SENT?"responded":"dismissed")]:!0})}else e===Go.SHOWN&&(u.$set=U({},u.$set,{[Eh.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=U({},u.properties.$set,u.$set);if(ls(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)&&!xn(a.distinct_id)||Ih(a.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=GR(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===Ko.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),ls(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=uT),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(xn(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!==Po){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(jo)&&(this.unregister(jo),this.register({distinct_id:e}));var o=(this.persistence.get_property(mn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(mn,"identified"),this.setPersonPropertiesForFlags(U({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=F_(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Lc))}}else j.critical('The string "'+Po+'" 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=F_(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(mn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Po,$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(_0)?(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(jo,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,Z_(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 Xo(U({},this.config,{persistence:"sessionStorage"}),u);var d=this.Kr(this.config.debug);_n(d)&&(this.config.debug=d),_n(this.config.debug)&&(this.config.debug?(gn.DEBUG=!0,Re.H()&&Re.G("ph_debug","true"),j.info("set_config",{config:e,oldConfig:t,newConfig:U({},this.config)})):(gn.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:os;return t!==os&&(t=os+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(mn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(mn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ls(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[jo])&&((t=this.persistence)==null||(t=t.props)==null||!t[Dc]))}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(Dc,!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 Xc(this),this.pageViewManager=new zc(this),this.persistence&&(this.sessionPropsManager=new Yc(this,this.sessionManager,this.persistence)),this.sessionRecording=new Jc(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:Po,$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===vn.GRANTED?"granted":e===vn.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 ht?Q0(ht,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 zA(e.event)?j.warn(s+". This can cause unexpected behavior."):j.info(s),null}r.properties&&!ls(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=_n(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]]=vR(n.prototype[e[t]])})(Qc,["identify"]);var G_;var tx=(G_=Jo[os]=new Qc,(function(){function n(){n.done||(n.done=!0,ex=!1,ke(Jo,(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")})(),G_);var Xf=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=tx.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 ru(n={}){return new Xf(n)}var nx={posthog:n=>ru(n),noop:()=>Sc()};function rx(n,e){let t=nx[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(nx).join(", ")}`);return t(e)}async function ix(n){_d(),K("Syntro Bootstrap","====== INIT ======"),K("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Ll();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",mo()),console.log("[DIAG] editorConf:",Nl()),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=Nl()?.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=ji(t),_d(r.d);else if(e)K("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw tl("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),tl("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 tl("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")||Xy,l=Gy(),c=Tp(),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=Ip(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=Ui({debug:n.debug,history:f?new zi(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let y=vd({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=zb(),_,b=A=>{K("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let F=Yy(A);if(K("Syntro Bootstrap","Segment flags from PostHog:",F),Ky(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=rx(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 cc({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=Hb("growthbook",{clientKey:r.e,apiHost:i,attributes:d,onExperimentViewed:x?.trackExperiment?(A,F,X)=>{x.trackExperiment(A,F,X)}:void 0})),R=oc({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=kc({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=Uu({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=jb(r.f,r.o??{});N=async()=>{let F=await A.fetch();return{...F.config,tiles:F.config.tiles??[]}}}else v&&(N=hr({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 ns(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,Be=P.getRequiredApps(de);return Be.length>0?console.log("[Syntro Bootstrap] Required external apps:",Be.join(", ")):K("Syntro Bootstrap","No external apps required (all executors are built-in)"),Be.length>0&&await P.loadAppsForConfig(de).then(async Et=>{let Ct=Et.filter(Pe=>Pe.success),lu=Et.filter(Pe=>!Pe.success);Ct.length>0&&console.log(`[Syntro Bootstrap] Apps loaded from CDN: ${Ct.map(Pe=>Pe.appId).join(", ")}`);let ys=lu.filter(Pe=>!z.has(Pe.appId));ys.length>0&&(console.error("[Syntro Bootstrap] Apps FAILED to load from CDN:",ys.map(Pe=>`${Pe.appId} (${Pe.error})`).join(", ")),ys.forEach(Pe=>z.add(Pe.appId)));for(let Pe of Be)if(E.apps.has(Pe))try{await E.apps.activate(Pe),console.log(`[Syntro Bootstrap] App activated: ${Pe}`)}catch(Bt){console.error(`[Syntro Bootstrap] Failed to activate app: ${Pe}`,Bt)}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 Fl({...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 vT(n){try{return await ix(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 yT(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 Jf={init:vT,encodeToken:Dl,decodeToken:ji,events:{emit:yT}};typeof window<"u"&&(window.Syntro=Jf);function vs(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function bT(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=vs(i),o=vs(nn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${nn}. 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${nn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:_T(r,i)}):{valid:!0,warnings:e,errors:t}}function _T(n,e){let t={...n};return vs(e).major===1&&(t=xT(t)),t.schemaVersion=nn,t}function xT(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 wT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=vs(t),i=vs(nn);return r.major<i.major||!e.schemaVersion}var sx=p.object({url:p.string(),routeId:p.string().optional(),title:p.string().optional(),locale:p.string().optional()}),ox=p.object({url:p.string(),ts:p.number()}),ax=p.object({sessionId:p.string(),startTs:p.number(),pageHistory:p.array(ox).optional()}),lx=p.object({width:p.number(),height:p.number()}),cx=p.object({x:p.number(),y:p.number(),w:p.number(),h:p.number()}),ux=p.object({anchorId:p.string(),present:p.boolean(),visible:p.boolean().optional(),boundingBox:cx.optional()}),dx=p.record(p.string(),p.union([p.number(),p.string(),p.boolean(),p.undefined()])),px=p.object({page:sx,session:ax,viewport:lx,anchors:p.array(ux).optional(),augmented:dx.optional()});function kT(n){return px.safeParse(n)}var iu=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 su=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 ou=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 Qf=p.enum(["posthog","canvas","derived"]),hx=p.object({ts:p.number(),name:p.string(),source:Qf,props:p.record(p.string(),p.unknown()).optional(),schemaVersion:p.string()}),fx=p.object({names:p.array(p.string()).optional(),patterns:p.array(p.string()).optional(),sources:p.array(Qf).optional()});function ST(n){return hx.safeParse(n)}function ET(n){return fx.safeParse(n)}var eg=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()})]),gx=p.object({kind:p.literal("tooltip"),id:p.string(),anchor:eg,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()}),mx=p.object({kind:p.literal("highlight"),id:p.string(),anchor:eg,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()}),au=p.object({id:p.string(),version:p.number(),routes:p.array(p.string()).optional(),steps:p.array(p.union([gx,mx]))});function CT(n){return au.parse(n)}var AT=({configUri:n,experiments:e,featureKey:t="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=rl({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 au.parse(o)};var vx=p.object({value:p.unknown(),expiresAt:p.number().optional()}),yx=p.object({count:p.number(),resetAt:p.number().optional()});function RT(n){return vx.safeParse(n)}function TT(n){return yx.safeParse(n)}var tg="2026-04-25T08:19:59.191Z (69d7d18cab7)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${tg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||Bs;window.SynOS={...n,appRegistry:e,_runtimeBuild:tg,_renderer:"lit"},io(),Uv(e)}return Cx(IT);})();
|
|
1163
1163
|
/*! Bundled license information:
|
|
1164
1164
|
|
|
1165
1165
|
@lit/reactive-element/css-tag.js:
|