@syntrologie/runtime-sdk 2.8.0-canary.477 → 2.8.0-canary.478
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/index.js +1 -1
- package/dist/index.js.map +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/smart-canvas.shopify.js +2 -2
- package/dist/smart-canvas.shopify.js.map +1 -1
- package/dist/smart-canvas.shopify.min.js +2 -2
- package/dist/smart-canvas.shopify.min.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -380,7 +380,7 @@ Actions:`,b.map((Z,te)=>` [${te}] ${Z.kind} ${Z.anchorId?`anchor="${Z.anchorId.
|
|
|
380
380
|
style=${O({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",borderRadius:"9999px",background:`var(--sc-launcher-badge-background, var(--sc-color-primary-hover, ${this.colorPrimaryHover}))`,color:"var(--sc-launcher-badge-color, #ffffff)",fontSize:"11px",fontWeight:"700"})}
|
|
381
381
|
>${r}</span>
|
|
382
382
|
</div>
|
|
383
|
-
`}};ic.properties={isOpen:{type:Boolean},notificationCount:{type:Number},launcherIcon:{attribute:!1},label:{type:String},colorPrimaryHover:{type:String},hasActiveTiles:{type:Boolean},pendingCanvasShape:{type:Boolean},_launcherPos:{state:!0},_hovered:{state:!0},_shapeReady:{state:!0},_pulseResting:{state:!0}};customElements.define("syntro-launcher",ic);function sc(n,e,t="merge"){return t==="first-match"?GC(n,e):KC(n,e)}function GC(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,a=i.slots&&Object.keys(i.slots).length>0;if(s||o||a)return py([i])}return null}function KC(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,l=s.slots&&Object.keys(s.slots).length>0;(o||a||l)&&t.push(s)}return t.length===0?null:py(t)}function py(n){let e=[],t=[],r=new Set,i=[],s,o,a,l,c,u,p,f,h;for(let y of n){let w=y.tiles?.length??0;y.tiles&&e.push(...y.tiles);let x=0;if(y.actions)for(let k of y.actions){let I=k.label;if(I){if(r.has(I))continue;r.add(I)}t.push(k),x++}let _=y.meta?.variant_id;_&&(w>0||x>0)&&i.push({variant_id:_,tiles:w,actions:x}),s??(s=y.fetchedAt),o??(o=y.schemaVersion),a??(a=y.configVersion),l??(l=y.canvasTitle),c??(c=y.displayMode),u??(u=y.theme),p??(p=y.launcher),f??(f=y.meta),h??(h=y.slots)}let g=new Map,v=[];for(let y of e){let w=y?.id;if(typeof w=="string"&&w){let x=g.get(w);if(x!==void 0){v[x]=y;continue}g.set(w,v.length)}v.push(y)}let m=i.length>0?{...f??{},variants:i}:f;return{tiles:v,actions:t,fetchedAt:s??new Date().toISOString(),...o&&{schemaVersion:o},...a&&{configVersion:a},...l&&{canvasTitle:l},...c&&{displayMode:c},...u&&{theme:u},...p&&{launcher:p},...m&&{meta:m},...h&&{slots:h}}}var Lp=!1;function fy(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Np(n){if(fy()){Lp=!0;return}Lp=n??!1}function YC(){return fy()?!0:Lp}function q(n,e,t){YC()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function We(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function oc(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var ac=class{constructor(e){this.config=e;this.counters=new Map;this.histograms=new Map;this.windowStartMs=Date.now();this.timer=null;this.pagehideHandler=null;this.runtime=null;this.adapterCleanup=null;this.resource=e.resource,this.flushIntervalMs=e.flushIntervalMs??6e4}bindRuntime(e){this.runtime=e}attachAdapterCleanup(e){this.adapterCleanup=e}increment(e,t=1){this.counters.set(e,(this.counters.get(e)??0)+t)}snapshotCounters(){let e={};for(let[t,r]of this.counters)e[t]=r;return e}recordHistogram(e,t){let r=this.histograms.get(e)??[];r.push(t),this.histograms.set(e,r)}snapshotHistograms(){let e={};for(let[t,r]of this.histograms){if(r.length===0)continue;let i=[...r].sort((s,o)=>s-o);e[t]={count:i.length,p50:hy(i,.5),p95:hy(i,.95)}}return e}async flush(){let e=this.snapshotCounters(),t=this.snapshotHistograms();if(!(Object.keys(e).length>0||Object.keys(t).length>0))return;let i=null,s="";try{i=this.runtime?.getSurface()??null}catch{}try{s=this.runtime?.getSessionId()??""}catch{}let o={resource:{...this.resource,sessionId:s,surfaceType:i?.type??"unknown",surfaceHost:i?.host??"unknown",surfaceDevice:i?.device??"unknown",surfaceMode:i?.mode??"unknown"},windowSeconds:Math.max(1,Math.round((Date.now()-this.windowStartMs)/1e3)),windowStartUnixMs:this.windowStartMs,counters:e,histograms:t};this.counters.clear(),this.histograms.clear(),this.windowStartMs=Date.now();try{await this.config.emit(o)}catch{}}start(){this.timer===null&&(this.timer=setInterval(()=>{this.flush()},this.flushIntervalMs),typeof window<"u"&&(this.pagehideHandler=()=>{this.flush()},window.addEventListener("pagehide",this.pagehideHandler)))}stop(){if(this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.pagehideHandler!==null&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pagehideHandler),this.pagehideHandler=null),this.adapterCleanup!==null){try{this.adapterCleanup()}catch{}this.adapterCleanup=null}}};function hy(n,e){if(n.length===0)return 0;let t=(n.length-1)*e,r=Math.floor(t),i=Math.ceil(t);return r===i?n[r]:n[r]+(n[i]-n[r])*(t-r)}var Co=null;function Fp(n){return Co?.stop(),Co=new ac(n),Co.start(),Co}function jt(){return Co}var mn=(n,e)=>({key:n,value:{stringValue:e}}),Dp=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),gy=(n,e)=>({key:n,value:{doubleValue:e}});function JC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[mn("service.name",e.serviceName),mn("service.version",e.serviceVersion),mn("syntro.posthog_key",e.posthogKey),mn("syntro.session_id",e.sessionId),mn("syntro.surface_type",e.surfaceType),mn("syntro.surface_host",e.surfaceHost),mn("syntro.surface_device",e.surfaceDevice),mn("syntro.surface_mode",e.surfaceMode),mn("syntro.host_origin",e.hostOrigin)],a=[Dp("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Dp(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Dp(`${u}_count`,p.count)),a.push(gy(`${u}_p50`,p.p50)),a.push(gy(`${u}_p95`,p.p95)));let l=`${Date.now()}000000`,c=`${s}000000`;return{resourceLogs:[{resource:{attributes:o},scopeLogs:[{scope:{name:"syntro.sdk.health"},logRecords:[{timeUnixNano:c,observedTimeUnixNano:l,severityText:"INFO",body:{stringValue:"sdk_health_window"},attributes:a}]}]}]}}function Hp(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(JC(t)),i=()=>e(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0,mode:"cors"});try{let s=await i();if(!s.ok&&s.status>=500)try{await i()}catch{}}catch{try{await i()}catch{}}}}function XC(){if(typeof document>"u")return;let n=document.currentScript;if(n?.src)return n.src;try{let e=Array.from(document.scripts);for(let t=e.length-1;t>=0;t-=1){let r=e[t]?.src;if(typeof r=="string"&&(r.includes("runtime-sdk")||r.includes("smart-canvas")))return r}}catch{}}var Bp=XC();function Vp(){if(!Bp)return;let n=Bp.lastIndexOf("/");if(n!==-1)return Bp.substring(0,n+1)}var Ey=-1,qi=n=>{addEventListener("pageshow",(e=>{e.persisted&&(Ey=e.timeStamp,n(e))}),!0)},Wt=(n,e,t,r)=>{let i,s;return o=>{e.value>=0&&(o||r)&&(s=e.value-(i??0),(s||i===void 0)&&(i=e.value,e.delta=s,e.rating=((a,l)=>a>l[1]?"poor":a>l[0]?"needs-improvement":"good")(e.value,t),n(e)))}},Yp=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},Jp=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},ko=()=>Jp()?.activationStart??0,zt=(n,e=-1)=>{let t=Jp(),r="navigate";return Ey>=0?r="back-forward-cache":t&&(document.prerendering||ko()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-"))),{name:n,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},Up=new WeakMap;function Xp(n,e){return Up.get(n)||Up.set(n,new e),Up.get(n)}var Wp=class{constructor(){en(this,"t");en(this,"i",0);en(this,"o",[])}h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},Ao=(n,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(n)){let r=new PerformanceObserver((i=>{Promise.resolve().then((()=>{e(i.getEntries())}))}));return r.observe({type:n,buffered:!0,...t}),r}}catch{}},Qp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},zi=-1,Cy=new Set,my=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,zp=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of Cy)e();isFinite(zi)||(zi=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",zp,!0))}},cc=()=>{if(zi<0){let n=ko();zi=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??my(),addEventListener("visibilitychange",zp,!0),addEventListener("prerenderingchange",zp,!0),qi((()=>{setTimeout((()=>{zi=my()}))}))}return{get firstHiddenTime(){return zi},onHidden(n){Cy.add(n)}}},uc=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},vy=[1800,3e3],ef=(n,e={})=>{uc((()=>{let t=cc(),r,i=zt("FCP"),s=Ao("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-ko(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,vy,e.reportAllChanges),qi((o=>{i=zt("FCP"),r=Wt(n,i,vy,e.reportAllChanges),Yp((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},yy=[.1,.25],ky=(n,e={})=>{let t=cc();ef(Qp((()=>{let r,i=zt("CLS",0),s=Xp(e,Wp),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=Ao("layout-shift",o);a&&(r=Wt(n,i,yy,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,yy,e.reportAllChanges),Yp((()=>r()))})),setTimeout(r))})))},Ay=0,jp=1/0,lc=0,QC=n=>{for(let e of n)e.interactionId&&(jp=Math.min(jp,e.interactionId),lc=Math.max(lc,e.interactionId),Ay=lc?(lc-jp)/7+1:0)},qp,_y=()=>qp?Ay:performance.interactionCount??0,ek=()=>{"interactionCount"in performance||qp||(qp=Ao("event",QC,{type:"event",buffered:!0,durationThreshold:0}))},by=0,Zp=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){by=_y(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((_y()-by)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort(((i,s)=>s.P-i.P)),this.u.length>10){let i=this.u.splice(10);for(let s of i)this.l.delete(s.id)}this.p?.(r)}}},Ty=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=Qp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},wy=[200,500],Ry=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=cc();uc((()=>{ek();let r,i=zt("INP"),s=Xp(e,Zp),o=l=>{Ty((()=>{for(let u of l)s.h(u);let c=s.L();c&&c.P!==i.value&&(i.value=c.P,i.entries=c.entries,r())}))},a=Ao("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,wy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.v(),i=zt("INP"),r=Wt(n,i,wy,e.reportAllChanges)})))}))},Gp=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},xy=[2500,4e3],Iy=(n,e={})=>{uc((()=>{let t=cc(),r,i=zt("LCP"),s=Xp(e,Gp),o=l=>{e.reportAllChanges||(l=l.slice(-1));for(let c of l)s.h(c),c.startTime<t.firstHiddenTime&&(i.value=Math.max(c.startTime-ko(),0),i.entries=[c],r())},a=Ao("largest-contentful-paint",o);if(a){r=Wt(n,i,xy,e.reportAllChanges);let l=Qp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(Ty(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});qi((u=>{i=zt("LCP"),r=Wt(n,i,xy,e.reportAllChanges),Yp((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},Sy=[800,1800],Kp=n=>{document.prerendering?uc((()=>Kp(n))):document.readyState!=="complete"?addEventListener("load",(()=>Kp(n)),!0):setTimeout(n)},$y=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,Sy,e.reportAllChanges);Kp((()=>{let i=Jp();i&&(t.value=Math.max(i.responseStart-ko(),0),t.entries=[i],r(!0),qi((()=>{t=zt("TTFB",0),r=Wt(n,t,Sy,e.reportAllChanges),r(!0)})))}))};var Py="__syntro_vitals_bound",dc="__syntro_vitals_current_reporter";function tf(n,e){if(typeof window>"u")return()=>{};let t=window;t[dc]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[dc];if(o)for(let a of s.getEntries()){let l=a.attribution;if(!l)continue;l.some(u=>(u.containerSrc??u.name??"").startsWith(i))&&(o.increment("longtasks_self_count"),o.increment("longtasks_self_blocking_ms",Math.round(a.duration)))}}),r.observe({type:"longtask",buffered:!0})}catch{r=null}if(!t[Py]){t[Py]=!0;let s=o=>a=>{t[dc]?.recordHistogram(o,a.value)};Iy(s("lcp_ms")),Ry(s("inp_ms")),ef(s("fcp_ms")),$y(s("ttfb_ms")),ky(o=>{t[dc]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var Zi="2.8.0-canary.477";var vn="2.0";var tk=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function nk(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):tk.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 rk(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Oy="syntro_config_cache",ik=1440*60*1e3;function My(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function sk(n,e){if(My())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Oy,JSON.stringify(t))}catch{}}function ok(n){if(!My())return null;try{let e=localStorage.getItem(Oy);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>ik?null:t.config}catch{return null}}var Ly=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function ak(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 Ur=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=ak(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=sc(e,p);if(console.log("[SmartCanvas Config] resolveVariantConfigs result:",f?`tiles=${f.tiles?.length}`:"null"),f)return q("SmartCanvas Config","Resolved config from variant flags",f),f}}else console.log("[SmartCanvas Config] Skipping multi-flag mode:",{hasExperiments:!!e,manifestKey:i,variantFlagPrefix:s,hasGetAllFeatures:!!e?.getAllFeatures});let a=Ly({configUri:n,experiments:e,featureKey:t});if(!a)return q("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!nk(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(rk(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":Zi,"X-SDK-Schema-Version":vn}});if(!p.ok)throw jt()?.increment("flag_fetch_errors"),u=!0,new Error(`SmartCanvas: failed to fetch config (${p.status})`);let f=await p.json(),h=performance.now()-c;return jt()?.increment("flag_fetch_count"),jt()?.recordHistogram("flag_fetch_latency_ms",h),q("SmartCanvas Config","Fetched config from URI",f),o&&sk(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=ok(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var pc=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)}},nf=n=>new pc(n);var Pt={white:"#ffffff",black:"#000000"},ce={0:"#2c0b0a",1:"#5b1715",2:"#89221f",3:"#b72e2a",4:"#d44844",5:"#dd6d69",6:"#e5918f",7:"#eeb6b4",8:"#f6dada",9:"#faebea"},E={0:"#07080a",1:"#0f1318",2:"#0e1114",3:"#1c222a",4:"#2b333f",5:"#394454",6:"#475569",7:"#677384",8:"#87919f",9:"#a8afba",10:"#cbd0d7",11:"#e8eaee",12:"#f6f7f9"},Ae={0:"#07230a",1:"#0e4514",2:"#16681e",3:"#1d8a28",4:"#24ad32",5:"#4fbd5a",6:"#7acd82",7:"#a5deab",8:"#d0eed3",9:"#e5f6e7"},dt={0:"#301f09",1:"#5f3e12",2:"#8f5e1b",3:"#be7d24",4:"#ee9c2d",5:"#f1b057",6:"#f5c481",7:"#f8d7ab",8:"#fcebd5",9:"#fdf5ea"},Ce={0:"#330707",1:"#660f0e",2:"#991616",3:"#cc1e1d",4:"#ff2524",5:"#ff5150",6:"#ff7c7c",7:"#ffa8a7",8:"#ffd3d3",9:"#ffe9e9"},To={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},Ro={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},Io={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},$o={0:"#37091f",1:"#69123c",2:"#9b1c58",3:"#cd2575",4:"#ff2e92",5:"#ff58a8",6:"#ff82be",7:"#ffabd3",8:"#ffd5e9",9:"#ffeaf4"};var qt={primary:E[10],secondary:E[9],tertiary:E[8]},dL={primary:E[2],secondary:E[0]},pL={primary:E[4],secondary:E[3]},fc={primary:{text:Pt.white,icon:Pt.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:Pt.white,icon:E[10],iconHover:Pt.white,border:E[4],background:E[2]},link:{text:Pt.white,icon:Pt.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},fL={slateGrey:{content:E[10],pillOutline:E[10],borderPrimary:E[5],borderSecondary:E[5],background:E[3]},brand:{content:ce[9],pillOutline:ce[9],borderPrimary:ce[6],borderSecondary:ce[6],background:ce[0]},red:{content:Ce[8],pillOutline:Ce[4],borderPrimary:Ce[2],borderSecondary:Ce[2],background:Ce[0]},yellow:{content:dt[8],pillOutline:dt[4],borderPrimary:dt[2],borderSecondary:dt[2],background:dt[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:Io[8],pillOutline:Io[4],borderPrimary:Io[2],borderSecondary:Io[2],background:Io[0]},blue:{content:To[8],pillOutline:To[4],borderPrimary:To[2],borderSecondary:To[2],background:To[0]},orange:{content:Ro[8],pillOutline:Ro[4],borderPrimary:Ro[2],borderSecondary:Ro[2],background:Ro[0]},pink:{content:$o[8],pillOutline:$o[4],borderPrimary:$o[2],borderSecondary:$o[2],background:$o[0]}},hL={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:dt[8],border:dt[2],background:dt[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},gL={green:{content:Ae[1],background:Ae[9]},yellow:{content:dt[1],background:dt[9]},red:{content:Ce[1],background:Ce[9]}},mL={content:E[10],border:E[4],background:E[3]},vL={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},yL={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},_L={backgroundDefault:E[2],backgroundDisabled:E[0],textLabel:E[9],textPlaceholder:E[8],textHint:E[8],textError:Ce[5],iconDefault:E[9],iconPlaceholder:E[10],iconError:Ce[5],borderDefault:E[4],borderSelected:ce[3],borderError:Ce[5]},bL={handleDefault:Pt.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},wL={off:{backgroundDefault:"#00000000",backgroundHover:E[5],backgroundDisabled:E[2],border:E[6]},on:{backgroundDefault:Ae[0],backgroundHover:Ae[1],backgroundDisabled:E[2],border:Ae[3]}},xL={content:E[10],background:E[4]},SL={background:E[4],active:Ae[3]},EL={background:E[1],content:E[9],border:E[4]},CL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},kL={background:E[1],content:E[9],border:E[4]},AL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},TL={header:{textDefault:E[9],textHover:E[8],backgroundDefault:E[1]},border:E[4],cell:{textPrimary:E[10],textSecondary:E[9],backgroundDefault:E[2],backgroundHover:E[1]}},RL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},IL={background:Ae[1],active:Ae[5]},$L={textDefault:E[10],textSelected:Pt.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},PL=E[9];var NL={size:56,inset:12,background:Pt.black,color:Pt.white,border:`2px solid ${ce[3]}`,shadowOpen:"0 4px 24px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.08)",shadowClosed:"0 4px 24px rgba(0,0,0,0.6)"};function ae(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}function lk(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Ny={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[4],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[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%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.4)",padding:"0"},launcher:{background:fc.primary.backgroundDefault,backgroundHover:fc.primary.backgroundHover,color:fc.primary.icon,size:"56px",shadow:`0 8px 32px ${ae(E[0],.6)}`,borderRadius:"9999px"},tile:{background:ae(E[1],.6),backgroundHover:ae(E[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:qt.primary,textColor:qt.secondary,iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[1],.6),textColor:qt.primary,titleColor:qt.primary,arrowColor:ae(E[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[0],.95),textColor:qt.primary,textSecondaryColor:qt.secondary,border:`1px solid ${E[5]}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.15),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[4]})`},content:{background:ae(E[3],.8),backgroundHover:ae(E[5],.6),border:`1px solid ${ae(E[5],.5)}`,borderRadius:"8px",textColor:qt.primary,textSecondaryColor:qt.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:ae(E[3],.8),searchColor:qt.primary,chevronColor:"currentColor",bubbleBackground:ae(E[0],.35),bubbleBorder:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundUser:ae(ce[3],.14),bubbleBorderUser:`1px solid ${ae(ce[3],.28)}`,bubbleBackgroundIdle:ae(E[3],.4),bubbleBorderIdle:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundError:ae(Ce[1],.42),bubbleBorderError:`1px solid ${ae(Ce[4],.55)}`,bubbleTextError:Ce[8],codeBackground:ae(E[0],.25),codeBackgroundBlock:ae(E[0],.35),dividerColor:ae(E[12],.12),linkColor:ce[4]},mobile:{canvas:{backdrop:!0}}},Fy={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[2],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[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%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.3)",padding:"0"},launcher:{background:ce[3],backgroundHover:ce[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:ae(E[12],.7),backgroundHover:ae(E[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:E[1],textColor:E[6],iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[12],.7),textColor:E[1],titleColor:E[1],arrowColor:ae(E[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[12],.95),textColor:E[1],textSecondaryColor:E[6],border:`1px solid ${ae(E[0],.12)}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.1),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[2]})`},content:{background:ae(E[12],.8),backgroundHover:ae(E[11],.6),border:`1px solid ${E[11]}`,borderRadius:"8px",textColor:E[1],textSecondaryColor:E[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:E[12],searchColor:E[1],chevronColor:"currentColor",bubbleBackground:ae(E[11],.6),bubbleBorder:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundUser:ae(ce[3],.1),bubbleBorderUser:`1px solid ${ae(ce[3],.32)}`,bubbleBackgroundIdle:ae(E[10],.5),bubbleBorderIdle:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundError:ae(Ce[8],.5),bubbleBorderError:`1px solid ${ae(Ce[4],.5)}`,bubbleTextError:Ce[2],codeBackground:ae(E[11],.7),codeBackgroundBlock:ae(E[11],.85),dividerColor:ae(E[6],.14),linkColor:ce[3]},mobile:{canvas:{backdrop:!0}}};function Dy(n){let e=n.mode==="light"?Fy:Ny;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,accentColor:n.accentColor??e.accentColor,accentForeground:n.accentForeground??e.accentForeground,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},mobile:{canvas:{...e.mobile.canvas,...n.mobile?.canvas}}}}function Hy(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?Fy:Ny;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,accentColor:e.accentColor??n.accentColor??r.accentColor,accentForeground:e.accentForeground??n.accentForeground??r.accentForeground,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},mobile:{canvas:{...r.mobile.canvas,...n.mobile?.canvas,...e.mobile?.canvas}}}}var ck=["canvas","launcher","tile","overlay","notification","content"];function By(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.accentColor&&(e["--sc-accent-color"]=n.accentColor),n.accentForeground&&(e["--sc-accent-foreground"]=n.accentForeground),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of ck){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${lk(i)}`]=s)}return e}var Un,jr,Wr,yn,_n,rf,hc,Gi=class{constructor(e,t,r){ne(this,_n);ne(this,Un);ne(this,jr);ne(this,Wr);ne(this,yn);L(this,Un,e),L(this,jr,t??{}),L(this,Wr,r),L(this,yn,ue(this,_n,rf).call(this)),e.addController(this)}get config(){return C(this,yn).config}get mode(){return C(this,yn).mode}get cssVariables(){return C(this,yn).cssVariables}hostConnected(){ue(this,_n,hc).call(this)}hostDisconnected(){}hostUpdated(){ue(this,_n,hc).call(this)}setThemeConfig(e,t){L(this,jr,e),L(this,Wr,t),L(this,yn,ue(this,_n,rf).call(this)),ue(this,_n,hc).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,jr=new WeakMap,Wr=new WeakMap,yn=new WeakMap,_n=new WeakSet,rf=function(){let e=C(this,Wr)?Hy(C(this,Wr),C(this,jr)):Dy(C(this,jr)),t=By(e);return{config:e,mode:e.mode,cssVariables:t}},hc=function(){let e=C(this,Un).shadowRoot??("renderRoot"in C(this,Un)?C(this,Un).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(C(this,yn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
383
|
+
`}};ic.properties={isOpen:{type:Boolean},notificationCount:{type:Number},launcherIcon:{attribute:!1},label:{type:String},colorPrimaryHover:{type:String},hasActiveTiles:{type:Boolean},pendingCanvasShape:{type:Boolean},_launcherPos:{state:!0},_hovered:{state:!0},_shapeReady:{state:!0},_pulseResting:{state:!0}};customElements.define("syntro-launcher",ic);function sc(n,e,t="merge"){return t==="first-match"?GC(n,e):KC(n,e)}function GC(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,a=i.slots&&Object.keys(i.slots).length>0;if(s||o||a)return py([i])}return null}function KC(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,l=s.slots&&Object.keys(s.slots).length>0;(o||a||l)&&t.push(s)}return t.length===0?null:py(t)}function py(n){let e=[],t=[],r=new Set,i=[],s,o,a,l,c,u,p,f,h;for(let y of n){let w=y.tiles?.length??0;y.tiles&&e.push(...y.tiles);let x=0;if(y.actions)for(let k of y.actions){let I=k.label;if(I){if(r.has(I))continue;r.add(I)}t.push(k),x++}let _=y.meta?.variant_id;_&&(w>0||x>0)&&i.push({variant_id:_,tiles:w,actions:x}),s??(s=y.fetchedAt),o??(o=y.schemaVersion),a??(a=y.configVersion),l??(l=y.canvasTitle),c??(c=y.displayMode),u??(u=y.theme),p??(p=y.launcher),f??(f=y.meta),h??(h=y.slots)}let g=new Map,v=[];for(let y of e){let w=y?.id;if(typeof w=="string"&&w){let x=g.get(w);if(x!==void 0){v[x]=y;continue}g.set(w,v.length)}v.push(y)}let m=i.length>0?{...f??{},variants:i}:f;return{tiles:v,actions:t,fetchedAt:s??new Date().toISOString(),...o&&{schemaVersion:o},...a&&{configVersion:a},...l&&{canvasTitle:l},...c&&{displayMode:c},...u&&{theme:u},...p&&{launcher:p},...m&&{meta:m},...h&&{slots:h}}}var Lp=!1;function fy(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Np(n){if(fy()){Lp=!0;return}Lp=n??!1}function YC(){return fy()?!0:Lp}function q(n,e,t){YC()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function We(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function oc(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var ac=class{constructor(e){this.config=e;this.counters=new Map;this.histograms=new Map;this.windowStartMs=Date.now();this.timer=null;this.pagehideHandler=null;this.runtime=null;this.adapterCleanup=null;this.resource=e.resource,this.flushIntervalMs=e.flushIntervalMs??6e4}bindRuntime(e){this.runtime=e}attachAdapterCleanup(e){this.adapterCleanup=e}increment(e,t=1){this.counters.set(e,(this.counters.get(e)??0)+t)}snapshotCounters(){let e={};for(let[t,r]of this.counters)e[t]=r;return e}recordHistogram(e,t){let r=this.histograms.get(e)??[];r.push(t),this.histograms.set(e,r)}snapshotHistograms(){let e={};for(let[t,r]of this.histograms){if(r.length===0)continue;let i=[...r].sort((s,o)=>s-o);e[t]={count:i.length,p50:hy(i,.5),p95:hy(i,.95)}}return e}async flush(){let e=this.snapshotCounters(),t=this.snapshotHistograms();if(!(Object.keys(e).length>0||Object.keys(t).length>0))return;let i=null,s="";try{i=this.runtime?.getSurface()??null}catch{}try{s=this.runtime?.getSessionId()??""}catch{}let o={resource:{...this.resource,sessionId:s,surfaceType:i?.type??"unknown",surfaceHost:i?.host??"unknown",surfaceDevice:i?.device??"unknown",surfaceMode:i?.mode??"unknown"},windowSeconds:Math.max(1,Math.round((Date.now()-this.windowStartMs)/1e3)),windowStartUnixMs:this.windowStartMs,counters:e,histograms:t};this.counters.clear(),this.histograms.clear(),this.windowStartMs=Date.now();try{await this.config.emit(o)}catch{}}start(){this.timer===null&&(this.timer=setInterval(()=>{this.flush()},this.flushIntervalMs),typeof window<"u"&&(this.pagehideHandler=()=>{this.flush()},window.addEventListener("pagehide",this.pagehideHandler)))}stop(){if(this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.pagehideHandler!==null&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pagehideHandler),this.pagehideHandler=null),this.adapterCleanup!==null){try{this.adapterCleanup()}catch{}this.adapterCleanup=null}}};function hy(n,e){if(n.length===0)return 0;let t=(n.length-1)*e,r=Math.floor(t),i=Math.ceil(t);return r===i?n[r]:n[r]+(n[i]-n[r])*(t-r)}var Co=null;function Fp(n){return Co?.stop(),Co=new ac(n),Co.start(),Co}function jt(){return Co}var mn=(n,e)=>({key:n,value:{stringValue:e}}),Dp=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),gy=(n,e)=>({key:n,value:{doubleValue:e}});function JC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[mn("service.name",e.serviceName),mn("service.version",e.serviceVersion),mn("syntro.posthog_key",e.posthogKey),mn("syntro.session_id",e.sessionId),mn("syntro.surface_type",e.surfaceType),mn("syntro.surface_host",e.surfaceHost),mn("syntro.surface_device",e.surfaceDevice),mn("syntro.surface_mode",e.surfaceMode),mn("syntro.host_origin",e.hostOrigin)],a=[Dp("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Dp(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Dp(`${u}_count`,p.count)),a.push(gy(`${u}_p50`,p.p50)),a.push(gy(`${u}_p95`,p.p95)));let l=`${Date.now()}000000`,c=`${s}000000`;return{resourceLogs:[{resource:{attributes:o},scopeLogs:[{scope:{name:"syntro.sdk.health"},logRecords:[{timeUnixNano:c,observedTimeUnixNano:l,severityText:"INFO",body:{stringValue:"sdk_health_window"},attributes:a}]}]}]}}function Hp(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(JC(t)),i=()=>e(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0,mode:"cors"});try{let s=await i();if(!s.ok&&s.status>=500)try{await i()}catch{}}catch{try{await i()}catch{}}}}function XC(){if(typeof document>"u")return;let n=document.currentScript;if(n?.src)return n.src;try{let e=Array.from(document.scripts);for(let t=e.length-1;t>=0;t-=1){let r=e[t]?.src;if(typeof r=="string"&&(r.includes("runtime-sdk")||r.includes("smart-canvas")))return r}}catch{}}var Bp=XC();function Vp(){if(!Bp)return;let n=Bp.lastIndexOf("/");if(n!==-1)return Bp.substring(0,n+1)}var Ey=-1,qi=n=>{addEventListener("pageshow",(e=>{e.persisted&&(Ey=e.timeStamp,n(e))}),!0)},Wt=(n,e,t,r)=>{let i,s;return o=>{e.value>=0&&(o||r)&&(s=e.value-(i??0),(s||i===void 0)&&(i=e.value,e.delta=s,e.rating=((a,l)=>a>l[1]?"poor":a>l[0]?"needs-improvement":"good")(e.value,t),n(e)))}},Yp=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},Jp=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},ko=()=>Jp()?.activationStart??0,zt=(n,e=-1)=>{let t=Jp(),r="navigate";return Ey>=0?r="back-forward-cache":t&&(document.prerendering||ko()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-"))),{name:n,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},Up=new WeakMap;function Xp(n,e){return Up.get(n)||Up.set(n,new e),Up.get(n)}var Wp=class{constructor(){en(this,"t");en(this,"i",0);en(this,"o",[])}h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},Ao=(n,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(n)){let r=new PerformanceObserver((i=>{Promise.resolve().then((()=>{e(i.getEntries())}))}));return r.observe({type:n,buffered:!0,...t}),r}}catch{}},Qp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},zi=-1,Cy=new Set,my=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,zp=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of Cy)e();isFinite(zi)||(zi=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",zp,!0))}},cc=()=>{if(zi<0){let n=ko();zi=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??my(),addEventListener("visibilitychange",zp,!0),addEventListener("prerenderingchange",zp,!0),qi((()=>{setTimeout((()=>{zi=my()}))}))}return{get firstHiddenTime(){return zi},onHidden(n){Cy.add(n)}}},uc=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},vy=[1800,3e3],ef=(n,e={})=>{uc((()=>{let t=cc(),r,i=zt("FCP"),s=Ao("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-ko(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,vy,e.reportAllChanges),qi((o=>{i=zt("FCP"),r=Wt(n,i,vy,e.reportAllChanges),Yp((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},yy=[.1,.25],ky=(n,e={})=>{let t=cc();ef(Qp((()=>{let r,i=zt("CLS",0),s=Xp(e,Wp),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=Ao("layout-shift",o);a&&(r=Wt(n,i,yy,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,yy,e.reportAllChanges),Yp((()=>r()))})),setTimeout(r))})))},Ay=0,jp=1/0,lc=0,QC=n=>{for(let e of n)e.interactionId&&(jp=Math.min(jp,e.interactionId),lc=Math.max(lc,e.interactionId),Ay=lc?(lc-jp)/7+1:0)},qp,_y=()=>qp?Ay:performance.interactionCount??0,ek=()=>{"interactionCount"in performance||qp||(qp=Ao("event",QC,{type:"event",buffered:!0,durationThreshold:0}))},by=0,Zp=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){by=_y(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((_y()-by)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort(((i,s)=>s.P-i.P)),this.u.length>10){let i=this.u.splice(10);for(let s of i)this.l.delete(s.id)}this.p?.(r)}}},Ty=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=Qp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},wy=[200,500],Ry=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=cc();uc((()=>{ek();let r,i=zt("INP"),s=Xp(e,Zp),o=l=>{Ty((()=>{for(let u of l)s.h(u);let c=s.L();c&&c.P!==i.value&&(i.value=c.P,i.entries=c.entries,r())}))},a=Ao("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,wy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.v(),i=zt("INP"),r=Wt(n,i,wy,e.reportAllChanges)})))}))},Gp=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},xy=[2500,4e3],Iy=(n,e={})=>{uc((()=>{let t=cc(),r,i=zt("LCP"),s=Xp(e,Gp),o=l=>{e.reportAllChanges||(l=l.slice(-1));for(let c of l)s.h(c),c.startTime<t.firstHiddenTime&&(i.value=Math.max(c.startTime-ko(),0),i.entries=[c],r())},a=Ao("largest-contentful-paint",o);if(a){r=Wt(n,i,xy,e.reportAllChanges);let l=Qp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(Ty(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});qi((u=>{i=zt("LCP"),r=Wt(n,i,xy,e.reportAllChanges),Yp((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},Sy=[800,1800],Kp=n=>{document.prerendering?uc((()=>Kp(n))):document.readyState!=="complete"?addEventListener("load",(()=>Kp(n)),!0):setTimeout(n)},$y=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,Sy,e.reportAllChanges);Kp((()=>{let i=Jp();i&&(t.value=Math.max(i.responseStart-ko(),0),t.entries=[i],r(!0),qi((()=>{t=zt("TTFB",0),r=Wt(n,t,Sy,e.reportAllChanges),r(!0)})))}))};var Py="__syntro_vitals_bound",dc="__syntro_vitals_current_reporter";function tf(n,e){if(typeof window>"u")return()=>{};let t=window;t[dc]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[dc];if(o)for(let a of s.getEntries()){let l=a.attribution;if(!l)continue;l.some(u=>(u.containerSrc??u.name??"").startsWith(i))&&(o.increment("longtasks_self_count"),o.increment("longtasks_self_blocking_ms",Math.round(a.duration)))}}),r.observe({type:"longtask",buffered:!0})}catch{r=null}if(!t[Py]){t[Py]=!0;let s=o=>a=>{t[dc]?.recordHistogram(o,a.value)};Iy(s("lcp_ms")),Ry(s("inp_ms")),ef(s("fcp_ms")),$y(s("ttfb_ms")),ky(o=>{t[dc]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var Zi="2.8.0-canary.478";var vn="2.0";var tk=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function nk(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):tk.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 rk(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Oy="syntro_config_cache",ik=1440*60*1e3;function My(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function sk(n,e){if(My())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Oy,JSON.stringify(t))}catch{}}function ok(n){if(!My())return null;try{let e=localStorage.getItem(Oy);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>ik?null:t.config}catch{return null}}var Ly=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function ak(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 Ur=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=ak(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=sc(e,p);if(console.log("[SmartCanvas Config] resolveVariantConfigs result:",f?`tiles=${f.tiles?.length}`:"null"),f)return q("SmartCanvas Config","Resolved config from variant flags",f),f}}else console.log("[SmartCanvas Config] Skipping multi-flag mode:",{hasExperiments:!!e,manifestKey:i,variantFlagPrefix:s,hasGetAllFeatures:!!e?.getAllFeatures});let a=Ly({configUri:n,experiments:e,featureKey:t});if(!a)return q("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!nk(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(rk(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":Zi,"X-SDK-Schema-Version":vn}});if(!p.ok)throw jt()?.increment("flag_fetch_errors"),u=!0,new Error(`SmartCanvas: failed to fetch config (${p.status})`);let f=await p.json(),h=performance.now()-c;return jt()?.increment("flag_fetch_count"),jt()?.recordHistogram("flag_fetch_latency_ms",h),q("SmartCanvas Config","Fetched config from URI",f),o&&sk(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=ok(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var pc=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)}},nf=n=>new pc(n);var Pt={white:"#ffffff",black:"#000000"},ce={0:"#2c0b0a",1:"#5b1715",2:"#89221f",3:"#b72e2a",4:"#d44844",5:"#dd6d69",6:"#e5918f",7:"#eeb6b4",8:"#f6dada",9:"#faebea"},E={0:"#07080a",1:"#0f1318",2:"#0e1114",3:"#1c222a",4:"#2b333f",5:"#394454",6:"#475569",7:"#677384",8:"#87919f",9:"#a8afba",10:"#cbd0d7",11:"#e8eaee",12:"#f6f7f9"},Ae={0:"#07230a",1:"#0e4514",2:"#16681e",3:"#1d8a28",4:"#24ad32",5:"#4fbd5a",6:"#7acd82",7:"#a5deab",8:"#d0eed3",9:"#e5f6e7"},dt={0:"#301f09",1:"#5f3e12",2:"#8f5e1b",3:"#be7d24",4:"#ee9c2d",5:"#f1b057",6:"#f5c481",7:"#f8d7ab",8:"#fcebd5",9:"#fdf5ea"},Ce={0:"#330707",1:"#660f0e",2:"#991616",3:"#cc1e1d",4:"#ff2524",5:"#ff5150",6:"#ff7c7c",7:"#ffa8a7",8:"#ffd3d3",9:"#ffe9e9"},To={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},Ro={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},Io={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},$o={0:"#37091f",1:"#69123c",2:"#9b1c58",3:"#cd2575",4:"#ff2e92",5:"#ff58a8",6:"#ff82be",7:"#ffabd3",8:"#ffd5e9",9:"#ffeaf4"};var qt={primary:E[10],secondary:E[9],tertiary:E[8]},dL={primary:E[2],secondary:E[0]},pL={primary:E[4],secondary:E[3]},fc={primary:{text:Pt.white,icon:Pt.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:Pt.white,icon:E[10],iconHover:Pt.white,border:E[4],background:E[2]},link:{text:Pt.white,icon:Pt.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},fL={slateGrey:{content:E[10],pillOutline:E[10],borderPrimary:E[5],borderSecondary:E[5],background:E[3]},brand:{content:ce[9],pillOutline:ce[9],borderPrimary:ce[6],borderSecondary:ce[6],background:ce[0]},red:{content:Ce[8],pillOutline:Ce[4],borderPrimary:Ce[2],borderSecondary:Ce[2],background:Ce[0]},yellow:{content:dt[8],pillOutline:dt[4],borderPrimary:dt[2],borderSecondary:dt[2],background:dt[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:Io[8],pillOutline:Io[4],borderPrimary:Io[2],borderSecondary:Io[2],background:Io[0]},blue:{content:To[8],pillOutline:To[4],borderPrimary:To[2],borderSecondary:To[2],background:To[0]},orange:{content:Ro[8],pillOutline:Ro[4],borderPrimary:Ro[2],borderSecondary:Ro[2],background:Ro[0]},pink:{content:$o[8],pillOutline:$o[4],borderPrimary:$o[2],borderSecondary:$o[2],background:$o[0]}},hL={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:dt[8],border:dt[2],background:dt[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},gL={green:{content:Ae[1],background:Ae[9]},yellow:{content:dt[1],background:dt[9]},red:{content:Ce[1],background:Ce[9]}},mL={content:E[10],border:E[4],background:E[3]},vL={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},yL={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},_L={backgroundDefault:E[2],backgroundDisabled:E[0],textLabel:E[9],textPlaceholder:E[8],textHint:E[8],textError:Ce[5],iconDefault:E[9],iconPlaceholder:E[10],iconError:Ce[5],borderDefault:E[4],borderSelected:ce[3],borderError:Ce[5]},bL={handleDefault:Pt.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},wL={off:{backgroundDefault:"#00000000",backgroundHover:E[5],backgroundDisabled:E[2],border:E[6]},on:{backgroundDefault:Ae[0],backgroundHover:Ae[1],backgroundDisabled:E[2],border:Ae[3]}},xL={content:E[10],background:E[4]},SL={background:E[4],active:Ae[3]},EL={background:E[1],content:E[9],border:E[4]},CL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},kL={background:E[1],content:E[9],border:E[4]},AL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},TL={header:{textDefault:E[9],textHover:E[8],backgroundDefault:E[1]},border:E[4],cell:{textPrimary:E[10],textSecondary:E[9],backgroundDefault:E[2],backgroundHover:E[1]}},RL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},IL={background:Ae[1],active:Ae[5]},$L={textDefault:E[10],textSelected:Pt.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},PL=E[9];var NL={size:56,inset:12,background:Pt.black,color:Pt.white,border:`2px solid ${ce[3]}`,shadowOpen:"0 4px 24px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.08)",shadowClosed:"0 4px 24px rgba(0,0,0,0.6)"};function ae(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}function lk(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Ny={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[4],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[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%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.4)",padding:"0"},launcher:{background:fc.primary.backgroundDefault,backgroundHover:fc.primary.backgroundHover,color:fc.primary.icon,size:"56px",shadow:`0 8px 32px ${ae(E[0],.6)}`,borderRadius:"9999px"},tile:{background:ae(E[1],.6),backgroundHover:ae(E[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:qt.primary,textColor:qt.secondary,iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[1],.6),textColor:qt.primary,titleColor:qt.primary,arrowColor:ae(E[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[0],.95),textColor:qt.primary,textSecondaryColor:qt.secondary,border:`1px solid ${E[5]}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.15),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[4]})`},content:{background:ae(E[3],.8),backgroundHover:ae(E[5],.6),border:`1px solid ${ae(E[5],.5)}`,borderRadius:"8px",textColor:qt.primary,textSecondaryColor:qt.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:ae(E[3],.8),searchColor:qt.primary,chevronColor:"currentColor",bubbleBackground:ae(E[0],.35),bubbleBorder:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundUser:ae(ce[3],.14),bubbleBorderUser:`1px solid ${ae(ce[3],.28)}`,bubbleBackgroundIdle:ae(E[3],.4),bubbleBorderIdle:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundError:ae(Ce[1],.42),bubbleBorderError:`1px solid ${ae(Ce[4],.55)}`,bubbleTextError:Ce[8],codeBackground:ae(E[0],.25),codeBackgroundBlock:ae(E[0],.35),dividerColor:ae(E[12],.12),linkColor:ce[4]},mobile:{canvas:{backdrop:!0}}},Fy={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[2],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[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%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.3)",padding:"0"},launcher:{background:ce[3],backgroundHover:ce[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:ae(E[12],.7),backgroundHover:ae(E[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:E[1],textColor:E[6],iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[12],.7),textColor:E[1],titleColor:E[1],arrowColor:ae(E[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[12],.95),textColor:E[1],textSecondaryColor:E[6],border:`1px solid ${ae(E[0],.12)}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.1),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[2]})`},content:{background:ae(E[12],.8),backgroundHover:ae(E[11],.6),border:`1px solid ${E[11]}`,borderRadius:"8px",textColor:E[1],textSecondaryColor:E[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:E[12],searchColor:E[1],chevronColor:"currentColor",bubbleBackground:ae(E[11],.6),bubbleBorder:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundUser:ae(ce[3],.1),bubbleBorderUser:`1px solid ${ae(ce[3],.32)}`,bubbleBackgroundIdle:ae(E[10],.5),bubbleBorderIdle:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundError:ae(Ce[8],.5),bubbleBorderError:`1px solid ${ae(Ce[4],.5)}`,bubbleTextError:Ce[2],codeBackground:ae(E[11],.7),codeBackgroundBlock:ae(E[11],.85),dividerColor:ae(E[6],.14),linkColor:ce[3]},mobile:{canvas:{backdrop:!0}}};function Dy(n){let e=n.mode==="light"?Fy:Ny;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,accentColor:n.accentColor??e.accentColor,accentForeground:n.accentForeground??e.accentForeground,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},mobile:{canvas:{...e.mobile.canvas,...n.mobile?.canvas}}}}function Hy(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?Fy:Ny;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,accentColor:e.accentColor??n.accentColor??r.accentColor,accentForeground:e.accentForeground??n.accentForeground??r.accentForeground,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},mobile:{canvas:{...r.mobile.canvas,...n.mobile?.canvas,...e.mobile?.canvas}}}}var ck=["canvas","launcher","tile","overlay","notification","content"];function By(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.accentColor&&(e["--sc-accent-color"]=n.accentColor),n.accentForeground&&(e["--sc-accent-foreground"]=n.accentForeground),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of ck){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${lk(i)}`]=s)}return e}var Un,jr,Wr,yn,_n,rf,hc,Gi=class{constructor(e,t,r){ne(this,_n);ne(this,Un);ne(this,jr);ne(this,Wr);ne(this,yn);L(this,Un,e),L(this,jr,t??{}),L(this,Wr,r),L(this,yn,ue(this,_n,rf).call(this)),e.addController(this)}get config(){return C(this,yn).config}get mode(){return C(this,yn).mode}get cssVariables(){return C(this,yn).cssVariables}hostConnected(){ue(this,_n,hc).call(this)}hostDisconnected(){}hostUpdated(){ue(this,_n,hc).call(this)}setThemeConfig(e,t){L(this,jr,e),L(this,Wr,t),L(this,yn,ue(this,_n,rf).call(this)),ue(this,_n,hc).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,jr=new WeakMap,Wr=new WeakMap,yn=new WeakMap,_n=new WeakSet,rf=function(){let e=C(this,Wr)?Hy(C(this,Wr),C(this,jr)):Dy(C(this,jr)),t=By(e);return{config:e,mode:e.mode,cssVariables:t}},hc=function(){let e=C(this,Un).shadowRoot??("renderRoot"in C(this,Un)?C(this,Un).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(C(this,yn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
384
384
|
`);t.textContent=`:host {
|
|
385
385
|
${r}
|
|
386
386
|
}`};var uk=new Set(["tag_name","$el_text"]);function dk(n){return uk.has(n)||n.startsWith("attr__")}function Vy(n,e){return n.equals!==void 0?e===n.equals:n.contains!==void 0?typeof e=="string"&&e.includes(n.contains):!1}function pk(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(dk(i)){let o=r.props?.elements;if(!o||!o.some(l=>Vy(s,l[i])))return!1}else if(!Vy(s,r.props?.[i]))return!1}return!0}}function Uy(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?pk(i):()=>!0,o=typeof r.withinMs=="number";e.register(r.key,s,o)}}function zr(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"&&Uy(o.triggerWhen,e)}if(t)for(let r of t){let i=r;i.triggerWhen?.type==="rules"&&Uy(i.triggerWhen,e)}}var Zy=sd,jy="smart-canvas",Wy=n=>[...n].sort((e,t)=>(t.priority??0)-(e.priority??0));function zy(n){let e=typeof window<"u"?window.SynOS?.interventionTracker:null;if(e)for(let t of n)e.trackTriggered(t.id,t.widget??"unknown")}function fk(n,e){if(Nn(n.kind)===e)return!0;if(n.kind!=="core:mountWidget")return!1;let r=n.widget?.widgetId;return typeof r=="string"&&Rt(r)===e}var qy=1e4;function hk(n,e){let t=e.apps;if(!t.get&&!t.isActive)return[];let r=new Set;for(let i of n){let s=Nn(i.kind);if(!s&&i.kind==="core:mountWidget"){let l=i.widget?.widgetId;s=typeof l=="string"?Rt(l):null}if(!s)continue;let o=t.get?.(s)?.state;if(o==="error")continue;(t.isActive?.(s)??o==="active")||r.add(s)}return[...r]}var gk=new Set(["drawer","floating"]);function mk(n){if(!n||typeof n!="object")return null;let e=n.canvas;if(!e||typeof e!="object")return null;let t=e.element;return typeof t=="string"&&t.length>0?t:null}function vk(n,e){let t=n?.[e];if(!t||typeof t!="object")return;let r=t.theme;if(!r||typeof r!="object")return;let i=r.chromeless;return typeof i=="boolean"?i:void 0}function yk(n){if(!n)return[];let e=[];for(let[t,r]of Object.entries(n)){if(gk.has(t)||!r||typeof r!="object")continue;let i=r;if(i.kind!=="inline"){typeof process<"u";continue}let s=i.anchor;!s||typeof s.selector!="string"||typeof s.route!="string"&&!Array.isArray(s.route)||e.push({name:t,config:r})}return e}function _k(n){let e=n?.drawer;if(!e||typeof e!="object")return;let t=e.lid;if(!t||typeof t!="object")return;let r=t.widget;if(typeof r!="string"||r.length===0)return;let i=t.props,s=t.hideWhileVisible;return{widget:r,props:i&&typeof i=="object"?i:void 0,hideWhileVisible:typeof s=="string"&&s.length>0?s:void 0}}var jn,lt,Ki,Zt,bn,Ot,Zr,Yi,Po,Wn,Ji,Gr,Oo,Mo,Lo,No,Kr,Yr,zn,qn,Zn,tt,Xi,Gn,Kn,Yn,Jn,Xn,Qi,Gt,Qn,vc,Jr,Xr,er,Fo,yc,es,oe,sf,Gy,of,Ky,ts,gc,mc,af,lf,cf,Yy,uf,Jy,Xy,df,Qy,pf,Qr,_c,bc,qr=class extends be{constructor(){super();ne(this,oe);this.fetcher=void 0;this.configUri=void 0;this.configUriFeatureKey=void 0;this.fetchCredentials="include";this.experiments=void 0;this.telemetry=void 0;this.runtime=void 0;this.initialBatchHandle=null;this.initialBatchActions=void 0;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._drawerLid=void 0;this._inlineSlots=[];this._isOpen=!1;this._nudgeBadgeCount=0;ne(this,jn,null);this._pageUrl=typeof window<"u"?window.location.href:"/";this._llmTilesVersion=0;this._customCanvasFailed=!1;this._previewToasts=[];this._chatTakeover=!1;ne(this,lt);ne(this,Ki,null);ne(this,Zt,null);ne(this,bn,null);ne(this,Ot,null);ne(this,Zr);ne(this,Yi,"[]");ne(this,Po,0);ne(this,Wn,null);ne(this,Ji,"[]");ne(this,Gr,"[]");ne(this,Oo,"null");ne(this,Mo,"null");ne(this,Lo,"null");ne(this,No,"[]");ne(this,Kr,null);ne(this,Yr,null);ne(this,zn,null);ne(this,qn,null);ne(this,Zn,null);ne(this,tt,null);ne(this,Xi,!1);ne(this,Gn,null);ne(this,Kn,null);ne(this,Yn,null);ne(this,Jn,null);ne(this,Xn,null);ne(this,Qi,!1);ne(this,Gt,new Map);ne(this,Qn,new Set);ne(this,vc,new Set);ne(this,Jr,!1);ne(this,Xr,()=>{this._pageUrl=window.location.href});ne(this,er);ne(this,Fo);ne(this,yc,0);ne(this,es,new Map);ne(this,ts,0);ne(this,Qr,t=>{this._chatTakeover=!1,this._nudgeBadgeCount=0,C(this,lt).toggle()});ne(this,_c,t=>{let r=t.detail;q("SmartCanvas","[SmartCanvas] custom canvas load failed; falling back to bundled overlay",r),this._customCanvasFailed=!0;try{this.telemetry?.trackAction?.("canvas-load-failed",r?.canvasName??"unknown","overlay")}catch{}});ne(this,bc,t=>{this._chatTakeover=!!t.detail?.active});L(this,lt,nf()),L(this,Zr,!1),L(this,er,new Gi(this)),L(this,Fo,new yi(this,{context:Zy,initialValue:null}))}connectedCallback(){super.connectedCallback(),L(this,jn,t=>{if(t.detail?.suppressToast!==!0){if(this._isOpen){this._nudgeBadgeCount=0,this.requestUpdate();return}this._nudgeBadgeCount+=1,this.requestUpdate()}}),document.addEventListener("syntro:nudge",C(this,jn)),this.style.setProperty("font-family","inherit"),L(this,Ki,C(this,lt).subscribe(t=>{this._isOpen&&!t.open&&L(this,Jr,!1),t.open&&this._previewToasts.length>0&&(this._previewToasts=[]),this._isOpen=t.open})),this._isOpen=C(this,lt).getState().open,L(this,Zt,document.createElement("div")),C(this,Zt).id="overlayContainer",Object.assign(C(this,Zt).style,{position:"fixed",inset:"0",zIndex:"2147483645",pointerEvents:"none"}),this.shadowRoot.appendChild(C(this,Zt)),L(this,bn,document.createElement("div")),C(this,bn).id="portalRoot",this.shadowRoot.appendChild(C(this,bn)),ue(this,oe,af).call(this),ue(this,oe,pf).call(this),ue(this,oe,cf).call(this)}disconnectedCallback(){var t,r,i,s,o,a,l,c,u,p;super.disconnectedCallback(),C(this,jn)&&(document.removeEventListener("syntro:nudge",C(this,jn)),L(this,jn,null)),this._nudgeBadgeCount=0,this._chatTakeover=!1,(t=C(this,Ki))==null||t.call(this),L(this,Ki,null),(r=C(this,Yr))==null||r.call(this),L(this,Yr,null),(i=C(this,zn))==null||i.call(this),L(this,zn,null),(s=C(this,qn))==null||s.call(this),L(this,qn,null),(o=C(this,Zn))==null||o.call(this),L(this,Zn,null),C(this,tt)!=null&&(clearTimeout(C(this,tt)),L(this,tt,null)),(a=C(this,Gn))==null||a.call(this),L(this,Gn,null),(l=C(this,Kn))==null||l.call(this),L(this,Kn,null),(c=C(this,Yn))==null||c.call(this),L(this,Yn,null),(u=C(this,Jn))==null||u.call(this),L(this,Jn,null),(p=C(this,Xn))==null||p.call(this),L(this,Xn,null),L(this,Qi,!1),ue(this,oe,lf).call(this),C(this,Ot)&&(C(this,Ot).revertAll().catch(f=>{console.error("[SmartCanvasElementLit] Failed to revert actions on disconnect:",f)}),L(this,Ot,null)),C(this,Zt)?.remove(),L(this,Zt,null),C(this,bn)?.remove(),L(this,bn,null)}willUpdate(t){t.has("initialBatchHandle")&&this.initialBatchHandle&&(L(this,Ot,this.initialBatchHandle),L(this,Zr,!0),this.initialBatchActions&&(this._configActions=this.initialBatchActions,L(this,Yi,JSON.stringify(this.initialBatchActions)),L(this,Ji,C(this,Yi))));let r=t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("fetchCredentials")||t.has("experiments");if(r&&ue(this,oe,of).call(this),(r||t.has("_pageUrl"))&&this._loadConfig(),(t.has("_theme")||t.has("workspaceTheme"))&&C(this,er).setThemeConfig(this._theme??{},this.workspaceTheme),t.has("_pageUrl")&&(L(this,Jr,!1),this._chatTakeover=!1),t.has("_tiles")||t.has("_isLoading")||t.has("_error")||t.has("_llmTilesVersion")){let s=this._tiles.length+C(this,Gt).size>0&&!this._error;!this._isLoading&&!s&&C(this,lt).getState().open&&!C(this,Jr)&&C(this,lt).setOpen(!1)}}updated(t){var i;t.has("runtime")&&(C(this,Fo).setValue(this.runtime??null),ue(this,oe,Qy).call(this),ue(this,oe,cf).call(this),ue(this,oe,pf).call(this),ue(this,oe,lf).call(this),ue(this,oe,af).call(this)),(t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("fetchCredentials")||t.has("experiments"))&&((i=C(this,Yr))==null||i.call(this),this.experiments?.onFeaturesChanged&&L(this,Yr,this.experiments.onFeaturesChanged(()=>this._loadConfig({silent:!0})))),(t.has("_configActions")||t.has("_pageUrl"))&&ue(this,oe,mc).call(this)}render(){let r=this._tiles.length+C(this,Gt).size>0&&!this._error,i=this._isLoading||r;if(this._displayMode==="inline"){if(!i)return Q;let x=C(this,Gt).size===0?this._tiles:[...this._tiles,...C(this,Gt).values()];return F`
|
|
@@ -623,7 +623,7 @@ ${r}
|
|
|
623
623
|
})();`}var xk=["cdn.syntrologie.com","api.syntrologie.com","dev-api.syntrologie.com","localhost","127.0.0.1",".syntrologie.com"];function l_(n){if(typeof window>"u")return null;let t=new URLSearchParams(window.location.search).get(n);if(!t)return null;try{let r=t.replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(r))}catch(r){return We("Syntro Runtime",`Failed to decode ${n}:`,r),null}}var ff="__syntro_rt_editor_source",hf="__syntro_rt_editor_conf";function xc(n,e){try{sessionStorage.setItem(n,JSON.stringify(e))}catch{}}function c_(n){try{let e=sessionStorage.getItem(n);return e?JSON.parse(e):null}catch{return null}}var tr,nr;function Vo(){if(tr==null){let n=typeof window<"u"?window.__SYNTRO_EDITOR_PARAMS__:null;if(n?.token)tr={token:n.token,api_base:n.apiBase||""},xc(ff,tr),console.log(`[DIAG] getEditorSource: from __SYNTRO_EDITOR_PARAMS__ (token=${tr.token.slice(0,15)}...)`);else{let e=l_("editor_source");if(e)tr=e,xc(ff,e);else{let t=c_(ff);t?.token&&(tr=t,console.log(`[DIAG] getEditorSource: restored from sessionStorage (token=${t.token.slice(0,15)}...)`))}console.log(`[DIAG] getEditorSource: from URL param \u2192 ${e?`token=${e.token?.slice(0,15)}...`:"NULL"}`),!e&&typeof window<"u"&&console.log(`[DIAG] getEditorSource: URL search = ${window.location.search.slice(0,200)}`)}}return tr??null}function Sc(){if(nr==null){let n=typeof window<"u"?window.__SYNTRO_EDITOR_PARAMS__:null;if(n?.mode)nr={mode:n.mode,audit_session_id:n.auditSessionId,syntro_token:n.syntroToken,workspace_id:n.workspaceId},xc(hf,nr),console.log(`[DIAG] getEditorConf: from __SYNTRO_EDITOR_PARAMS__ (mode=${nr.mode})`);else{let e=l_("editor_conf");if(e)nr=e,xc(hf,e);else{let t=c_(hf);t?.mode&&(nr=t,console.log(`[DIAG] getEditorConf: restored from sessionStorage (mode=${t.mode})`))}console.log(`[DIAG] getEditorConf: from URL param \u2192 ${e?`mode=${e.mode}`:"NULL"}`)}}return nr??null}function Sk(n){q("Syntro Runtime","Validating editor URL:",n);try{if(n.startsWith("/"))return q("Syntro Runtime","\u2713 Relative URL allowed (same-origin):",n),!0;let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(We("Syntro Runtime","\u274C Editor URL must use HTTPS:",n),!1):xk.some(i=>i.startsWith(".")?e.hostname.endsWith(i)||e.hostname===i.slice(1):e.hostname===i)?(q("Syntro Runtime","\u2713 Editor URL validated"),!0):(We("Syntro Runtime","\u274C Editor URL host not in allowlist:",e.hostname),!1)}catch(e){return We("Syntro Runtime",`\u274C Invalid editor URL: ${n}`,e),!1}}var Ec=()=>{let n=Sc();return!Vo()?.token||!n?.mode?null:n.mode};function Ek(){return Vo()?.token??null}function Ck(){return Vo()?.api_base??null}var Bo=null,u_=async n=>{if(q("Syntro Runtime","====== LOAD EDITOR SDK ======"),typeof window>"u"){q("Syntro Runtime","Not in browser - skipping editor SDK load");return}if(window.SyntroEditor){q("Syntro Runtime","Editor SDK already loaded (window.SyntroEditor exists)");return}if(Bo)return q("Syntro Runtime","Editor SDK load already in progress, waiting..."),Bo;let e=typeof n=="string"?{editorUrl:n}:n??{};if(e.editorUrl==="skip"){q("Syntro Runtime",'editorUrl="skip" \u2014 deferring to caller'),q("Syntro Runtime","================================");return}let t=Ck(),i=(t?`${t}/api/editor/sdk/editor-sdk.js`:null)||e.editorUrl;if(!i){We("Syntro Runtime","\u274C No editor SDK URL available (no api_base, no editorUrl option)"),q("Syntro Runtime","================================");return}let s=Ek(),o=s?`${i}?token=${encodeURIComponent(s)}`:i;if(q("Syntro Runtime","Editor URL:",o),q("Syntro Runtime","Options:",{hasIntegrity:!!e.integrity,hasEditorUrl:!!i,hasApiBase:!!t,tokenPrefix:s?`${s.slice(0,10)}...`:"none"}),!Sk(i)){console.error("[Syntro Runtime] \u274C BLOCKED: Editor from untrusted URL:",i),q("Syntro Runtime","================================");return}return q("Syntro Runtime","\u2713 URL validated, injecting script tag..."),Bo=new Promise((a,l)=>{let c=document.createElement("script");c.src=o,c.async=!0,e.integrity&&(c.integrity=e.integrity,c.crossOrigin="anonymous",q("Syntro Runtime","SRI integrity check enabled")),c.onload=()=>{q("Syntro Runtime","\u2713 Editor SDK script loaded successfully"),q("Syntro Runtime","================================"),a()},c.onerror=u=>{console.error("[Syntro Runtime] \u274C Failed to load Editor SDK:",u),console.error("[Syntro Runtime] URL attempted:",o),q("Syntro Runtime","================================"),Bo=null,l(u)},document.head.appendChild(c),q("Syntro Runtime","Script tag appended to <head>")}),Bo};function kk(n,e){let t=Nn(n.kind);if(!t&&n.kind==="core:mountWidget"){let o=n.widget?.widgetId;t=typeof o=="string"?Rt(o):null}if(!t)return null;let r=e.apps,i=r.get?.(t)?.state;return i==="error"||(r.isActive?.(t)??i==="active")?null:t}function Ak(n,e){let t=new Set;for(let r of n){let i=kk(r,e);i&&t.add(i)}return[...t]}function Tk(n){if(typeof window>"u")return n;let t=window.SynOS?.wrapCanvasConfigFetcher;if(!t)return n;try{return t(n)}catch(r){return console.warn("[SmartCanvas] Failed to wrap config fetcher:",r),n}}var Cc=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=o_(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();if(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,w)=>`[${w}] ${y.kind}${y.anchorId?` anchor="${y.anchorId.selector}"`:""}${y.label?` "${y.label}"`:""}`).join(", ")),m.actions&&m.actions.length>0&&s?.actions){let y=Ak(m.actions,s);y.length>0?console.warn(`[SmartCanvas] Skipping eager action apply until app(s) activate: ${y.join(", ")}`):(await o(m.actions),console.log("[SmartCanvas] Initial actions applied successfully"))}m.tiles&&s?.accumulator&&zr(m.tiles,s.accumulator,m.actions)}catch(m){console.error("[SmartCanvas] Error fetching/applying initial config:",m)}e&&e();let l=Ec();Do();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,p=n.integrations?.telemetry,f=n.fetcher??Ur({configUri:n.configUri,experiments:u,featureKey:n.configUriFeatureKey,credentials:n.fetchCredentials});r||(r=f);let h={fetcher:f,configUri:n.configUri,configUriFeatureKey:n.configUriFeatureKey,fetchCredentials:n.fetchCredentials,experiments:u,telemetry:p,runtime:s,initialBatchHandle:i,initialBatchActions:i?t?.actions??[]:void 0,workspaceTheme:n.workspaceTheme};c.mountLitApp(h),n.defaultOpen&&c.open();let g=()=>{let m=n.target??document.body;if(m){m.appendChild(c);let y=c.getOverlayContainer();y&&ny(y)}};document.body?g():document.addEventListener("DOMContentLoaded",g,{once:!0}),(l||n.editorUrl)&&(console.log(`[SmartCanvas] Loading editor SDK for ${l??"config"} mode`),u_(n.editorUrl).catch(console.error));let v={el:c,open:()=>c.open(),close:()=>c.close(),destroy:()=>{a(),c.remove()},setTokens:m=>{for(let[y,w]of Object.entries(m))c.style.setProperty(y,w)},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=>{let y=Tk(m);r=y,c.setOverrideFetcher(y),s?.accumulator&&y().then(w=>{w?.tiles&&zr(w.tiles,s.accumulator,w.actions)}).catch(()=>{})},registerTelemetryProperties:m=>{p?.register?.(m)},getSessionId:()=>p?.getSessionId?.(),startSessionRecording:()=>{p?.startSessionRecording?.()},track:(m,y)=>p?.track?(p.track(m,y),!0):!1,previewNotification:m=>c.previewNotification(m),runtime:s};if(typeof window<"u"){let m=window.SynOS;m&&(m.handle=v)}return v};typeof window<"u"&&(window.SmartCanvas={async create(n){return Cc(n)}});var gf="syn_";function ns(n){if(!n.startsWith(gf))throw new Error("Invalid Syntro token: must start with 'syn_'");let t=n.slice(gf.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 kc(n){let e=JSON.stringify(n),t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return gf+t}function xt(n){if(typeof process<"u"&&process.env)return process.env[n]}function _f(n,e){if(typeof window>"u")return null;try{let t=localStorage.getItem(n);if(!t)return null;let r=JSON.parse(t);return!r||typeof r.ts!="number"||!("data"in r)||e!=null&&Date.now()-r.ts>e?null:r.data}catch{return null}}function bf(n,e){if(!(typeof window>"u"))try{let t={ts:Date.now(),data:e};localStorage.setItem(n,JSON.stringify(t))}catch{}}var f_="syntro_segment_attributes";function h_(){let n=_f(f_);return n?(q("Syntro Bootstrap","Loaded cached segment attributes:",n),n):{}}function g_(n){bf(f_,n),q("Syntro Bootstrap","Cached segment attributes:",n)}var Ac="syntro_device_id",Uo="syntro_session_id_choice",rs=null,yf=!1,mf=null;function Rk(n){return!n||n.startsWith("$")?null:n}var m_=n=>{if(n!=="denied"){yf=!1;return}yf=!0;let e=null;try{e=localStorage.getItem(Ac),localStorage.removeItem(Ac)}catch{}if(e){try{sessionStorage.getItem(Uo)===e&&sessionStorage.removeItem(Uo)}catch{}rs===e&&(rs=null)}};function vf(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}function Ik(){if(yf)return{id:vf(),source:"session_uuid",persisted:!1};try{let n=localStorage.getItem(Ac);if(n)return{id:n,source:"device_uuid",persisted:!0};let e=vf();return localStorage.setItem(Ac,e),{id:e,source:"device_uuid",persisted:!0}}catch{return{id:vf(),source:"device_uuid",persisted:!1}}}function is(n){if(rs)return rs;try{let o=sessionStorage.getItem(Uo);if(o)if(o.startsWith("$"))try{sessionStorage.removeItem(Uo)}catch{}else return rs=o,mf={source:"session_choice",persisted:!0},o}catch{}let e=Rk(n),t,r,i;if(e)t=e,r="posthog_distinct_id",i=!1;else{let o=Ik();t=o.id,r=o.source,i=o.persisted}rs=t;let s=!1;try{sessionStorage.setItem(Uo,t),s=!0}catch{}return mf={source:r,persisted:r==="posthog_distinct_id"||i||s},q("Syntro Bootstrap","Stable visitor id chosen:",mf),t}function v_(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 $k(n){return!n||n==="/"?n:n.replace(/\/+$/,"")||"/"}function wf(){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=$k(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"}try{let e=n.surface_type;e==="telegram"||e==="mcp-app"?n.surface="personal_agent":n.device_type==="mobile"?n.surface="mobile":n.surface="desktop"}catch{n.surface="desktop"}return n}var y_="syntro_initial_attrs",Pk=1800*1e3,d_=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function Ok(n){if(typeof window>"u")return!1;try{return n===window.location.hostname}catch{return!1}}function xf(n,e){let t={},r=d_.some(o=>typeof n[o]=="string");for(let o of d_){let a=r?n[o]:e?.[o];a&&(t[o]=a)}let i=typeof n.referrer_hostname=="string"?n.referrer_hostname:void 0;return!(i?Ok(i):!0)&&typeof n.referrer=="string"?(t.referrer=n.referrer,i&&(t.referrer_hostname=i)):e?.referrer&&(t.referrer=e.referrer,e.referrer_hostname&&(t.referrer_hostname=e.referrer_hostname)),e?.initial_page_url?(t.initial_page_url=e.initial_page_url,e.initial_page_path&&(t.initial_page_path=e.initial_page_path),e.initial_page_query&&(t.initial_page_query=e.initial_page_query)):(typeof n.page_url=="string"&&(t.initial_page_url=n.page_url),typeof n.page_path=="string"&&(t.initial_page_path=n.page_path),typeof n.page_query=="string"&&(t.initial_page_query=n.page_query)),t}function __(){return _f(y_,Pk)}function b_(n){bf(y_,n),q("Syntro Bootstrap","Cached initial attrs:",n)}var p_="syntro_geo",w_="https://geo.syntrologie.com";async function Sf(n){if(typeof window>"u")return{};try{let e=localStorage.getItem(p_);if(e){let t=JSON.parse(e);return q("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(p_,JSON.stringify(r))}catch{}return q("Syntro Bootstrap","Geo: fetched from worker:",r),r}}catch{}return{}}var Mk=/\/(?:products?|pdp\/dynamic)\/([a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?)/,Lk=/^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;function Nk(n){let e=n.attr__href??n.href;return typeof e=="string"&&e.length>0?e:void 0}function Fk(n){let e=n["attr__aria-label"];if(typeof e=="string"&&e.trim())return e.trim();let t=n.$el_text??n.text;if(typeof t=="string"&&t.trim())return t.trim()}function Dk(n){let e=Nk(n);if(!e)return null;let t=Mk.exec(e);if(!t)return null;let r=t[1],i=e.slice(e.indexOf(t[0])).split(/[?#]/)[0],s=Fk(n);return s?{productHandle:r,productUrl:i,productTitle:s}:{productHandle:r,productUrl:i}}function Hk(n){let e=n["attr__data-product-handle"];if(typeof e!="string"||!Lk.test(e))return null;let t={productHandle:e,productUrl:`/products/${e}`},r=n["attr__aria-label"];return typeof r=="string"&&r.trim()&&(t.productTitle=r.trim()),t}function Ef(n){for(let e of n){let t=Dk(e)??Hk(e);if(t)return t}return null}var jo=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 Wo=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.resetInitSideEffects(),this.abortController=new AbortController;let{signal:e}=this.abortController;this.attachSectionListeners(e),this.antiFlicker=new jo(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} `:""}extractProductIdentity(e){return Ef(e)}destroy(){this.resetInitSideEffects(),this.loadCallbacks.clear(),this.unloadCallbacks.clear()}resetInitSideEffects(){this.antiFlicker?.destroy(),this.antiFlicker=null,this.abortController&&(this.abortController.abort(),this.abortController=null)}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 a=window.Shopify?.designMode===!0?e:0,l=setTimeout(s,a);t.addEventListener("abort",()=>{clearTimeout(l),s()},{once:!0})})}};var Tc="syntro_experiments";var ss={distinctId:"_syntro_distinct_id",telemetryHost:"_syntro_telemetry_host",telemetryKey:"_syntro_telemetry_key",workspaceKey:"_syntro_workspace_key"};var Bk=720*60*60,zo=class{constructor(e){this.context={...e,telemetryHost:e.telemetryHost.replace(/\/$/,"")},this.writeCookie(),this.writeCartAttributes()}updateContext(e){this.context={...e,telemetryHost:e.telemetryHost.replace(/\/$/,"")},this.writeCookie(),this.writeCartAttributes()}destroy(){document.cookie=`${Tc}=; 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=`${Tc}=${t}; max-age=${Bk}; path=/; SameSite=Lax; Secure`;document.cookie=r}writeCartAttributes(){let{distinctId:e,telemetryHost:t,telemetryKey:r}=this.context;if(!e)return;let i={};i[ss.distinctId]=e,i[ss.telemetryHost]=t,i[ss.telemetryKey]=r,i[ss.workspaceKey]=r;let s=JSON.stringify({attributes:i});try{fetch("/cart/update.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:s}).then(o=>{o.ok||console.warn(`[shopify-pixel-bridge] /cart/update.js returned ${o.status}; checkout_completed events will fall back to cookie (likely to drop).`)}).catch(o=>{console.warn("[shopify-pixel-bridge] /cart/update.js request failed; checkout_completed events will fall back to cookie (likely to drop).",o)})}catch{}}};function Rc(n){return n.trim().toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_-]/g,"")}function S_(n,e){let t=n.options??[],r=t.map(o=>Rc(o.name)),i=t.map(o=>({key:Rc(o.name),label:o.name,kind:"pill",values:o.values.map(a=>({id:Rc(a),label:a,swatch:null}))})),s=(n.variants??[]).map(o=>{let a=[o.option1,o.option2,o.option3],l={};return r.forEach((c,u)=>{let p=a[u];p!=null&&(l[c]=Rc(p))}),{id:String(o.id),selection:l,price:o.price/100,compare_at_price:o.compare_at_price!=null?o.compare_at_price/100:null,in_stock:o.available,...o.featured_image?.src?{featured_image:o.featured_image.src}:{}}});return{product_id:e,product_numeric_id:String(n.id),attributes:i,variants:s}}function Vk(n){let e=typeof n.handle=="string"?n.handle:"";if(!e)return null;let t=n.product_title??"",r=n.variant_title??"";if(!t){let i=n.title??"",s=i.indexOf(" - ");s>=0?(t=i.slice(0,s),r||(r=i.slice(s+3))):t=i}return{handle:e,title:t,variantTitle:r,quantity:typeof n.quantity=="number"?n.quantity:1,priceCents:typeof n.price=="number"?n.price:0}}function Uk(n){return{items:(n&&typeof n=="object"&&"items"in n&&Array.isArray(n.items)?n.items:[n]).map(r=>Vk(r)).filter(r=>r!==null)}}function jk(n){typeof window<"u"&&window.location.assign(n)}function Cf(n={}){let e=n.navigate??jk;async function t(r){let i=await fetch(`/products/${r}.js`,{credentials:"same-origin",headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`Shopify product fetch failed: ${i.status}`);let s=await i.json();return S_(s,r)}return{fetchVariants(r){return t(r)},async addToCart(r){let i=r.variant_id;if(!i)try{let s=await t(r.product_id);i=s.variants.find(o=>o.in_stock)?.id??s.variants[0]?.id??null}catch{}if(!i)return{ok:!1,error:{code:"validation",message:"No variant available to add."}};try{let s=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},credentials:"same-origin",body:JSON.stringify({items:[{id:i,quantity:r.quantity}]})});if(s.ok){try{let l=Uk(await s.json());l.items.length>0&&typeof document<"u"&&document.dispatchEvent(new CustomEvent(od,{detail:l}))}catch{}return{ok:!0}}let o=`Add to cart failed (${s.status}).`,a=s.status===422?"validation":"unknown";try{let l=await s.json();o=l.description??l.message??o}catch{}return/sold out|out of stock|in stock|inventory|stock/i.test(o)&&(a="oos"),{ok:!1,error:{code:a,message:o}}}catch(s){return{ok:!1,error:{code:"network",message:s instanceof Error?s.message:"Network error"}}}},async openCart(){typeof window<"u"&&!window.dispatchEvent(new CustomEvent("syntro:open-cart",{cancelable:!0}))||e("/cart")}}}var Wk="__SYNTRO_PRODUCT_ADAPTER__";function E_(n){typeof window>"u"||(window[Wk]=n)}var C_=[()=>new Wo];function k_(n){let e={};if(n.platformAdapter?.name==="shopify"&&n.telemetryHost)try{let t={distinctId:n.telemetry.getDistinctId?.()??"",telemetryHost:n.telemetryHost,telemetryKey:n.telemetryKey};e.shopifyPixelBridge=new zo(t),n.debug("Syntro Bootstrap","ShopifyPixelBridge initialized for checkout attribution")}catch(t){n.warn("Syntro Bootstrap","ShopifyPixelBridge init failed",t)}return n.platformAdapter?.name==="shopify"&&(E_(Cf()),n.debug("Syntro Bootstrap","Shopify product commerce adapter exposed to widgets")),e}var A_=["fbclid","ttclid","gclid","gbraid","wbraid","msclkid","twclid","li_fat_id","epik","ScCid","yclid","_kx","mc_eid","mc_cid"];function kf(n){if(typeof window>"u"||!n.setPersonPropertiesOnce)return;let e=new URLSearchParams(window.location.search),t={};for(let r of A_){let i=e.get(r);i&&(t[`$initial_${r}`]=i)}Object.keys(t).length>0&&n.setPersonPropertiesOnce(t)}var zk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,qk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Zk=[/@yopmail\.com$/i,/@mailinator\.com$/i,/@guerrillamail\.(com|info|net|org|biz)$/i,/@10minutemail\.com$/i,/^test@/i,/^noreply@/i,/^no-reply@/i];function Ic(n){return n?qk.test(n):!1}function T_(n){return Zk.some(e=>e.test(n))}function Gk(n){if(n.type==="email")return!0;let e=(n.name||"").toLowerCase(),t=(n.id||"").toLowerCase();return!!(/email/.test(e)||/email/.test(t))}function Kk(n){return n.closest("[data-syntro-no-identify]")!==null}function Yk(n){return n?zk.test(n):!0}function Af(n,e){if(typeof document>"u")return()=>{};if(!n.identify&&!n.alias)return()=>{};let t=new Set,r=s=>{let o=n.getDistinctId?.();if(o===s){t.add(s);return}Yk(o)?n.identify?.(s,{email:s}):n.alias?.(s),t.add(s)},i=s=>{let o=s.target;if(!(o instanceof HTMLInputElement)||Kk(o)||!Gk(o))return;let a=(o.value??"").trim().toLowerCase();if(!Ic(a)||T_(a)||t.has(a))return;if(!e){r(a);return}let l=e.getStatus();if(l==="granted"){r(a);return}l!=="denied"&&e.resolvePending().then(c=>{c==="granted"&&r(a)})};return document.addEventListener("change",i,!0),()=>{document.removeEventListener("change",i,!0),t.clear()}}var R_="_syu",Jk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Xk(n){return n?Jk.test(n):!0}function Tf(n,e){if(typeof window>"u"||!n.identify&&!n.alias)return;let t=new URLSearchParams(window.location.search).get(R_);if(!t)return;let r=t.trim();if(!r)return;let i=()=>{let a=n.getDistinctId?.();if(a===r)return;let l=Ic(r)?{email:r}:void 0;Xk(a)?n.identify?.(r,l):n.alias?.(r)};if(!e){i();return}if(e.getStatus()==="granted"){i();return}let s=!1,o=e.subscribe(a=>{s||a==="granted"&&(s=!0,o(),i())})}var Qk=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function eA(n){return n.is_eu==="true"||n.country_code==="GB"||n.country_code==="CH"||!n.is_eu&&!n.country_code}function tA(n){if(!n)return"";try{return new URL(n).hostname}catch{return""}}function Rf(){return typeof window>"u"?"":`${window.location.origin}${window.location.pathname}`}function If(n,e){if(typeof window>"u"||typeof document>"u"||!n.setPersonPropertiesOnce)return;let t=document.referrer||"",r=new URLSearchParams(window.location.search),i={$initial_pathname:window.location.pathname,$initial_referrer:t,$initial_referring_domain:tA(t)};for(let s of Qk){let o=r.get(s);o&&(i[`$initial_${s}`]=o)}if(n.setPersonPropertiesOnce(i),!e){n.setPersonPropertiesOnce({$initial_url:Rf()});return}e.then(s=>{let o=eA(s)?Rf():window.location.href;n.setPersonPropertiesOnce?.({$initial_url:o})}).catch(()=>{n.setPersonPropertiesOnce?.({$initial_url:Rf()})})}var I_=new Set(["email","telephone","streetAddress","addressLocality","addressRegion","postalCode","givenName","familyName"]),$_=500,$f=3;function $c(n){if(Array.isArray(n))return n.map($c);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))I_.has(t)||(e[t]=$c(r));return e}return n}function Pc(n){if(Array.isArray(n))return n.map(Pc);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))if(!(t==="description"&&typeof r=="string"&&r.length>$_)){if(t==="image"&&Array.isArray(r)&&r.length>$f){e[t]=r.slice(0,$f);continue}e[t]=Pc(r)}return e}return n}function nA(){return typeof document>"u"?[]:Array.from(document.querySelectorAll('script[type="application/ld+json"]')).filter(n=>!n.hasAttribute("data-syntro-no-jsonld")).map(n=>{try{return JSON.parse(n.textContent??"")}catch{return null}}).filter(n=>n!==null)}function Pf(n){if(!n.register)return;let e=nA().map(Pc).map($c);e.length!==0&&n.register({json_ld:e})}function P_(n,e,t={}){If(n,t.geoPromise),kf(n),Pf(n),Tf(n,e);let r=Af(n,e);return()=>{r()}}var os=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 M_={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function L_(){return M_}function Of(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 qo(n,e,t){return t===2?Of(Of(n+e)+"")%1e4/1e4:t===1?Of(e+n)%1e3/1e3:null}function rA(n){return n<=0?[]:new Array(n).fill(1/n)}function Oc(n,e){return n>=e[0]&&n<e[1]}function N_(n,e){let t=qo("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function F_(n,e){for(let t=0;t<e.length;t++)if(Oc(n,e[t]))return t;return-1}function Lf(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function Mc(n,e){if(!e.length)return!1;let t=!1,r=!1;for(let i=0;i<e.length;i++){let s=oA(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 iA(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 sA(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=>!iA(i[0],i[1],i[2]))}catch{return!1}}function oA(n,e,t){try{let r=new URL(n,"https://_");if(e==="regex"){let i=Lf(t);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return sA(r,t);return!1}catch{return!1}}function D_(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=rA(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 H_(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 B_(n){try{return n()}catch(e){return console.error(e),!1}}var Mf=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0));async function ei(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||M_.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",Mf(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:Mf(i)},r,Mf(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Zo(n){return typeof n=="string"?n:JSON.stringify(n)}function pt(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 V_(){let n;try{n="1.6.4"}catch{n=""}return n}function U_(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 O_(n){return typeof n=="object"&&n!==null}function Lc(n){return n.urlPatterns&&n.variations.some(e=>O_(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>O_(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function Nc(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},Kt=L_(),as={fetchFeaturesCall:({host:n,clientKey:e,headers:t})=>Kt.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 Kt.fetch(`${n}/api/eval/${e}`,i)},eventSourceCall:({host:n,clientKey:e,headers:t})=>t?new Kt.EventSource(`${n}/sub/${e}`,{headers:t}):new Kt.EventSource(`${n}/sub/${e}`),startIdleListener:()=>{let n;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(n),cA()):document.visibilityState==="hidden"&&(n=window.setTimeout(lA,Ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Kt.localStorage=globalThis.localStorage)}catch{}var ls=new Map,j_=!1,wn=new Map,Fc=new Map,cs=new Map,us=new Set;function z_(n){Object.assign(Ke,n),Ke.backgroundSync||Vf()}async function q_({instance:n,timeout:e,skipCache:t,allowStale:r,backgroundSync:i}){return i||(Ke.backgroundSync=!1),uA({instance:n,allowStale:r,timeout:e,skipCache:t})}function aA(n){let e=Go(n),t=ls.get(e)||new Set;t.add(n),ls.set(e,t)}function Z_(n){ls.forEach(e=>e.delete(n))}function lA(){cs.forEach(n=>{n&&(n.state="idle",Hf(n))})}function cA(){cs.forEach(n=>{n&&n.state==="idle"&&Bf(n)})}async function W_(){try{if(!Kt.localStorage)return;await Kt.localStorage.setItem(Ke.cacheKey,JSON.stringify(Array.from(wn.entries())))}catch{}}async function uA({instance:n,allowStale:e,timeout:t,skipCache:r}){let i=Go(n),s=Ff(n),o=new Date,a=new Date(o.getTime()-Ke.maxAge+Ke.staleTTL);await dA();let l=!Ke.disableCache&&!r?wn.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&us.add(i),l.staleAt<o?Nf(n):Df(n),{data:l.data,success:!0,source:"cache"}):await Nc(Nf(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Go(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function Ff(n){let e=Go(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 dA(){if(!j_){j_=!0;try{if(Kt.localStorage){let n=await Kt.localStorage.getItem(Ke.cacheKey);if(!Ke.disableCache&&n){let e=JSON.parse(n);e&&Array.isArray(e)&&e.forEach(([t,r])=>{wn.set(t,{...r,staleAt:new Date(r.staleAt)})}),G_()}}}catch{}if(!Ke.disableIdleStreams){let n=as.startIdleListener();n&&(as.stopIdleListener=n)}}}function G_(){let n=Array.from(wn.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,wn.size-Ke.maxEntries),wn.size);for(let t=0;t<e;t++)wn.delete(n[t].key)}function K_(n,e,t){let r=t.dateUpdated||"",i=new Date(Date.now()+Ke.staleTTL),s=Ke.disableCache?void 0:wn.get(e);if(s&&r&&s.version===r){s.staleAt=i,W_();return}Ke.disableCache||(wn.set(e,{data:t,version:r,staleAt:i,sse:us.has(n)}),G_()),W_();let o=ls.get(n);o&&o.forEach(a=>pA(a,t))}async function pA(n,e){await n.setPayload(e||n.getPayload())}async function Nf(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),r=n.getClientKey(),i="isRemoteEval"in n&&n.isRemoteEval(),s=Go(n),o=Ff(n),a=Fc.get(o);return a||(a=(i?as.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):as.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"&&us.add(s),c.json()}).then(c=>(K_(s,o,c),Df(n),Fc.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(Fc.delete(o),{data:null,source:"error",success:!1,error:c})),Fc.set(o,a)),a}function Df(n,e=!1){let t=Go(n),r=Ff(n),{streamingHost:i,streamingHostRequestHeaders:s}=n.getApiHosts(),o=n.getClientKey();if(e&&us.add(t),Ke.backgroundSync&&us.has(t)&&Kt.EventSource){if(cs.has(t))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=ls.get(t);c&&c.forEach(u=>{Nf(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);K_(t,r,c)}a.errors=0}catch{Y_(a)}},errors:0,state:"active"};cs.set(t,a),Bf(a)}}function Y_(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);Hf(n),setTimeout(()=>{["idle","active"].includes(n.state)||Bf(n)},Math.min(e,3e5))}}function Hf(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function Bf(n){n.src=as.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=()=>Y_(n),n.src.onopen=()=>{n.errors=0}}function fA(n,e){Hf(n),cs.delete(e)}function Vf(){us.clear(),cs.forEach(fA),ls.clear(),as.stopIdleListener()}function Dc(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Df(n,!0),aA(n)}}var hA=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Wf={revert:function(){}},Uc=new Map,zf=new Set;function gA(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function jc(n){var e=Uc.get(n);return e||(e={element:n,attributes:{}},Uc.set(n,e)),e}function Wc(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,gA(e)),o}function zc(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,J_()):n!==t&&(e.isDirty=!0,J_())}function mA(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),zc(IA(e),n)}function vA(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),zc(Array.from(e).filter(Boolean).join(" "),n)}function yA(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),zc(e,n)}function _A(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 bA(n){var e=n.originalValue;n.mutations.forEach(function(t){var r=t.mutate(),i=_A(r);e=i||e}),zc(e,n)}var wA=function(e){return e.innerHTML},xA=function(e,t){return e.innerHTML=t};function Q_(n){var e=jc(n);return e.html||(e.html=Wc(n,"html",wA,xA,mA)),e.html}var SA=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},EA=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};function eb(n){var e=jc(n);return e.position||(e.position=Wc(n,"position",SA,EA,bA)),e.position}var CA=function(e,t){return t?e.className=t:e.removeAttribute("class")},kA=function(e){return e.className};function tb(n){var e=jc(n);return e.classes||(e.classes=Wc(n,"class",kA,CA,vA)),e.classes}var AA=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},TA=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};function nb(n,e){var t=jc(n);return t.attributes[e]||(t.attributes[e]=Wc(n,e,AA(e),TA(e),yA)),t.attributes[e]}function RA(n,e){var t=Uc.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,p;(c=t.attributes)==null||(u=c[e])==null||(p=u.observer)==null||p.disconnect(),delete t.attributes[e]}}var Hc;function IA(n){return Hc||(Hc=document.createElement("div")),Hc.innerHTML=n,Hc.innerHTML}function Bc(n,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||RA(n,e),t.setValue(n,r)}}function $A(n,e){n.html&&Bc(e,"html",n.html),n.classes&&Bc(e,"class",n.classes),n.position&&Bc(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){Bc(e,t,n.attributes[t])})}function J_(){Uc.forEach($A)}function PA(n,e){var t=null;n.kind==="html"?t=Q_(e):n.kind==="class"?t=tb(e):n.kind==="attribute"?t=nb(e,n.attribute):n.kind==="position"&&(t=eb(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function OA(n,e){var t=null;if(n.kind==="html"?t=Q_(e):n.kind==="class"?t=tb(e):n.kind==="attribute"?t=nb(e,n.attribute):n.kind==="position"&&(t=eb(e)),!!t){var r=t.mutations.indexOf(n);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function rb(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),PA(n,r))})}}function MA(n){n.elements.forEach(function(e){return OA(n,e)}),n.elements.clear(),zf.delete(n)}function X_(){zf.forEach(rb)}var Uf;function LA(){typeof document>"u"||(Uf||(Uf=new MutationObserver(function(){X_()})),X_(),Uf.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}LA();function qc(n){return typeof document>"u"?Wf:(zf.add(n),rb(n),{revert:function(){MA(n)}})}function jf(n,e){return qc({kind:"html",elements:new Set,mutate:e,selector:n})}function ib(n,e){return qc({kind:"position",elements:new Set,mutate:e,selector:n})}function Ko(n,e){return qc({kind:"class",elements:new Set,mutate:e,selector:n})}function Vc(n,e,t){return hA.test(e)?e==="class"||e==="className"?Ko(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)})}):qc({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):Wf}function NA(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 jf(e,function(a){return a+(r??"")});if(t==="set")return jf(e,function(){return r??""})}else if(i==="class"){if(t==="append")return Ko(e,function(a){r&&a.add(r)});if(t==="remove")return Ko(e,function(a){r&&a.delete(r)});if(t==="set")return Ko(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(t==="set"&&s)return ib(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(t==="append")return Vc(e,i,function(a){return a!==null?a+(r??""):r??""});if(t==="set")return Vc(e,i,function(){return r??""});if(t==="remove")return Vc(e,i,function(){return null})}return Wf}var FA={html:jf,classes:Ko,attribute:Vc,position:ib,declarative:NA},sb=FA;var qf={};function rr(n,e,t){t=t||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!lb(n,i,t))return!1;break;case"$nor":if(lb(n,i,t))return!1;break;case"$and":if(!UA(n,i,t))return!1;break;case"$not":if(rr(n,i,t))return!1;break;default:if(!Yo(i,DA(n,r),t))return!1}return!0}function DA(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 ob(n,e=!1){let t=`${n}${e?"/i":""}`;return qf[t]||(qf[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),qf[t]}function Yo(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)||!cb(n))return JSON.stringify(e)===JSON.stringify(n);for(let i in n)if(!VA(i,e,n[i],t))return!1;return!0}function cb(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function HA(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 BA(n,e,t){if(!Array.isArray(n))return!1;let r=cb(e)?i=>Yo(e,i,t):i=>rr(i,e,t);for(let i=0;i<n.length;i++)if(n[i]&&r(n[i]))return!0;return!1}function ds(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 ab(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(Yo(e[i],n[o],t,r)){s=!0;break}if(!s)return!1}return!0}function VA(n,e,t,r){switch(n){case"$veq":return pt(e)===pt(t);case"$vne":return pt(e)!==pt(t);case"$vgt":return pt(e)>pt(t);case"$vgte":return pt(e)>=pt(t);case"$vlt":return pt(e)<pt(t);case"$vlte":return pt(e)<=pt(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)?ds(e,t):!1;case"$ini":return Array.isArray(t)?ds(e,t,!0):!1;case"$inGroup":return ds(e,r[t]||[]);case"$notInGroup":return!ds(e,r[t]||[]);case"$nin":return Array.isArray(t)?!ds(e,t):!1;case"$nini":return Array.isArray(t)?!ds(e,t,!0):!1;case"$not":return!Yo(t,e,r);case"$size":return Array.isArray(e)?Yo(t,e.length,r):!1;case"$elemMatch":return BA(e,t,r);case"$all":return Array.isArray(t)?ab(e,t,r):!1;case"$alli":return Array.isArray(t)?ab(e,t,r,!0):!1;case"$regex":try{return ob(t).test(e)}catch{return!1}case"$regexi":try{return ob(t,!0).test(e)}catch{return!1}case"$type":return HA(e)===t;default:return console.error("Unknown operator: "+n),!1}}function lb(n,e,t){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(rr(n,e[r],t))return!0;return!1}function UA(n,e,t){for(let r=0;r<e.length;r++)if(!rr(n,e[r],t))return!1;return!0}var jA="Feature Evaluated",WA="Experiment Viewed";function zA(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 qA(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 ps(n){try{await n()}catch{}}function ub(n,e,t){if(n.user.trackedExperiments){let i=Kc(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(ps(()=>i(e,t,n.user)))}if(n.user.trackingCallback){let i=n.user.trackingCallback;r.push(ps(()=>i(e,t)))}if(n.global.eventLogger){let i=n.global.eventLogger;r.push(ps(()=>i(WA,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return r}function ZA(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;ps(()=>r(e,t,n.user))}if(n.user.onFeatureUsage){let r=n.user.onFeatureUsage;ps(()=>r(e,t))}if(n.global.eventLogger){let r=n.global.eventLogger;ps(()=>r(jA,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function Zc(n,e){if(e.stack.evaluatedFeatures.has(n))return ir(e,n,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(n),e.stack.id=n;let t=zA(e);if(t.has(n))return ir(e,n,t.get(n),"override");if(!e.global.features||!e.global.features[n])return ir(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=Zc(l.id,e);if(c.source==="cyclicPrerequisite")return ir(e,n,null,"cyclicPrerequisite");let u={value:c.value};if(!rr(u,l.condition||{})){if(l.gate)return ir(e,n,null,"prerequisite");continue e}}if(s.filters&&fb(s.filters,e))continue;if("force"in s){if(s.condition&&!pb(s.condition,e)||!GA(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=>{!ub(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),ir(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}=Gc(o,n,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return ir(e,n,a.value,"experiment",s.id,o,a)}}return ir(e,n,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Gc(n,e,t){let r=n.key,i=n.variations.length;if(i<2)return{result:ke(t,n,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ke(t,n,-1,!1,e)};if(n=KA(n,t),n.urlPatterns&&!Mc(t.user.url||"",n.urlPatterns))return{result:ke(t,n,-1,!1,e)};let s=H_(r,t.user.url||"",i);if(s!==null)return{result:ke(t,n,s,!1,e)};let o=qA(t);if(r in o){let m=o[r];return{result:ke(t,n,m,!1,e)}}if(n.status==="draft"||n.active===!1)return{result:ke(t,n,-1,!1,e)};let{hashAttribute:a,hashValue:l}=ti(t,n.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0);if(!l)return{result:ke(t,n,-1,!1,e)};let c=-1,u=!1,p=!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,p=!!y}if(!u){if(n.filters){if(fb(n.filters,t))return{result:ke(t,n,-1,!1,e)}}else if(n.namespace&&!N_(l,n.namespace))return{result:ke(t,n,-1,!1,e)};if(n.include&&!B_(n.include))return{result:ke(t,n,-1,!1,e)};if(n.condition&&!pb(n.condition,t))return{result:ke(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 w=Zc(y.id,t);if(w.source==="cyclicPrerequisite")return{result:ke(t,n,-1,!1,e)};let x={value:w.value};if(!rr(x,y.condition||{}))return{result:ke(t,n,-1,!1,e)}}}if(n.groups&&!JA(n.groups,t))return{result:ke(t,n,-1,!1,e)}}if(n.url&&!YA(n.url,t))return{result:ke(t,n,-1,!1,e)};let f=qo(n.seed||r,l,n.hashVersion||1);if(f===null)return{result:ke(t,n,-1,!1,e)};if(!u){let m=n.ranges||D_(i,n.coverage===void 0?1:n.coverage,n.weights);c=F_(f,m)}if(p)return{result:ke(t,n,-1,!1,e,void 0,!0)};if(c<0)return{result:ke(t,n,-1,!1,e)};if("force"in n)return{result:ke(t,n,n.force===void 0?-1:n.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ke(t,n,-1,!1,e)};if(n.status==="stopped")return{result:ke(t,n,-1,!1,e)};let h=ke(t,n,c,!0,e,f,u);if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{changed:m,key:y,doc:w}=e1(t,a,Zo(l),{[Zf(n.key,n.bucketVersion)]:h.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=w,t.user.saveStickyBucketAssignmentDoc(w))}let g=ub(t,n,h);g.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:n,result:h});let v=g.length?g.length===1?g[0]:Promise.all(g).then(()=>{}):void 0;return"changeId"in n&&n.changeId&&t.global.recordChangeId&&t.global.recordChangeId(n.changeId),{result:h,trackingCall:v}}function ir(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"&&ZA(n,e,a),a}function db(n){return{...n.user.attributes,...n.user.attributeOverrides}}function pb(n,e){return rr(db(e),n,e.global.savedGroups||{})}function fb(n,e){return n.some(t=>{let{hashValue:r}=ti(e,t.attribute);if(!r)return!0;let i=qo(t.seed,r,t.hashVersion||2);return i===null?!0:!t.ranges.some(s=>Oc(i,s))})}function GA(n,e,t,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=ti(n,t,r);if(!a)return!1;let l=qo(e,a,o||1);return l===null?!1:i?Oc(l,i):s!==void 0?l<=s:!0}function ke(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}=ti(n,e.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},p={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&&(p.name=u.name),s!==void 0&&(p.bucket=s),u.passthrough&&(p.passthrough=u.passthrough),p}function KA(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=Lf(n.url))),n}function ti(n,e,t){let r=e||"id",i="",s=db(n);return s[r]&&(i=s[r]),!i&&t&&(s[t]&&(i=s[t]),i&&(r=t)),{hashAttribute:r,hashValue:i}}function YA(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 JA(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=Zf(e,t),l=QA(n,r,i);if(s>0)for(let p=0;p<s;p++){let f=Zf(e,p);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let u=o.findIndex(p=>p.key===c);return u<0?{variation:-1}:{variation:u}}function Zf(n,e){return e=e||0,`${n}__${e}`}function Gf(n,e){return`${n}||${e}`}function QA(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=ti(n,e),s=Gf(r,Zo(i)),{hashAttribute:o,hashValue:a}=ti(n,t),l=a?Gf(o,Zo(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 e1(n,e,t,r){let i=Gf(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 t1(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 hb(n,e,t){let r=Kf(n,t);return e.getAllAssignments(r)}function Kf(n,e){let t={};return t1(n,e).forEach(i=>{let{hashValue:s}=ti(n,i);t[i]=Zo(s)}),t}async function gb(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await ei(n.encryptedFeatures,e,t))}catch(r){console.error(r)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await ei(n.encryptedExperiments,e,t))}catch(r){console.error(r)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await ei(n.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete n.encryptedSavedGroups}return n}function mb(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 Kc(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var fs=typeof window<"u"&&typeof document<"u",n1=V_(),Jo=class{constructor(e){if(e=e||{},this.version=n1,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),fs&&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 gb(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,Dc(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&z_(e.cacheSettings),e.payload)return await this.setPayload(e.payload),Dc(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return Dc(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 mb(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 q_({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 ei(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 ei(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,Z_(this),e.destroyAllStreams&&Vf(),this.logs=[],fs&&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}=Gc(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=ke(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=Gc(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=Lc(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?U_(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(Mc(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:p}=this._getNavigateFunction();if(u)if(fs)Promise.all([...o?[Nc(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??p))]).then(()=>{try{u(c)}catch(f){console.error(f)}});else try{u(c)}catch(f){console.error(f)}}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&&Lc(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 Zc(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=>[Kc(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(Kc(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(fs?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=Lc(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}:fs?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!fs)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(sb.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await hb(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=Kf(r,t);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var r1="https://experiment.syntrologie.com",Yf=class{constructor(e={}){this.featureListeners=new Set;this.lastFeatureSnapshot=null;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 Jo({...e,apiHost:e.apiHost??r1,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(()=>{let t=this.snapshotFeatures();if(t!==this.lastFeatureSnapshot){this.lastFeatureSnapshot=t;for(let r of this.featureListeners)r()}}),()=>{this.featureListeners.delete(e),this.featureListeners.size===0&&(this.gb.setRenderer(null),this.lastFeatureSnapshot=null)}}snapshotFeatures(){let e=this.getAllFeatures(),t=Object.keys(e).sort(),r={};for(let i of t)r[i]=e[i];return JSON.stringify(r)}};function Yc(n={}){return new Yf(n)}var vb={growthbook:n=>Yc({...n,autoInit:!0})};function yb(n,e){let t=vb[n];if(!t)throw new Error(`Unknown experiment provider: ${n}. Supported: ${Object.keys(vb).join(", ")}`);return t(e)}var i1=["cdn.syntrologie.com","localhost","127.0.0.1"];function s1(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):i1.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 Jf=class{constructor(e){this.name="cdn";if(this.url=`${e.baseUrl}/${e.configId}.json`,this.integrity=e.integrity,!s1(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 o1(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 o1(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 _b(n){return new Jf(n)}var a1="syntro_exp",l1="syntro_var",Xf=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(a1),o=i.get(l1);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:sc(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 bb(n){return new Xf(n)}var c1="https://cdn.syntrologie.com/configs",wb={cdn:n=>{if(!n.configId)throw new Error("CDN fetcher requires 'configId' option");return _b({baseUrl:n.baseUrl??c1,configId:n.configId,integrity:n.integrity})},experiments:n=>{if(!n.featureKey)throw new Error("Experiments fetcher requires 'featureKey' option");return bb({featureKey:n.featureKey})}};function xb(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 u1=[25,50,75,100];function Sb(n){if(typeof window>"u"||typeof document>"u")return()=>{};let e=new Set,t=!1,r=()=>{t=!1;let o=document.documentElement,a=window.scrollY||o.scrollTop,l=Math.max(1,o.scrollHeight-window.innerHeight),c=Math.round(a/l*100);for(let u of u1)c>=u&&!e.has(u)&&(e.add(u),n.publish("nav.scroll_depth",{percent:u,path:window.location.pathname}))},i=()=>{t||(t=!0,requestAnimationFrame(r))};window.addEventListener("scroll",i,{passive:!0});let s=n.subscribe?.({names:["nav.page_view"]},()=>{e.clear()});return()=>{window.removeEventListener("scroll",i),s?.()}}var d1=new Set(["adaptive-chat-anchor","adaptive-spill-anchor","drawer-anchor"]);function Eb(n){if(typeof window>"u"||typeof document>"u"||typeof IntersectionObserver>"u")return()=>{};let e=new Map,t=new Map,r=c=>{let u=c.getAttribute("data-section");return typeof u!="string"||u.length===0||c.closest("[data-syntro-anchor]")||c.querySelector("[data-syntro-anchor]")||d1.has(u)?null:u},i=new IntersectionObserver(c=>{for(let u of c){let p=t.get(u.target);if(!p)continue;let f=e.get(p);if(f?.kind!=="emitted")if(u.intersectionRatio>=.5){if(f?.kind==="timer")continue;let h=setTimeout(()=>{t.has(u.target)&&(e.set(p,{kind:"emitted"}),n.publish("nav.section_viewed",{section:p,path:window.location.pathname}))},500);e.set(p,{kind:"timer",timer:h})}else f?.kind==="timer"&&(clearTimeout(f.timer),e.delete(p))}},{threshold:[.5]}),s=c=>{let u=r(c);u&&(t.has(c)||(t.set(c,u),i.observe(c)))},o=()=>{for(let c of document.querySelectorAll("[data-section]"))s(c)};o();let a=new MutationObserver(()=>o());a.observe(document.body,{childList:!0,subtree:!0});let l=n.subscribe?.({names:["nav.page_view"]},()=>{for(let c of e.values())c.kind==="timer"&&clearTimeout(c.timer);e.clear()});return()=>{i.disconnect(),a.disconnect(),l?.();for(let c of e.values())c.kind==="timer"&&clearTimeout(c.timer);e.clear(),t.clear()}}var Cb="syntro_session_metrics",Xo=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(Cb);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(Cb,JSON.stringify(e))}catch(e){console.warn("[SessionMetricTracker] Failed to save to sessionStorage:",e)}}};function Jc(n={}){return new Xo(n)}function kb(){for(let n of C_){let e=n();if(e.detect())return e}return null}var p1="syntro:score:v2:",hs="unknown";function Tb(n,e){return`${p1}${n}:${e}`}function eh(n,e){if(!e)return null;try{let t=sessionStorage.getItem(Tb(n,e));if(!t)return null;let r=JSON.parse(t);return typeof r=="object"&&r!==null&&typeof r.v=="string"&&typeof r.exp=="number"?r:null}catch{return null}}function xn(n,e){return eh(n,e)?.v??hs}function Rb(n,e,t,r){try{let i={v:t,exp:Date.now()+r*1e3};sessionStorage.setItem(Tb(n,e),JSON.stringify(i))}catch{}}var ni=new Map,Qf=new Map,Ib=new Map;function Qo(n,e){return`${n}:${e}`}function Xc(n,e){let t=Ib.get(Qo(n,e))??0;return Date.now()-t<5e3}function Qc(n,e){Ib.set(Qo(n,e),Date.now())}async function $b(n,e,t,r){let{model_id:i,signals:s,context_fp:o,...a}=e;try{let l=await fetch(`${n.backendUrl}/api/score`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"Content-Type":"application/json","X-Distinct-Id":r},body:JSON.stringify({posthog_sdk:n.posthogKey,session_id:t,user_id:r,model_id:i,output:a,signals:s,context_fp:o})});if(!l.ok)return xn(e.name,t);let u=(await l.json()).output??{};if(u.name!==e.name)return console.warn(`[syntro] score drift: asked for "${e.name}", got "${String(u.name)}"`),xn(e.name,t);let p=typeof u.value=="string"?u.value:hs;if(e.type==="enum"&&e.values&&!e.values.includes(p))return console.warn(`[syntro] score drift: "${p}" not in declared values for "${e.name}"`),xn(e.name,t);let f=typeof u.ttl_s=="number"?u.ttl_s:30;return Rb(e.name,t,p,f),p}catch{return xn(e.name,t)}}async function Ab(n,e,t,r){let{model_id:i,signals:s,context_fp:o}=e[0],a=new Map;try{let l=await fetch(`${n.backendUrl}/api/score`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"Content-Type":"application/json","X-Distinct-Id":r},body:JSON.stringify({posthog_sdk:n.posthogKey,session_id:t,user_id:r,model_id:i,outputs:e.map(({model_id:p,signals:f,context_fp:h,...g})=>g),signals:s,context_fp:o})});if(!l.ok)return a;let c=await l.json(),u=new Map(e.map(p=>[p.name,p]));for(let p of c.outputs??[]){let f=typeof p.name=="string"?u.get(p.name):void 0;if(!f)continue;let h=typeof p.value=="string"?p.value:hs;if(f.type==="enum"&&f.values&&!f.values.includes(h)){console.warn(`[syntro] score drift: "${h}" not in declared values for "${f.name}"`);continue}let g=typeof p.ttl_s=="number"?p.ttl_s:30;Rb(f.name,t,h,g),a.set(f.name,h)}return a}catch{return a}}function Pb(n,e){let t=n.getSessionId(),r=n.getUserId();if(e.length===0)return Promise.resolve([]);if(!t||!r)return Promise.resolve(e.map(u=>xn(u.name,t)));let i=new Map,s=[],o=[];for(let u of e){let p=eh(u.name,t);p&&p.v!==hs?(i.set(u.name,p.v),Date.now()>=p.exp&&s.push(u)):o.push(u)}let a=s.filter(u=>!ni.has(Qo(u.name,t))&&!Xc(u.name,t));if(a.length>0){for(let u of a)Qc(u.name,t);Ab(n,a,t,r)}if(o.length===0)return Promise.resolve(e.map(u=>i.get(u.name)??hs));let l=`${o.map(u=>u.name).join("\0")}:${t}`,c=Qf.get(l);if(!c){let u=o.filter(p=>!Xc(p.name,t));if(u.length===0)return Promise.resolve(e.map(p=>i.get(p.name)??xn(p.name,t)));for(let p of u)Qc(p.name,t);c=Ab(n,u,t,r).finally(()=>Qf.delete(l)),Qf.set(l,c)}return c.then(u=>e.map(p=>i.get(p.name)??u.get(p.name)??xn(p.name,t)))}function f1(n,e,t,r){let i=Qo(e.name,t);if(ni.has(i)||Xc(e.name,t))return;Qc(e.name,t);let s=$b(n,e,t,r).finally(()=>ni.delete(i));ni.set(i,s)}function Ob(n,e){let t=n.getSessionId(),r=n.getUserId();if(!t||!r)return Promise.resolve(xn(e.name,t));let i=eh(e.name,t);if(i&&i.v!==hs)return Date.now()<i.exp||f1(n,e,t,r),Promise.resolve(i.v);let s=Qo(e.name,t),o=ni.get(s);if(!o){if(Xc(e.name,t))return Promise.resolve(xn(e.name,t));Qc(e.name,t),o=$b(n,e,t,r).finally(()=>ni.delete(s)),ni.set(s,o)}return o}function Mb(n){return n==="granted"?"granted":n==="denied"?"denied":"pending"}function th(n){return n?Array.isArray(n)&&n[0]==="consent"?n[2]?.analytics_storage??null:typeof n=="object"&&n.event==="consent_update"?n.analytics_storage??null:null:null}var ea=class{constructor(){this.name="gtm-consent-mode-v2"}detect(){if(typeof window>"u")return!1;let e=window.dataLayer;if(!Array.isArray(e))return!1;for(let t of e)if(th(t)!==null)return!0;return!1}initialize(e){if(typeof window>"u")return e("pending"),()=>{};Array.isArray(window.dataLayer)||(window.dataLayer=[]),e(this.readCurrentState());let t=window.dataLayer,r=t.push.bind(t),i=(...s)=>{let o=r(...s);for(let a of s){let l=th(a);l!==null&&e(Mb(l))}return o};return t.push=i,()=>{t.push===i&&(t.push=r)}}readCurrentState(){if(typeof window>"u")return"pending";let e=window.dataLayer;if(!Array.isArray(e))return"pending";for(let t=e.length-1;t>=0;t--){let r=th(e[t]);if(r!==null)return Mb(r)}return"pending"}};var ta=class{constructor(){this.name="iab-tcf-v2"}detect(){return typeof window>"u"?!1:typeof window.__tcfapi=="function"}initialize(e){if(e("pending"),typeof window>"u")return()=>{};let t=window.__tcfapi;if(typeof t!="function")return()=>{};let r;return t("addEventListener",2,(i,s)=>{if(!s||!i||(r===void 0&&typeof i.listenerId=="number"&&(r=i.listenerId),!(i.eventStatus==="tcloaded"||i.eventStatus==="useractioncomplete")))return;if(i.gdprApplies===!1){e("granted");return}let a=i.purpose?.consents??{},l=a[1]===!0,c=a[8]===!0;e(l&&c?"granted":"denied")}),()=>{if(r!==void 0)try{t("removeEventListener",2,()=>{},r)}catch{}}}};var Lb="visitorConsentCollected",na=class{constructor(){this.name="shopify-customer-privacy"}detect(){return typeof window>"u"?!1:typeof window.Shopify?.loadFeatures=="function"}initialize(e){if(e("pending"),typeof window>"u")return()=>{};let t=window.Shopify;if(!t?.loadFeatures)return()=>{};let r;return t.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],i=>{if(i)return;let s=t.customerPrivacy?.userCanBeTracked()??!0;e(s?"granted":"denied"),r=o=>{let a=o.detail;e(a?.analyticsAllowed?"granted":"denied")},document.addEventListener(Lb,r)}),()=>{r&&document.removeEventListener(Lb,r)}}};var ra=class{constructor(e){this.options=e}async start(e){for(let r of this.options.adapters){let i=!1;try{i=r.detect()}catch{continue}if(i)try{let s=r.initialize(o=>e.setStatus(o));return this.options.onAdapterSelected?.(r.name),s}catch(s){console.warn(`[Syntro consent] Adapter "${r.name}" failed:`,s)}}this.options.onAdapterSelected?.(null);let t=await this.resolveFallback();return e.setStatus(t),()=>{}}async resolveFallback(){if(!this.options.fallbackStatus)return"pending";try{return await this.options.fallbackStatus()}catch{return"pending"}}};var ia=class{constructor(e={}){this.listeners=new Set;this.destroyed=!1;this.status=e.initialStatus??"pending",this.configCallback=e.onConsentChange,this.gtmEnabled=e.readFromGtmConsentMode??!1,this.pendingResolverFn=e.pendingResolver}grant(){this.setStatus("granted")}deny(){this.setStatus("denied")}getStatus(){return this.status}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}subscribeOnce(e){if(this.status!=="pending")return queueMicrotask(()=>e(this.status)),()=>{};let t=this.subscribe(r=>{r!=="pending"&&(t(),e(r))});return t}async resolvePending(){if(this.status!=="pending")return this.status;if(!this.pendingResolverFn)return"denied";try{return await this.pendingResolverFn()}catch{return"denied"}}setStatus(e){this.applyStatus(e)}pollGtmConsent(){if(!this.gtmEnabled||typeof window>"u")return;let e=window.dataLayer;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r)continue;if(r[0]==="consent"&&r[1]==="update"&&r[2]){let s=r[2].analytics_storage;s==="granted"?this.setStatus("granted"):s==="denied"&&this.setStatus("denied");return}}}destroy(){this.destroyed=!0,this.listeners.clear()}applyStatus(e){this.destroyed||this.status!==e&&(this.status=e,this.notify(e))}notify(e){if(this.configCallback)try{this.configCallback(e)}catch{}for(let t of this.listeners)try{t(e)}catch{}}};var gs=class{constructor(e,t){this.seenSet=new Set;this.triggeredSet=new Set;this.servedVariants=new Set;this.telemetry=e,this.variantId=t}trackServed(e,t){this.trackServedForVariant(this.variantId,e,t)}trackServedForVariant(e,t,r){this.servedVariants.has(e)||(this.servedVariants.add(e),this.telemetry.track?.("syntro_config_served",{variant_id:e,tiles:t,actions:r}))}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 h1(){let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=n[Math.floor(Math.random()*n.length)];return e}var nh=class{constructor(){this.sessionId=h1(),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){}identify(e,t){}alias(e,t){}optInCapturing(){}optOutCapturing(){}};function eu(){return new nh}var S=typeof window<"u"?window:void 0,Ze=typeof globalThis<"u"?globalThis:S;typeof self>"u"&&(Ze.self=Ze),typeof File>"u"&&(Ze.File=function(){});var $0=Array.prototype,Nb=$0.forEach,Fb=$0.indexOf,ht=Ze?.navigator,D=Ze?.document,qe=Ze?.location,bh=Ze?.fetch,wh=Ze!=null&&Ze.XMLHttpRequest&&"withCredentials"in new Ze.XMLHttpRequest?Ze.XMLHttpRequest:void 0,Db=Ze?.AbortController,ct=ht?.userAgent,ee=S??{},Cn={DEBUG:!1,LIB_VERSION:"1.341.0"};function Hb(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 bs(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var s=n.apply(e,t);function o(l){Hb(s,r,i,o,a,"next",l)}function a(l){Hb(s,r,i,o,a,"throw",l)}o(void 0)}))}}function W(){return W=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},W.apply(null,arguments)}function P0(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 g1=["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"],Bb=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return g1.concat(e).some((r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1}))},m1=["$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 me(n,e){return n.indexOf(e)!==-1}var Iu=function(n){return n.trim()},xh=function(n){return n.replace(/^\$/,"")},v1=Array.isArray,O0=Object.prototype,M0=O0.hasOwnProperty,$u=O0.toString,_e=v1||function(n){return $u.call(n)==="[object Array]"},ur=n=>typeof n=="function",Be=n=>n===Object(n)&&!_e(n),ws=n=>{if(Be(n)){for(var e in n)if(M0.call(n,e))return!1;return!0}return!1},H=n=>n===void 0,Ve=n=>$u.call(n)=="[object String]",Sh=n=>Ve(n)&&n.trim().length===0,Mt=n=>n===null,ve=n=>H(n)||Mt(n),$n=n=>$u.call(n)=="[object Number]"&&n==n,ys=n=>$n(n)&&n>0,In=n=>$u.call(n)==="[object Boolean]",y1=n=>n instanceof FormData,_1=n=>me(m1,n);function Eh(n){return n===null||typeof n!="object"}function lu(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function L0(n){return!H(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}var b1=[!0,"true",1,"1","yes"],rh=n=>me(b1,n),w1=[!1,"false",0,"0","no"];function Jt(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),$n(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),Jt(i||t,e,t,r))}var Ch=class{constructor(e){this.t={},this.i=e.i,this.o=Jt(e.bucketSize,0,100,e.h),this.m=Jt(e.refillRate,0,this.o,e.h),this.$=Jt(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={}}},St="Mobile",cu="iOS",Rn="Android",Ca="Tablet",N0=Rn+" "+Ca,F0="iPad",D0="Apple",H0=D0+" Watch",ka="Safari",Cs="BlackBerry",B0="Samsung",V0=B0+"Browser",U0=B0+" Internet",oi="Chrome",x1=oi+" OS",j0=oi+" "+cu,Og="Internet Explorer",W0=Og+" "+St,Mg="Opera",S1=Mg+" Mini",Lg="Edge",z0="Microsoft "+Lg,Ss="Firefox",q0=Ss+" "+cu,Aa="Nintendo",Ta="PlayStation",Es="Xbox",Z0=Rn+" "+St,G0=St+" "+ka,ha="Windows",kh=ha+" Phone",Vb="Nokia",Ah="Ouya",K0="Generic",E1=K0+" "+St.toLowerCase(),Y0=K0+" "+Ca.toLowerCase(),Th="Konqueror",nt="(\\d+(\\.\\d+)?)",ih=new RegExp("Version/"+nt),C1=new RegExp(Es,"i"),k1=new RegExp(Ta+" \\w+","i"),A1=new RegExp(Aa+" \\w+","i"),Ng=new RegExp(Cs+"|PlayBook|BB10","i"),T1={"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"},tu,Ub,sh,R1=(n,e)=>e&&me(e,D0)||(function(t){return me(t,ka)&&!me(t,oi)&&!me(t,Rn)})(n),J0=function(n,e){return e=e||"",me(n," OPR/")&&me(n,"Mini")?S1:me(n," OPR/")?Mg:Ng.test(n)?Cs:me(n,"IE"+St)||me(n,"WPDesktop")?W0:me(n,V0)?U0:me(n,Lg)||me(n,"Edg/")?z0:me(n,"FBIOS")?"Facebook "+St:me(n,"UCWEB")||me(n,"UCBrowser")?"UC Browser":me(n,"CriOS")?j0:me(n,"CrMo")||me(n,oi)?oi:me(n,Rn)&&me(n,ka)?Z0:me(n,"FxiOS")?q0:me(n.toLowerCase(),Th.toLowerCase())?Th:R1(n,e)?me(n,St)?G0:ka:me(n,Ss)?Ss:me(n,"MSIE")||me(n,"Trident/")?Og:me(n,"Gecko")?Ss:""},I1={[W0]:[new RegExp("rv:"+nt)],[z0]:[new RegExp(Lg+"?\\/"+nt)],[oi]:[new RegExp("("+oi+"|CrMo)\\/"+nt)],[j0]:[new RegExp("CriOS\\/"+nt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+nt)],[ka]:[ih],[G0]:[ih],[Mg]:[new RegExp("(Opera|OPR)\\/"+nt)],[Ss]:[new RegExp(Ss+"\\/"+nt)],[q0]:[new RegExp("FxiOS\\/"+nt)],[Th]:[new RegExp("Konqueror[:/]?"+nt,"i")],[Cs]:[new RegExp(Cs+" "+nt),ih],[Z0]:[new RegExp("android\\s"+nt,"i")],[U0]:[new RegExp(V0+"\\/"+nt)],[Og]:[new RegExp("(rv:|MSIE )"+nt)],Mozilla:[new RegExp("rv:"+nt)]},$1=function(n,e){var t=J0(n,e),r=I1[t];if(H(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},jb=[[new RegExp(Es+"; "+Es+" (.*?)[);]","i"),n=>[Es,n&&n[1]||""]],[new RegExp(Aa,"i"),[Aa,""]],[new RegExp(Ta,"i"),[Ta,""]],[Ng,[Cs,""]],[new RegExp(ha,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[kh,""];if(new RegExp(St).test(e)&&!/IEMobile\b/.test(e))return[ha+" "+St,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=T1[r]||"";return/arm/i.test(e)&&(i="RT"),[ha,i]}return[ha,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[cu,e.join(".")]}return[cu,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=H(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+Rn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rn+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Rn,e.join(".")]}return[Rn,""]}],[/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/,[x1,""]],[/Linux|debian/i,["Linux",""]]],Wb=function(n){return A1.test(n)?Aa:k1.test(n)?Ta:C1.test(n)?Es:new RegExp(Ah,"i").test(n)?Ah:new RegExp("("+kh+"|WPDesktop)","i").test(n)?kh:/iPad/.test(n)?F0:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?H0:Ng.test(n)?Cs:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(Vb,"i").test(n)?Vb:/(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(St).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)?Rn:N0:new RegExp("(pda|"+St+")","i").test(n)?E1:new RegExp(Ca,"i").test(n)&&!new RegExp(Ca+" pc","i").test(n)?Y0:""},P1=n=>n instanceof Error;function O1(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return sh&&t.length===Ub||(Ub=t.length,sh=t.reduce(((r,i)=>{tu||(tu={});var s=tu[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,tu[i]=[c,u];break}}return r}),{})),sh}}var Rh=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 bs((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&_e(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)),W({},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 bs((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,W({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:O1(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 W({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},ks="?";function Ih(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?ks:t,in_app:!0};return H(r)||(s.lineno=r),H(i)||(s.colno=i),s}var X0=(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]:ks,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},M1=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,L1=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,N1=/\((\S*)(?::(\d+))(?::(\d+))\)/,F1=(n,e)=>{var t=M1.exec(n);if(t){var[,r,i,s]=t;return Ih(e,r,ks,+i,+s)}var o=L1.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=N1.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=X0(o[1]||ks,o[2]);return Ih(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},D1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,H1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,B1=(n,e)=>{var t=D1.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=H1.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]||ks;return[s,i]=X0(s,i),Ih(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},zb=/\(error: (.*)\)/,qb=50;function V1(){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(`
|
|
624
624
|
`),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=zb.test(c)?c.replace(zb,"$1"):c;if(!u.match(/\S*Error: /)){for(var p of t){var f=p(u,n);if(f){o.push(f);break}}if(o.length>=qb)break}}}return(function(h){if(!h.length)return[];var g=Array.from(h);return g.reverse(),g.slice(0,qb).map((v=>{return W({},v,{filename:v.filename||(m=g,m[m.length-1]||{}).filename,function:v.function||ks});var m}))})(o)}})("web:javascript",F1,B1)}var $h=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=Ve(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 lu(e,"DOMException")}isDOMError(e){return lu(e,"DOMError")}},Ph=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}},Oh=class{constructor(){}match(e){return lu(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}}},U1=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Mh=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(U1);return i&&(t=i[1],r=i[2]),[t,r]}},j1=["fatal","error","warning","log","info","debug"];function Q0(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 Lh=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 L0(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: "+Q0(e)}isSeverityLevel(e){return Ve(e)&&!Sh(e)&&j1.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(P1(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Nh=class{match(e){return L0(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+Q0(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Fh=class{match(e){return Eh(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}}},Dh=class{match(e){return lu(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return Eh(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(Eh(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}},ew=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(S&&(Cn.DEBUG||ee.POSTHOG_DEBUG||t)&&!H(S.console)&&S.console){for(var s=("__rrweb_original__"in S.console[i])?S.console[i].__rrweb_original__:S.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)=>ew(n+" "+i,s)};return r},V=ew("[PostHog.js]"),Pe=V.createLogger,W1=Pe("[ExternalScriptsLoader]"),Zb=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return W1.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=D?.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(!D)return t("document not found");var l=D.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=p=>{l.__posthog_loading_callback_fired=!0,t(void 0,p)},l.onerror=p=>t(p),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")D.head.appendChild(l);else{var c,u=D.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):D.body.appendChild(l)}};D!=null&&D.body?a():D?.addEventListener("DOMContentLoaded",a)};ee.__PosthogExtensions__=ee.__PosthogExtensions__||{},ee.__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);Zb(n,s,t)},ee.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Zb(n,r,t)};var uu={};function dr(n,e,t){if(_e(n)){if(Nb&&n.forEach===Nb)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)===uu)return}}}function xe(n,e,t){if(!ve(n)){if(_e(n))return dr(n,e,t);if(y1(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===uu)return}else for(var i in n)if(M0.call(n,i)&&e.call(t,n[i],i)===uu)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 dr(t,(function(i){for(var s in i)i[s]!==void 0&&(n[s]=i[s])})),n},Ts=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 dr(t,(function(i){dr(i,(function(s){n.push(s)}))})),n};function ou(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 Gb=function(n){try{return n()}catch{return}},z1=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){V.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),V.critical(i)}}},Fg=function(n){var e={};return xe(n,(function(t,r){(Ve(t)&&t.length>0||$n(t))&&(e[r]=t)})),e};function q1(n,e){return t=n,r=s=>Ve(s)&&!Mt(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),_e(o)?(l=[],dr(o,(c=>{l.push(s(c))}))):(l={},xe(o,((c,u)=>{i.has(c)||(l[u]=s(c,u))}))),l);var l})(t);var t,r,i}var Z1=["herokuapp.com","vercel.app","netlify.app"];function G1(n){var e=n?.hostname;if(!Ve(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of Z1)if(t===r)return!1;return!0}function tw(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function Fe(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var nw="$people_distinct_id",ga="__alias",ma="__timers",Kb="$autocapture_disabled_server_side",Hh="$heatmaps_enabled_server_side",Yb="$exception_capture_enabled_server_side",Bh="$error_tracking_suppression_rules",Jb="$error_tracking_capture_extension_exceptions",Xb="$web_vitals_enabled_server_side",rw="$dead_clicks_enabled_server_side",Qb="$product_tours_enabled_server_side",e0="$web_vitals_allowed_metrics",oh="$session_recording_remote_config",du="$sesid",iw="$session_is_sampled",xs="$enabled_feature_flags",va="$early_access_features",Vh="$feature_flag_details",ya="$stored_person_properties",si="$stored_group_properties",Uh="$surveys",pu="$flag_call_reported",kn="$user_state",jh="$client_session_props",Wh="$capture_rate_limit",zh="$initial_campaign_params",qh="$initial_referrer_info",fu="$initial_person_info",hu="$epp",sw="__POSTHOG_TOOLBAR__",sa="$posthog_cookieless",K1=[nw,ga,"__cmpns",ma,"$session_recording_enabled_server_side",Hh,du,xs,Bh,kn,va,Vh,si,ya,Uh,pu,jh,Wh,zh,qh,hu,fu,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function t0(n){return n instanceof Element&&(n.id===sw||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Pu(n){return!!n&&n.nodeType===1}function pr(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function ow(n){return!!n&&n.nodeType===3}function aw(n){return!!n&&n.nodeType===11}function Dg(n){return n?Iu(n).split(/\s+/):[]}function n0(n){var e=S?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function gu(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 Dg(e)}function lw(n){return ve(n)?null:Iu(n).split(/(\s+)/).filter((e=>Ra(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function $a(n){var e="";return Zh(n)&&!fw(n)&&n.childNodes&&n.childNodes.length&&xe(n.childNodes,(function(t){var r;ow(t)&&t.textContent&&(e+=(r=lw(t.textContent))!==null&&r!==void 0?r:"")})),Iu(e)}function cw(n){return H(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Hg=["a","button","form","input","select","textarea","label"];function uw(n,e){if(H(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 dw(n){var e=n.parentNode;return!(!e||!Pu(e))&&e}var Y1=["next","previous","prev",">","<"],r0=10,i0=[".ph-no-rageclick",".ph-no-capture"];function J1(n,e){if(!S||Bg(n))return!1;var t,r,i;if(In(e)?(t=!!e&&i0,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:i0,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=pw(n,!1);return!(function(o,a){if(o===!1||H(o))return!1;var l;if(o===!0)l=Y1;else{if(!_e(o))return!1;if(o.length>r0)return V.error("[PostHog] content_ignorelist array cannot exceed "+r0+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:p}=c;return l.some((f=>u.includes(f)||p.includes(f)))}))})(r,s.map((o=>{var a;return{safeText:$a(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!uw(s,t)}var Bg=n=>!n||pr(n,"html")||!Pu(n),pw=(n,e)=>{if(!S||Bg(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!pr(i,"body");)if(aw(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=dw(i);if(!s)break;if(e||Hg.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=S.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function X1(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!S||Bg(n)||(s=t)!=null&&s.url_allowlist&&!n0(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&n0(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((g=>e.type===g)))return!1}var{parentIsUsefulElement:u,targetElementList:p}=pw(n,r);if(!(function(g,v){var m=v?.element_allowlist;if(H(m))return!0;var y,w=function(_){if(m.some((k=>_.tagName.toLowerCase()===k)))return{v:!0}};for(var x of g)if(y=w(x))return y.v;return!1})(p,t)||!uw(p,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var f=S.getComputedStyle(n);if(f&&f.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var h=n.tagName.toLowerCase();switch(h){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&&(Hg.indexOf(h)>-1||n.getAttribute("contenteditable")==="true")}}function Zh(n){for(var e=n;e.parentNode&&!pr(e,"body");e=e.parentNode){var t=gu(e);if(me(t,"ph-sensitive")||me(t,"ph-no-capture"))return!1}if(me(gu(n),"ph-include"))return!0;var r=n.type||"";if(Ve(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(Ve(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 fw(n){return!!(pr(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||pr(n,"select")||pr(n,"textarea")||n.getAttribute("contenteditable")==="true")}var hw="(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})",Q1=new RegExp("^(?:"+hw+")$"),eT=new RegExp(hw),gw="\\d{3}-?\\d{2}-?\\d{4}",tT=new RegExp("^("+gw+")$"),nT=new RegExp("("+gw+")");function Ra(n,e){return e===void 0&&(e=!0),!(ve(n)||Ve(n)&&(n=Iu(n),(e?Q1:eT).test((n||"").replace(/[- ]/g,""))||(e?tT:nT).test(n)))}function mw(n){var e=$a(n);return Ra(e=(e+" "+vw(n)).trim())?e:""}function vw(n){var e="";return n&&n.childNodes&&n.childNodes.length&&xe(n.childNodes,(function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=$a(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+vw(t)).trim())}catch(s){V.error("[AutoCapture]",s)}})),e}function rT(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=W({},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 ou(l).sort(((u,p)=>{var[f]=u,[h]=p;return f.localeCompare(h)})).forEach((u=>{var[p,f]=u;return c[s0(p.toString())]=s0(f.toString())})),o+=":",o+=ou(c).map((u=>{var[p,f]=u;return p+'="'+f+'"'})).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:iT(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return ou(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 s0(n){return n.replace(/"|\\"/g,'\\"')}function iT(n){var e=n.attr__class;return e?_e(e)?e:Dg(e):void 0}var mu=class{constructor(e){this.disabled=e===!1;var t=Be(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}},vu=n=>{var e=D?.createElement("a");return H(e)?null:(e.href=n,e)},sT=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return xe(n,(function(s,o){H(s)||H(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)},yu=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(!_e(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{V.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Pa=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=[],p=0;p<c.length;p++){var f=c[p].split("=");_e(f)&&(e.includes(f[0])?u.push(f[0]+"="+t):u.push(c[p]))}var h=l;return a!=null&&(h+="?"+u.join("&")),s!=null&&(h+="#"+s),h},_u=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},ah="$copy_autocapture",o0=Pe("[AutoCapture]");function lh(n,e){return e.length>n?e.slice(0,n)+"...":e}function oT(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Pu(e));return e}function aT(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Hg.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=lh(1024,mw(n)):s.$el_text=lh(1024,$a(n)));var o=gu(n);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),xe(n.attributes,(function(u){var p;if((!fw(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Ra(u.value)&&(p=u.name,!Ve(p)||p.substring(0,10)!=="_ngcontent"&&p.substring(0,7)!=="_nghost")){var f=u.value;u.name==="class"&&(f=Dg(f).join(" ")),s["attr__"+u.name]=lh(1024,f)}}));for(var a=1,l=1,c=n;c=oT(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function lT(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!pr(u,"body");)aw(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var p,f=[],h={},g=!1,v=!1;if(xe(c,(_=>{var k=Zh(_);_.tagName.toLowerCase()==="a"&&(g=_.getAttribute("href"),g=k&&g&&Ra(g)&&g),me(gu(_),"ph-no-capture")&&(v=!0),f.push(aT(_,s,o,a));var I=(function(b){if(!Zh(b))return{};var A={};return xe(b.attributes,(function(M){if(M.name&&M.name.indexOf("data-ph-capture-attribute")===0){var J=M.name.replace("data-ph-capture-attribute-",""),$=M.value;J&&$&&Ra($)&&(A[J]=$)}})),A})(_);Me(h,I)})),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?f[0].$el_text=mw(n):f[0].$el_text=$a(n)),g){var m,y;f[0].attr__href=g;var w=(m=vu(g))==null?void 0:m.host,x=S==null||(y=S.location)==null?void 0:y.host;w&&x&&w!==x&&(p=g)}return{props:Me({$event_type:i.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:rT(f)},(t=f[0])!=null&&t.$el_text?{$el_text:(r=f[0])==null?void 0:r.$el_text}:{},p&&i.type==="click"?{$external_click_url:p}:{},h)}}var Gh=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new mu(e.config.rageclick),this.C=null}get R(){var e,t,r=Be(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(S&&D){var e=r=>{r=r||S?.event;try{this.O(r)}catch(i){o0.error("Failed to capture event",i)}};if(Fe(D,"submit",e,{capture:!0}),Fe(D,"change",e,{capture:!0}),Fe(D,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||S?.event,this.O(r,ah)};Fe(D,"copy",t,{capture:!0}),Fe(D,"cut",t,{capture:!0})}}}else o0.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({[Kb]:!!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=D?.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[Kb],i=this.T;if(Mt(i)&&!In(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=cw(e);ow(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())&&J1(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ah;if(i&&X1(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=lT(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===ah){var c,u=lw(S==null||(c=S.getSelection())==null?void 0:c.toString()),p=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=p}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return ur(D?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return $n(n)&&isFinite(n)&&Math.floor(n)===n});var a0="0123456789abcdef",Kh=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+a0.charAt(this.bytes[t]>>>4)+a0.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}},Yh=class{constructor(){this.A=0,this.j=0,this.D=new Jh}generate(){var e=this.generateOrAbort();if(H(e)){this.A=0;var t=this.generateOrAbort();if(H(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 Kh.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())}},l0,yw=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};S&&!H(S.crypto)&&crypto.getRandomValues&&(yw=n=>crypto.getRandomValues(n));var Jh=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(yw(this.N),this.U=0),this.N[this.U++]}},cr=()=>cT().toString(),cT=()=>(l0||(l0=new Yh)).generate(),oa="",uT=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function dT(n,e){if(e){var t=(function(i,s){if(s===void 0&&(s=D),oa)return oa;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+cr();!oa&&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",oa=c)}return oa})(n);if(!t){var r=(i=>{var s=i.match(uT);return s?s[0]:""})(n);r!==t&&V.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var Yt={H:()=>!!D,B:function(n){V.error("cookieStore error: "+n)},q:function(n){if(D){try{for(var e=n+"=",t=D.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(Yt.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(D)try{var s="",o="",a=dT(D.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&&V.warn("cookieStore warning: large cookie, len="+c.length),D.cookie=c,c}catch{return}},V:function(n,e){if(D!=null&&D.cookie)try{Yt.G(n,"",-1,e)}catch{return}}},ch=null,Te={H:function(){if(!Mt(ch))return ch;var n=!0;if(H(S))n=!1;else try{var e="__mplssupport__";Te.G(e,"xyz"),Te.q(e)!=='"xyz"'&&(n=!1),Te.V(e)}catch{n=!1}return n||V.error("localStorage unsupported; falling back to cookie store"),ch=n,n},B:function(n){V.error("localStorage error: "+n)},q:function(n){try{return S?.localStorage.getItem(n)}catch(e){Te.B(e)}return null},W:function(n){try{return JSON.parse(Te.q(n))||{}}catch{}return null},G:function(n,e){try{S?.localStorage.setItem(n,JSON.stringify(e))}catch(t){Te.B(t)}},V:function(n){try{S?.localStorage.removeItem(n)}catch(e){Te.B(e)}}},pT=["$device_id","distinct_id",du,iw,hu,fu],nu={},fT={H:function(){return!0},B:function(n){V.error("memoryStorage error: "+n)},q:function(n){return nu[n]||null},W:function(n){return nu[n]||null},G:function(n,e){nu[n]=e},V:function(n){delete nu[n]}},ri=null,ze={H:function(){if(!Mt(ri))return ri;if(ri=!0,H(S))ri=!1;else try{var n="__support__";ze.G(n,"xyz"),ze.q(n)!=='"xyz"'&&(ri=!1),ze.V(n)}catch{ri=!1}return ri},B:function(n){V.error("sessionStorage error: ",n)},q:function(n){try{return S?.sessionStorage.getItem(n)}catch(e){ze.B(e)}return null},W:function(n){try{return JSON.parse(ze.q(n))||null}catch{}return null},G:function(n,e){try{S?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){ze.B(t)}},V:function(n){try{S?.sessionStorage.removeItem(n)}catch(e){ze.B(e)}}},An=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),Xh=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?An.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===An.DENIED||this.consent===An.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===An.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 rh(e)?An.GRANTED:me(w1,e)?An.DENIED:An.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?Te:Yt;var t=e==="localStorage"?Yt:Te;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(rh(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!tw([ht?.doNotTrack,ht?.msDoNotTrack,ee.doNotTrack],(e=>rh(e)))}},ru=Pe("[Dead Clicks]"),hT=()=>!0,gT=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(rw)),r=n.instance.config.capture_dead_clicks;return In(r)?r:!!Be(r)||t},bu=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({[rw]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?ru.error("failed to load script",i):e()}))}et(){var e;if(D){if(!this.tt&&(e=ee.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Be(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=ee.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(D),ru.info("starting...")}}else ru.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,ru.info("stopping..."))}},aa=Pe("[ExceptionAutocapture]"),Qh=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(S&&this.isEnabled&&(s=ee.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=ee.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=ee.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=ee.__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){aa.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Yb]),this.dt=new Ch({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:aa}),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 Be(e)?t=W({},t,e):(H(e)?this.ht:e)&&(t=W({},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?(aa.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return aa.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({[Yb]: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)?aa.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function c0(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return ur(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var eg=class{constructor(e){var t;this._instance=e,this.ct=(S==null||(t=S.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(V.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,V.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(S&&S.history){var r=this;(e=S.history.pushState)!=null&&e.__posthog_wrapped__||c0(S.history,"pushState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")})),(t=S.history.replaceState)!=null&&t.__posthog_wrapped__||c0(S.history,"replaceState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")})),this.bt()}}_t(e){try{var t,r=S==null||(t=S.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){V.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Fe(S,"popstate",e),this.ft=()=>{S&&S.removeEventListener("popstate",e)}}}},uh=Pe("[SegmentIntegration]");function mT(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()||cr();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(kn,"identified")),i()},a=s.user();"then"in a&&ur(a.then)?a.then(o):o(a)})(n,(()=>{t.register((r=>{Promise&&Promise.resolve||uh.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()||(uh.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(uh.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 _w="posthog-js";function bw(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,p,f;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var h=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=h,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var g=((l=a.exception)==null?void 0:l.values)||[],v=g.map((y=>W({},y,{stacktrace:y.stacktrace?W({},y.stacktrace,{type:"raw",frames:(y.stacktrace.frames||[]).map((w=>W({},w,{platform:"web:javascript"})))}):void 0}))),m={$exception_message:((c=g[0])==null?void 0:c.value)||a.message,$exception_type:(u=g[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((p=g[0])==null?void 0:p.value)||a.message,$sentry_exception_type:(f=g[0])==null?void 0:f.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 tg=class{constructor(e,t,r,i,s,o){this.name=_w,this.setupOnce=function(a){a(bw(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},vT=S!=null&&S.location?_u(S.location.hash,"__posthog")||_u(location.hash,"state"):null,u0="_postHogToolbarParams",d0=Pe("[Toolbar]"),lr=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(lr||{}),ng=class{constructor(e){this.instance=e}yt(e){ee.ph_toolbar_state=e}wt(){var e;return(e=ee.ph_toolbar_state)!==null&&e!==void 0?e:lr.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),!S||!D)return!1;e=e??S.location,r=r??S.history;try{if(!t){try{S.localStorage.setItem("test","test"),S.localStorage.removeItem("test")}catch{return!1}t=S?.localStorage}var i,s=vT||_u(e.hash,"__posthog")||_u(e.hash,"state"),o=s?Gb((()=>JSON.parse(atob(decodeURIComponent(s)))))||Gb((()=>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(u0)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=ee.ph_load_toolbar||ee.ph_load_editor;!ve(t)&&ur(t)?t(e,this.instance):d0.warn("No toolbar load function found")}loadToolbar(e){var t=!(D==null||!D.getElementById(sw));if(!S||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=W({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(S.localStorage.setItem(u0,JSON.stringify(W({},i,{source:void 0}))),this.wt()===lr.LOADED)this.xt(i);else if(this.wt()===lr.UNINITIALIZED){var s;this.yt(lr.LOADING),(s=ee.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return d0.error("[Toolbar] Failed to load",o),void this.yt(lr.UNINITIALIZED);this.yt(lr.LOADED),this.xt(i)})),Fe(S,"turbolinks:load",(()=>{this.yt(lr.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)}},yT=Pe("[TracingHeaders]"),rg=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;H(this.$t)&&((t=ee.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),H(this.St)&&((r=ee.__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=ee.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return yT.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)}},iu="https?://(.*)",Rs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],_T=Ts(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Rs),Oa="<masked>",bT=["li_fat_id"];function ww(n,e,t){if(!D)return{};var r,i=e?Ts([],Rs,t||[]):[],s=xw(Pa(D.URL,i,Oa),n),o=(r={},xe(bT,(function(a){var l=Yt.q(a);r[a]=l||null})),r);return Me(o,s)}function xw(n,e){var t=_T.concat(e||[]),r={};return xe(t,(function(i){var s=yu(n,i);r[i]=s||null})),r}function Sw(n){var e=(function(s){return s?s.search(iu+"google.([^/?]*)")===0?"google":s.search(iu+"bing.com")===0?"bing":s.search(iu+"yahoo.com")===0?"yahoo":s.search(iu+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",r={};if(!Mt(e)){r.$search_engine=e;var i=D?yu(D.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function p0(){return navigator.language||navigator.userLanguage}function Ew(){return D?.referrer||"$direct"}function Cw(n,e){var t=n?Ts([],Rs,e||[]):[],r=qe?.href.substring(0,1e3);return{r:Ew().substring(0,1e3),u:r?Pa(r,t,Oa):void 0}}function kw(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=vu(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=vu(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=xw(r);Me(i,o)}if(t){var a=Sw(t);Me(i,a)}return i}function Aw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function wT(){try{return new Date().getTimezoneOffset()}catch{return}}function xT(n,e){if(!ct)return{};var t,r,i,s=n?Ts([],Rs,e||[]):[],[o,a]=(function(l){for(var c=0;c<jb.length;c++){var[u,p]=jb[c],f=u.exec(l),h=f&&(ur(p)?p(f,l):p);if(h)return h}return["",""]})(ct);return Me(Fg({$os:o,$os_version:a,$browser:J0(ct,navigator.vendor),$device:Wb(ct),$device_type:(r=ct,i=Wb(r),i===F0||i===N0||i==="Kobo"||i==="Kindle Fire"||i===Y0?Ca:i===Aa||i===Es||i===Ta||i===Ah?"Console":i===H0?"Wearable":i?St:"Desktop"),$timezone:Aw(),$timezone_offset:wT()}),{$current_url:Pa(qe?.href,s,Oa),$host:qe?.host,$pathname:qe?.pathname,$raw_user_agent:ct.length>1e3?ct.substring(0,997)+"...":ct,$browser_version:$1(ct,navigator.vendor),$browser_language:p0(),$browser_language_prefix:(t=p0(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:S?.screen.height,$screen_width:S?.screen.width,$viewport_height:S?.innerHeight,$viewport_width:S?.innerWidth,$lib:"web",$lib_version:Cn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var sr=Pe("[Web Vitals]"),f0=9e5,ig=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)=>W({},r,{["$web_vitals_"+i.name+"_event"]:W({},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(H(s))sr.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();H(o)||(ve(r?.name)||ve(r?.value)?sr.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?sr.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),H(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=H(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(W({},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=ee.__PosthogExtensions__;H(a)||H(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):sr.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Xb]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=Be(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return ve(r)?((t=this._instance.persistence)==null?void 0:t.props[e0])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=Be(this._instance.config.capture_performance)&&$n(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:f0;return 0<e&&e<=6e4?f0:e}get isEnabled(){var e=qe?.protocol;if(e!=="http:"&&e!=="https:")return sr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:In(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return In(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(sr.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=Be(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Be(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Xb]:t}),this._instance.persistence.register({[e0]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=ee.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,(s=>{s?sr.error("failed to load script",s):e()}))}}Ct(){var e=S?S.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?Ts([],Rs,r||[]):[];return Pa(e,i,Oa)}sr.error("Could not determine current URL")}},ST=Pe("[Heatmaps]");function h0(n){return Be(n)&&"clientX"in n&&"clientY"in n&&$n(n.clientX)&&$n(n.clientY)}var sg=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[Hh]),this.rageclicks=new mu(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return Be(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 ve(this.instance.config.capture_heatmaps)?ve(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;ST.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({[Hh]: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"})(D)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){S&&D&&(this.Nt=this.Lt.bind(this),Fe(S,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||S?.event),Fe(D,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||S?.event),Fe(D,"mousemove",this.zt,{capture:!0}),this.Bt=new bu(this.instance,hT,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Fe(D,"visibilitychange",this.qt),this.P=!0)}At(){var e;S&&D&&(this.Nt&&S.removeEventListener("beforeunload",this.Nt),this.Ut&&D.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&D.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&D.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&&Pu(u)&&!pr(u,"body");){if(u===c)return!1;if(me(l,S?.getComputedStyle(u).position))return!0;u=dw(u)}return!1})(cw(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"),!t0(e.target)&&h0(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(W({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!t0(e.target)&&h0(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(S){var t=S.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?Ts([],Rs,i||[]):[],o=Pa(t,s,Oa);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!ws(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},wu=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(V.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=S?.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:p}=s;if(!(H(o)||H(a)||H(l)||H(c)||H(u)||H(p))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),p=Math.ceil(p);var f=o<=1?1:Jt(a/o,0,1,V),h=o<=1?1:Jt(l/o,0,1,V),g=c<=1?1:Jt(u/c,0,1,V),v=c<=1?1:Jt(p/c,0,1,V);i=Me(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:v})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}};var Tn=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),Et=Uint8Array,rt=Uint16Array,As=Uint32Array,Vg=new Et([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]),Ug=new Et([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]),g0=new Et([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Tw=function(n,e){for(var t=new rt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new As(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]},Rw=Tw(Vg,2),ET=Rw[0],og=Rw[1];ET[28]=258,og[258]=28;for(ag=Tw(Ug,0)[1],xu=new rt(32768),Se=0;Se<32768;++Se)or=(43690&Se)>>>1|(21845&Se)<<1,or=(61680&(or=(52428&or)>>>2|(13107&or)<<2))>>>4|(3855&or)<<4,xu[Se]=((65280&or)>>>8|(255&or)<<8)>>>1;var or,ag,xu,Se,xa=function(n,e,t){for(var r=n.length,i=0,s=new rt(e);i<r;++i)++s[n[i]-1];var o,a=new rt(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new rt(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],p=a[n[i]-1]++<<u,f=p|(1<<u)-1;p<=f;++p)o[xu[p]>>>l]=c}else for(o=new rt(r),i=0;i<r;++i)o[i]=xu[a[n[i]-1]++]>>>15-n[i];return o},ai=new Et(288);for(Se=0;Se<144;++Se)ai[Se]=8;for(Se=144;Se<256;++Se)ai[Se]=9;for(Se=256;Se<280;++Se)ai[Se]=7;for(Se=280;Se<288;++Se)ai[Se]=8;var Su=new Et(32);for(Se=0;Se<32;++Se)Su[Se]=5;var CT=xa(ai,9,0),kT=xa(Su,5,0),Iw=function(n){return(n/8>>0)+(7&n&&1)},$w=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof rt?rt:n instanceof As?As:Et)(t-e);return r.set(n.subarray(e,t)),r},Sn=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},la=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},dh=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 Et(0),0];if(i==1){var o=new Et(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(k,I){return k.f-I.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,p=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=t[t[c].f<t[p].f?c++:p++],l=t[c!=u&&t[c].f<t[p].f?c++:p++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var f=s[0].s;for(r=1;r<i;++r)s[r].s>f&&(f=s[r].s);var h=new rt(f+1),g=lg(t[u-1],h,0);if(g>e){r=0;var v=0,m=g-e,y=1<<m;for(s.sort((function(k,I){return h[I.s]-h[k.s]||k.f-I.f}));r<i;++r){var w=s[r].s;if(!(h[w]>e))break;v+=y-(1<<g-h[w]),h[w]=e}for(v>>>=m;v>0;){var x=s[r].s;h[x]<e?v-=1<<e-h[x]++-1:++r}for(;r>=0&&v;--r){var _=s[r].s;h[_]==e&&(--h[_],++v)}g=e}return[new Et(h),g]},lg=function(n,e,t){return n.s==-1?Math.max(lg(n.l,e,t+1),lg(n.r,e,t+1)):e[n.s]=t},m0=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new rt(++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]},ca=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},cg=function(n,e,t){var r=t.length,i=Iw(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)},v0=function(n,e,t,r,i,s,o,a,l,c,u){Sn(e,u++,t),++i[256];for(var p=dh(i,15),f=p[0],h=p[1],g=dh(s,15),v=g[0],m=g[1],y=m0(f),w=y[0],x=y[1],_=m0(v),k=_[0],I=_[1],b=new rt(19),A=0;A<w.length;++A)b[31&w[A]]++;for(A=0;A<k.length;++A)b[31&k[A]]++;for(var M=dh(b,7),J=M[0],$=M[1],U=19;U>4&&!J[g0[U-1]];--U);var G,Z,te,ye,pe=c+5<<3,j=ca(i,ai)+ca(s,Su)+o,X=ca(i,f)+ca(s,v)+o+14+3*U+ca(b,J)+(2*b[16]+3*b[17]+7*b[18]);if(pe<=j&&pe<=X)return cg(e,u,n.subarray(l,l+c));if(Sn(e,u,1+(X<j)),u+=2,X<j){G=xa(f,h,0),Z=f,te=xa(v,m,0),ye=v;var Oe=xa(J,$,0);for(Sn(e,u,x-257),Sn(e,u+5,I-1),Sn(e,u+10,U-4),u+=14,A=0;A<U;++A)Sn(e,u+3*A,J[g0[A]]);u+=3*U;for(var Ye=[w,k],De=0;De<2;++De){var Je=Ye[De];for(A=0;A<Je.length;++A){var Xe=31&Je[A];Sn(e,u,Oe[Xe]),u+=J[Xe],Xe>15&&(Sn(e,u,Je[A]>>>5&127),u+=Je[A]>>>12)}}}else G=CT,Z=ai,te=kT,ye=Su;for(A=0;A<a;++A)if(r[A]>255){Xe=r[A]>>>18&31,la(e,u,G[Xe+257]),u+=Z[Xe+257],Xe>7&&(Sn(e,u,r[A]>>>23&31),u+=Vg[Xe]);var Pn=31&r[A];la(e,u,te[Pn]),u+=ye[Pn],Pn>3&&(la(e,u,r[A]>>>5&8191),u+=Ug[Pn])}else la(e,u,G[r[A]]),u+=Z[r[A]];return la(e,u,G[256]),u+Z[256]},AT=new As([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),TT=(function(){for(var n=new As(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),RT=function(n,e,t,r,i){return(function(s,o,a,l,c,u){var p=s.length,f=new Et(l+p+5*(1+Math.floor(p/7e3))+c),h=f.subarray(l,f.length-c),g=0;if(!o||p<8)for(var v=0;v<=p;v+=65535){var m=v+65535;m<p?g=cg(h,g,s.subarray(v,m)):(h[v]=u,g=cg(h,g,s.subarray(v,p)))}else{for(var y=AT[o-1],w=y>>>13,x=8191&y,_=(1<<a)-1,k=new rt(32768),I=new rt(_+1),b=Math.ceil(a/3),A=2*b,M=function(Ps){return(s[Ps]^s[Ps+1]<<b^s[Ps+2]<<A)&_},J=new As(25e3),$=new rt(288),U=new rt(32),G=0,Z=0,te=(v=0,0),ye=0,pe=0;v<p;++v){var j=M(v),X=32767&v,Oe=I[j];if(k[X]=Oe,I[j]=X,ye<=v){var Ye=p-v;if((G>7e3||te>24576)&&Ye>423){g=v0(s,h,0,J,$,U,Z,te,pe,v-pe,g),te=G=Z=0,pe=v;for(var De=0;De<286;++De)$[De]=0;for(De=0;De<30;++De)U[De]=0}var Je=2,Xe=0,Pn=x,Lt=X-Oe&32767;if(Ye>2&&j==M(v-Lt))for(var $s=Math.min(w,Ye)-1,R=Math.min(32767,v),Y=Math.min(258,Ye);Lt<=R&&--Pn&&X!=Oe;){if(s[v+Je]==s[v+Je-Lt]){for(var B=0;B<Y&&s[v+B]==s[v+B-Lt];++B);if(B>Je){if(Je=B,Xe=Lt,B>$s)break;var fe=Math.min(Lt,B-2),he=0;for(De=0;De<fe;++De){var se=v-Lt+De+32768&32767,Re=se-k[se]+32768&32767;Re>he&&(he=Re,Oe=se)}}}Lt+=(X=Oe)-(Oe=k[X])+32768&32767}if(Xe){J[te++]=268435456|og[Je]<<18|ag[Xe];var Xt=31&og[Je],Qt=31&ag[Xe];Z+=Vg[Xt]+Ug[Qt],++$[257+Xt],++U[Qt],ye=v+Je,++G}else J[te++]=s[v],++$[s[v]]}}g=v0(s,h,u,J,$,U,Z,te,pe,v-pe,g)}return $w(f,0,l+Iw(g)+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)},ph=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function IT(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=TT[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=n.length;t.p(n);var i,s=RT(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&&ph(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),ph(s,o-8,t.d()),ph(s,o-4,r),s}var $T=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
|
|
625
625
|
`).replace(/\r/g,`
|
|
626
|
-
`)).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),Mt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},PT=!!wh||!!bh,y0="text/plain",Eu=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=W({},e),a=(r=s?.split("&").map((c=>{var u,[p,f]=c.split("="),h=t&&(u=o[p])!==null&&u!==void 0?u:f;return delete o[p],p+"="+h})))!==null&&r!==void 0?r:[],l=sT(o);return l&&a.push(l),i+"?"+a.join("&")},_a=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),fh=n=>{var{data:e,compression:t}=n;if(e){if(t===Tn.GZipJS){var r=IT((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new Et(l.length+(l.length>>>1)),f=0,h=function(y){p[f++]=y},g=0;g<u;++g){if(f+5>p.length){var v=new Et(f+8+(u-g<<1));v.set(p),p=v}var m=l.charCodeAt(g);m<128||c?h(m):m<2048?(h(192|m>>>6),h(128|63&m)):m>55295&&m<57344?(h(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++g))>>>18),h(128|m>>>12&63),h(128|m>>>6&63),h(128|63&m)):(h(224|m>>>12),h(128|m>>>6&63),h(128|63&m))}return $w(p,0,f)})(_a(e)),{mtime:0}),i=new Blob([r],{type:y0});return{contentType:y0,body:i,estimatedSize:i.size}}if(t===Tn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=$T(l);do c=(h=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=h>>12&63,p=h>>6&63,f=63&h,w[m++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(f);while(v<l.length);switch(y=w.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(_a(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:_a(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=_a(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},au=[];bh&&au.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=fh(n))!==null&&e!==void 0?e:{},o=new Headers;xe(n.headers,(function(u,p){o.append(p,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(Db){var c=new Db;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}bh(a,W({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((p=>{var f={statusCode:u.status,text:p};if(u.status===200)try{f.json=JSON.parse(p)}catch(h){V.error(h)}n.callback==null||n.callback(f)})))).catch((u=>{V.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),wh&&au.push({transport:"XHR",method:n=>{var e,t=new wh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=fh(n))!==null&&e!==void 0?e:{};xe(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&&au.push({transport:"sendBeacon",method:n=>{var e=Eu(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=fh(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var Cu=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 _0(n,e,t){return _a({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Pw={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=>Cu(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Cu(t,r))))),icontains:(n,e)=>e.map(su).some((t=>n.map(su).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(su).every((t=>n.map(su).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)))}))},su=n=>n.toLowerCase();function Ow(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Mt(s))return!1;var o=[String(s)],a=Pw[i.operator];return!!a&&a(i.values,o)}))}var hh=Pe("[Error tracking]"),ug=class{constructor(e){var t,r;this.Zt=[],this.ti=new Rh([new $h,new Dh,new Oh,new Ph,new Nh,new Lh,new Mh,new Fh],V1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Bh))!==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({[Bh]:this.Zt,[Jb]:o})}get ii(){var e,t=!!this._instance.get_property(Jb),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 hh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void hh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void hh.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 Ve(s)&&s.length>0&&r.$exception_types.push(s),Ve(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=Pw[s.operator],l=_e(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!ve(e)&&_e(e)}},ft=Pe("[FeatureFlags]"),ua=Pe("[FeatureFlags]",{debugEnabled:!0}),gh="$active_feature_flags",ms="$override_feature_flags",b0="$feature_flag_payloads",da="$override_feature_flag_payloads",w0="$feature_flag_request_id",x0="$feature_flag_evaluated_at",S0=n=>{var e={};for(var[t,r]of ou(n||{}))r&&(e[t]=r);return e},OT=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]})))):ft.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},MT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),dg=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||(ft.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||ft.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(Vh),t=this._instance.get_property(ms),r=this._instance.get_property(da);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],p=H(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,f=H(u)?c.variant:typeof u=="string"?u:void 0,h=r?.[o],g=W({},c,{enabled:p,variant:p?f??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),f!==c?.variant&&(g.original_variant=c?.variant),h&&(g.metadata=W({},c?.metadata,{payload:h,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(ft.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(xs),t=this._instance.get_property(ms);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||(ft.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(b0),t=this._instance.get_property(da);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||(ft.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:W({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(ya)||{}),group_properties:this._instance.get_property(si)};Mt(i)||H(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=Aw()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,f,h=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),h=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((f=u.json)!==null&&f!==void 0?f:{})),!s.disable_flags||this.hi)if(this.vi=!h,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(MT.FeatureFlags))ft.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 g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},h),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}ft.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(w0)||void 0,c=this._instance.get_property(x0)||void 0,u=this._instance.get_property(pu)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,f,h,g,v,m,y,w,x;_e(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[pu]:u});var _=this.getFeatureFlagDetails(e),k={$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:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((h=this._instance.config.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.vi};H(_==null||(g=_.metadata)==null?void 0:g.version)||(k.$feature_flag_version=_.metadata.version);var I,b=(v=_==null||(m=_.reason)==null?void 0:m.description)!==null&&v!==void 0?v:_==null||(y=_.reason)==null?void 0:y.code;b&&(k.$feature_flag_reason=b),_!=null&&(w=_.metadata)!=null&&w.id&&(k.$feature_flag_id=_.metadata.id),H(_?.original_variant)&&H(_?.original_enabled)||(k.$feature_flag_original_response=H(_.original_variant)?_.original_enabled:_.original_variant),_!=null&&(x=_.metadata)!=null&&x.original_payload&&(k.$feature_flag_original_payload=_==null||(I=_.metadata)==null?void 0:I.original_payload),this._instance.capture("$feature_flag_called",k)}if(i){var A=o;if(!H(o))try{A=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:A}}}else ft.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:Tn.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 H(r)?void 0:!!r}ft.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 p=OT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){ft.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(h)for(var w=0;w<h.length;w++)y[h[w]]=!0;a&&a.register({[gh]:h,[xs]:y})}else{var x=h,_=g,k=f;if(o.errorsWhileComputingFlags)if(f){var I=new Set(Object.keys(f).filter((b=>{var A;return!((A=f[b])!=null&&A.failed)})));x=W({},l,Object.fromEntries(Object.entries(x).filter((b=>{var[A]=b;return I.has(A)})))),_=W({},c,Object.fromEntries(Object.entries(_||{}).filter((b=>{var[A]=b;return I.has(A)})))),k=W({},u,Object.fromEntries(Object.entries(k||{}).filter((b=>{var[A]=b;return I.has(A)}))))}else x=W({},l,x),_=W({},c,_),k=W({},u,k);a&&a.register(W({[gh]:Object.keys(S0(x)),[xs]:x||{},[b0]:_||{},[Vh]:k||{}},v?{[w0]:v}:{},m?{[x0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ft.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ft.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ms),this._instance.persistence.unregister(da),this.wi(),ua.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(ms),ua.info("Flag overrides cleared");else if(r.flags){if(_e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[ms]:i})}else this._instance.persistence.register({[ms]:r.flags});ua.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(da),ua.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[da]:r.payloads}),ua.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(va)||[]).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=W({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[gh]:Object.keys(S0(l)),[xs]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(va),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(va),(l=this._instance.persistence)==null||l.register({[va]: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(ya)||{};this._instance.register({[ya]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ya)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(si)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[si]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(si)||{};this._instance.register({[si]:W({},t,{[e]:{}})})}else this._instance.unregister(si)}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}},LT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Sa=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&&V.info("Persistence loaded",e.persistence,W({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){LT.indexOf(e.persistence.toLowerCase())===-1&&(V.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=[...pT,...i];return W({},Te,{W:function(o){try{var a={};try{a=Yt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Te.q(o)||"{}"));return Te.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{Te.G(o,a,void 0,void 0,p);var f={};s.forEach((h=>{a[h]&&(f[h]=a[h])})),Object.keys(f).length&&Yt.G(o,f,l,c,u,p)}catch(h){Te.B(h)}},V:function(o,a){try{S?.localStorage.removeItem(o),Yt.V(o,a)}catch(l){Te.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Te.H()?Te:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&ze.H()?ze:r==="memory"?fT:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===xs&&Be(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,(Mt(o=K1)?l:Fb&&o.indexOf===Fb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return uu})),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(Be(e)){H(t)&&(t="None"),this.Pi=H(r)?this.Ci:r;var i=!1;if(xe(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(Be(e)){this.Pi=H(t)?this.Ci:t;var r=!1;if(xe(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=ww(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ws(Fg(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?Sw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Ew(),$referring_domain:D!=null&&D.referrer&&((e=vu(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[zh]||this.props[qh]||this.register_once({[fu]:Cw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([qh,zh],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+xh(c)]=l}))}));var t,r,i=this.props[fu];if(i){var s=(t=kw(i),r={},xe(t,(function(o,a){r["$initial_"+xh(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return xe(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,p)=>u===c[p]))})(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[ma]||{};r[e]=t,this.props[ma]=r,this.save()}remove_event_timer(e){var t=(this.props[ma]||{})[e];return H(t)||(delete this.props[ma][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},E0=Pe("[Product Tours]"),mh="ph_product_tours",pg=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Qb]:!(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(Qb)||this.it((()=>this.Oi()))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?E0.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=ee.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=ee.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!_e(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[mh];if(_e(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 E0.error(a),void e([],{isLoaded:!1,error:a})}var l=_e(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[mh]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){ve(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(mh)}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)}},pa=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),SD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),ED=(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})({}),CD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),vh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),kD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),AD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),TD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),ba=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),yh=(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})({}),fg=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Pe("[Surveys]"),Mw="seenSurvey_",NT=(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},C0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(Mw,n),FT=[vh.Popover,vh.Widget,vh.API],DT={ignoreConditions:!1,ignoreDelay:!1,displayType:fg.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 vs(n,e,t){if(ve(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 hg=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(!H((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(!H((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"||!vs(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=>vs(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&vs((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=>vs(c.text,t.text,t.text_matching||"exact")||vs(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,p=[],f=/(?::|")text="(.*?)"/g;!ve(u=f.exec(c));)p.includes(u[1])||p.push(u[1]);return p})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>vs(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||Ow(t.properties.reduce(((r,i)=>{var s=_e(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)}},gg=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&Ow(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===pa.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;H((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 hg(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,pa.Activation),this.Yi=this.Zi(e,pa.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 p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var f=this.te(e,t,pa.Cancellation);f.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((g=>g.id))}),f.forEach((g=>{var v=a.indexOf(g.id);v>=0&&a.splice(v,1),this.ue(g.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var h=this.te(e,t,pa.Activation);this.le(a.concat(h.map((g=>g.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}},mg=class extends gg{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return ba.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()}},vg=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(ve(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=_e(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(Mw)||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=ee?.__PosthogExtensions__;if(e){if(!H(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 mg(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(Uh);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,p=s.json.surveys||[],f=p.filter((g=>(function(v){return!(!v.start_date||v.end_date)})(g)&&((function(v){var m;return!((m=v.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(g)||(function(v){var m;return!((m=v.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(g))));f.length>0&&((u=this._surveyEventReceiver)==null||u.register(f)),(o=this._instance.persistence)==null||o.register({[Uh]:p});var h={isLoaded:!0};e(p,h),r?.({surveys:p,context:h})}}))}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),!ve(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(ve(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(ve(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 ve(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(ve(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(FT.includes(s.type)){var o=D?.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(ve(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=W({},i,{appearance:W({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==fg.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!==fg.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){ve(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},En=Pe("[Conversations]"),yg=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;ve(t)||(In(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=ee?.__PosthogExtensions__;if(e&&!H(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 En.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),En.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else En.error("Cannot complete initialization: remote config is null")}Se(e,t){En.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():En.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Mt(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 bs((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(En.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return bs((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(En.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return bs((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(En.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return bs((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(En.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}},_g=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;!ve(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Pe("[logs]"),t=ee?.__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.")}}},k0=Pe("[RateLimiter]"),bg=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=>{k0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void k0.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(Wh))!==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(Wh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ii=Pe("[RemoteConfig]"),wg=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(ii.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 ii.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ii.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ii.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){ii.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()):ii.info("__preview_remote_config is disabled. Logging config instead",e):ii.error("Failed to fetch remote config from PostHog.")}},xg=3e3,Sg=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||xg,250,5e3,V.createLogger("flush interval"),xg),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(W({},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&&_e(s.data)&&xe(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 xe(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;H(e[s])&&(e[s]=W({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},HT=["retriesPerformedSoFar"],Eg=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!H(S)&&"onLine"in S.navigator&&(this.Ue=S.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Fe(S,"online",this.ze),Fe(S,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=P0(e,HT);ys(t)&&(r.url=Eu(r.url,{retry_count:t})),this._instance._send_request(W({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(W({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)"),V.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,H(S)||(this.ze&&(S.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(S.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(W({},e,{transport:"sendBeacon"}))}catch(t){V.error(t)}this.Re=[]}},Cg=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(){Fe(S,"scroll",this.Ge,{capture:!0}),Fe(S,"scrollend",this.Ge,{capture:!0}),Fe(S,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return S?.document.documentElement;var e=_e(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=S?.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 S&&(S.scrollY||S.pageYOffset||S.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return S&&(S.scrollX||S.pageXOffset||S.document.documentElement.scrollLeft)||0}},BT=n=>Cw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),ku=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({[jh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||BT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[jh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?kw(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 xe(Fg(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+xh(r)]=t})),e}},_h=Pe("[SessionId]"),Au=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,p)=>!(!ys(u)||!ys(p))&&Math.abs(u-p)>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||cr,this.ar=r||cr;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Jt(o,60,36e3,_h.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=ze.W(this.ur),l=ze.W(this.hr);a&&!l?this.rr=a:ze.V(this.ur),ze.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){_h.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(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&&ze.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&ze.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?ze.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({[du]:[t,e,r]}))}_r(){var e=this.Xe.props[du];return _e(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&&S&&(S.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&ze.V(this.hr)},Fe(S,"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=ys(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),_h.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var f=ys(i)&&e&&!l?i:r,h=ys(o)?o:new Date().getTime();return this.pr(a),this.vr(s,f,h),e||this.lr(),c&&this.tr.forEach((g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:c?{noSessionId:u,activityTimeout:p,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)}},VT=["$set_once","$set"],ar=Pe("[SiteApps]"),kg=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=ee._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")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[f,h]of Object.entries(p))c[f]={id:u[f],type:f,properties:h};var{$set_once:g,$set:v}=e;return{event:W({},P0(e,VT),{properties:W({},e.properties,v?{$set:W({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},g?{$set_once:W({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),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&&(ar.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,ar.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){ar.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){ar.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){ar.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 ar.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;ee["__$$ph_site_app_"+c]=s._instance,(u=ee.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(p=>{if(p)return ar.error("Error while initializing PostHog app with config id "+c,p)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Lw=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Bb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Bb(i?.brand,e))))return!0}catch{}return!!n.webdriver},wa=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),A0="i.posthog.com",Ag=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("."+A0,".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]=wa.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=wa.EU:this.Sr[this.apiHost]=wa.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===wa.CUSTOM)return this.apiHost+t;var r=A0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},UT={icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!S&&Cu(e.href,n),not_regex:(n,e)=>!!S&&!Cu(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Tg=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);Ve(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(ve(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=yu(e?.search,"__experiment_id"),r=yu(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!ve(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(ve(e.conditions)||ve((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||UT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return S?.location}static Fr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.utm))return!0;var r=ww();if(r.utm_source){var i,s,o,a,l,c,u,p,f=(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,h=(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,g=(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,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return f&&g&&v&&h}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];V.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?Lw(ht,this._instance.config.custom_blocked_useragents):void 0}},jT=Pe("[PostHog ExternalIntegrations]"),WT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Rg=class{constructor(e){this._instance=e}it(e,t){var r;(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return jT.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=ee.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(WT[o],(()=>{var u;(u=ee.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=ee.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=ee.__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)}}},Ig="[SessionRecording]",fa=Pe(Ig),Tu=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 fa.error("started without valid sessionManager"),new Error(Ig+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ig+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(oh))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return S&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!H(Object.assign)&&!H(Array.from);this.Ar&&r?(this.Dr(e),fa.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(ee!=null&&(t=ee.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=ee.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=ee.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return fa.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(iw)}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=ve(a)?null:parseFloat(a);ve(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[oh]:W({enabled:!!o},o,{networkPayloadCapture:W({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:H(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:fa.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):fa.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(oh);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=ee.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=ee.__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))}},Ea={},$g=()=>{},_s="posthog",Nw=!PT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,T0=n=>{var e;return W({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:G1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:$g,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:qe&&Ve(qe?.search)&&qe.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:(S==null||(e=S.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;V.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:xg},error_tracking:{},_onCapture:$g,__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))},R0=n=>{var e={};H(n.process_person)||(e.person_profiles=n.process_person),H(n.xhr_headers)||(e.request_headers=n.xhr_headers),H(n.cookie_name)||(e.persistence_name=n.cookie_name),H(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),H(n.store_google)||(e.save_campaign_params=n.store_google),H(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return _e(n.property_blacklist)&&(H(n.property_denylist)?t.property_denylist=n.property_blacklist:_e(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:V.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Pg=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Ru=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 Pg,this.Br=!1,this.version=Cn.LIB_VERSION,this.qr=new Ia,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=T0(),this.SentryIntegration=tg,this.sentryIntegration=e=>(function(t,r){var i=bw(t,r);return{name:_w,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 dg(this),this.toolbar=new ng(this),this.scrollManager=new Cg(this),this.pageViewManager=new wu(this),this.surveys=new vg(this),this.conversations=new yg(this),this.logs=new _g(this),this.experiments=new Tg(this),this.exceptions=new ug(this),this.rateLimiter=new bg(this),this.requestRouter=new Ag(this),this.consent=new Xh(this),this.externalIntegrations=new Rg(this),this.people={set:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>V.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==_s){var i,s=(i=Ea[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Ea[r]=s,Ea[_s][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||Sh(e))return V.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({},T0(t.defaults),R0(t),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Tn.GZipJS;var s=this.Qr();this.persistence=new Sa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sa(W({},this.config,{persistence:"sessionStorage"}),s);var o=W({},this.persistence.props),a=W({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Sg((w=>this.ts(w)),this.config.request_queue_config),this.es=new Eg(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 Au(this),this.sessionPropsManager=new ku(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(V.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(V.info("Initializing extensions synchronously"),this.rs(l)),Cn.DEBUG=Cn.DEBUG||this.config.debug,Cn.DEBUG&&V.info("Starting in debug mode",{this:this,config:t,thisC:W({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(cr()),f=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(kn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:f})}if(this.ss()){var h,g,v=Object.keys(((h=t.bootstrap)==null?void 0:h.featureFlags)||{}).filter((w=>{var x;return!((x=t.bootstrap)==null||(x=x.featureFlags)==null||!x[w])})).reduce(((w,x)=>{var _;return w[x]=((_=t.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[x])||!1,w}),{}),m=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter((w=>v[w])).reduce(((w,x)=>{var _,k;return(_=t.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[x]&&(w[x]=(k=t.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[x]),w}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:sa,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(cr());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(kn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?mT(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==$g&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(w=>this.config._onCapture(w.event,w)))),this.config.ip&&V.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 eg(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new rg(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new kg(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Tu(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new Gh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new pg(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new sg(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new ig(this)})),r.push((()=>{this.exceptionObserver=new Qh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new bu(this,gT),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){V.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&&V.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!D||!D.body)return V.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=me(e.supportedCompression,Tn.GZipJS)?Tn.GZipJS:me(e.supportedCompression,Tn.Base64)?Tn.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){V.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&qe!=null&&qe.hostname){var e=qe.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 wg(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()&&dr(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&&(Nw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Eu(e.url,{ip:this.config.ip?1:0}),e.headers=W({},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=W({},t);o.timeout=o.timeout||6e4,o.url=Eu(o.url,{_:new Date().getTime().toString(),ver:Cn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=au.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=tw(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)})(W({},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=[];dr(e,(a=>{a&&(t=a[0],_e(t)?s.push(a):ur(a)?a.call(this):_e(a)&&t==="alias"?r.push(a):_e(a)&&t.indexOf("capture")!==-1&&ur(this[t])?s.push(a):i.push(a))}));var o=function(a,l){dr(a,(function(c){if(_e(c[0])){var u=l;xe(c,(function(p){u=u[p[0]].apply(u,p.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(!H(e)&&Ve(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&&!Ve(t?.$current_url)&&(V.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=cr(),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 p,f=e!=="$groupidentify",h=this.vs(r?.$set_once,f);if(h&&(u.$set_once=h),(u=q1(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,H(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ba.DISMISSED||e===ba.SENT){var g=t?.[yh.SURVEY_ID],v=t?.[yh.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(C0(p))||localStorage.setItem(C0(p),"true"),u.$set=W({},u.$set,{[NT({id:g,current_iteration:v},e===ba.SENT?"responded":"dismissed")]:!0})}else e===ba.SHOWN&&(u.$set=W({},u.$set,{[yh.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(ws(m)||this.setPersonPropertiesForFlags(m),!ve(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var w={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(w):this.Zr.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.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=W({},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=W({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Ve(a.distinct_id)&&!$n(a.distinct_id)||Sh(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=xT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=f}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.es)==null?void 0:h.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===wa.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"&&D&&(a.title=D.title),!H(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}ct&&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(),_e(this.config.property_denylist)?xe(this.config.property_denylist,(function(y){delete a[y]})):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=v(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&&(V.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),ws(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=W({},i,e),a=W({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:H(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=DT),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 V.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),V.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()))V.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!==sa){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(ga)&&(this.unregister(ga),this.register({distinct_id:e}));var o=(this.persistence.get_property(kn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(kn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=_0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(pu))}}else V.critical('The string "'+sa+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=_0(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(W({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):V.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:W({},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 V.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(V.info("reset"),!this.__loaded)return V.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(kn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:sa,$device_id:null},"");else{var a=this.config.get_device_id(cr());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(nw)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(ga,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=W({},this.config);if(Be(e)){var r,i,s,o,a,l,c;Me(this.config,R0(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 Sa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);In(p)&&(this.config.debug=p),In(this.config.debug)&&(this.config.debug?(Cn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(Cn.DEBUG=!1,Te.H()&&Te.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(W({},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:_s;return t!==_s&&(t=_s+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(kn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(kn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ws(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[ga])&&((t=this.persistence)==null||(t=t.props)==null||!t[hu]))}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"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(hu,!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 Au(this),this.pageViewManager=new wu(this),this.persistence&&(this.sessionPropsManager=new ku(this,this.sessionManager,this.persistence)),this.sessionRecording=new Tu(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(),(H(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 V.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:sa,$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())):V.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===An.GRANTED?"granted":e===An.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?Lw(ht,this.config.custom_blocked_useragents):void 0}hs(){D&&(D.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:D.title},{send_instantly:!0}),this.Gr&&(D.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Fe(D,"visibilitychange",this.Gr)))}debug(e){e===!1?(S?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(S?.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?(V.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=V,o=(t="advanced_disable_flags")in(e=l)&&!ve(e[t]),a=r in e&&!ve(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(ve(this.config.before_send))return e;var t=_e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),ve(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return _1(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!ws(r.properties)||V.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=In(e)&&!e,r=Te.H()&&Te.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=z1(n.prototype[e[t]])})(Ru,["identify"]);var I0;var Fw=(I0=Ea[_s]=new Ru,(function(){function n(){n.done||(n.done=!0,Nw=!1,xe(Ea,(function(e){e._dom_loaded()})))}D!=null&&D.addEventListener?D.readyState==="complete"?n():Fe(D,"DOMContentLoaded",n,{capture:!1}):S&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),I0);var jg=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};e.cookieless_mode&&(o.cookieless_mode=e.cookieless_mode);let a=Fw.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,p=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,p)}),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)}optInCapturing(){this.client?.opt_in_capturing()}optOutCapturing(){this.client?.opt_out_capturing()}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 Ou(n={}){return new jg(n)}var Dw={posthog:n=>Ou(n),noop:()=>eu()};function Hw(n,e){let t=Dw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(Dw).join(", ")}`);return t(e)}function zT(n){return n?.manifest?.runtime!==void 0}async function Bw(n){Np(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Ec();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",Vo()),console.log("[DIAG] editorConf:",Sc()),q("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let R=!!window.__SYNTRO_EDITOR_PARAMS__,Y=!!window.__SYNTRO_AUDIT_LEGEND__,B=!!window.__SYNTRO_REVIEW_DATA__;if(R||Y||B){let fe=[R&&"__SYNTRO_EDITOR_PARAMS__",Y&&"__SYNTRO_AUDIT_LEGEND__",B&&"__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 Y=Sc()?.syntro_token;Y?.startsWith("syn_")&&(t=Y,q("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))q("Syntro Bootstrap","Token starts with syn_, decoding..."),r=ns(t),Np(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw oc("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),oc("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)q("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw oc("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=xt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||xt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=xt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||xt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th;if(r!=null&&r.obd!==!0&&s)try{let R=`${s.replace(/\/$/,"")}/sdk-otel/v1/logs`,Y=Fp({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:Zi,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Hp({endpoint:R})}),B=Vp()??"https://cdn.syntrologie.com/runtime-sdk/",fe=tf(Y,{attributedScriptUrlPrefix:B});Y.attachAdapterCleanup(fe)}catch{}let o=xt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||xt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||xt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||xt("VITE_SYNTRO_GEO_HOST")||w_,l=h_(),c=wf(),u=n.appSignalsInit??{},p=__(),f=xf(c,p);b_(f);let h={...c,...f,...l,...u};q("Syntro Bootstrap","Phase 1: Browser metadata:",c),q("Syntro Bootstrap","Phase 1: Initial attrs:",f),q("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&q("Syntro Bootstrap","Phase 1: App signals:",u);let g=Sf(a),v=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(R=>{let Y=setTimeout(()=>{window.removeEventListener("message",B),R(null)},500);function B(fe){let he=fe.data;he?.jsonrpc==="2.0"&&he?.id===1&&he?.result?.hostInfo&&(clearTimeout(Y),window.removeEventListener("message",B),R(he.result.hostInfo))}window.addEventListener("message",B);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(Y),window.removeEventListener("message",B),R(null)}})})(),m,y=n.debug||n.testMode,w=Bi({debug:n.debug,history:y?new os(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=Ed({elementResolver:typeof window<"u"?(R,Y)=>{let B=document.elementFromPoint(R,Y);if(!B)return null;let fe={tag_name:B.tagName.toLowerCase()};B.id&&(fe.attr__id=B.id),B.className&&typeof B.className=="string"&&(fe.classes=B.className.split(" ").filter(Boolean));for(let he of B.attributes)he.name.startsWith("data-")&&(fe[`attr__${he.name}`]=he.value);return fe}:void 0});if(x.onEvent(R=>w.publishEvent(R)),typeof window<"u")try{Sb(w),Eb(w)}catch(R){We("Syntro Bootstrap","scroll instrumentation install failed",R)}typeof window<"u"&&(setInterval(()=>x.tick(Date.now()),1e3),document.addEventListener("click",R=>{let Y=[],B=R.target;for(;B&&B!==document.body;){let fe={tag_name:B.tagName.toLowerCase()};for(let he of B.attributes)(he.name.startsWith("data-")||he.name==="id"||he.name==="class"||he.name==="aria-label")&&(fe[`attr__${he.name}`]=he.value);Y.push(fe),B=B.parentElement}x.enrichClickAttributes(Date.now(),Y)},!0));let _=kb(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=v_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),g_(Y),m){let B=A?.getAll?.()??{},fe=is(b?.getDistinctId?.()),he={...c,...f,...B,...Y,...u,id:fe};q("Syntro Bootstrap","Updating GrowthBook with attributes:",he),m.setAttributes?.(he)}if(k&&b?.getDistinctId){let B=b.getDistinctId();B&&s&&r?.t&&k.updateContext({distinctId:B,telemetryHost:s,telemetryKey:r.t})}},b;if(r?.t){let R=r.t==="noop"?"noop":"posthog";if(b=Hw(R,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,cookieless_mode:"on_reject",onFeatureFlagsLoaded:I,onCapture:(se,Re)=>{x.ingest({kind:"posthog",event:se,properties:Re,timestamp:Date.now()})},onRRWebEvent:se=>{x.ingest(se)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${R}) with EventBus wiring`),b){let se=b.getDistinctId?.bind(b);b.getDistinctId=()=>is(se?.())}try{b.track?.("syntro_bootstrap_step",{stage:"telemetry_ready"})}catch{}Object.keys(u).length>0&&(b.track?.("app_signals_init",u),q("Syntro Bootstrap","Tracked app signals event:",u));let Y=b;w.setPosthogCapture((se,Re)=>{Y.track?.(se,Re)});let B=b,fe=async()=>{let se=await g;return se.is_eu==="true"||se.country_code==="GB"||se.country_code==="CH"?"denied":"granted"},he=new ia({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{m_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{P_(b,he,{geoPromise:g}),q("Syntro Bootstrap","SDK defaults installed (D-1..D-5) with consent gate");try{B.track?.("syntro_bootstrap_step",{stage:"defaults_installed"})}catch{}}catch(se){We("Syntro Bootstrap","installDefaults failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"defaults_install_failed",err:String(se)})}catch{}}try{let se=new ra({adapters:[new na,new ta,new ea],fallbackStatus:fe,onAdapterSelected:Re=>{B.track?.("syntro_consent_adapter_selected",{adapter:Re??"none"}),q("Syntro Bootstrap",`Consent adapter selected: ${Re??"none"}`)}});try{B.track?.("syntro_bootstrap_step",{stage:"detector_started"})}catch{}se.start(he).then(()=>{try{B.track?.("syntro_bootstrap_step",{stage:"detector_resolved"})}catch{}}).catch(Re=>{We("Syntro Bootstrap","Consent detector failed to start",Re);try{B.track?.("syntro_bootstrap_step",{stage:"detector_failed",err:String(Re)})}catch{}})}catch(se){We("Syntro Bootstrap","Consent detector setup failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"detector_setup_failed",err:String(se)})}catch{}}try{k=k_({telemetry:b,telemetryHost:s,telemetryKey:r.t,platformAdapter:_,debug:q,warn:We}).shopifyPixelBridge}catch(se){We("Syntro Bootstrap","wirePlatformAdapters failed",se)}}let A;r?.e&&(m=yb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:is(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=Jc({experiments:m,onMetricChange:(R,Y)=>{q("Syntro Bootstrap",`Session metric changed: ${R} = ${Y}`)}}),q("Syntro Bootstrap","SessionMetricTracker created");let M="production";e==="editor"?M="editor":e==="audit"?M="audit":xt("NODE_ENV")==="development"&&(M="development");let J=typeof c.surface_type=="string"?c.surface_type:"web",$=typeof c.surface_host=="string"?c.surface_host:"web",U=tc({telemetry:b,sessionMetrics:A,mode:M,events:w,initialSurfaceType:J,initialSurfaceHost:$,backendUrl:n.backendUrl});_&&(U.getProductIdentity=R=>_.extractProductIdentity(R)),q("Syntro Bootstrap","Runtime created:",{version:U.version,mode:U.mode,hasContext:!!U.context,hasEvents:!!U.events,hasState:!!U.state,hasProductIdentity:!!U.getProductIdentity});let G=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return"unknown";let Y=await Ob({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.({[R.name]:Y}),Y},Z=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return R.map(()=>"unknown");let Y=await Pb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.(Object.fromEntries(R.map((B,fe)=>[B.name,Y[fe]]))),Y},te=(R,Y)=>{if(!n.backendUrl)throw new Error("[syntro] authedFetch: no backendUrl configured");let B=n.backendUrl.replace(/\/$/,""),fe=/^https?:\/\//.test(R)?R:`${B}${R.startsWith("/")?R:`/${R}`}`;if(new URL(fe).origin!==new URL(B).origin)throw new Error("[syntro] authedFetch: refusing cross-origin request (token would leak)");let he={};t&&(he.Authorization=`Bearer ${t}`);let se=b?.getDistinctId?.();se&&(he["X-Distinct-Id"]=se);let Re=b?.getSessionId?.();return Re&&(he["X-Syntro-Session"]=Re),fetch(fe,{...Y,credentials:"include",headers:{"Content-Type":"application/json",...Y?.headers,...he}})};q("Syntro Bootstrap","Core app executors already registered");let ye=n.cdnBase||xt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||xt("VITE_SYNTRO_CDN_BASE")||$l()||"https://cdn.syntrologie.com",pe=rd({cdnBase:ye,registry:U.apps,onLoadStart:R=>{q("Syntro Bootstrap",`Loading app from CDN: ${R}`)},onLoadEnd:(R,Y,B)=>{Y?q("Syntro Bootstrap",`App loaded successfully: ${R}`):We("Syntro Bootstrap",`Failed to load app: ${R}`,B)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:U.apps,appLoader:pe,runtime:U,experiments:m,score:G,scoreMulti:Z,authedFetch:te,version:U.version},q("Syntro Bootstrap","Global SynOS object exposed")),typeof window<"u"&&window.parent!==window&&pe.loadApp("adaptive-mcp").catch(R=>{q("Syntro Bootstrap","auto-load of adaptive-mcp failed (non-fatal):",R)});let j=U.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${j.length} apps in registry:`,j.map(R=>`${R.manifest.id}(${R.state})`).join(", "));for(let R of j)if(R.state==="registered"&&zT(R))try{await U.apps.activate(R.manifest.id),console.log(`[DIAG] Activated: ${R.manifest.id} \u2192 widgets: [${U.widgets.list().join(", ")}]`)}catch(Y){console.error(`[DIAG] FAILED to activate: ${R.manifest.id}`,Y),We("Syntro Bootstrap",`Failed to auto-activate built-in app: ${R.manifest.id}`,Y)}if(console.log(`[DIAG] Activation complete. Total widgets: [${U.widgets.list().join(", ")}]`),m?.refreshFeatures){let Y=performance.now(),B=!1,fe=!1;try{await Promise.race([m.refreshFeatures().then(()=>{}),new Promise(he=>setTimeout(()=>{B=!0,he()},500))]),q("Syntro Bootstrap","GrowthBook features loaded (or timeout reached)")}catch(he){fe=!0,We("Syntro Bootstrap","Failed to load GrowthBook features:",he)}try{b?.track?.("syntro_bootstrap_step",{stage:"gb_features_fetch",duration_ms:Math.round(performance.now()-Y),timeout_ms:500,timed_out:B,failed:fe})}catch{}}let X=await g;if(m&&Object.keys(X).length>0){let R={...c,...f,...X,...u,id:is(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Oe=await v;Oe&&m&&(c.surface_type="mcp-app",c.surface_host=Oe.name,m.setAttributes?.({...c,...f,...X,id:is(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Oe.name),q("Syntro Bootstrap","MCP App detected:",Oe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=xb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ur({experiments:m}));let De=new Set;function Je(R,Y){let B=pe.getRequiredApps(R);B.length>0?console.log("[Syntro Bootstrap] Required external apps:",B.join(", ")):q("Syntro Bootstrap","No external apps required (all executors are built-in)"),B.length!==0&&vl({appIds:B,loadApp:fe=>pe.loadApp(fe),apps:U.apps,warnedAppFailures:De}).catch(fe=>{console.error(`[Syntro Bootstrap] app loading (${Y}) rejected:`,fe)})}function Xe(R){return async()=>{let Y=await R();return Je(Y,"override"),Y}}let Pn=Ye?async()=>{let R=await Ye(),Y=R.tiles?.length??0,B=R.actions?.length??0,fe=R.meta?.variant_id,he=R.meta?.variants;if((Y>0||B>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),b&&fe){let se=typeof window<"u"?window.SynOS??(window.SynOS={}):void 0,Re=se?.interventionTracker,Xt;if(Re&&Re.variantId===fe)Xt=Re;else{let Qt=se?.interventionTrackerUnsub;if(Qt)try{Qt()}catch(Qw){console.warn("[Syntro] interventionTracker nav unsub threw:",Qw)}Xt=new gs(b,fe),se&&(se.interventionTracker=Xt);let Ps=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=Ps)}if(he&&he.length>0)for(let Qt of he)Xt.trackServedForVariant(Qt.variant_id,Qt.tiles,Qt.actions);else Xt.trackServed(Y,B)}return console.log("[Syntro Bootstrap] Config fetched:",`tiles=${R.tiles?.length??0},`,`actions=${R.actions?.length??0},`,`theme=${R.theme?.name??"none"}`),R.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",R.actions.map((se,Re)=>`[${Re}] ${se.kind}${se.anchorId?` anchor="${se.anchorId.selector}"`:""}${se.label?` "${se.label}"`:""}`).join(", ")),Je(R,"initial"),R}:void 0;if(_){q("Syntro Bootstrap",`Detected platform: ${_.name}`);try{await _.onInit(),q("Syntro Bootstrap",`Platform adapter initialized: ${_.name}`)}catch(R){We("Syntro Bootstrap",`Platform adapter init failed: ${_.name}`,R)}}if(typeof window<"u"){let R=window.SynOS??(window.SynOS={});R.wrapCanvasConfigFetcher=Xe}let Lt=await Cc({...n.canvas,fetcher:Pn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),$s=jt();if($s!==null)try{let R=b,Y=U;$s.bindRuntime({getSessionId:()=>{try{return R?.getSessionId?.()??""}catch{return""}},getSurface:()=>{try{let B=Y.context.get().surface;return B?{...B}:null}catch{return null}}})}catch{}return $s?.increment("bootstrap_ok"),{canvas:Lt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function qT(n){try{return await Bw(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),jt()?.increment("bootstrap_errors"),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function ZT(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}async function GT(n){if(typeof window>"u")return{appId:n,success:!1,error:"no-window"};let e=window.SynOS?.appLoader;return e?e.loadApp(n):{appId:n,success:!1,error:"syntro-not-initialized"}}var Wg={init:qT,loadAdaptive:GT,encodeToken:kc,decodeToken:ns,events:{emit:ZT}};typeof window<"u"&&(window.Syntro=Wg);function Is(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function KT(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=Is(i),o=Is(vn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${vn}. 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${vn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:YT(r,i)}):{valid:!0,warnings:e,errors:t}}function YT(n,e){let t={...n};return Is(e).major===1&&(t=JT(t)),t.schemaVersion=vn,t}function JT(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 XT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Is(t),i=Is(vn);return r.major<i.major||!e.schemaVersion}var Vw=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),Uw=d.object({url:d.string(),ts:d.number()}),jw=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(Uw).optional()}),Ww=d.object({width:d.number(),height:d.number()}),zw=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),qw=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:zw.optional()}),Zw=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),Gw=d.object({page:Vw,session:jw,viewport:Ww,anchors:d.array(qw).optional(),augmented:Zw.optional()});function QT(n){return Gw.safeParse(n)}var Mu=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 Lu=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 Nu=class{constructor(e,t,r,i){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 zg=d.enum(["posthog","canvas","derived"]),Kw=d.object({ts:d.number(),name:d.string(),source:zg,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),Yw=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(zg).optional()});function eR(n){return Kw.safeParse(n)}function tR(n){return Yw.safeParse(n)}var Jw=d.object({value:d.unknown(),expiresAt:d.number().optional()}),Xw=d.object({count:d.number(),resetAt:d.number().optional()});function nR(n){return Jw.safeParse(n)}function rR(n){return Xw.safeParse(n)}var qg="2026-07-24T18:59:36.948Z (31156e4c3)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${qg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||to;window.SynOS={...n,appRegistry:e,_runtimeBuild:qg,_renderer:"lit"},Do(),dv(e)}return sx(iR);})();
|
|
626
|
+
`)).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),Mt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},PT=!!wh||!!bh,y0="text/plain",Eu=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=W({},e),a=(r=s?.split("&").map((c=>{var u,[p,f]=c.split("="),h=t&&(u=o[p])!==null&&u!==void 0?u:f;return delete o[p],p+"="+h})))!==null&&r!==void 0?r:[],l=sT(o);return l&&a.push(l),i+"?"+a.join("&")},_a=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),fh=n=>{var{data:e,compression:t}=n;if(e){if(t===Tn.GZipJS){var r=IT((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new Et(l.length+(l.length>>>1)),f=0,h=function(y){p[f++]=y},g=0;g<u;++g){if(f+5>p.length){var v=new Et(f+8+(u-g<<1));v.set(p),p=v}var m=l.charCodeAt(g);m<128||c?h(m):m<2048?(h(192|m>>>6),h(128|63&m)):m>55295&&m<57344?(h(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++g))>>>18),h(128|m>>>12&63),h(128|m>>>6&63),h(128|63&m)):(h(224|m>>>12),h(128|m>>>6&63),h(128|63&m))}return $w(p,0,f)})(_a(e)),{mtime:0}),i=new Blob([r],{type:y0});return{contentType:y0,body:i,estimatedSize:i.size}}if(t===Tn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=$T(l);do c=(h=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=h>>12&63,p=h>>6&63,f=63&h,w[m++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(f);while(v<l.length);switch(y=w.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(_a(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:_a(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=_a(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},au=[];bh&&au.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=fh(n))!==null&&e!==void 0?e:{},o=new Headers;xe(n.headers,(function(u,p){o.append(p,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(Db){var c=new Db;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}bh(a,W({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((p=>{var f={statusCode:u.status,text:p};if(u.status===200)try{f.json=JSON.parse(p)}catch(h){V.error(h)}n.callback==null||n.callback(f)})))).catch((u=>{V.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),wh&&au.push({transport:"XHR",method:n=>{var e,t=new wh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=fh(n))!==null&&e!==void 0?e:{};xe(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&&au.push({transport:"sendBeacon",method:n=>{var e=Eu(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=fh(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var Cu=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 _0(n,e,t){return _a({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Pw={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=>Cu(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Cu(t,r))))),icontains:(n,e)=>e.map(su).some((t=>n.map(su).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(su).every((t=>n.map(su).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)))}))},su=n=>n.toLowerCase();function Ow(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Mt(s))return!1;var o=[String(s)],a=Pw[i.operator];return!!a&&a(i.values,o)}))}var hh=Pe("[Error tracking]"),ug=class{constructor(e){var t,r;this.Zt=[],this.ti=new Rh([new $h,new Dh,new Oh,new Ph,new Nh,new Lh,new Mh,new Fh],V1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Bh))!==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({[Bh]:this.Zt,[Jb]:o})}get ii(){var e,t=!!this._instance.get_property(Jb),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 hh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void hh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void hh.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 Ve(s)&&s.length>0&&r.$exception_types.push(s),Ve(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=Pw[s.operator],l=_e(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!ve(e)&&_e(e)}},ft=Pe("[FeatureFlags]"),ua=Pe("[FeatureFlags]",{debugEnabled:!0}),gh="$active_feature_flags",ms="$override_feature_flags",b0="$feature_flag_payloads",da="$override_feature_flag_payloads",w0="$feature_flag_request_id",x0="$feature_flag_evaluated_at",S0=n=>{var e={};for(var[t,r]of ou(n||{}))r&&(e[t]=r);return e},OT=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]})))):ft.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},MT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),dg=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||(ft.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||ft.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(Vh),t=this._instance.get_property(ms),r=this._instance.get_property(da);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],p=H(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,f=H(u)?c.variant:typeof u=="string"?u:void 0,h=r?.[o],g=W({},c,{enabled:p,variant:p?f??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),f!==c?.variant&&(g.original_variant=c?.variant),h&&(g.metadata=W({},c?.metadata,{payload:h,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(ft.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(xs),t=this._instance.get_property(ms);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||(ft.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(b0),t=this._instance.get_property(da);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||(ft.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:W({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(ya)||{}),group_properties:this._instance.get_property(si)};Mt(i)||H(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=Aw()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,f,h=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),h=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((f=u.json)!==null&&f!==void 0?f:{})),!s.disable_flags||this.hi)if(this.vi=!h,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(MT.FeatureFlags))ft.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 g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},h),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}ft.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(w0)||void 0,c=this._instance.get_property(x0)||void 0,u=this._instance.get_property(pu)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,f,h,g,v,m,y,w,x;_e(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[pu]:u});var _=this.getFeatureFlagDetails(e),k={$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:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((h=this._instance.config.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.vi};H(_==null||(g=_.metadata)==null?void 0:g.version)||(k.$feature_flag_version=_.metadata.version);var I,b=(v=_==null||(m=_.reason)==null?void 0:m.description)!==null&&v!==void 0?v:_==null||(y=_.reason)==null?void 0:y.code;b&&(k.$feature_flag_reason=b),_!=null&&(w=_.metadata)!=null&&w.id&&(k.$feature_flag_id=_.metadata.id),H(_?.original_variant)&&H(_?.original_enabled)||(k.$feature_flag_original_response=H(_.original_variant)?_.original_enabled:_.original_variant),_!=null&&(x=_.metadata)!=null&&x.original_payload&&(k.$feature_flag_original_payload=_==null||(I=_.metadata)==null?void 0:I.original_payload),this._instance.capture("$feature_flag_called",k)}if(i){var A=o;if(!H(o))try{A=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:A}}}else ft.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:Tn.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 H(r)?void 0:!!r}ft.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 p=OT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){ft.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(h)for(var w=0;w<h.length;w++)y[h[w]]=!0;a&&a.register({[gh]:h,[xs]:y})}else{var x=h,_=g,k=f;if(o.errorsWhileComputingFlags)if(f){var I=new Set(Object.keys(f).filter((b=>{var A;return!((A=f[b])!=null&&A.failed)})));x=W({},l,Object.fromEntries(Object.entries(x).filter((b=>{var[A]=b;return I.has(A)})))),_=W({},c,Object.fromEntries(Object.entries(_||{}).filter((b=>{var[A]=b;return I.has(A)})))),k=W({},u,Object.fromEntries(Object.entries(k||{}).filter((b=>{var[A]=b;return I.has(A)}))))}else x=W({},l,x),_=W({},c,_),k=W({},u,k);a&&a.register(W({[gh]:Object.keys(S0(x)),[xs]:x||{},[b0]:_||{},[Vh]:k||{}},v?{[w0]:v}:{},m?{[x0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ft.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ft.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ms),this._instance.persistence.unregister(da),this.wi(),ua.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(ms),ua.info("Flag overrides cleared");else if(r.flags){if(_e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[ms]:i})}else this._instance.persistence.register({[ms]:r.flags});ua.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(da),ua.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[da]:r.payloads}),ua.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(va)||[]).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=W({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[gh]:Object.keys(S0(l)),[xs]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(va),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(va),(l=this._instance.persistence)==null||l.register({[va]: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(ya)||{};this._instance.register({[ya]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ya)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(si)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[si]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(si)||{};this._instance.register({[si]:W({},t,{[e]:{}})})}else this._instance.unregister(si)}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}},LT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Sa=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&&V.info("Persistence loaded",e.persistence,W({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){LT.indexOf(e.persistence.toLowerCase())===-1&&(V.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=[...pT,...i];return W({},Te,{W:function(o){try{var a={};try{a=Yt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Te.q(o)||"{}"));return Te.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{Te.G(o,a,void 0,void 0,p);var f={};s.forEach((h=>{a[h]&&(f[h]=a[h])})),Object.keys(f).length&&Yt.G(o,f,l,c,u,p)}catch(h){Te.B(h)}},V:function(o,a){try{S?.localStorage.removeItem(o),Yt.V(o,a)}catch(l){Te.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Te.H()?Te:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&ze.H()?ze:r==="memory"?fT:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===xs&&Be(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,(Mt(o=K1)?l:Fb&&o.indexOf===Fb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return uu})),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(Be(e)){H(t)&&(t="None"),this.Pi=H(r)?this.Ci:r;var i=!1;if(xe(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(Be(e)){this.Pi=H(t)?this.Ci:t;var r=!1;if(xe(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=ww(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ws(Fg(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?Sw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Ew(),$referring_domain:D!=null&&D.referrer&&((e=vu(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[zh]||this.props[qh]||this.register_once({[fu]:Cw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([qh,zh],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+xh(c)]=l}))}));var t,r,i=this.props[fu];if(i){var s=(t=kw(i),r={},xe(t,(function(o,a){r["$initial_"+xh(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return xe(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,p)=>u===c[p]))})(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[ma]||{};r[e]=t,this.props[ma]=r,this.save()}remove_event_timer(e){var t=(this.props[ma]||{})[e];return H(t)||(delete this.props[ma][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},E0=Pe("[Product Tours]"),mh="ph_product_tours",pg=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Qb]:!(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(Qb)||this.it((()=>this.Oi()))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?E0.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=ee.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=ee.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!_e(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[mh];if(_e(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 E0.error(a),void e([],{isLoaded:!1,error:a})}var l=_e(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[mh]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){ve(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(mh)}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)}},pa=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),SD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),ED=(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})({}),CD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),vh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),kD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),AD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),TD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),ba=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),yh=(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})({}),fg=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Pe("[Surveys]"),Mw="seenSurvey_",NT=(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},C0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(Mw,n),FT=[vh.Popover,vh.Widget,vh.API],DT={ignoreConditions:!1,ignoreDelay:!1,displayType:fg.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 vs(n,e,t){if(ve(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 hg=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(!H((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(!H((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"||!vs(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=>vs(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&vs((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=>vs(c.text,t.text,t.text_matching||"exact")||vs(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,p=[],f=/(?::|")text="(.*?)"/g;!ve(u=f.exec(c));)p.includes(u[1])||p.push(u[1]);return p})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>vs(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||Ow(t.properties.reduce(((r,i)=>{var s=_e(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)}},gg=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&Ow(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===pa.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;H((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 hg(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,pa.Activation),this.Yi=this.Zi(e,pa.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 p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var f=this.te(e,t,pa.Cancellation);f.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((g=>g.id))}),f.forEach((g=>{var v=a.indexOf(g.id);v>=0&&a.splice(v,1),this.ue(g.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var h=this.te(e,t,pa.Activation);this.le(a.concat(h.map((g=>g.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}},mg=class extends gg{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return ba.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()}},vg=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(ve(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=_e(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(Mw)||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=ee?.__PosthogExtensions__;if(e){if(!H(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 mg(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(Uh);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,p=s.json.surveys||[],f=p.filter((g=>(function(v){return!(!v.start_date||v.end_date)})(g)&&((function(v){var m;return!((m=v.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(g)||(function(v){var m;return!((m=v.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(g))));f.length>0&&((u=this._surveyEventReceiver)==null||u.register(f)),(o=this._instance.persistence)==null||o.register({[Uh]:p});var h={isLoaded:!0};e(p,h),r?.({surveys:p,context:h})}}))}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),!ve(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(ve(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(ve(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 ve(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(ve(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(FT.includes(s.type)){var o=D?.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(ve(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=W({},i,{appearance:W({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==fg.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!==fg.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){ve(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},En=Pe("[Conversations]"),yg=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;ve(t)||(In(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=ee?.__PosthogExtensions__;if(e&&!H(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 En.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),En.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else En.error("Cannot complete initialization: remote config is null")}Se(e,t){En.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():En.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Mt(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 bs((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(En.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return bs((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(En.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return bs((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(En.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return bs((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(En.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}},_g=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;!ve(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Pe("[logs]"),t=ee?.__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.")}}},k0=Pe("[RateLimiter]"),bg=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=>{k0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void k0.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(Wh))!==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(Wh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ii=Pe("[RemoteConfig]"),wg=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(ii.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 ii.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ii.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ii.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){ii.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()):ii.info("__preview_remote_config is disabled. Logging config instead",e):ii.error("Failed to fetch remote config from PostHog.")}},xg=3e3,Sg=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||xg,250,5e3,V.createLogger("flush interval"),xg),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(W({},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&&_e(s.data)&&xe(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 xe(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;H(e[s])&&(e[s]=W({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},HT=["retriesPerformedSoFar"],Eg=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!H(S)&&"onLine"in S.navigator&&(this.Ue=S.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Fe(S,"online",this.ze),Fe(S,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=P0(e,HT);ys(t)&&(r.url=Eu(r.url,{retry_count:t})),this._instance._send_request(W({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(W({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)"),V.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,H(S)||(this.ze&&(S.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(S.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(W({},e,{transport:"sendBeacon"}))}catch(t){V.error(t)}this.Re=[]}},Cg=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(){Fe(S,"scroll",this.Ge,{capture:!0}),Fe(S,"scrollend",this.Ge,{capture:!0}),Fe(S,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return S?.document.documentElement;var e=_e(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=S?.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 S&&(S.scrollY||S.pageYOffset||S.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return S&&(S.scrollX||S.pageXOffset||S.document.documentElement.scrollLeft)||0}},BT=n=>Cw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),ku=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({[jh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||BT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[jh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?kw(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 xe(Fg(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+xh(r)]=t})),e}},_h=Pe("[SessionId]"),Au=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,p)=>!(!ys(u)||!ys(p))&&Math.abs(u-p)>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||cr,this.ar=r||cr;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Jt(o,60,36e3,_h.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=ze.W(this.ur),l=ze.W(this.hr);a&&!l?this.rr=a:ze.V(this.ur),ze.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){_h.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(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&&ze.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&ze.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?ze.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({[du]:[t,e,r]}))}_r(){var e=this.Xe.props[du];return _e(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&&S&&(S.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&ze.V(this.hr)},Fe(S,"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=ys(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),_h.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var f=ys(i)&&e&&!l?i:r,h=ys(o)?o:new Date().getTime();return this.pr(a),this.vr(s,f,h),e||this.lr(),c&&this.tr.forEach((g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:c?{noSessionId:u,activityTimeout:p,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)}},VT=["$set_once","$set"],ar=Pe("[SiteApps]"),kg=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=ee._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")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[f,h]of Object.entries(p))c[f]={id:u[f],type:f,properties:h};var{$set_once:g,$set:v}=e;return{event:W({},P0(e,VT),{properties:W({},e.properties,v?{$set:W({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},g?{$set_once:W({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),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&&(ar.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,ar.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){ar.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){ar.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){ar.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 ar.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;ee["__$$ph_site_app_"+c]=s._instance,(u=ee.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(p=>{if(p)return ar.error("Error while initializing PostHog app with config id "+c,p)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Lw=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Bb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Bb(i?.brand,e))))return!0}catch{}return!!n.webdriver},wa=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),A0="i.posthog.com",Ag=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("."+A0,".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]=wa.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=wa.EU:this.Sr[this.apiHost]=wa.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===wa.CUSTOM)return this.apiHost+t;var r=A0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},UT={icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!S&&Cu(e.href,n),not_regex:(n,e)=>!!S&&!Cu(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Tg=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);Ve(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(ve(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=yu(e?.search,"__experiment_id"),r=yu(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!ve(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(ve(e.conditions)||ve((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||UT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return S?.location}static Fr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.utm))return!0;var r=ww();if(r.utm_source){var i,s,o,a,l,c,u,p,f=(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,h=(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,g=(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,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return f&&g&&v&&h}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];V.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?Lw(ht,this._instance.config.custom_blocked_useragents):void 0}},jT=Pe("[PostHog ExternalIntegrations]"),WT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Rg=class{constructor(e){this._instance=e}it(e,t){var r;(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return jT.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=ee.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(WT[o],(()=>{var u;(u=ee.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=ee.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=ee.__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)}}},Ig="[SessionRecording]",fa=Pe(Ig),Tu=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 fa.error("started without valid sessionManager"),new Error(Ig+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Ig+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(oh))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return S&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!H(Object.assign)&&!H(Array.from);this.Ar&&r?(this.Dr(e),fa.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(ee!=null&&(t=ee.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=ee.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=ee.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return fa.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(iw)}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=ve(a)?null:parseFloat(a);ve(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[oh]:W({enabled:!!o},o,{networkPayloadCapture:W({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:H(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:fa.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):fa.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(oh);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=ee.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=ee.__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))}},Ea={},$g=()=>{},_s="posthog",Nw=!PT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,T0=n=>{var e;return W({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:G1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:$g,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:qe&&Ve(qe?.search)&&qe.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:(S==null||(e=S.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;V.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:xg},error_tracking:{},_onCapture:$g,__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))},R0=n=>{var e={};H(n.process_person)||(e.person_profiles=n.process_person),H(n.xhr_headers)||(e.request_headers=n.xhr_headers),H(n.cookie_name)||(e.persistence_name=n.cookie_name),H(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),H(n.store_google)||(e.save_campaign_params=n.store_google),H(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return _e(n.property_blacklist)&&(H(n.property_denylist)?t.property_denylist=n.property_blacklist:_e(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:V.error("Invalid value for property_denylist config: "+n.property_denylist)),t},Pg=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Ru=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 Pg,this.Br=!1,this.version=Cn.LIB_VERSION,this.qr=new Ia,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=T0(),this.SentryIntegration=tg,this.sentryIntegration=e=>(function(t,r){var i=bw(t,r);return{name:_w,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 dg(this),this.toolbar=new ng(this),this.scrollManager=new Cg(this),this.pageViewManager=new wu(this),this.surveys=new vg(this),this.conversations=new yg(this),this.logs=new _g(this),this.experiments=new Tg(this),this.exceptions=new ug(this),this.rateLimiter=new bg(this),this.requestRouter=new Ag(this),this.consent=new Xh(this),this.externalIntegrations=new Rg(this),this.people={set:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>V.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==_s){var i,s=(i=Ea[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),Ea[r]=s,Ea[_s][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||Sh(e))return V.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({},T0(t.defaults),R0(t),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Tn.GZipJS;var s=this.Qr();this.persistence=new Sa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Sa(W({},this.config,{persistence:"sessionStorage"}),s);var o=W({},this.persistence.props),a=W({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Sg((w=>this.ts(w)),this.config.request_queue_config),this.es=new Eg(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 Au(this),this.sessionPropsManager=new ku(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(V.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(V.info("Initializing extensions synchronously"),this.rs(l)),Cn.DEBUG=Cn.DEBUG||this.config.debug,Cn.DEBUG&&V.info("Starting in debug mode",{this:this,config:t,thisC:W({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(cr()),f=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(kn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:f})}if(this.ss()){var h,g,v=Object.keys(((h=t.bootstrap)==null?void 0:h.featureFlags)||{}).filter((w=>{var x;return!((x=t.bootstrap)==null||(x=x.featureFlags)==null||!x[w])})).reduce(((w,x)=>{var _;return w[x]=((_=t.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[x])||!1,w}),{}),m=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter((w=>v[w])).reduce(((w,x)=>{var _,k;return(_=t.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[x]&&(w[x]=(k=t.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[x]),w}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:sa,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(cr());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(kn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?mT(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==$g&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(w=>this.config._onCapture(w.event,w)))),this.config.ip&&V.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 eg(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new rg(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new kg(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Tu(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new Gh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new pg(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new sg(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new ig(this)})),r.push((()=>{this.exceptionObserver=new Qh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new bu(this,gT),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){V.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&&V.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!D||!D.body)return V.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=me(e.supportedCompression,Tn.GZipJS)?Tn.GZipJS:me(e.supportedCompression,Tn.Base64)?Tn.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){V.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&qe!=null&&qe.hostname){var e=qe.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 wg(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()&&dr(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&&(Nw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Eu(e.url,{ip:this.config.ip?1:0}),e.headers=W({},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=W({},t);o.timeout=o.timeout||6e4,o.url=Eu(o.url,{_:new Date().getTime().toString(),ver:Cn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=au.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=tw(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)})(W({},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=[];dr(e,(a=>{a&&(t=a[0],_e(t)?s.push(a):ur(a)?a.call(this):_e(a)&&t==="alias"?r.push(a):_e(a)&&t.indexOf("capture")!==-1&&ur(this[t])?s.push(a):i.push(a))}));var o=function(a,l){dr(a,(function(c){if(_e(c[0])){var u=l;xe(c,(function(p){u=u[p[0]].apply(u,p.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(!H(e)&&Ve(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&&!Ve(t?.$current_url)&&(V.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=cr(),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 p,f=e!=="$groupidentify",h=this.vs(r?.$set_once,f);if(h&&(u.$set_once=h),(u=q1(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,H(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ba.DISMISSED||e===ba.SENT){var g=t?.[yh.SURVEY_ID],v=t?.[yh.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(C0(p))||localStorage.setItem(C0(p),"true"),u.$set=W({},u.$set,{[NT({id:g,current_iteration:v},e===ba.SENT?"responded":"dismissed")]:!0})}else e===ba.SHOWN&&(u.$set=W({},u.$set,{[yh.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(ws(m)||this.setPersonPropertiesForFlags(m),!ve(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var w={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(w):this.Zr.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.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=W({},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=W({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Ve(a.distinct_id)&&!$n(a.distinct_id)||Sh(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=xT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=f}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.es)==null?void 0:h.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===wa.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"&&D&&(a.title=D.title),!H(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}ct&&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(),_e(this.config.property_denylist)?xe(this.config.property_denylist,(function(y){delete a[y]})):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=v(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&&(V.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),ws(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=W({},i,e),a=W({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:H(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=DT),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 V.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),V.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()))V.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!==sa){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(ga)&&(this.unregister(ga),this.register({distinct_id:e}));var o=(this.persistence.get_property(kn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(kn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=_0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(pu))}}else V.critical('The string "'+sa+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=_0(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(W({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):V.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:W({},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 V.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(V.info("reset"),!this.__loaded)return V.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(kn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:sa,$device_id:null},"");else{var a=this.config.get_device_id(cr());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(nw)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(ga,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=W({},this.config);if(Be(e)){var r,i,s,o,a,l,c;Me(this.config,R0(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 Sa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);In(p)&&(this.config.debug=p),In(this.config.debug)&&(this.config.debug?(Cn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(Cn.DEBUG=!1,Te.H()&&Te.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(W({},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:_s;return t!==_s&&(t=_s+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(kn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(kn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ws(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[ga])&&((t=this.persistence)==null||(t=t.props)==null||!t[hu]))}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"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(hu,!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 Au(this),this.pageViewManager=new wu(this),this.persistence&&(this.sessionPropsManager=new ku(this,this.sessionManager,this.persistence)),this.sessionRecording=new Tu(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(),(H(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 V.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:sa,$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())):V.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===An.GRANTED?"granted":e===An.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?Lw(ht,this.config.custom_blocked_useragents):void 0}hs(){D&&(D.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:D.title},{send_instantly:!0}),this.Gr&&(D.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Fe(D,"visibilitychange",this.Gr)))}debug(e){e===!1?(S?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(S?.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?(V.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=V,o=(t="advanced_disable_flags")in(e=l)&&!ve(e[t]),a=r in e&&!ve(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(ve(this.config.before_send))return e;var t=_e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),ve(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return _1(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!ws(r.properties)||V.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=In(e)&&!e,r=Te.H()&&Te.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=z1(n.prototype[e[t]])})(Ru,["identify"]);var I0;var Fw=(I0=Ea[_s]=new Ru,(function(){function n(){n.done||(n.done=!0,Nw=!1,xe(Ea,(function(e){e._dom_loaded()})))}D!=null&&D.addEventListener?D.readyState==="complete"?n():Fe(D,"DOMContentLoaded",n,{capture:!1}):S&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),I0);var jg=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};e.cookieless_mode&&(o.cookieless_mode=e.cookieless_mode);let a=Fw.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,p=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,p)}),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)}optInCapturing(){this.client?.opt_in_capturing()}optOutCapturing(){this.client?.opt_out_capturing()}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 Ou(n={}){return new jg(n)}var Dw={posthog:n=>Ou(n),noop:()=>eu()};function Hw(n,e){let t=Dw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(Dw).join(", ")}`);return t(e)}function zT(n){return n?.manifest?.runtime!==void 0}async function Bw(n){Np(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Ec();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",Vo()),console.log("[DIAG] editorConf:",Sc()),q("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let R=!!window.__SYNTRO_EDITOR_PARAMS__,Y=!!window.__SYNTRO_AUDIT_LEGEND__,B=!!window.__SYNTRO_REVIEW_DATA__;if(R||Y||B){let fe=[R&&"__SYNTRO_EDITOR_PARAMS__",Y&&"__SYNTRO_AUDIT_LEGEND__",B&&"__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 Y=Sc()?.syntro_token;Y?.startsWith("syn_")&&(t=Y,q("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))q("Syntro Bootstrap","Token starts with syn_, decoding..."),r=ns(t),Np(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw oc("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),oc("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)q("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw oc("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=xt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||xt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=xt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||xt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th;if(r!=null&&r.obd!==!0&&s)try{let R=`${s.replace(/\/$/,"")}/sdk-otel/v1/logs`,Y=Fp({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:Zi,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Hp({endpoint:R})}),B=Vp()??"https://cdn.syntrologie.com/runtime-sdk/",fe=tf(Y,{attributedScriptUrlPrefix:B});Y.attachAdapterCleanup(fe)}catch{}let o=xt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||xt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||xt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||xt("VITE_SYNTRO_GEO_HOST")||w_,l=h_(),c=wf(),u=n.appSignalsInit??{},p=__(),f=xf(c,p);b_(f);let h={...c,...f,...l,...u};q("Syntro Bootstrap","Phase 1: Browser metadata:",c),q("Syntro Bootstrap","Phase 1: Initial attrs:",f),q("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&q("Syntro Bootstrap","Phase 1: App signals:",u);let g=Sf(a),v=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(R=>{let Y=setTimeout(()=>{window.removeEventListener("message",B),R(null)},500);function B(fe){let he=fe.data;he?.jsonrpc==="2.0"&&he?.id===1&&he?.result?.hostInfo&&(clearTimeout(Y),window.removeEventListener("message",B),R(he.result.hostInfo))}window.addEventListener("message",B);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(Y),window.removeEventListener("message",B),R(null)}})})(),m,y=n.debug||n.testMode,w=Bi({debug:n.debug,history:y?new os(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=Ed({elementResolver:typeof window<"u"?(R,Y)=>{let B=document.elementFromPoint(R,Y);if(!B)return null;let fe={tag_name:B.tagName.toLowerCase()};B.id&&(fe.attr__id=B.id),B.className&&typeof B.className=="string"&&(fe.classes=B.className.split(" ").filter(Boolean));for(let he of B.attributes)he.name.startsWith("data-")&&(fe[`attr__${he.name}`]=he.value);return fe}:void 0});if(x.onEvent(R=>w.publishEvent(R)),typeof window<"u")try{Sb(w),Eb(w)}catch(R){We("Syntro Bootstrap","scroll instrumentation install failed",R)}typeof window<"u"&&(setInterval(()=>x.tick(Date.now()),1e3),document.addEventListener("click",R=>{let Y=[],B=R.target;for(;B&&B!==document.body;){let fe={tag_name:B.tagName.toLowerCase()};for(let he of B.attributes)(he.name.startsWith("data-")||he.name==="id"||he.name==="class"||he.name==="aria-label")&&(fe[`attr__${he.name}`]=he.value);Y.push(fe),B=B.parentElement}x.enrichClickAttributes(Date.now(),Y)},!0));let _=kb(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=v_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),g_(Y),m){let B=A?.getAll?.()??{},fe=is(b?.getDistinctId?.()),he={...c,...f,...B,...Y,...u,id:fe};q("Syntro Bootstrap","Updating GrowthBook with attributes:",he),m.setAttributes?.(he)}if(k&&b?.getDistinctId){let B=b.getDistinctId();B&&s&&r?.t&&k.updateContext({distinctId:B,telemetryHost:s,telemetryKey:r.t})}},b;if(r?.t){let R=r.t==="noop"?"noop":"posthog";if(b=Hw(R,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,cookieless_mode:"on_reject",onFeatureFlagsLoaded:I,onCapture:(se,Re)=>{x.ingest({kind:"posthog",event:se,properties:Re,timestamp:Date.now()})},onRRWebEvent:se=>{x.ingest(se)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${R}) with EventBus wiring`),b){let se=b.getDistinctId?.bind(b);b.getDistinctId=()=>is(se?.())}try{b.track?.("syntro_bootstrap_step",{stage:"telemetry_ready"})}catch{}Object.keys(u).length>0&&(b.track?.("app_signals_init",u),q("Syntro Bootstrap","Tracked app signals event:",u));let Y=b;w.setPosthogCapture((se,Re)=>{Y.track?.(se,Re)});let B=b,fe=async()=>{let se=await g;return se.is_eu==="true"||se.country_code==="GB"||se.country_code==="CH"?"denied":"granted"},he=new ia({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{m_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{P_(b,he,{geoPromise:g}),q("Syntro Bootstrap","SDK defaults installed (D-1..D-5) with consent gate");try{B.track?.("syntro_bootstrap_step",{stage:"defaults_installed"})}catch{}}catch(se){We("Syntro Bootstrap","installDefaults failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"defaults_install_failed",err:String(se)})}catch{}}try{let se=new ra({adapters:[new na,new ta,new ea],fallbackStatus:fe,onAdapterSelected:Re=>{B.track?.("syntro_consent_adapter_selected",{adapter:Re??"none"}),q("Syntro Bootstrap",`Consent adapter selected: ${Re??"none"}`)}});try{B.track?.("syntro_bootstrap_step",{stage:"detector_started"})}catch{}se.start(he).then(()=>{try{B.track?.("syntro_bootstrap_step",{stage:"detector_resolved"})}catch{}}).catch(Re=>{We("Syntro Bootstrap","Consent detector failed to start",Re);try{B.track?.("syntro_bootstrap_step",{stage:"detector_failed",err:String(Re)})}catch{}})}catch(se){We("Syntro Bootstrap","Consent detector setup failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"detector_setup_failed",err:String(se)})}catch{}}try{k=k_({telemetry:b,telemetryHost:s,telemetryKey:r.t,platformAdapter:_,debug:q,warn:We}).shopifyPixelBridge}catch(se){We("Syntro Bootstrap","wirePlatformAdapters failed",se)}}let A;r?.e&&(m=yb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:is(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=Jc({experiments:m,onMetricChange:(R,Y)=>{q("Syntro Bootstrap",`Session metric changed: ${R} = ${Y}`)}}),q("Syntro Bootstrap","SessionMetricTracker created");let M="production";e==="editor"?M="editor":e==="audit"?M="audit":xt("NODE_ENV")==="development"&&(M="development");let J=typeof c.surface_type=="string"?c.surface_type:"web",$=typeof c.surface_host=="string"?c.surface_host:"web",U=tc({telemetry:b,sessionMetrics:A,mode:M,events:w,initialSurfaceType:J,initialSurfaceHost:$,backendUrl:n.backendUrl});_&&(U.getProductIdentity=R=>_.extractProductIdentity(R)),q("Syntro Bootstrap","Runtime created:",{version:U.version,mode:U.mode,hasContext:!!U.context,hasEvents:!!U.events,hasState:!!U.state,hasProductIdentity:!!U.getProductIdentity});let G=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return"unknown";let Y=await Ob({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.({[R.name]:Y}),Y},Z=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return R.map(()=>"unknown");let Y=await Pb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.(Object.fromEntries(R.map((B,fe)=>[B.name,Y[fe]]))),Y},te=(R,Y)=>{if(!n.backendUrl)throw new Error("[syntro] authedFetch: no backendUrl configured");let B=n.backendUrl.replace(/\/$/,""),fe=/^https?:\/\//.test(R)?R:`${B}${R.startsWith("/")?R:`/${R}`}`;if(new URL(fe).origin!==new URL(B).origin)throw new Error("[syntro] authedFetch: refusing cross-origin request (token would leak)");let he={};t&&(he.Authorization=`Bearer ${t}`);let se=b?.getDistinctId?.();se&&(he["X-Distinct-Id"]=se);let Re=b?.getSessionId?.();return Re&&(he["X-Syntro-Session"]=Re),fetch(fe,{...Y,credentials:"include",headers:{"Content-Type":"application/json",...Y?.headers,...he}})};q("Syntro Bootstrap","Core app executors already registered");let ye=n.cdnBase||xt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||xt("VITE_SYNTRO_CDN_BASE")||$l()||"https://cdn.syntrologie.com",pe=rd({cdnBase:ye,registry:U.apps,onLoadStart:R=>{q("Syntro Bootstrap",`Loading app from CDN: ${R}`)},onLoadEnd:(R,Y,B)=>{Y?q("Syntro Bootstrap",`App loaded successfully: ${R}`):We("Syntro Bootstrap",`Failed to load app: ${R}`,B)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:U.apps,appLoader:pe,runtime:U,experiments:m,score:G,scoreMulti:Z,authedFetch:te,version:U.version},q("Syntro Bootstrap","Global SynOS object exposed")),typeof window<"u"&&window.parent!==window&&pe.loadApp("adaptive-mcp").catch(R=>{q("Syntro Bootstrap","auto-load of adaptive-mcp failed (non-fatal):",R)});let j=U.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${j.length} apps in registry:`,j.map(R=>`${R.manifest.id}(${R.state})`).join(", "));for(let R of j)if(R.state==="registered"&&zT(R))try{await U.apps.activate(R.manifest.id),console.log(`[DIAG] Activated: ${R.manifest.id} \u2192 widgets: [${U.widgets.list().join(", ")}]`)}catch(Y){console.error(`[DIAG] FAILED to activate: ${R.manifest.id}`,Y),We("Syntro Bootstrap",`Failed to auto-activate built-in app: ${R.manifest.id}`,Y)}if(console.log(`[DIAG] Activation complete. Total widgets: [${U.widgets.list().join(", ")}]`),m?.refreshFeatures){let Y=performance.now(),B=!1,fe=!1;try{await Promise.race([m.refreshFeatures().then(()=>{}),new Promise(he=>setTimeout(()=>{B=!0,he()},500))]),q("Syntro Bootstrap","GrowthBook features loaded (or timeout reached)")}catch(he){fe=!0,We("Syntro Bootstrap","Failed to load GrowthBook features:",he)}try{b?.track?.("syntro_bootstrap_step",{stage:"gb_features_fetch",duration_ms:Math.round(performance.now()-Y),timeout_ms:500,timed_out:B,failed:fe})}catch{}}let X=await g;if(m&&Object.keys(X).length>0){let R={...c,...f,...X,...u,id:is(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Oe=await v;Oe&&m&&(c.surface_type="mcp-app",c.surface_host=Oe.name,m.setAttributes?.({...c,...f,...X,id:is(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Oe.name),q("Syntro Bootstrap","MCP App detected:",Oe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=xb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ur({experiments:m}));let De=new Set;function Je(R,Y){let B=pe.getRequiredApps(R);B.length>0?console.log("[Syntro Bootstrap] Required external apps:",B.join(", ")):q("Syntro Bootstrap","No external apps required (all executors are built-in)"),B.length!==0&&vl({appIds:B,loadApp:fe=>pe.loadApp(fe),apps:U.apps,warnedAppFailures:De}).catch(fe=>{console.error(`[Syntro Bootstrap] app loading (${Y}) rejected:`,fe)})}function Xe(R){return async()=>{let Y=await R();return Je(Y,"override"),Y}}let Pn=Ye?async()=>{let R=await Ye(),Y=R.tiles?.length??0,B=R.actions?.length??0,fe=R.meta?.variant_id,he=R.meta?.variants;if((Y>0||B>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),b&&fe){let se=typeof window<"u"?window.SynOS??(window.SynOS={}):void 0,Re=se?.interventionTracker,Xt;if(Re&&Re.variantId===fe)Xt=Re;else{let Qt=se?.interventionTrackerUnsub;if(Qt)try{Qt()}catch(Qw){console.warn("[Syntro] interventionTracker nav unsub threw:",Qw)}Xt=new gs(b,fe),se&&(se.interventionTracker=Xt);let Ps=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=Ps)}if(he&&he.length>0)for(let Qt of he)Xt.trackServedForVariant(Qt.variant_id,Qt.tiles,Qt.actions);else Xt.trackServed(Y,B)}return console.log("[Syntro Bootstrap] Config fetched:",`tiles=${R.tiles?.length??0},`,`actions=${R.actions?.length??0},`,`theme=${R.theme?.name??"none"}`),R.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",R.actions.map((se,Re)=>`[${Re}] ${se.kind}${se.anchorId?` anchor="${se.anchorId.selector}"`:""}${se.label?` "${se.label}"`:""}`).join(", ")),Je(R,"initial"),R}:void 0;if(_){q("Syntro Bootstrap",`Detected platform: ${_.name}`);try{await _.onInit(),q("Syntro Bootstrap",`Platform adapter initialized: ${_.name}`)}catch(R){We("Syntro Bootstrap",`Platform adapter init failed: ${_.name}`,R)}}if(typeof window<"u"){let R=window.SynOS??(window.SynOS={});R.wrapCanvasConfigFetcher=Xe}let Lt=await Cc({...n.canvas,fetcher:Pn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),$s=jt();if($s!==null)try{let R=b,Y=U;$s.bindRuntime({getSessionId:()=>{try{return R?.getSessionId?.()??""}catch{return""}},getSurface:()=>{try{let B=Y.context.get().surface;return B?{...B}:null}catch{return null}}})}catch{}return $s?.increment("bootstrap_ok"),{canvas:Lt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function qT(n){try{return await Bw(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),jt()?.increment("bootstrap_errors"),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function ZT(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}async function GT(n){if(typeof window>"u")return{appId:n,success:!1,error:"no-window"};let e=window.SynOS?.appLoader;return e?e.loadApp(n):{appId:n,success:!1,error:"syntro-not-initialized"}}var Wg={init:qT,loadAdaptive:GT,encodeToken:kc,decodeToken:ns,events:{emit:ZT}};typeof window<"u"&&(window.Syntro=Wg);function Is(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function KT(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=Is(i),o=Is(vn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${vn}. 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${vn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:YT(r,i)}):{valid:!0,warnings:e,errors:t}}function YT(n,e){let t={...n};return Is(e).major===1&&(t=JT(t)),t.schemaVersion=vn,t}function JT(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 XT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Is(t),i=Is(vn);return r.major<i.major||!e.schemaVersion}var Vw=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),Uw=d.object({url:d.string(),ts:d.number()}),jw=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(Uw).optional()}),Ww=d.object({width:d.number(),height:d.number()}),zw=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),qw=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:zw.optional()}),Zw=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),Gw=d.object({page:Vw,session:jw,viewport:Ww,anchors:d.array(qw).optional(),augmented:Zw.optional()});function QT(n){return Gw.safeParse(n)}var Mu=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 Lu=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 Nu=class{constructor(e,t,r,i){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 zg=d.enum(["posthog","canvas","derived"]),Kw=d.object({ts:d.number(),name:d.string(),source:zg,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),Yw=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(zg).optional()});function eR(n){return Kw.safeParse(n)}function tR(n){return Yw.safeParse(n)}var Jw=d.object({value:d.unknown(),expiresAt:d.number().optional()}),Xw=d.object({count:d.number(),resetAt:d.number().optional()});function nR(n){return Jw.safeParse(n)}function rR(n){return Xw.safeParse(n)}var qg="2026-07-24T19:21:30.096Z (1235b1302)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${qg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||to;window.SynOS={...n,appRegistry:e,_runtimeBuild:qg,_renderer:"lit"},Do(),dv(e)}return sx(iR);})();
|
|
627
627
|
/*! Bundled license information:
|
|
628
628
|
|
|
629
629
|
@lit/reactive-element/css-tag.js:
|