@deriv-com/analytics 1.39.8 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  /* @deriv-com/analytics - Browser ESM Bundle (RudderStack + PostHog) - Built with tsup */
2
2
  import{d as gr,e as _r,f as fr,g as mr,h as yr}from"./chunk-F3U33XPR.mjs";var d=typeof window<"u"?window:void 0,X=typeof globalThis<"u"?globalThis:d;typeof self>"u"&&(X.self=X),typeof File>"u"&&(X.File=function(){});var ue=X?.navigator,y=X?.document,Q=X?.location,Zi=X?.fetch,Qi=X!=null&&X.XMLHttpRequest&&"withCredentials"in new X.XMLHttpRequest?X.XMLHttpRequest:void 0,br=X?.AbortController,Mo=X?.CompressionStream,oe=ue?.userAgent,$=d??{},wr="1.364.1",le={DEBUG:!1,LIB_VERSION:wr,LIB_NAME:"web",JS_SDK_VERSION:wr};function Er(i,e,t,s,r,n,o){try{var a=i[n](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(s,r)}function ye(i){return function(){var e=this,t=arguments;return new Promise((function(s,r){var n=i.apply(e,t);function o(l){Er(n,s,r,o,a,"next",l)}function a(l){Er(n,s,r,o,a,"throw",l)}o(void 0)}))}}function m(){return m=Object.assign?Object.assign.bind():function(i){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var s in t)({}).hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},m.apply(null,arguments)}function kn(i,e){if(i==null)return{};var t={};for(var s in i)if({}.hasOwnProperty.call(i,s)){if(e.indexOf(s)!==-1)continue;t[s]=i[s]}return t}function Sn(){return(Sn=ye((function*(i,e){e===void 0&&(e=!0);try{var t=new Blob([i],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(t).blob()}catch(s){return e&&console.error("Failed to gzip compress data",s),null}}))).apply(this,arguments)}var No=["$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"],Ao=["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"],xr=function(i,e){if(e===void 0&&(e=[]),!i)return!1;var t=i.toLowerCase();return Ao.concat(e).some((s=>{var r=s.toLowerCase();return t.indexOf(r)!==-1}))};function C(i,e){return i.indexOf(e)!==-1}var Si=function(i){return i.trim()},es=function(i){return i.replace(/^\$/,"")},Pn=Object.prototype,Tn=Pn.hasOwnProperty,Pi=Pn.toString,L=Array.isArray||function(i){return Pi.call(i)==="[object Array]"},Oe=i=>typeof i=="function",K=i=>i===Object(i)&&!L(i),st=i=>{if(K(i)){for(var e in i)if(Tn.call(i,e))return!1;return!0}return!1},E=i=>i===void 0,Y=i=>Pi.call(i)=="[object String]",Zt=i=>Y(i)&&i.trim().length===0,Ie=i=>i===null,M=i=>E(i)||Ie(i),ke=i=>Pi.call(i)=="[object Number]"&&i==i,et=i=>ke(i)&&i>0,$e=i=>Pi.call(i)==="[object Boolean]",Lo=i=>i instanceof FormData,Do=i=>C(No,i);function On(i){return i===null||typeof i!="object"}function ti(i,e){return{}.toString.call(i)==="[object "+e+"]"}function er(i){return!E(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(i,Event)}var Uo=[!0,"true",1,"1","yes"],Ii=i=>C(Uo,i),jo=[!1,"false",0,"0","no"];function xe(i,e,t,s,r){return e>t&&(s.warn("min cannot be greater than max."),e=t),ke(i)?i>t?(s.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>i?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):i:(s.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),xe(r||t,e,t,s))}var ts=class{constructor(e){this.t={},this.i=e.i,this.o=xe(e.bucketSize,0,100,e.h),this.m=xe(e.refillRate,0,this.o,e.h),this.S=xe(e.refillInterval,0,864e5,e.h)}T(e,t){var s=Math.floor((t-e.lastAccess)/this.S);s>0&&(e.tokens=Math.min(e.tokens+s*this.m,this.o),e.lastAccess=e.lastAccess+s*this.S)}consumeRateLimit(e){var t,s=Date.now(),r=String(e),n=this.t[r];return n?this.T(n,s):this.t[r]=n={tokens:this.o,lastAccess:s},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}},qt,kr,Ri,ce="Mobile",ii="iOS",Fe="Android",lt="Tablet",$n=Fe+" "+lt,Fn="iPad",In="Apple",Rn=In+" Watch",$t="Safari",ut="BlackBerry",Cn="Samsung",Mn=Cn+"Browser",Nn=Cn+" Internet",Ge="Chrome",Ho=Ge+" OS",An=Ge+" "+ii,tr="Internet Explorer",Ln=tr+" "+ce,ir="Opera",Wo=ir+" Mini",sr="Edge",Dn="Microsoft "+sr,ot="Firefox",Un=ot+" "+ii,Nt="Nintendo",At="PlayStation",at="Xbox",jn=Fe+" "+ce,Hn=ce+" "+$t,xt="Windows",is=xt+" Phone",Sr="Nokia",ss="Ouya",Wn="Generic",qo=Wn+" "+ce.toLowerCase(),qn=Wn+" "+lt.toLowerCase(),rs="Konqueror",se="(\\d+(\\.\\d+)?)",Ci=new RegExp("Version/"+se),zo=new RegExp(at,"i"),Bo=new RegExp(At+" \\w+","i"),Vo=new RegExp(Nt+" \\w+","i"),rr=new RegExp(ut+"|PlayBook|BB10","i"),Go={"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"},zn=function(i,e){return e=e||"",C(i," OPR/")&&C(i,"Mini")?Wo:C(i," OPR/")?ir:rr.test(i)?ut:C(i,"IE"+ce)||C(i,"WPDesktop")?Ln:C(i,Mn)?Nn:C(i,sr)||C(i,"Edg/")?Dn:C(i,"FBIOS")?"Facebook "+ce:C(i,"UCWEB")||C(i,"UCBrowser")?"UC Browser":C(i,"CriOS")?An:C(i,"CrMo")||C(i,Ge)?Ge:C(i,Fe)&&C(i,$t)?jn:C(i,"FxiOS")?Un:C(i.toLowerCase(),rs.toLowerCase())?rs:((t,s)=>s&&C(s,In)||(function(r){return C(r,$t)&&!C(r,Ge)&&!C(r,Fe)})(t))(i,e)?C(i,ce)?Hn:$t:C(i,ot)?ot:C(i,"MSIE")||C(i,"Trident/")?tr:C(i,"Gecko")?ot:""},Yo={[Ln]:[new RegExp("rv:"+se)],[Dn]:[new RegExp(sr+"?\\/"+se)],[Ge]:[new RegExp("("+Ge+"|CrMo)\\/"+se)],[An]:[new RegExp("CriOS\\/"+se)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+se)],[$t]:[Ci],[Hn]:[Ci],[ir]:[new RegExp("(Opera|OPR)\\/"+se)],[ot]:[new RegExp(ot+"\\/"+se)],[Un]:[new RegExp("FxiOS\\/"+se)],[rs]:[new RegExp("Konqueror[:/]?"+se,"i")],[ut]:[new RegExp(ut+" "+se),Ci],[jn]:[new RegExp("android\\s"+se,"i")],[Nn]:[new RegExp(Mn+"\\/"+se)],[tr]:[new RegExp("(rv:|MSIE )"+se)],Mozilla:[new RegExp("rv:"+se)]},Jo=function(i,e){var t=zn(i,e),s=Yo[t];if(E(s))return null;for(var r=0;s.length>r;r++){var n=i.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Pr=[[new RegExp(at+"; "+at+" (.*?)[);]","i"),i=>[at,i&&i[1]||""]],[new RegExp(Nt,"i"),[Nt,""]],[new RegExp(At,"i"),[At,""]],[rr,[ut,""]],[new RegExp(xt,"i"),(i,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[is,""];if(new RegExp(ce).test(e)&&!/IEMobile\b/.test(e))return[xt+" "+ce,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var s=Go[t[1]]||"";return/arm/i.test(e)&&(s="RT"),[xt,s]}return[xt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,i=>i&&i[3]?[ii,[i[3],i[4],i[5]||"0"].join(".")]:[ii,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,i=>{var e="";return i&&i.length>=3&&(e=E(i[2])?i[3]:i[2]),["watchOS",e]}],[new RegExp("("+Fe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Fe+")","i"),i=>i&&i[2]?[Fe,[i[2],i[3],i[4]||"0"].join(".")]:[Fe,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,i=>{var e=["Mac OS X",""];return i&&i[1]&&(e[1]=[i[1],i[2],i[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Ho,""]],[/Linux|debian/i,["Linux",""]]],Tr=function(i){return Vo.test(i)?Nt:Bo.test(i)?At:zo.test(i)?at:new RegExp(ss,"i").test(i)?ss:new RegExp("("+is+"|WPDesktop)","i").test(i)?is:/iPad/.test(i)?Fn:/iPod/.test(i)?"iPod Touch":/iPhone/.test(i)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(i)?Rn:rr.test(i)?ut:/(kobo)\s(ereader|touch)/i.test(i)?"Kobo":new RegExp(Sr,"i").test(i)?Sr:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(i)||/(kf[a-z]+)( bui|\)).+silk\//i.test(i)?"Kindle Fire":/(Android|ZTE)/i.test(i)?new RegExp(ce).test(i)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(i)||/pixel[\daxl ]{1,6}/i.test(i)&&!/pixel c/i.test(i)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(i)||/lmy47v/i.test(i)&&!/QTAQZ3/i.test(i)?Fe:$n:new RegExp("(pda|"+ce+")","i").test(i)?qo:new RegExp(lt,"i").test(i)&&!new RegExp(lt+" pc","i").test(i)?qn:""},Ko=i=>i instanceof Error;function Xo(i){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Ri&&t.length===kr||(kr=t.length,Ri=t.reduce(((s,r)=>{qt||(qt={});var n=qt[r];if(n)s[n[0]]=n[1];else for(var o=i(r),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[r];if(c&&u){s[c]=u,qt[r]=[c,u];break}}return s}),{})),Ri}}var ns=class{constructor(e,t,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=t,this.modifiers=s}buildFromUnknown(e,t){t===void 0&&(t={});var s=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var t=this;return ye((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&L(s.stacktrace.frames)&&(s.stacktrace.frames=yield t.applyModifiers(s.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 s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),m({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((s=>(s.filename&&t&&(s.chunk_id=t[s.filename]),s)))}applyCoercers(e,t){for(var s of this.coercers)if(s.match(e))return s.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return ye((function*(){var s=e;for(var r of t.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=t.type)!==null&&s!==void 0?s:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,m({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Xo(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,s){s===void 0&&(s=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return m({},t,{syntheticException:s==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},ct="?";function os(i,e,t,s,r){var n={platform:i,filename:e,function:t==="<anonymous>"?ct:t,in_app:!0};return E(s)||(n.lineno=s),E(r)||(n.colno=r),n}var Bn=(i,e)=>{var t=i.indexOf("safari-extension")!==-1,s=i.indexOf("safari-web-extension")!==-1;return t||s?[i.indexOf("@")!==-1?i.split("@")[0]:ct,t?"safari-extension:"+e:"safari-web-extension:"+e]:[i,e]},Zo=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Qo=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ea=/\((\S*)(?::(\d+))(?::(\d+))\)/,ta=(i,e)=>{var t=Zo.exec(i);if(t){var[,s,r,n]=t;return os(e,s,ct,+r,+n)}var o=Qo.exec(i);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=ea.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=Bn(o[1]||ct,o[2]);return os(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},ia=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sa=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ra=(i,e)=>{var t=ia.exec(i);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var s=sa.exec(t[3]);s&&(t[1]=t[1]||"eval",t[3]=s[1],t[4]=s[2],t[5]="")}var r=t[3],n=t[1]||ct;return[n,r]=Bn(n,r),os(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Or=/\(error: (.*)\)/,as=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var s=Y(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?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 ti(e,"DOMException")}isDOMError(e){return ti(e,"DOMError")}},ls=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 s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}},us=class{constructor(){}match(e){return ti(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var s;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},na=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,cs=class{match(e){return typeof e=="string"}coerce(e,t){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var t="Error",s=e,r=e.match(na);return r&&(t=r[1],s=r[2]),[t,s]}},oa=["fatal","error","warning","log","info","debug"];function Vn(i,e){e===void 0&&(e=40);var t=Object.keys(i);if(t.sort(),!t.length)return"[object has no keys]";for(var s=t.length;s>0;s--){var r=t.slice(0,s).join(", ");if(e>=r.length)return s===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}var hs=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var s,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=t.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return er(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 s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+Vn(e)}isSeverityLevel(e){return Y(e)&&!Zt(e)&&oa.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var s=e[t];if(Ko(s))return s}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},ds=class{match(e){return er(e)}coerce(e,t){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Vn(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ps=class{match(e){return On(e)}coerce(e,t){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}}},vs=class{match(e){return ti(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!er(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var s,r=this.getUnhandledRejectionReason(e);return On(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=t.syntheticException)==null?void 0:s.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Gn=function(i,e){var{debugEnabled:t}=e===void 0?{}:e,s={$(r){if(d&&(le.DEBUG||$.POSTHOG_DEBUG||t)&&!E(d.console)&&d.console){for(var n=("__rrweb_original__"in d.console[r])?d.console[r].__rrweb_original__:d.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];n(i,...a)}},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.$("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.$("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.$("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(i,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Gn(i+" "+r,n)};return s},w=Gn("[PostHog.js]"),z=w.createLogger,aa=z("[ExternalScriptsLoader]"),$r=(i,e,t)=>{if(i.config.disable_external_dependency_loading)return aa.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var s=y?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[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;s.length>o;o++)if(r=n())return r.v}var a=()=>{if(!y)return t("document not found");var l=y.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),i.config.prepare_external_dependency_script&&(l=i.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(i.config.external_scripts_inject_target==="head")y.head.appendChild(l);else{var c,u=y.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):y.body.appendChild(l)}};y!=null&&y.body?a():y?.addEventListener("DOMContentLoaded",a)};$.__PosthogExtensions__=$.__PosthogExtensions__||{},$.__PosthogExtensions__.loadExternalDependency=(i,e,t)=>{var s="/static/"+e+".js?v="+i.version;if(e==="remote-config"&&(s="/array/"+i.config.token+"/config.js"),e==="toolbar"){var r=3e5;s=s+"&t="+Math.floor(Date.now()/r)*r}var n=i.requestRouter.endpointFor("assets",s);$r(i,n,t)},$.__PosthogExtensions__.loadSiteApp=(i,e,t)=>{var s=i.requestRouter.endpointFor("api",e);$r(i,s,t)};var Yn="$people_distinct_id",si="$device_id",kt="__alias",St="__timers",Fr="$autocapture_disabled_server_side",gs="$heatmaps_enabled_server_side",Ir="$exception_capture_enabled_server_side",_s="$error_tracking_suppression_rules",Rr="$error_tracking_capture_extension_exceptions",Cr="$web_vitals_enabled_server_side",Jn="$dead_clicks_enabled_server_side",Mr="$product_tours_enabled_server_side",Nr="$web_vitals_allowed_metrics",zt="$session_recording_remote_config",ri="$sesid",Kn="$session_is_sampled",rt="$enabled_feature_flags",Pt="$early_access_features",fs="$feature_flag_details",Tt="$stored_person_properties",Ve="$stored_group_properties",ms="$surveys",Ft="$flag_call_reported",ys="$flag_call_reported_session_id",bs="$feature_flag_errors",ni="$feature_flag_evaluated_at",me="$user_state",ws="$client_session_props",Es="$capture_rate_limit",xs="$initial_campaign_params",ks="$initial_referrer_info",oi="$initial_person_info",ai="$epp",Xn="__POSTHOG_TOOLBAR__",Bt="$posthog_cookieless",la=[Yn,kt,"__cmpns",St,"$session_recording_enabled_server_side",gs,ri,rt,_s,me,Pt,fs,Ve,Tt,ms,Ft,ys,bs,ni,ws,Es,xs,ks,ai,oi],nr="PostHog loadExternalDependency extension not found.",Te="on_reject",be="always",Xe="anonymous",Ze="identified",Ss="identified_only",li="visibilitychange",ui="beforeunload",tt="$pageview",Mi="$pageleave",Ni="$identify",Ar="$groupidentify";function Vt(i,e){L(i)&&i.forEach(e)}function W(i,e){if(!M(i))if(L(i))i.forEach(e);else if(Lo(i))i.forEach(((s,r)=>e(s,r)));else for(var t in i)Tn.call(i,t)&&e(i[t],t)}var V=function(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),s=1;e>s;s++)t[s-1]=arguments[s];for(var r of t)for(var n in r)r[n]!==void 0&&(i[n]=r[n]);return i};function Qt(i){for(var e=Object.keys(i),t=e.length,s=new Array(t);t--;)s[t]=[e[t],i[e[t]]];return s}var Lr=function(i){try{return i()}catch{return}},ua=function(i){return function(){try{for(var e=arguments.length,t=new Array(e),s=0;e>s;s++)t[s]=arguments[s];return i.apply(this,t)}catch(r){w.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),w.critical(r)}}},or=function(i){var e={};return W(i,(function(t,s){(Y(t)&&t.length>0||ke(t))&&(e[s]=t)})),e},ca=["herokuapp.com","vercel.app","netlify.app"];function ha(i){var e=i?.hostname;if(!Y(e))return!1;var t=e.split(".").slice(-2).join(".");for(var s of ca)if(t===s)return!1;return!0}function G(i,e,t,s){var{capture:r=!1,passive:n=!0}=s??{};i?.addEventListener(e,t,{capture:r,passive:n})}function Zn(i){return i.name==="ph_toolbar_internal"}Math.trunc||(Math.trunc=function(i){return 0>i?Math.ceil(i):Math.floor(i)}),Number.isInteger||(Number.isInteger=function(i){return ke(i)&&isFinite(i)&&Math.floor(i)===i});var Ps=class i{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,s,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(s)||!Number.isInteger(r)||0>e||0>t||0>s||0>r||e>0xffffffffffff||t>4095||s>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new i(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),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 i(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var s=this.bytes[t]-e.bytes[t];if(s!==0)return Math.sign(s)}return 0}},Ts=class{constructor(){this.k=0,this.R=0,this.P=new Os}generate(){var e=this.generateOrAbort();if(E(e)){this.k=0;var t=this.generateOrAbort();if(E(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.k)this.k=e,this.O();else{if(this.k>=e+1e4)return;this.R++,this.R>4398046511103&&(this.k++,this.O())}return Ps.fromFieldsV7(this.k,Math.trunc(this.R/Math.pow(2,30)),this.R&Math.pow(2,30)-1,this.P.nextUint32())}O(){this.R=1024*this.P.nextUint32()+(1023&this.P.nextUint32())}},Dr,Qn=i=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;i.length>e;e++)i[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return i};d&&!E(d.crypto)&&crypto.getRandomValues&&(Qn=i=>crypto.getRandomValues(i));var Os=class{constructor(){this.I=new Uint32Array(8),this.C=1/0}nextUint32(){return this.I.length>this.C||(Qn(this.I),this.C=0),this.I[this.C++]}},Ue=()=>da().toString(),da=()=>(Dr||(Dr=new Ts)).generate(),vt="",pa=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Ee={F:()=>!!y,A(i){w.error("cookieStore error: "+i)},M(i){if(y){try{for(var e=i+"=",t=y.cookie.split(";").filter((n=>n.length)),s=0;t.length>s;s++){for(var r=t[s];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},D(i){var e;try{e=JSON.parse(Ee.M(i))||{}}catch{}return e},L(i,e,t,s,r){if(y)try{var n="",o="",a=(function(u,h){if(h){var v=(function(_,p){if(p===void 0&&(p=y),vt)return vt;if(!p||["localhost","127.0.0.1"].includes(_))return"";for(var I=_.split("."),O=Math.min(I.length,8),P="dmn_chk_"+Ue();!vt&&O--;){var F=I.slice(O).join("."),S=P+"=1;domain=."+F+";path=/";p.cookie=S+";max-age=3",p.cookie.includes(P)&&(p.cookie=S+";max-age=0",vt=F)}return vt})(u);if(!v){var g=(_=>{var p=_.match(pa);return p?p[0]:""})(u);g!==v&&w.info("Warning: cookie subdomain discovery mismatch",g,v),v=g}return v?"; domain=."+v:""}return""})(y.location.hostname,s);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=i+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&w.warn("cookieStore warning: large cookie, len="+c.length),y.cookie=c,c}catch{return}},U(i,e){if(y!=null&&y.cookie)try{Ee.L(i,"",-1,e)}catch{return}}},Ai=null,q={F(){if(!Ie(Ai))return Ai;var i=!0;if(E(d))i=!1;else try{var e="__mplssupport__";q.L(e,"xyz"),q.M(e)!=='"xyz"'&&(i=!1),q.U(e)}catch{i=!1}return i||w.error("localStorage unsupported; falling back to cookie store"),Ai=i,i},A(i){w.error("localStorage error: "+i)},M(i){try{return d?.localStorage.getItem(i)}catch(e){q.A(e)}return null},D(i){try{return JSON.parse(q.M(i))||{}}catch{}return null},L(i,e){try{d?.localStorage.setItem(i,JSON.stringify(e))}catch(t){q.A(t)}},U(i){try{d?.localStorage.removeItem(i)}catch(e){q.A(e)}}},va=[si,"distinct_id",ri,Kn,ai,oi,me],Gt={},ga={F:()=>!0,A(i){w.error("memoryStorage error: "+i)},M:i=>Gt[i]||null,D:i=>Gt[i]||null,L(i,e){Gt[i]=e},U(i){delete Gt[i]}},We=null,ee={F(){if(!Ie(We))return We;if(We=!0,E(d))We=!1;else try{var i="__support__";ee.L(i,"xyz"),ee.M(i)!=='"xyz"'&&(We=!1),ee.U(i)}catch{We=!1}return We},A(i){w.error("sessionStorage error: ",i)},M(i){try{return d?.sessionStorage.getItem(i)}catch(e){ee.A(e)}return null},D(i){try{return JSON.parse(ee.M(i))||null}catch{}return null},L(i,e){try{d?.sessionStorage.setItem(i,JSON.stringify(e))}catch(t){ee.A(t)}},U(i){try{d?.sessionStorage.removeItem(i)}catch(e){ee.A(e)}}},$s=class{constructor(e){this._instance=e}get N(){return this._instance.config}get consent(){return this.j()?0:this.B}isOptedOut(){return this.N.cookieless_mode===be||this.consent===0||this.consent===-1&&(this.N.opt_out_capturing_by_default||this.N.cookieless_mode===Te)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.H.L(this.q,e?1:0,this.N.cookie_expiration,this.N.cross_subdomain_cookie,this.N.secure_cookie)}reset(){this.H.U(this.q,this.N.cross_subdomain_cookie)}get q(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:s}=this._instance.config;return s||(t?t+e:"__ph_opt_in_out_"+e)}get B(){var e=this.H.M(this.q);return Ii(e)?1:C(jo,e)?0:-1}get H(){if(!this.W){var e=this.N.opt_out_capturing_persistence_type;this.W=e==="localStorage"?q:Ee;var t=e==="localStorage"?Ee:q;t.M(this.q)&&(this.W.M(this.q)||this.optInOut(Ii(t.M(this.q))),t.U(this.q,this.N.cross_subdomain_cookie))}return this.W}j(){return!!this.N.respect_dnt&&[ue?.doNotTrack,ue?.msDoNotTrack,$.doNotTrack].some((e=>Ii(e)))}},Yt=z("[Dead Clicks]"),_a=()=>!0,fa=i=>{var e,t=!((e=i.instance.persistence)==null||!e.get_property(Jn)),s=i.instance.config.capture_dead_clicks;return $e(s)?s:!!K(s)||t},ci=class{get lazyLoadedDeadClicksAutocapture(){return this.V}constructor(e,t,s){this.instance=e,this.isEnabled=t,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Jn]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.Y((()=>{this.G()})):this.stop()}Y(e){var t,s;(t=$.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Yt.error("failed to load script",r):e()}))}G(){var e;if(y){if(!this.V&&(e=$.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=K(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.V=$.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.V.start(y),Yt.info("starting...")}}else Yt.error("`document` not found. Cannot start.")}stop(){this.V&&(this.V.stop(),this.V=void 0,Yt.info("stopping..."))}},Li=z("[SegmentIntegration]"),eo="posthog-js";function to(i,e){var{organization:t,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,v;if(n!=="*"&&!n.includes(a.level)||!i.__loaded)return a;a.tags||(a.tags={});var g=i.requestRouter.endpointFor("ui","/project/"+i.config.token+"/person/"+i.get_distinct_id());a.tags["PostHog Person URL"]=g,i.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=i.get_session_replay_url({withTimestamp:!0}));var _,p=((l=a.exception)==null?void 0:l.values)||[],I=p.map((P=>m({},P,{stacktrace:P.stacktrace?m({},P.stacktrace,{type:"raw",frames:(P.stacktrace.frames||[]).map((F=>m({},F,{platform:"web:javascript"})))}):void 0}))),O={$exception_message:((c=p[0])==null?void 0:c.value)||a.message,$exception_type:(u=p[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:I,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=p[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(v=p[0])==null?void 0:v.type,$sentry_tags:a.tags};return t&&s&&(O.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+s+"&query="+a.event_id),o&&((_=i.exceptions)==null||_.sendExceptionEvent(O)),a}}var Fs=class{constructor(e,t,s,r,n,o){this.name=eo,this.setupOnce=function(a){a(to(e,{organization:t,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},hi=class{constructor(e){this.J=(t,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(w.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.K=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.X()}X(){var e;this.Z=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.J)}destroy(){var e;(e=this.Z)==null||e.call(this),this.Z=void 0}doPageView(e,t){var s,r=this.tt(e,t);return this.K={pathname:(s=d?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.tt(e,(t=this.K)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.K)==null?void 0:e.pageViewId}}tt(e,t){var s=this.K;if(!s)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=n;if(!(E(o)||E(a)||E(l)||E(c)||E(u)||E(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),h=Math.ceil(h);var v=o>1?xe(a/o,0,1,w):1,g=o>1?xe(l/o,0,1,w):1,_=c>1?xe(u/c,0,1,w):1,p=c>1?xe(h/c,0,1,w):1;r=V(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:v,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},di=i=>{var e=y?.createElement("a");return E(e)?null:(e.href=i,e)},pi=function(i,e){for(var t,s=((i.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===e){t=n;break}}if(!L(t)||2>t.length)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{w.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Lt=function(i,e,t){if(!i||!e||!e.length)return i;for(var s=i.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),c=[],u=0;l.length>u;u++){var h=l[u].split("=");L(h)&&(e.includes(h[0])?c.push(h[0]+"="+t):c.push(l[u]))}var v=a;return o!=null&&(v+="?"+c.join("&")),r!=null&&(v+="#"+r),v},vi=function(i,e){var t=i.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Jt="https?://(.*)",ht=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ma=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...ht],Dt="<masked>",ya=["li_fat_id"];function io(i,e,t){if(!y)return{};var s,r=e?[...ht,...t||[]]:[],n=so(Lt(y.URL,r,Dt),i),o=(s={},W(ya,(function(a){var l=Ee.M(a);s[a]=l||null})),s);return V(o,n)}function so(i,e){var t=ma.concat(e||[]),s={};return W(t,(function(r){var n=pi(i,r);s[r]=n||null})),s}function ro(i){var e=(function(n){return n?n.search(Jt+"google.([^/?]*)")===0?"google":n.search(Jt+"bing.com")===0?"bing":n.search(Jt+"yahoo.com")===0?"yahoo":n.search(Jt+"duckduckgo.com")===0?"duckduckgo":null:null})(i),t=e!="yahoo"?"q":"p",s={};if(!Ie(e)){s.$search_engine=e;var r=y?pi(y.referrer,t):"";r.length&&(s.ph_keyword=r)}return s}function Ur(){return navigator.language||navigator.userLanguage}var gi="$direct";function no(){return y?.referrer||gi}function oo(i,e){var t=i?[...ht,...e||[]]:[],s=Q?.href.substring(0,1e3);return{r:no().substring(0,1e3),u:s?Lt(s,t,Dt):void 0}}function ao(i){var e,{r:t,u:s}=i,r={$referrer:t,$referring_domain:t==null?void 0:t==gi?gi:(e=di(t))==null?void 0:e.host};if(s){r.$current_url=s;var n=di(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=so(s);V(r,o)}if(t){var a=ro(t);V(r,a)}return r}function lo(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function ba(){try{return new Date().getTimezoneOffset()}catch{return}}var wa=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],It=class{constructor(e,t){this.N=e,this.props={},this.it=!1,this.et=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.H=this.rt(e),this.load(),e.debug&&w.info("Persistence loaded",e.persistence,m({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.st}rt(e){wa.indexOf(e.persistence.toLowerCase())===-1&&(w.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...va,...r];return m({},q,{D(o){try{var a={};try{a=Ee.D(o)||{}}catch{}var l=V(a,JSON.parse(q.M(o)||"{}"));return q.L(o,l),l}catch{}return null},L(o,a,l,c,u,h){try{q.L(o,a,void 0,void 0,h);var v={};n.forEach((g=>{a[g]&&(v[g]=a[g])})),Object.keys(v).length&&Ee.L(o,v,l,c,u,h)}catch(g){q.A(g)}},U(o,a){try{d?.localStorage.removeItem(o),Ee.U(o,a)}catch(l){q.A(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&q.F()?q:s==="localstorage+cookie"&&t.F()?t:s==="sessionstorage"&&ee.F()?ee:s==="memory"?ga:s==="cookie"?Ee:t.F()?t:Ee}nt(e){var t=e??this.N.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var s=this.props[ni];return!s||typeof s!="number"||Date.now()-s>t}properties(){var e={};return W(this.props,((t,s)=>{if(s===rt&&K(t)){if(!this.nt())for(var r=Object.keys(t),n=0;r.length>n;n++)e["$feature/"+r[n]]=t[r[n]]}else la.indexOf(s)===-1&&(e[s]=t)})),e}load(){if(!this.st){var e=this.H.D(this.et);e&&(this.props=V({},e))}}save(){this.st||this.H.L(this.et,this.props,this.ot,this.ut,this.ht,this.N.debug)}remove(){this.H.U(this.et,!1),this.H.U(this.et,!0)}clear(){this.remove(),this.props={}}register_once(e,t,s){if(K(e)){E(t)&&(t="None"),this.ot=E(s)?this.dt:s;var r=!1;if(W(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(K(e)){this.ot=E(t)?this.dt:t;var s=!1;if(W(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.it){var e=io(this.N.custom_campaign_params,this.N.mask_personal_data_properties,this.N.custom_personal_data_properties);st(or(e))||this.register(e),this.it=!0}}update_search_keyword(){var e;this.register((e=y?.referrer)?ro(e):{})}update_referrer_info(){var e;this.register_once({$referrer:no(),$referring_domain:y!=null&&y.referrer&&((e=di(y.referrer))==null?void 0:e.host)||gi},void 0)}set_initial_person_info(){this.props[xs]||this.props[ks]||this.register_once({[oi]:oo(this.N.mask_personal_data_properties,this.N.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};W([ks,xs],(o=>{var a=this.props[o];a&&W(a,(function(l,c){e["$initial_"+es(c)]=l}))}));var t,s,r=this.props[oi];if(r){var n=(t=ao(r),s={},W(t,(function(o,a){s["$initial_"+es(a)]=o})),s);V(e,n)}return e}safe_merge(e){return W(this.props,(function(t,s){s in e||(e[s]=t)})),e}update_config(e,t,s){if(this.dt=this.ot=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),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,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.rt(e),n=this.props;this.clear(),this.H=r,this.props=n,this.save()}}set_disabled(e){this.st=e,this.st?this.remove():this.save()}set_cross_subdomain(e){e!==this.ut&&(this.ut=e,this.remove(),this.save())}set_secure(e){e!==this.ht&&(this.ht=e,this.remove(),this.save())}set_event_timer(e,t){var s=this.props[St]||{};s[e]=t,this.props[St]=s,this.save()}remove_event_timer(e){var t=(this.props[St]||{})[e];return E(t)||(delete this.props[St][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},gt={Activation:"events",Cancellation:"cancelEvents"};var Di={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"};var Ot={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Ui={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},Is={Popover:"popover",Inline:"inline"};var Ea={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},jr={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Hr=z("[RateLimiter]"),Rs=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var s=t.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{Hr.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Hr.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},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,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(s=this.instance.persistence)==null?void 0:s.get_property(Es))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var c=1>l.tokens;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 "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(r=this.instance.persistence)==null||r.set_property(Es,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},_t=z("[RemoteConfig]"),_i=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=$._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}vt(e){var t,s;(t=$.__PosthogExtensions__)!=null&&t.loadExternalDependency?(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}ct(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 _t.info("Using preloaded remote config",this.remoteConfig),this.ft(this.remoteConfig),void this._t();if(this._instance.bt())return void _t.warn("Remote config is disabled. Falling back to local config.");this.vt((e=>{if(!e)return _t.info("No config found after loading remote JS config. Falling back to JSON."),void this.ct((t=>{this.ft(t),this._t()}));this.ft(e),this._t()}))}catch(e){_t.error("Error loading remote config",e)}}stop(){this.yt&&(clearInterval(this.yt),this.yt=void 0)}refresh(){this._instance.bt()||y?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}_t(){var e;if(!this.yt){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.yt=setInterval((()=>{this.refresh()}),t))}}ft(e){var t;e||_t.error("Failed to fetch remote config from PostHog."),this._instance.ft(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}};var we={GZipJS:"gzip-js",Base64:"base64"},ve=Uint8Array,re=Uint16Array,dt=Uint32Array,ar=new ve([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]),lr=new ve([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]),Wr=new ve([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uo=function(i,e){for(var t=new re(31),s=0;31>s;++s)t[s]=e+=1<<i[s-1];var r=new dt(t[30]);for(s=1;30>s;++s)for(var n=t[s];t[s+1]>n;++n)r[n]=n-t[s]<<5|s;return[t,r]},co=uo(ar,2),Cs=co[1];co[0][28]=258,Cs[258]=28;for(Ms=uo(lr,0)[1],fi=new re(32768),H=0;32768>H;++H)qe=(43690&H)>>>1|(21845&H)<<1,fi[H]=((65280&(qe=(61680&(qe=(52428&qe)>>>2|(13107&qe)<<2))>>>4|(3855&qe)<<4))>>>8|(255&qe)<<8)>>>1;var qe,Ms,fi,H,Rt=function(i,e,t){for(var s=i.length,r=0,n=new re(e);s>r;++r)++n[i[r]-1];var o,a=new re(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new re(1<<e);var l=15-e;for(r=0;s>r;++r)if(i[r])for(var c=r<<4|i[r],u=e-i[r],h=a[i[r]-1]++<<u,v=h|(1<<u)-1;v>=h;++h)o[fi[h]>>>l]=c}else for(o=new re(s),r=0;s>r;++r)o[r]=fi[a[i[r]-1]++]>>>15-i[r];return o},Ye=new ve(288);for(H=0;144>H;++H)Ye[H]=8;for(H=144;256>H;++H)Ye[H]=9;for(H=256;280>H;++H)Ye[H]=7;for(H=280;288>H;++H)Ye[H]=8;var mi=new ve(32);for(H=0;32>H;++H)mi[H]=5;var xa=Rt(Ye,9,0),ka=Rt(mi,5,0),ho=function(i){return(i/8>>0)+(7&i&&1)},po=function(i,e,t){(t==null||t>i.length)&&(t=i.length);var s=new(i instanceof re?re:i instanceof dt?dt:ve)(t-e);return s.set(i.subarray(e,t)),s},Pe=function(i,e,t){var s=e/8>>0;i[s]|=t<<=7&e,i[s+1]|=t>>>8},ft=function(i,e,t){var s=e/8>>0;i[s]|=t<<=7&e,i[s+1]|=t>>>8,i[s+2]|=t>>>16},ji=function(i,e){for(var t=[],s=0;i.length>s;++s)i[s]&&t.push({s,f:i[s]});var r=t.length,n=t.slice();if(!r)return[new ve(0),0];if(r==1){var o=new ve(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(x,k){return x.f-k.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=t[t[h].f>t[c].f?c++:h++],l=t[c!=u&&t[h].f>t[c].f?c++:h++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(s=1;r>s;++s)n[s].s>v&&(v=n[s].s);var g=new re(v+1),_=Ns(t[u-1],g,0);if(_>e){s=0;var p=0,I=_-e,O=1<<I;for(n.sort((function(x,k){return g[k.s]-g[x.s]||x.f-k.f}));r>s;++s){var P=n[s].s;if(e>=g[P])break;p+=O-(1<<_-g[P]),g[P]=e}for(p>>>=I;p>0;){var F=n[s].s;e>g[F]?p-=1<<e-g[F]++-1:++s}for(;s>=0&&p;--s){var S=n[s].s;g[S]==e&&(--g[S],++p)}_=e}return[new ve(g),_]},Ns=function(i,e,t){return i.s==-1?Math.max(Ns(i.l,e,t+1),Ns(i.r,e,t+1)):e[i.s]=t},qr=function(i){for(var e=i.length;e&&!i[--e];);for(var t=new re(++e),s=0,r=i[0],n=1,o=function(l){t[s++]=l},a=1;e>=a;++a)if(i[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=i[a]}return[t.subarray(0,s),e]},mt=function(i,e){for(var t=0,s=0;e.length>s;++s)t+=i[s]*e[s];return t},As=function(i,e,t){var s=t.length,r=ho(e+2);i[r]=255&s,i[r+1]=s>>>8,i[r+2]=255^i[r],i[r+3]=255^i[r+1];for(var n=0;s>n;++n)i[r+n+4]=t[n];return 8*(r+4+s)},zr=function(i,e,t,s,r,n,o,a,l,c,u){Pe(e,u++,t),++r[256];for(var h=ji(r,15),v=h[0],g=h[1],_=ji(n,15),p=_[0],I=_[1],O=qr(v),P=O[0],F=O[1],S=qr(p),x=S[0],k=S[1],b=new re(19),f=0;P.length>f;++f)b[31&P[f]]++;for(f=0;x.length>f;++f)b[31&x[f]]++;for(var T=ji(b,7),A=T[0],N=T[1],R=19;R>4&&!A[Wr[R-1]];--R);var D,U,J,Z,ne=c+5<<3,B=mt(r,Ye)+mt(n,mi)+o,te=mt(r,v)+mt(n,p)+o+14+3*R+mt(b,A)+(2*b[16]+3*b[17]+7*b[18]);if(B>=ne&&te>=ne)return As(e,u,i.subarray(l,l+c));if(Pe(e,u,1+(B>te)),u+=2,B>te){D=Rt(v,g,0),U=v,J=Rt(p,I,0),Z=p;var he=Rt(A,N,0);for(Pe(e,u,F-257),Pe(e,u+5,k-1),Pe(e,u+10,R-4),u+=14,f=0;R>f;++f)Pe(e,u+3*f,A[Wr[f]]);u+=3*R;for(var de=[P,x],Se=0;2>Se;++Se){var ae=de[Se];for(f=0;ae.length>f;++f)Pe(e,u,he[ge=31&ae[f]]),u+=A[ge],ge>15&&(Pe(e,u,ae[f]>>>5&127),u+=ae[f]>>>12)}}else D=xa,U=Ye,J=ka,Z=mi;for(f=0;a>f;++f)if(s[f]>255){var ge;ft(e,u,D[257+(ge=s[f]>>>18&31)]),u+=U[ge+257],ge>7&&(Pe(e,u,s[f]>>>23&31),u+=ar[ge]);var _e=31&s[f];ft(e,u,J[_e]),u+=Z[_e],_e>3&&(ft(e,u,s[f]>>>5&8191),u+=lr[_e])}else ft(e,u,D[s[f]]),u+=U[s[f]];return ft(e,u,D[256]),u+U[256]},Sa=new dt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Pa=(function(){for(var i=new dt(256),e=0;256>e;++e){for(var t=e,s=9;--s;)t=(1&t&&3988292384)^t>>>1;i[e]=t}return i})(),Hi=function(i,e,t){for(;t;++e)i[e]=t,t>>>=8};function Ta(i,e){e===void 0&&(e={});var t=(function(){var h=4294967295;return{p(v){for(var g=h,_=0;v.length>_;++_)g=Pa[255&g^v[_]]^g>>>8;h=g},d(){return 4294967295^h}}})(),s=i.length;t.p(i);var r,n,o,a,l,c=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,v,g,_,p,I){var O=h.length,P=new ve(_+O+5*(1+Math.floor(O/7e3))+p),F=P.subarray(_,P.length-p),S=0;if(!v||8>O)for(var x=0;O>=x;x+=65535){var k=x+65535;O>k?S=As(F,S,h.subarray(x,k)):(F[x]=!0,S=As(F,S,h.subarray(x,O)))}else{for(var b=Sa[v-1],f=b>>>13,T=8191&b,A=(1<<g)-1,N=new re(32768),R=new re(A+1),D=Math.ceil(g/3),U=2*D,J=function(Fi){return(h[Fi]^h[Fi+1]<<D^h[Fi+2]<<U)&A},Z=new dt(25e3),ne=new re(288),B=new re(32),te=0,he=0,de=(x=0,0),Se=0,ae=0;O>x;++x){var ge=J(x),_e=32767&x,Ke=R[ge];if(N[_e]=Ke,R[ge]=_e,x>=Se){var Ht=O-x;if((te>7e3||de>24576)&&Ht>423){S=zr(h,F,0,Z,ne,B,he,de,ae,x-ae,S),de=te=he=0,ae=x;for(var fe=0;286>fe;++fe)ne[fe]=0;for(fe=0;30>fe;++fe)B[fe]=0}var He=2,Wt=0,$o=T,Ce=_e-Ke&32767;if(Ht>2&&ge==J(x-Ce))for(var Fo=Math.min(f,Ht)-1,Io=Math.min(32767,x),Ro=Math.min(258,Ht);Io>=Ce&&--$o&&_e!=Ke;){if(h[x+He]==h[x+He-Ce]){for(var Me=0;Ro>Me&&h[x+Me]==h[x+Me-Ce];++Me);if(Me>He){if(He=Me,Wt=Ce,Me>Fo)break;var Co=Math.min(Ce,Me-2),hr=0;for(fe=0;Co>fe;++fe){var $i=x-Ce+fe+32768&32767,dr=$i-N[$i]+32768&32767;dr>hr&&(hr=dr,Ke=$i)}}}Ce+=(_e=Ke)-(Ke=N[_e])+32768&32767}if(Wt){Z[de++]=268435456|Cs[He]<<18|Ms[Wt];var pr=31&Cs[He],vr=31&Ms[Wt];he+=ar[pr]+lr[vr],++ne[257+pr],++B[vr],Se=x+He,++te}else Z[de++]=h[x],++ne[h[x]]}}S=zr(h,F,!0,Z,ne,B,he,de,ae,x-ae,S)}return po(P,0,_+ho(S)+p)})(n=i,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),u=c.length;return(function(h,v){var g=v.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>v.level?4:v.level==9?2:0,h[9]=3,v.mtime!=0&&Hi(h,4,Math.floor(new Date(v.mtime||Date.now())/1e3)),g){h[3]=8;for(var _=0;g.length>=_;++_)h[_+10]=g.charCodeAt(_)}})(c,e),Hi(c,u-8,t.d()),Hi(c,u-4,s),c}var Oa=!!Qi||!!Zi,vo="text/plain",yi=function(i,e,t){var s;t===void 0&&(t=!0);var[r,n]=i.split("?"),o=m({},e),a=(s=n?.split("&").map((c=>{var u,[h,v]=c.split("="),g=t&&(u=o[h])!==null&&u!==void 0?u:v;return delete o[h],h+"="+g})))!==null&&s!==void 0?s:[],l=(function(c,u){var h,v;u===void 0&&(u="&");var g=[];return W(c,(function(_,p){E(_)||E(p)||p==="undefined"||(h=encodeURIComponent((I=>I instanceof File)(_)?_.name:_.toString()),v=encodeURIComponent(p),g[g.length]=v+"="+h)})),g.join(u)})(o);return l&&a.push(l),r+"?"+a.join("&")},nt=(i,e)=>JSON.stringify(i,((t,s)=>typeof s=="bigint"?s.toString():s),e),Wi=i=>{if(i.wt)return i.wt;var{data:e,compression:t}=i;if(e){if(t===we.GZipJS){var s=Ta((function(a,l){var c=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var u=new ve(a.length+(a.length>>>1)),h=0,v=function(I){u[h++]=I},g=0;c>g;++g){if(h+5>u.length){var _=new ve(h+8+(c-g<<1));_.set(u),u=_}var p=a.charCodeAt(g);128>p?v(p):2048>p?(v(192|p>>>6),v(128|63&p)):p>55295&&57344>p?(v(240|(p=65536+(1047552&p)|1023&a.charCodeAt(++g))>>>18),v(128|p>>>12&63),v(128|p>>>6&63),v(128|63&p)):(v(224|p>>>12),v(128|p>>>6&63),v(128|63&p))}return po(u,0,h)})(nt(e)),{mtime:0});return{contentType:vo,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(t===we.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,c)=>String.fromCharCode(parseInt(c,16)))))})(nt(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:nt(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=nt(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},$a=(function(){var i=ye((function*(e){var t=nt(e.data),s=yield(function(n,o){return Sn.apply(this,arguments)})(t,le.DEBUG);if(!s)return e;var r=yield s.arrayBuffer();return m({},e,{wt:{contentType:vo,body:r,estimatedSize:r.byteLength}})}));return function(e){return i.apply(this,arguments)}})(),ei=[];Zi&&ei.push({transport:"fetch",method(i){var e,t,{contentType:s,body:r,estimatedSize:n}=(e=Wi(i))!==null&&e!==void 0?e:{},o=new Headers;W(i.headers,(function(u,h){o.append(h,u)})),s&&o.append("Content-Type",s);var a=i.url,l=null;if(br){var c=new br;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),i.timeout)}}Zi(a,m({method:i?.method||"GET",headers:o,keepalive:i.method==="POST"&&52428.8>(n||0),body:r,signal:(t=l)==null?void 0:t.signal},i.fetchOptions)).then((u=>u.text().then((h=>{var v={statusCode:u.status,text:h};if(u.status===200)try{v.json=JSON.parse(h)}catch(g){w.error(g)}i.callback==null||i.callback(v)})))).catch((u=>{w.error(u),i.callback==null||i.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Qi&&ei.push({transport:"XHR",method(i){var e,t=new Qi;t.open(i.method||"GET",i.url,!0);var{contentType:s,body:r}=(e=Wi(i))!==null&&e!==void 0?e:{};W(i.headers,(function(n,o){t.setRequestHeader(o,n)})),s&&t.setRequestHeader("Content-Type",s),i.timeout&&(t.timeout=i.timeout),i.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}i.callback==null||i.callback(n)}},t.send(r)}}),ue!=null&&ue.sendBeacon&&ei.push({transport:"sendBeacon",method(i){var e=yi(i.url,{beacon:"1"});try{var t,{contentType:s,body:r}=(t=Wi(i))!==null&&t!==void 0?t:{},n=typeof r=="string"?new Blob([r],{type:s}):r;ue.sendBeacon(e,n)}catch{}}});var Ls=3e3,Ds=class{constructor(e,t){this.Et=!0,this.St=[],this.xt=xe(t?.flush_interval_ms||Ls,250,5e3,w.createLogger("flush interval"),Ls),this.Tt=e}enqueue(e){this.St.push(e),this.$t||this.kt()}unload(){this.Rt();var e=this.St.length>0?this.Pt():{},t=Object.values(e);[...t.filter((s=>s.url.indexOf("/e")===0)),...t.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.Tt(m({},s,{transport:"sendBeacon"}))}))}enable(){this.Et=!1,this.kt()}kt(){var e=this;this.Et||(this.$t=setTimeout((()=>{if(this.Rt(),this.St.length>0){var t=this.Pt(),s=function(){var n=t[r],o=new Date().getTime();n.data&&L(n.data)&&W(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Tt(n)};for(var r in t)s()}}),this.xt))}Rt(){clearTimeout(this.$t),this.$t=void 0}Pt(){var e={};return W(this.St,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;E(e[n])&&(e[n]=m({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.St=[],e}},Fa=["retriesPerformedSoFar"],Us=class{constructor(e){this.Ot=!1,this.It=3e3,this.St=[],this._instance=e,this.St=[],this.Ct=!0,!E(d)&&"onLine"in d.navigator&&(this.Ct=d.navigator.onLine,this.Ft=()=>{this.Ct=!0,this.At()},this.Mt=()=>{this.Ct=!1},G(d,"online",this.Ft),G(d,"offline",this.Mt))}get length(){return this.St.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,s=kn(e,Fa);et(t)&&(s.url=yi(s.url,{retry_count:t})),this._instance._send_request(m({},s,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(t??0)>=10?s.callback==null||s.callback(r):this.Dt(m({retriesPerformedSoFar:t},s))}}))}Dt(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var s=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=Math.random()-.5;return Math.ceil(c+u*(c-l))})(t),r=Date.now()+s;this.St.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),w.warn(n),this.Ot||(this.Ot=!0,this.Lt())}Lt(){if(this.Ut&&clearTimeout(this.Ut),this.St.length===0)return this.Ot=!1,void(this.Ut=void 0);this.Ut=setTimeout((()=>{this.Ct&&this.St.length>0&&this.At(),this.Lt()}),this.It)}At(){var e=Date.now(),t=[],s=this.St.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.St=t,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ut&&(clearTimeout(this.Ut),this.Ut=void 0),this.Ot=!1,E(d)||(this.Ft&&(d.removeEventListener("online",this.Ft),this.Ft=void 0),this.Mt&&(d.removeEventListener("offline",this.Mt),this.Mt=void 0)),this.St))try{this._instance._send_request(m({},e,{transport:"sendBeacon"}))}catch(t){w.error(t)}this.St=[]}},js=class{constructor(e){this.Nt=()=>{var t,s,r,n;this.jt||(this.jt={});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.jt.lastScrollY=Math.ceil(a),this.jt.maxScrollY=Math.max(a,(t=this.jt.maxScrollY)!==null&&t!==void 0?t:0),this.jt.maxScrollHeight=Math.max(l,(s=this.jt.maxScrollHeight)!==null&&s!==void 0?s:0),this.jt.lastContentY=c,this.jt.maxContentY=Math.max(c,(r=this.jt.maxContentY)!==null&&r!==void 0?r:0),this.jt.maxContentHeight=Math.max(u,(n=this.jt.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get zt(){return this._instance.config.scroll_root_selector}getContext(){return this.jt}resetContext(){var e=this.jt;return setTimeout(this.Nt,0),e}startMeasuringScrollPosition(){G(d,"scroll",this.Nt,{capture:!0}),G(d,"scrollend",this.Nt,{capture:!0}),G(d,"resize",this.Nt)}scrollElement(){if(!this.zt)return d?.document.documentElement;var e=L(this.zt)?this.zt:[this.zt];for(var t of e){var s=d?.document.querySelector(t);if(s)return s}}scrollY(){if(this.zt){var e=this.scrollElement();return e&&e.scrollTop||0}return d&&(d.scrollY||d.pageYOffset||d.document.documentElement.scrollTop)||0}scrollX(){if(this.zt){var e=this.scrollElement();return e&&e.scrollLeft||0}return d&&(d.scrollX||d.pageXOffset||d.document.documentElement.scrollLeft)||0}},Ia=i=>oo(i?.config.mask_personal_data_properties,i?.config.custom_personal_data_properties),bi=class{constructor(e,t,s,r){this.Bt=n=>{var o=this.Ht();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.qt(this._instance)};this.Wt.register({[ws]:a})}},this._instance=e,this.Vt=t,this.Wt=s,this.qt=r||Ia,this.Vt.onSessionId(this.Bt)}Ht(){return this.Wt.props[ws]}getSetOnceProps(){var e,t=(e=this.Ht())==null?void 0:e.props;return t?"r"in t?ao(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 W(or(this.getSetOnceProps()),((t,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+es(s)]=t})),e}},Ut=class{constructor(){this.Yt={}}on(e,t){return this.Yt[e]||(this.Yt[e]=[]),this.Yt[e].push(t),()=>{this.Yt[e]=this.Yt[e].filter((s=>s!==t))}}emit(e,t){for(var s of this.Yt[e]||[])s(t);for(var r of this.Yt["*"]||[])r(e,t)}},qi=z("[SessionId]"),wi=class{on(e,t){return this.Gt.on(e,t)}constructor(e,t,s){var r;if(this.Jt=[],this.Kt=void 0,this.Gt=new Ut,this.Xt=(c,u)=>!(!et(c)||!et(u))&&Math.abs(c-u)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===be)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.N=e.config,this.Wt=e.persistence,this.Qt=void 0,this.Zt=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ti=t||Ue,this.ii=s||Ue;var n=this.N.persistence_name||this.N.token;if(this._sessionTimeoutMs=1e3*xe(this.N.session_idle_timeout_seconds||1800,60,36e3,qi.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ei(),this.ri="ph_"+n+"_window_id",this.si="ph_"+n+"_primary_window_exists",this.ni()){var o=ee.D(this.ri),a=ee.D(this.si);o&&!a?this.Qt=o:ee.U(this.ri),ee.L(this.si,!0)}if((r=this.N.bootstrap)!=null&&r.sessionID)try{var l=(c=>{var u=this.N.bootstrap.sessionID.replace(/-/g,"");if(u.length!==32)throw new Error("Not a valid UUID");if(u[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(u.substring(0,12),16)})();this.oi(this.N.bootstrap.sessionID,new Date().getTime(),l)}catch(c){qi.error("Invalid sessionID in bootstrap",c)}this.ai()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return E(this.Jt)&&(this.Jt=[]),this.Jt.push(e),this.Zt&&e(this.Zt,this.Qt),()=>{this.Jt=this.Jt.filter((t=>t!==e))}}ni(){return this.N.persistence!=="memory"&&!this.Wt.st&&ee.F()}li(e){e!==this.Qt&&(this.Qt=e,this.ni()&&ee.L(this.ri,e))}ui(){return this.Qt?this.Qt:this.ni()?ee.D(this.ri):null}oi(e,t,s){e===this.Zt&&t===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=t,this.Zt=e,this.Wt.register({[ri]:[t,e,s]}))}hi(){var e=this.Wt.props[ri];return L(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.oi(null,null,null)}destroy(){clearTimeout(this.di),this.di=void 0,this.Kt&&d&&(d.removeEventListener(ui,this.Kt,{capture:!1}),this.Kt=void 0),this.Jt=[]}ai(){this.Kt=()=>{this.ni()&&ee.U(this.si)},G(d,ui,this.Kt,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.N.cookieless_mode===be)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=t||new Date().getTime(),[r,n,o]=this.hi(),a=this.ui(),l=et(o)&&Math.abs(s-o)>864e5,c=!1,u=!n,h=!u&&!e&&this.Xt(s,r);u||h||l?(n=this.ti(),a=this.ii(),qi.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,c=!0):a||(a=this.ii(),c=!0);var v=et(r)&&e&&!l?r:s,g=et(o)?o:new Date().getTime();return this.li(a),this.oi(n,v,g),e||this.ei(),c&&this.Jt.forEach((_=>_(n,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}ei(){clearTimeout(this.di),this.di=setTimeout((()=>{var[e]=this.hi();if(this.Xt(new Date().getTime(),e)){var t=this.Zt;this.resetSessionId(),this.Gt.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},go=function(i,e){if(!i)return!1;var t=i.userAgent;if(t&&xr(t,e))return!0;try{var s=i?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>xr(r?.brand,e))))return!0}catch{}return!!i.webdriver},Ei=function(i,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(i)}catch{return!1}};function Br(i,e,t){return nt({distinct_id:i,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var _o={exact:(i,e)=>e.some((t=>i.some((s=>t===s)))),is_not:(i,e)=>e.every((t=>i.every((s=>t!==s)))),regex:(i,e)=>e.some((t=>i.some((s=>Ei(t,s))))),not_regex:(i,e)=>e.every((t=>i.every((s=>!Ei(t,s))))),icontains:(i,e)=>e.map(Kt).some((t=>i.map(Kt).some((s=>t.includes(s))))),not_icontains:(i,e)=>e.map(Kt).every((t=>i.map(Kt).every((s=>!t.includes(s))))),gt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s>parseFloat(r)))})),lt:(i,e)=>e.some((t=>{var s=parseFloat(t);return!isNaN(s)&&i.some((r=>s<parseFloat(r)))}))},Kt=i=>i.toLowerCase();function fo(i,e){return!i||Object.entries(i).every((t=>{var[s,r]=t,n=e?.[s];if(E(n)||Ie(n))return!1;var o=[String(n)],a=_o[r.operator];return!!a&&a(r.values,o)}))}var Hs="custom",Vr="i.posthog.com",Ws=class{constructor(e){this.vi={},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("."+Vr,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.vi[this.apiHost]||(this.vi[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":Hs),this.vi[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===Hs)return this.apiHost+t;var s=Vr+t;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}},j=z("[Surveys]"),qs="seenSurvey_",Ra=(i,e)=>{var t="$survey_"+e+"/"+i.id;return i.current_iteration&&i.current_iteration>0&&(t="$survey_"+e+"/"+i.id+"/"+i.current_iteration),t},Gr=i=>((e,t)=>{var s=""+qs+t.id;return t.current_iteration&&t.current_iteration>0&&(s=""+qs+t.id+"_"+t.current_iteration),s})(0,i),Ca=[Di.Popover,Di.Widget,Di.API],Ma={ignoreConditions:!1,ignoreDelay:!1,displayType:Is.Popover},Na=z("[PostHog ExternalIntegrations]"),Aa={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},zs=class{constructor(e){this._instance=e}Y(e,t){var s;(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return Na.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!r||(a=$.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.Y(Aa[o],(()=>{var u;(u=$.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!r&&(l=$.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=$.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(s)}}},Ct={},zi=0,Bs=()=>{},Yr='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',yt="Surveys module not available",Jr="sanitize_properties is deprecated. Use before_send instead",mo="Invalid value for property_denylist config: ",it="posthog",yo=!Oa&&oe?.indexOf("MSIE")===-1&&oe?.indexOf("Mozilla")===-1,Kr=i=>{var e;return m({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ha(y?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Bs,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:i??"unset",__preview_deferred_init_extensions:!1,debug:Q&&Y(Q?.search)&&Q.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:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(d==null||(e=d.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_feature_flags_dedup_per_session:!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){w.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ss,before_send:void 0,request_queue_config:{flush_interval_ms:Ls},error_tracking:{},_onCapture:Bs,__preview_eager_load_replay:!1},(t=>({rageclick:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"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}))(i))},La=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Xr=i=>{var e={};for(var[t,s]of La)E(i[t])||(e[s]=i[t]);var r=V({},e,i);return L(i.property_blacklist)&&(E(i.property_denylist)?r.property_denylist=i.property_blacklist:L(i.property_denylist)?r.property_denylist=[...i.property_blacklist,...i.property_denylist]:w.error(mo+i.property_denylist)),r},Vs=class{constructor(){this.__forceAllowLocalhost=!1}get ci(){return this.__forceAllowLocalhost}set ci(e){w.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},pt=class i{fi(e,t){if(e){var s=this.pi.indexOf(e);s!==-1&&this.pi.splice(s,1)}return this.pi.push(t),t.initialize==null||t.initialize(),t}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(){var e;this.webPerformance=new Vs,this.gi=!1,this.version=le.LIB_VERSION,this.mi=new Ut,this.pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Kr(),this.SentryIntegration=Fs,this.sentryIntegration=s=>(function(r,n){var o=to(r,n);return{name:eo,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.bi=!1,this.yi=null,this.wi=null,this.Ei=null,this.scrollManager=new js(this),this.pageViewManager=new hi(this),this.rateLimiter=new Rs(this),this.requestRouter=new Ws(this),this.consent=new $s(this),this.externalIntegrations=new zs(this);var t=(e=i.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(s,r,n)=>{var o=Y(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=Y(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>w.info('send "'+s?.event+'"',s)))}init(e,t,s){if(s&&s!==it){var r,n=(r=Ct[s])!==null&&r!==void 0?r:new i;return n._init(e,t,s),Ct[s]=n,Ct[it][s]=n,n}return this._init(e,t,s)}_init(e,t,s){var r;if(t===void 0&&(t={}),E(e)||Zt(e))return w.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.Si(t.debug),this.xi=t,this.Ti=[],t.person_profiles?this.wi=t.person_profiles:t.process_person&&(this.wi=t.process_person),this.set_config(V({},Kr(t.defaults),Xr(t),{name:s,token:e})),this.config.on_xhr_error&&w.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:we.GZipJS;var n=this.$i();this.persistence=new It(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new It(m({},this.config,{persistence:"sessionStorage"}),n);var o=m({},this.persistence.props),a=m({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.ki=new Ds((p=>this.Ri(p)),this.config.request_queue_config),this.Pi=new Us(this),this.__request_queue=[];var l=this.config.cookieless_mode===be||this.config.cookieless_mode===Te&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new wi(this),this.sessionPropsManager=new bi(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(w.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Oi(l)}),0)):(w.info("Initializing extensions synchronously"),this.Oi(l)),le.DEBUG=le.DEBUG||this.config.debug,le.DEBUG&&w.info("Starting in debug mode",{this:this,config:t,thisC:m({},this.config),p:o,s:a}),((r=t.bootstrap)==null?void 0:r.distinctID)!==void 0){var c=t.bootstrap.distinctID,u=this.get_distinct_id(),h=this.persistence.get_property(me);if(t.bootstrap.isIdentifiedID&&u!=null&&u!==c&&h===Xe)this.identify(c);else if(t.bootstrap.isIdentifiedID&&u!=null&&u!==c&&h===Ze)w.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var v=this.config.get_device_id(Ue()),g=t.bootstrap.isIdentifiedID?v:c;this.persistence.set_property(me,t.bootstrap.isIdentifiedID?Ze:Xe),this.register({distinct_id:c,$device_id:g})}}if(l)this.register_once({distinct_id:Bt,$device_id:null},"");else if(!this.get_distinct_id()){var _=this.config.get_device_id(Ue());this.register_once({distinct_id:_,$device_id:_},""),this.persistence.set_property(me,Xe)}return G(d,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(p,I){var O=p.config.segment;if(!O)return I();(function(P,F){var S=P.config.segment;if(!S)return F();var x=b=>{var f=()=>b.anonymousId()||Ue();P.config.get_device_id=f,b.id()&&(P.register({distinct_id:b.id(),$device_id:f()}),P.persistence.set_property(me,Ze)),F()},k=S.user();"then"in k&&Oe(k.then)?k.then(x):x(k)})(p,(()=>{O.register((P=>{Promise&&Promise.resolve||Li.warn("This browser does not have Promise support, and can not use the segment integration");var F=(S,x)=>{if(!x)return S;S.event.userId||S.event.anonymousId===P.get_distinct_id()||(Li.info("No userId set, resetting PostHog"),P.reset()),S.event.userId&&S.event.userId!==P.get_distinct_id()&&(Li.info("UserId set, identifying with PostHog"),P.identify(S.event.userId));var k=P.calculateEventProperties(x,S.event.properties);return S.event.properties=Object.assign({},k,S.event.properties),S};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:S=>F(S,S.event.event),page:S=>F(S,tt),identify:S=>F(S,Ni),screen:S=>F(S,"$screen")}})(p)).then((()=>{I()}))}))})(this,(()=>this.Ii())):this.Ii(),Oe(this.config._onCapture)&&this.config._onCapture!==Bs&&(w.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(p=>this.config._onCapture(p.event,p)))),this.config.ip&&w.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}Oi(e){var t,s,r,n,o,a,l,c=performance.now(),u=m({},i.__defaultExtensionClasses,this.config.__extensionClasses),h=[];u.featureFlags&&this.pi.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new u.featureFlags(this)),u.exceptions&&this.pi.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new u.exceptions(this)),u.historyAutocapture&&this.pi.push(this.historyAutocapture=new u.historyAutocapture(this)),u.tracingHeaders&&this.pi.push(new u.tracingHeaders(this)),u.siteApps&&this.pi.push(this.siteApps=new u.siteApps(this)),u.sessionRecording&&!e&&this.pi.push(this.sessionRecording=new u.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),u.autocapture&&this.pi.push(this.autocapture=new u.autocapture(this)),u.surveys&&this.pi.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new u.surveys(this)),u.logs&&this.pi.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new u.logs(this)),u.conversations&&this.pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new u.conversations(this)),u.productTours&&this.pi.push(this.productTours=new u.productTours(this)),u.heatmaps&&this.pi.push(this.heatmaps=new u.heatmaps(this)),u.webVitalsAutocapture&&this.pi.push(this.webVitalsAutocapture=new u.webVitalsAutocapture(this)),u.exceptionObserver&&this.pi.push(this.exceptionObserver=new u.exceptionObserver(this)),u.deadClicksAutocapture&&this.pi.push(this.deadClicksAutocapture=new u.deadClicksAutocapture(this,fa)),u.toolbar&&this.pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new u.toolbar(this)),u.experiments&&this.pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new u.experiments(this)),this.pi.forEach((v=>{v.initialize&&h.push((()=>{v.initialize==null||v.initialize()}))})),h.push((()=>{if(this.Ci){var v=this.Ci;this.Ci=void 0,this.ft(v)}})),this.Fi(h,c)}Fi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Fi(e,t)}),0);var s=e.shift();if(s)try{s()}catch(n){w.error("Error initializing extension:",n)}}var r=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:r}),this.config.__preview_deferred_init_extensions&&w.info("PostHog extensions initialized ("+r+"ms)")}ft(e){var t;if(!y||!y.body)return w.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.ft(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Ci=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=C(e.supportedCompression,we.GZipJS)?we.GZipJS:C(e.supportedCompression,we.Base64)?we.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.wi?this.wi:Ss}),this.pi.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Ii(){try{this.config.loaded(this)}catch(s){w.critical("`loaded` function failed",s)}if(this.Ai(),this.config.internal_or_test_user_hostname&&Q!=null&&Q.hostname){var e=Q.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===be)&&this.Mi()}),1),this.Di=new _i(this),this.Di.load()}Ai(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.ki)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Vt(this.__request_queue,(e=>this.Ri(e))),this.__request_queue=[],this.Ai()}_handle_unload(){var e,t,s;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Li()&&this.capture(Mi),(t=this.ki)==null||t.unload(),(s=this.Pi)==null||s.unload()):this.Li()&&this.capture(Mi,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(yo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=yi(e.url,{ip:this.config.ip?1:0}),e.headers=m({},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 s,r,n,o=m({},t);o.timeout=o.timeout||6e4,o.url=yi(o.url,{_:new Date().getTime().toString(),ver:le.JS_SDK_VERSION,compression:o.compression});var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=ei.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(r=(n=(function(u,h){for(var v=0;u.length>v;v++)if(u[v].transport===a)return u[v]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!c)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===we.GZipJS&&Mo?$a(o).then((u=>{c(u)})).catch((()=>{c(o)})):c(o)})(m({},e,{callback:t=>{var s,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(s=(r=this.config).on_request_error)==null||s.call(r,t),e.callback==null||e.callback(t)}}))))}Ri(e){this.Pi?this.Pi.retriableRequest(e):this._send_request(e)}_execute_array(e){zi++;try{var t,s=[],r=[],n=[];Vt(e,(a=>{a&&(L(t=a[0])?n.push(a):Oe(a)?a.call(this):L(a)&&t==="alias"?s.push(a):L(a)&&t.indexOf("capture")!==-1&&Oe(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Vt(a,(function(c){if(L(c[0])){var u=l;W(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else l[c[0]].apply(l,c.slice(1))}))};o(s,this),o(r,this),o(n,this)}finally{zi--}}push(e){if(zi>0&&L(e)&&Y(e[0])){var t=i.prototype[e[0]];Oe(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r,n,o,a,l,c;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.ki){if(this.is_capturing())if(!E(e)&&Y(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var h=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(h==null||!h.isRateLimited){t!=null&&t.$current_url&&!Y(t?.$current_url)&&(w.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||s!=null&&s.Ui||w.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),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 v=new Date,g=s?.timestamp||v,_=Ue(),p={uuid:_,event:e,properties:this.calculateEventProperties(e,t||{},g,_)};e===tt&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),h&&(p.properties.$lib_rate_limit_remaining_tokens=h.remainingTokens),s?.$set&&(p.$set=s?.$set);var I,O=this.Ni(s?.$set_once,e!==Ar,e===Ni);if(O&&(p.$set_once=O),(n=p,o=s!=null&&s._noTruncate?null:this.config.properties_string_max_length,a=n,l=f=>Y(f)&&!Ie(o)?f.slice(0,o):f,c=new Set,p=(function f(T,A){return T!==Object(T)?l?l(T):T:c.has(T)?void 0:(c.add(T),L(T)?(N=[],Vt(T,(R=>{N.push(f(R))}))):(N={},W(T,((R,D)=>{c.has(R)||(N[D]=f(R,D))}))),N);var N})(a)).timestamp=g,E(s?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=v),e===Ot.DISMISSED||e===Ot.SENT){var P=t?.[Ui.SURVEY_ID],F=t?.[Ui.SURVEY_ITERATION];I={id:P,current_iteration:F},localStorage.getItem(Gr(I))||localStorage.setItem(Gr(I),"true"),p.$set=m({},p.$set,{[Ra({id:P,current_iteration:F},e===Ot.SENT?"responded":"dismissed")]:!0})}else e===Ot.SHOWN&&(p.$set=m({},p.$set,{[Ui.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Ea.SHOWN){var S=t?.[jr.TOUR_TYPE];S&&(p.$set=m({},p.$set,{[jr.TOUR_LAST_SEEN_DATE+"/"+S]:new Date().toISOString()}))}var x=m({},p.properties.$set,p.$set);if(st(x)||this.setPersonPropertiesForFlags(x),!M(this.config.before_send)){var k=this.ji(p);if(!k)return;p=k}this.mi.emit("eventCaptured",p);var b={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Ri(b):this.ki.enqueue(b),p}w.critical("This capture call is ignored due to client rate limiting.")}}else w.error("No event name provided to posthog.capture")}else w.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=m({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==be||this.config.cookieless_mode==Te&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=m({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Y(a.distinct_id)&&!ke(a.distinct_id)||Zt(a.distinct_id))&&w.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=(function(O,P){var F,S,x,k;if(!oe)return{};var b,f,T,A,N,R,D,U,J=O?[...ht,...P||[]]:[],[Z,ne]=(function(B){for(var te=0;Pr.length>te;te++){var[he,de]=Pr[te],Se=he.exec(B),ae=Se&&(Oe(de)?de(Se,B):de);if(ae)return ae}return["",""]})(oe);return V(or({$os:Z,$os_version:ne,$browser:zn(oe,navigator.vendor),$device:Tr(oe),$device_type:(f=oe,T={userAgentDataPlatform:(F=navigator)==null||(F=F.userAgentData)==null?void 0:F.platform,maxTouchPoints:(S=navigator)==null?void 0:S.maxTouchPoints,screenWidth:d==null||(x=d.screen)==null?void 0:x.width,screenHeight:d==null||(k=d.screen)==null?void 0:k.height,devicePixelRatio:d?.devicePixelRatio},U=Tr(f),U===Fn||U===$n||U==="Kobo"||U==="Kindle Fire"||U===qn?lt:U===Nt||U===at||U===At||U===ss?"Console":U===Rn?"Wearable":U?ce:T?.userAgentDataPlatform==="Android"&&((A=T?.maxTouchPoints)!==null&&A!==void 0?A:0)>0?600>Math.min((N=T?.screenWidth)!==null&&N!==void 0?N:0,(R=T?.screenHeight)!==null&&R!==void 0?R:0)/((D=T?.devicePixelRatio)!==null&&D!==void 0?D:1)?ce:lt:"Desktop"),$timezone:lo(),$timezone_offset:ba()}),{$current_url:Lt(Q?.href,J,Dt),$host:Q?.host,$pathname:Q?.pathname,$raw_user_agent:oe.length>1e3?oe.substring(0,997)+"...":oe,$browser_version:Jo(oe,navigator.vendor),$browser_language:Ur(),$browser_language_prefix:(b=Ur(),typeof b=="string"?b.split("-")[0]:void 0),$screen_height:d?.screen.height,$screen_width:d?.screen.width,$viewport_height:d?.innerHeight,$viewport_width:d?.innerWidth,$lib:le.LIB_NAME,$lib_version:le.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:v}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=h,a.$window_id=v}this.sessionPropsManager&&V(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&V(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Pi)==null?void 0:g.length}catch(O){a.$sdk_debug_error_capturing_properties=String(O)}if(this.requestRouter.region===Hs&&(a.$lib_custom_api_host=this.config.api_host),c=e!==tt||n?e!==Mi||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=V(a,c),e===tt&&y&&(a.title=y.title),!E(o)){var _=s.getTime()-o;a.$duration=parseFloat((_/1e3).toFixed(3))}oe&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=V({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),L(this.config.property_denylist)?W(this.config.property_denylist,(function(O){delete a[O]})):w.error(mo+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var p=this.config.sanitize_properties;p&&(w.error(Jr),a=p(a,e));var I=this.zi();return a.$process_person_profile=I,I&&!n&&this.Bi("_calculate_event_properties"),a}Ni(e,t,s){var r;if(t===void 0&&(t=!0),s===void 0&&(s=!1),!this.persistence||!this.zi()||this.gi&&!s)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=V({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(w.error(Jr),a=l(a,"$set_once")),t&&(this.gi=!0),st(a)?void 0:a}register(e,t){var s;(s=this.persistence)==null||s.register(e,t)}register_once(e,t,s){var r;(r=this.persistence)==null||r.register_once(e,t,s)}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)}Hi(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var s;return(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,s)}updateEarlyAccessFeatureEnrollment(e,t,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,s)}getEarlyAccessFeatures(e,t,s){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,s)}on(e,t){return this.mi.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:yt}),()=>{})}onSessionId(e){var t,s;return(t=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:yt})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:yt})}renderSurvey(e,t){var s;(s=this.surveys)==null||s.renderSurvey(e,t)}displaySurvey(e,t){var s;t===void 0&&(t=Ma),(s=this.surveys)==null||s.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,s;return(t=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:yt}}canRenderSurveyAsync(e,t){var s,r;return t===void 0&&(t=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:yt})}qi(e){return!e||Zt(e)?(w.critical("Unique user id has not been set in posthog.identify"),!1):e===Bt?(w.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(w.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.'),!1)}identify(e,t,s){if(!this.__loaded||!this.persistence)return w.uninitializedWarning("posthog.identify");if(ke(e)&&(e=e.toString(),w.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.qi(e)&&this.Bi("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(si)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(kt)&&(this.unregister(kt),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(me)||Xe)===Xe;e!==r&&o?(this.persistence.set_property(me,Ze),this.setPersonPropertiesForFlags(m({},s||{},t||{}),!1),this.capture(Ni,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this.Ei=Br(e,t,s),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(Ft))}}setPersonProperties(e,t){if((e||t)&&this.Bi("posthog.setPersonProperties")){var s=Br(this.get_distinct_id(),e,t);this.Ei!==s?(this.setPersonPropertiesForFlags(m({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ei=s):w.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:m({},r,{[e]:t})}),s&&(this.capture(Ar,{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}else w.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var s;t===void 0&&(t=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var s;t===void 0&&(t=!0),this.Bi("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,s,r,n,o,a,l;if(w.info("reset"),!this.__loaded)return w.uninitializedWarning("posthog.reset");var c=this.get_property(si);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Di)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.persistence)==null||a.set_property(me,Xe),(l=this.sessionManager)==null||l.resetSessionId(),this.Ei=null,this.config.cookieless_mode===be)this.register_once({distinct_id:Bt,$device_id:null},"");else{var u=this.config.get_device_id(Ue());this.register_once({distinct_id:u,$device_id:e?u:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),this.reloadFeatureFlags()}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:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(Yn)?(w.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bi("posthog.alias")?(E(t)&&(t=this.get_distinct_id()),e!==t?(this.Hi(kt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(w.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=m({},this.config);if(K(e)){var s,r,n,o,a,l,c,u,h;V(this.config,Xr(e));var v=this.$i();(s=this.persistence)==null||s.update_config(this.config,t,v),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new It(m({},this.config,{persistence:"sessionStorage"}),v);var g=this.Si(this.config.debug);$e(g)&&(this.config.debug=g),$e(this.config.debug)&&(this.config.debug?(le.DEBUG=!0,q.F()&&q.L("ph_debug",!0),w.info("set_config",{config:e,oldConfig:t,newConfig:m({},this.config)})):(le.DEBUG=!1,q.F()&&q.U("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(u=this.surveys)==null||u.loadIfEnabled(),this.Wi(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){le.LIB_NAME=e,le.LIB_VERSION=t}startSessionRecording(e){var t,s,r,n,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.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){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(m({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,s;return(t=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&t!==void 0&&t}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:it;return t!==it&&(t=it+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(me))===Ze||((t=this.sessionPersistence)==null?void 0:t.get_property(me))===Ze}zi(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ss&&!this._isIdentified()&&st(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[kt])&&((t=this.persistence)==null||(t=t.props)==null||!t[ai]))}Li(){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.zi()||this.Bi("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bi("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bi(e){return this.config.person_profiles==="never"?(w.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Hi(ai,!0),!0)}$i(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Te)}Wi(){var e,t,s,r,n=this.$i();return((e=this.persistence)==null?void 0:e.st)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.st)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==be){if(this.config.cookieless_mode===Te&&this.consent.isExplicitlyOptedOut()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new wi(this),this.pageViewManager=new hi(this),this.persistence&&(this.sessionPropsManager=new bi(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=i.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.fi(this.sessionRecording,new l(this)))}var c,u;this.consent.optInOut(!0),this.Wi(),this.Ai(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==Te&&((c=this.surveys)==null||c.loadIfEnabled()),(E(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((u=e?.captureEventName)!==null&&u!==void 0?u:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Mi()}else w.warn(Yr)}opt_out_capturing(){var e,t,s;this.config.cookieless_mode!==be?(this.config.cookieless_mode===Te&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Wi(),this.config.cookieless_mode===Te&&(this.register({distinct_id:Bt,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Mi())):w.warn(Yr)}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===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===be||(this.config.cookieless_mode===Te?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Wi()}_is_bot(){return ue?go(ue,this.config.custom_blocked_useragents):void 0}Mi(){y&&(y.visibilityState==="visible"?this.bi||(this.bi=!0,this.capture(tt,{title:y.title},{send_instantly:!0}),this.yi&&(y.removeEventListener(li,this.yi),this.yi=null)):this.yi||(this.yi=this.Mi.bind(this),G(y,li,this.yi)))}debug(e){e===!1?(d?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(d?.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}))}bt(){var e,t,s,r,n,o,a=this.xi||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(w.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):(s="advanced_disable_decide",r=w,n=(t="advanced_disable_flags")in(e=a)&&!M(e[t]),o=s in e&&!M(e[s]),n?e[t]:!!o&&(r&&r.warn("Config field '"+s+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[s]))}ji(e){if(M(this.config.before_send))return e;var t=L(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of t){if(s=r(s),M(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Do(e.event)?w.warn(n+". This can cause unexpected behavior."):w.info(n),null}s.properties&&!st(s.properties)||w.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.K)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(s)})}Si(e){var t=$e(e)&&!e,s=q.F()&&q.M("ph_debug")==="true";return!t&&(!!s||e)}};function Zr(i){return i instanceof Element&&(i.id===Xn||!(i.closest==null||!i.closest(".toolbar-global-fade-container")))}function Ti(i){return!!i&&i.nodeType===1}function je(i,e){return!!i&&!!i.tagName&&i.tagName.toLowerCase()===e.toLowerCase()}function bo(i){return!!i&&i.nodeType===3}function wo(i){return!!i&&i.nodeType===11}function ur(i){return i?Si(i).split(/\s+/):[]}function Qr(i){var e=d?.location.href;return!!(e&&i&&i.some((t=>e.match(t))))}function xi(i){var e="";switch(typeof i.className){case"string":e=i.className;break;case"object":e=(i.className&&"baseVal"in i.className?i.className.baseVal:null)||i.getAttribute("class")||"";break;default:e=""}return ur(e)}function Eo(i){return M(i)?null:Si(i).split(/(\s+)/).filter((e=>Mt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function jt(i){var e="";return Ys(i)&&!ko(i)&&i.childNodes&&i.childNodes.length&&W(i.childNodes,(function(t){var s;bo(t)&&t.textContent&&(e+=(s=Eo(t.textContent))!==null&&s!==void 0?s:"")})),Si(e)}function en(i){return E(i.target)?i.srcElement||null:(e=i.target)!=null&&e.shadowRoot?i.composedPath()[0]||null:i.target||null;var e}pt.__defaultExtensionClasses={},(function(i,e){for(var t=0;e.length>t;t++)i.prototype[e[t]]=ua(i.prototype[e[t]])})(pt,["identify"]);var cr=["a","button","form","input","select","textarea","label"];function tn(i,e){if(E(e))return!0;var t,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of i)if(t=s(r))return t.v;return!1}function xo(i){var e=i.parentNode;return!(!e||!Ti(e))&&e}var Da=["next","previous","prev",">","<"],sn=[".ph-no-rageclick",".ph-no-capture"],Gs=i=>!i||je(i,"html")||!Ti(i),rn=(i,e)=>{if(!d||Gs(i))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,s=[i],r=i;r.parentNode&&!je(r,"body");)if(wo(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=xo(r);if(!n)break;if(e||cr.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=d.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}s.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:s}};function Ys(i){for(var e=i;e.parentNode&&!je(e,"body");e=e.parentNode){var t=xi(e);if(C(t,"ph-sensitive")||C(t,"ph-no-capture"))return!1}if(C(xi(i),"ph-include"))return!0;var s=i.type||"";if(Y(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=i.name||i.id||"";return!Y(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function ko(i){return!!(je(i,"input")&&!["button","checkbox","submit","reset"].includes(i.type)||je(i,"select")||je(i,"textarea")||i.getAttribute("contenteditable")==="true")}var So="(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})",Ua=new RegExp("^(?:"+So+")$"),ja=new RegExp(So),Po="\\d{3}-?\\d{2}-?\\d{4}",Ha=new RegExp("^("+Po+")$"),Wa=new RegExp("("+Po+")");function Mt(i,e){return e===void 0&&(e=!0),!(M(i)||Y(i)&&(i=Si(i),(e?Ua:ja).test((i||"").replace(/[- ]/g,""))||(e?Ha:Wa).test(i)))}function nn(i){var e=jt(i);return Mt(e=(e+" "+To(i)).trim())?e:""}function To(i){var e="";return i&&i.childNodes&&i.childNodes.length&&W(i.childNodes,(function(t){var s;if(t&&((s=t.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=jt(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+To(t)).trim())}catch(n){w.error("[AutoCapture]",n)}})),e}function on(i){return i.replace(/"|\\"/g,'\\"')}function qa(i){var e=i.attr__class;return e?L(e)?e:ur(e):void 0}var ki=class{constructor(e){this.disabled=e===!1;var t=K(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,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>s-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:s}];return!1}},Bi="$copy_autocapture",an=z("[AutoCapture]");function Vi(i,e){return e.length>i?e.slice(0,i)+"...":e}function za(i){if(i.previousElementSibling)return i.previousElementSibling;var e=i;do e=e.previousSibling;while(e&&!Ti(e));return e}function Ba(i,e){for(var t,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[i],u=i;u.parentNode&&!je(u,"body");)wo(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,v,g=[],_={},p=!1,I=!1;if(W(c,(x=>{var k=Ys(x);x.tagName.toLowerCase()==="a"&&(p=x.getAttribute("href"),p=k&&p&&Mt(p)&&p),C(xi(x),"ph-no-capture")&&(I=!0),g.push((function(f,T,A,N){var R=f.tagName.toLowerCase(),D={tag_name:R};cr.indexOf(R)>-1&&!A&&(D.$el_text=R.toLowerCase()==="a"||R.toLowerCase()==="button"?Vi(1024,nn(f)):Vi(1024,jt(f)));var U=xi(f);U.length>0&&(D.classes=U.filter((function(B){return B!==""}))),W(f.attributes,(function(B){var te;if((!ko(f)||["name","id","class","aria-label"].indexOf(B.name)!==-1)&&(N==null||!N.includes(B.name))&&!T&&Mt(B.value)&&(!Y(te=B.name)||te.substring(0,10)!=="_ngcontent"&&te.substring(0,7)!=="_nghost")){var he=B.value;B.name==="class"&&(he=ur(he).join(" ")),D["attr__"+B.name]=Vi(1024,he)}}));for(var J=1,Z=1,ne=f;ne=za(ne);)J++,ne.tagName===f.tagName&&Z++;return D.nth_child=J,D.nth_of_type=Z,D})(x,n,o,a));var b=(function(f){if(!Ys(f))return{};var T={};return W(f.attributes,(function(A){if(A.name&&A.name.indexOf("data-ph-capture-attribute")===0){var N=A.name.replace("data-ph-capture-attribute-",""),R=A.value;N&&R&&Mt(R)&&(T[N]=R)}})),T})(x);V(_,b)})),I)return{props:{},explicitNoCapture:I};if(o||(g[0].$el_text=i.tagName.toLowerCase()==="a"||i.tagName.toLowerCase()==="button"?nn(i):jt(i)),p){var O,P;g[0].attr__href=p;var F=(O=di(p))==null?void 0:O.host,S=d==null||(P=d.location)==null?void 0:P.host;F&&S&&F!==S&&(h=p)}return{props:V({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(v=g,(function(x){return x.map((k=>{var b,f,T="";if(k.tag_name&&(T+=k.tag_name),k.attr_class)for(var A of(k.attr_class.sort(),k.attr_class))T+="."+A.replace(/"/g,"");var N=m({},k.text?{text:k.text}:{},{"nth-child":(b=k.nth_child)!==null&&b!==void 0?b:0,"nth-of-type":(f=k.nth_of_type)!==null&&f!==void 0?f:0},k.href?{href:k.href}:{},k.attr_id?{attr_id:k.attr_id}:{},k.attributes),R={};return Qt(N).sort(((D,U)=>{var[J]=D,[Z]=U;return J.localeCompare(Z)})).forEach((D=>{var[U,J]=D;return R[on(U.toString())]=on(J.toString())})),(T+=":")+Qt(R).map((D=>{var[U,J]=D;return U+'="'+J+'"'})).join("")})).join(";")})((function(x){return x.map((k=>{var b,f,T={text:(b=k.$el_text)==null?void 0:b.slice(0,400),tag_name:k.tag_name,href:(f=k.attr__href)==null?void 0:f.slice(0,2048),attr_class:qa(k),attr_id:k.attr__id,nth_child:k.nth_child,nth_of_type:k.nth_of_type,attributes:{}};return Qt(k).filter((A=>{var[N]=A;return N.indexOf("attr__")===0})).forEach((A=>{var[N,R]=A;return T.attributes[N]=R})),T}))})(v)))},(t=g[0])!=null&&t.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},_)}}var bt=z("[ExceptionAutocapture]");function ln(i,e,t){try{if(!(e in i))return()=>{};var s=i[e],r=t(s);return Oe(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),i[e]=r,()=>{i[e]=s}}catch{return()=>{}}}var Va=z("[TracingHeaders]"),Ne=z("[Web Vitals]"),un=9e5,cn="disabled",hn="lazy_loading",wt="awaiting_config",Xt="missing_config";z("[SessionRecording]");var Js="[SessionRecording]",Ae=z(Js),Ga=z("[Heatmaps]");function dn(i){return K(i)&&"clientX"in i&&"clientY"in i&&ke(i.clientX)&&ke(i.clientY)}var pn=z("[Product Tours]"),Gi="ph_product_tours",Ya=["$set_once","$set"],Le=z("[SiteApps]"),vn="Error while initializing PostHog app with config id ";function Qe(i,e,t){if(M(i))return!1;switch(t){case"exact":return i===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(i);case"regex":try{return new RegExp(e).test(i)}catch{return!1}default:return!1}}var Ks=class{constructor(e){this.Vi=new Ut,this.Yi=(t,s)=>this.Gi(t,s)&&this.Ji(t,s)&&this.Ki(t,s)&&this.Xi(t,s),this.Gi=(t,s)=>s==null||!s.event||t?.event===s?.event,this._instance=e,this.Qi=new Set,this.Zi=new Set}init(){var e,t;E((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((s,r)=>{this.on(s,r)}))}register(e){var t,s;if(!E((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Zi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.Qi)==null||u.add(c?.event||"")}))})),(s=this._instance)!=null&&s.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var s;t!=null&&e.length!=0&&(this.Qi.has(e)||this.Qi.has(t?.event))&&this.Zi&&((s=this.Zi)==null?void 0:s.size)>0&&this.Zi.forEach((r=>{this.te(t,r)&&this.Vi.emit("actionCaptured",r.name)}))}ie(e){this.onAction("actionCaptured",(t=>e(t)))}te(e,t){if(t?.steps==null)return!1;for(var s of t.steps)if(this.Yi(e,s))return!0;return!1}onAction(e,t){return this.Vi.on(e,t)}Ji(e,t){if(t!=null&&t.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Qe(r,t.url,t.url_matching||"contains"))return!1}return!0}Ki(e,t){return!!this.ee(e,t)&&!!this.re(e,t)&&!!this.se(e,t)}ee(e,t){var s;if(t==null||!t.href)return!0;var r=this.ne(e);if(r.length>0)return r.some((a=>Qe(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&Qe((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}re(e,t){var s;if(t==null||!t.text)return!0;var r=this.ne(e);if(r.length>0)return r.some((c=>Qe(c.text,t.text,t.text_matching||"exact")||Qe(c.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(c){for(var u,h=[],v=/(?::|")text="(.*?)"/g;!M(u=v.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((c=>Qe(c,o,a))))}se(e,t){var s,r;if(t==null||!t.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}ne(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Xi(e,t){return t==null||!t.properties||t.properties.length===0||fo(t.properties.reduce(((s,r)=>{var n=L(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},Xs=class{constructor(e){this._instance=e,this.oe=new Map,this.ae=new Map,this.le=new Map}ue(e,t){return!!e&&fo(e.propertyFilters,t?.properties)}he(e,t){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}de(e,t,s){var r=(s===gt.Activation?this.oe:this.ae).get(e),n=[];return this.ve((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.ue(l,t)}))}register(e){var t;E((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ce(e),this.fe(e))}fe(e){var t=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.pe==null&&(this.pe=new Ks(this._instance),this.pe.init(),this.pe.ie((s=>{this.onAction(s)}))),t.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.pe)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.le.get(c.name);u&&u.push(s.id),this.le.set(c.name,u||[s.id])}})))})))}ce(e){var t,s=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));s.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.oe=this.he(e,gt.Activation),this.ae=this.he(e,gt.Cancellation))}onEvent(e,t){var s,r=this._e(),n=this.ge(),o=this.me(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&t&&a.length>0){var l,c;r.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 h=a.indexOf(u);0>h||(a.splice(h,1),this.be(a))}}else{if(this.ae.has(e)){var v=this.de(e,t,gt.Cancellation);v.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:v.map((_=>_.id))}),v.forEach((_=>{var p=a.indexOf(_.id);0>p||a.splice(p,1),this.ye(_.id)})),this.be(a))}if(this.oe.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.oe.get(e)});var g=this.de(e,t,gt.Activation);this.be(a.concat(g.map((_=>_.id))||[]))}}}onAction(e){var t,s=this.ge(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[s])||[];this.le.has(e)&&this.be(r.concat(this.le.get(e)||[]))}be(e){var t,s=this._e(),r=this.ge(),n=[...new Set(e)].filter((o=>!this.we(o)));s.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.ge();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.oe}Ee(){return this.pe}},Zs=class extends Xs{constructor(e){super(e)}ge(){return"$surveys_activated"}me(){return Ot.SHOWN}ve(e){var t;(t=this._instance)==null||t.getSurveys(e)}ye(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}_e(){return j}we(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Yi="SDK is not enabled or survey functionality is not yet loaded",gn="Disabled. Not loading surveys.",Ja=d!=null&&d.location?vi(d.location.hash,"__posthog")||vi(location.hash,"state"):null,_n="_postHogToolbarParams",fn=z("[Toolbar]"),ie=z("[FeatureFlags]"),ze=z("[FeatureFlags]",{debugEnabled:!0}),Ji=`" failed. Feature flags didn't load in time.`,Ki="$active_feature_flags",De="$override_feature_flags",mn="$feature_flag_payloads",Et="$override_feature_flag_payloads",yn="$feature_flag_request_id",bn=i=>{for(var e={},t=0;i.length>t;t++)e[i[t]]=!0;return e},wn=i=>{var e={};for(var[t,s]of Qt(i||{}))s&&(e[t]=s);return e},Xi=z("[Error tracking]"),En="Refusing to render web experiment since the viewer is a likely bot",Ka={icontains:(i,e)=>!!d&&e.href.toLowerCase().indexOf(i.toLowerCase())>-1,not_icontains:(i,e)=>!!d&&e.href.toLowerCase().indexOf(i.toLowerCase())===-1,regex:(i,e)=>!!d&&Ei(e.href,i),not_regex:(i,e)=>!!d&&!Ei(e.href,i),exact:(i,e)=>e.href===i,is_not:(i,e)=>e.href!==i},Qs=class i{get N(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),t.getWebExperiments((r=>{i.Se("retrieved web experiments from the server"),t.xe=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.xe&&(i.Se("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.xe)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);Y(a)&&n.variants[a]&&t.Te(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var c=n.variants[l];i.$e(c)&&t.Te(n.name,l,c.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())i.Se(En);else if(!this.N.disable_web_experiments){if(M(this.xe))return this.xe=new Map,this.loadIfEnabled(),void this.previewWebExperiment();i.Se("applying feature flags",e),e.forEach((t=>{var s;if(this.xe&&(s=this.xe)!=null&&s.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.xe)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Te(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=i.getWindowLocation();if(e!=null&&e.search){var t=pi(e?.search,"__experiment_id"),s=pi(e?.search,"__experiment_variant");t&&s&&(i.Se("previewing web experiments "+t+" && "+s),this.getWebExperiments((r=>{this.ke(parseInt(t),s,r)}),!1,!0))}}loadIfEnabled(){this.N.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,s){if(this.N.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.N.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}ke(e,t,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(i.Se("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Te(r[0].name,t,r[0].variants[t].transforms))}static $e(e){return!M(e.conditions)&&i.Re(e)&&i.Pe(e)}static Re(e){var t;if(M(e.conditions)||M((t=e.conditions)==null?void 0:t.url))return!0;var s,r,n,o=i.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||Ka[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return d?.location}static Pe(e){var t;if(M(e.conditions)||M((t=e.conditions)==null?void 0:t.utm))return!0;var s=io();if(s.utm_source){var r,n,o,a,l,c,u,h,v=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==s.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==s.utm_source,_=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==s.utm_medium,p=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return v&&_&&p&&g}return!1}static Se(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;t>r;r++)s[r-1]=arguments[r];w.info("[WebExperiments] "+e,s)}Te(e,t,s){this._is_bot()?i.Se(En):t!=="control"?s.forEach((r=>{if(r.selector){var n;i.Se("applying transform of variant "+t+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):i.Se("Control variants leave the page unmodified.")}_is_bot(){return ue&&this._instance?go(ue,this.N.custom_blocked_useragents):void 0}},pe=z("[Conversations]"),Be="Conversations not available yet.",Oi={featureFlags:class{constructor(i){this.Oe=!1,this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.De=!1,this.Le=!1,this._instance=i,this.featureFlagEventHandlers=[]}get N(){return this._instance.config}get Wt(){return this._instance.persistence}Ue(i){return this._instance.get_property(i)}Ne(){var i,e;return(i=(e=this.Wt)==null?void 0:e.nt(this.N.feature_flag_cache_ttl_ms))!==null&&i!==void 0&&i}je(){return!!this.Ne()&&(this.Le||this.Ce||(this.Le=!0,ie.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}ze(){var i,e=(i=this.N.evaluation_contexts)!==null&&i!==void 0?i:this.N.evaluation_environments;return!this.N.evaluation_environments||this.N.evaluation_contexts||this.De||(ie.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.De=!0),e!=null&&e.length?e.filter((t=>{var s=t&&typeof t=="string"&&t.trim().length>0;return s||ie.error("Invalid evaluation context found:",t,"Expected non-empty string"),s})):[]}Be(){return this.ze().length>0}initialize(){var i,e,{config:t}=this._instance,s=(i=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&i!==void 0?i:{};if(Object.keys(s).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter((c=>!!s[c])).reduce(((c,u)=>(c[u]=s[u]||!1,c)),{}),l=Object.keys(o).filter((c=>a[c])).reduce(((c,u)=>(o[u]&&(c[u]=o[u]),c)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(i,e,t){var s=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=m({},s,i),o=m({},r,e),a={};for(var[l,c]of Object.entries(n)){var u=typeof c=="string";a[l]={key:l,enabled:!!u||!!c,variant:u?c:void 0,reason:void 0,metadata:E(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Ie}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var i=this.Ue(fs),e=this.Ue(De),t=this.Ue(Et);if(!t&&!e)return i||{};var s=V({},i||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=s[n],c=e?.[n],u=E(c)?(o=l?.enabled)!==null&&o!==void 0&&o:!!c,h=E(c)?l.variant:typeof c=="string"?c:void 0,v=t?.[n],g=m({},l,{enabled:u,variant:u?h??l?.variant:void 0});u!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),v&&(g.metadata=m({},l?.metadata,{payload:v,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),s[n]=g}return this.Oe||(ie.warn(" Overriding feature flag details!",{flagDetails:i,overriddenPayloads:t,finalDetails:s}),this.Oe=!0),s}getFlagVariants(){var i=this.Ue(rt),e=this.Ue(De);if(!e)return i||{};for(var t=V({},i),s=Object.keys(e),r=0;s.length>r;r++)t[s[r]]=e[s[r]];return this.Oe||(ie.warn(" Overriding feature flags!",{enabledFlags:i,overriddenFlags:e,finalFlags:t}),this.Oe=!0),t}getFlagPayloads(){var i=this.Ue(mn),e=this.Ue(Et);if(!e)return i||{};for(var t=V({},i||{}),s=Object.keys(e),r=0;s.length>r;r++)t[s[r]]=e[s[r]];return this.Oe||(ie.warn(" Overriding feature flag payloads!",{flagPayloads:i,overriddenPayloads:e,finalPayloads:t}),this.Oe=!0),t}reloadFeatureFlags(){this.Fe||this.N.advanced_disable_feature_flags||this.He||(this._instance.mi.emit("featureFlagsReloading",!0),this.He=setTimeout((()=>{this.qe()}),5))}We(){clearTimeout(this.He),this.He=void 0}ensureFlagsLoaded(){this.Ie||this.Ce||this.He||this.reloadFeatureFlags()}setAnonymousDistinctId(i){this.$anon_distinct_id=i}setReloadingPaused(i){this.Fe=i}qe(i){var e;if(this.We(),!this._instance.bt())if(this.Ce)this.Ae=!0;else{var t=this.N.token,s=this.Ue(si),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:m({},((e=this.Wt)==null?void 0:e.get_initial_props())||{},this.Ue(Tt)||{}),group_properties:this.Ue(Ve),timezone:lo()};Ie(s)||E(s)||(r.$device_id=s),(i!=null&&i.disableFlags||this.N.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Be()&&(r.evaluation_contexts=this.ze());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.N.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Ce=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.N.disable_compression?void 0:we.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback:o=>{var a,l,c,u=!0;if(o.statusCode===200&&(this.Ae||(this.$anon_distinct_id=void 0),u=!1),this.Ce=!1,!r.disable_flags||this.Ae){this.Me=!u;var h=[];o.error?o.error instanceof Error?h.push(o.error.name==="AbortError"?"timeout":"connection_error"):h.push("unknown_error"):o.statusCode!==200&&h.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var v,g=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));g&&h.push("quota_limited"),(c=this.Wt)==null||c.register({[bs]:h}),g?ie.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."):(r.disable_flags||this.receivedFeatureFlags((v=o.json)!==null&&v!==void 0?v:{},u),this.Ae&&(this.Ae=!1,this.qe()))}}})}}getFeatureFlag(i,e){var t;if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var s=this.getFeatureFlagResult(i,e);return(t=s?.variant)!==null&&t!==void 0?t:s?.enabled}}else ie.warn('getFeatureFlag for key "'+i+Ji)}getFeatureFlagDetails(i){return this.getFlagsWithDetails()[i]}getFeatureFlagPayload(i){var e=this.getFeatureFlagResult(i,{send_event:!1});return e?.payload}getFeatureFlagResult(i,e){if(e===void 0&&(e={}),!e.fresh||this.Me)if(this.Ie||this.getFlags()&&this.getFlags().length>0){if(!this.je()){var t=this.getFlagVariants(),s=i in t,r=t[i],n=this.getFlagPayloads()[i],o=String(r),a=this.Ue(yn)||void 0,l=this.Ue(ni)||void 0,c=this.Ue(Ft)||{};if(this.N.advanced_feature_flags_dedup_per_session){var u,h=this._instance.get_session_id(),v=this.Ue(ys);h&&h!==v&&(c={},(u=this.Wt)==null||u.register({[Ft]:c,[ys]:h}))}if((e.send_event||!("send_event"in e))&&(!(i in c)||!c[i].includes(o))){var g,_,p,I,O,P,F,S,x,k;L(c[i])?c[i].push(o):c[i]=[o],(g=this.Wt)==null||g.register({[Ft]:c});var b=this.getFeatureFlagDetails(i),f=[...(_=this.Ue(bs))!==null&&_!==void 0?_:[]];E(r)&&f.push("flag_missing");var T={$feature_flag:i,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((p=this.N.bootstrap)==null||(p=p.featureFlags)==null?void 0:p[i])||null,$feature_flag_bootstrapped_payload:((I=this.N.bootstrap)==null||(I=I.featureFlagPayloads)==null?void 0:I[i])||null,$used_bootstrap_value:!this.Me};E(b==null||(O=b.metadata)==null?void 0:O.version)||(T.$feature_flag_version=b.metadata.version);var A,N=(P=b==null||(F=b.reason)==null?void 0:F.description)!==null&&P!==void 0?P:b==null||(S=b.reason)==null?void 0:S.code;N&&(T.$feature_flag_reason=N),b!=null&&(x=b.metadata)!=null&&x.id&&(T.$feature_flag_id=b.metadata.id),E(b?.original_variant)&&E(b?.original_enabled)||(T.$feature_flag_original_response=E(b.original_variant)?b.original_enabled:b.original_variant),b!=null&&(k=b.metadata)!=null&&k.original_payload&&(T.$feature_flag_original_payload=b==null||(A=b.metadata)==null?void 0:A.original_payload),f.length&&(T.$feature_flag_error=f.join(",")),this._instance.capture("$feature_flag_called",T)}if(s){var R=n;if(!E(n))try{R=JSON.parse(n)}catch{}return{key:i,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:R}}}}else ie.warn('getFeatureFlagResult for key "'+i+Ji)}getRemoteConfigPayload(i,e){var t=this.N.token,s={distinct_id:this._instance.get_distinct_id(),token:t};this.Be()&&(s.evaluation_contexts=this.ze()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this.N.disable_compression?void 0:we.Base64,timeout:this.N.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[i]||void 0)}})}isFeatureEnabled(i,e){if(e===void 0&&(e={}),!e.fresh||this.Me){if(this.Ie||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(i,e);return E(t)?void 0:!!t}ie.warn('isFeatureEnabled for key "'+i+Ji)}}addFeatureFlagsHandler(i){this.featureFlagEventHandlers.push(i)}removeFeatureFlagsHandler(i){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==i))}receivedFeatureFlags(i,e){if(this.Wt){this.Ie=!0;var t=this.getFlagVariants(),s=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(n,o,a,l,c){a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c={});var u=(k=>{var b=k.flags;return b?(k.featureFlags=Object.fromEntries(Object.keys(b).map((f=>{var T;return[f,(T=b[f].variant)!==null&&T!==void 0?T:b[f].enabled]}))),k.featureFlagPayloads=Object.fromEntries(Object.keys(b).filter((f=>b[f].enabled)).filter((f=>{var T;return(T=b[f].metadata)==null?void 0:T.payload})).map((f=>{var T;return[f,(T=b[f].metadata)==null?void 0:T.payload]})))):ie.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),k})(n),h=u.flags,v=u.featureFlags,g=u.featureFlagPayloads;if(v){var _=n.requestId,p=n.evaluatedAt;if(L(v)){ie.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var I={};if(v)for(var O=0;v.length>O;O++)I[v[O]]=!0;o&&o.register({[Ki]:v,[rt]:I})}else{var P=v,F=g,S=h;if(n.errorsWhileComputingFlags)if(h){var x=new Set(Object.keys(h).filter((k=>{var b;return!((b=h[k])!=null&&b.failed)})));P=m({},a,Object.fromEntries(Object.entries(P).filter((k=>{var[b]=k;return x.has(b)})))),F=m({},l,Object.fromEntries(Object.entries(F||{}).filter((k=>{var[b]=k;return x.has(b)})))),S=m({},c,Object.fromEntries(Object.entries(S||{}).filter((k=>{var[b]=k;return x.has(b)}))))}else P=m({},a,P),F=m({},l,F),S=m({},c,S);o&&o.register(m({[Ki]:Object.keys(wn(P)),[rt]:P||{},[mn]:F||{},[fs]:S||{}},_?{[yn]:_}:{},p?{[ni]:p}:{}))}}})(i,this.Wt,t,s,r),e||(this.Le=!1),this.Ve(e)}}override(i,e){e===void 0&&(e=!1),ie.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:i,suppressWarning:e})}overrideFeatureFlags(i){if(!this._instance.__loaded||!this.Wt)return ie.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(i===!1)return this.Wt.unregister(De),this.Wt.unregister(Et),this.Ve(),ze.info("All overrides cleared");if(L(i)){var e=bn(i);return this.Wt.register({[De]:e}),this.Ve(),ze.info("Flag overrides set",{flags:i})}if(i&&typeof i=="object"&&("flags"in i||"payloads"in i)){var t,s=i;if(this.Oe=!!((t=s.suppressWarning)!==null&&t!==void 0&&t),"flags"in s){if(s.flags===!1)this.Wt.unregister(De),ze.info("Flag overrides cleared");else if(s.flags){if(L(s.flags)){var r=bn(s.flags);this.Wt.register({[De]:r})}else this.Wt.register({[De]:s.flags});ze.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this.Wt.unregister(Et),ze.info("Payload overrides cleared")):s.payloads&&(this.Wt.register({[Et]:s.payloads}),ze.info("Payload overrides set",{payloads:s.payloads}))),void this.Ve()}if(i&&typeof i=="object")return this.Wt.register({[De]:i}),this.Ve(),ze.info("Flag overrides set",{flags:i});ie.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:i})}onFeatureFlags(i){if(this.addFeatureFlagsHandler(i),this.Ie){var{flags:e,flagVariants:t}=this.Ye();i(e,t)}return()=>this.removeFeatureFlagsHandler(i)}updateEarlyAccessFeatureEnrollment(i,e,t){var s,r=(this.Ue(Pt)||[]).find((l=>l.flagKey===i)),n={["$feature_enrollment/"+i]:e},o={$feature_flag:i,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=m({},this.getFlagVariants(),{[i]:e});(s=this.Wt)==null||s.register({[Ki]:Object.keys(wn(a)),[rt]:a}),this.Ve()}getEarlyAccessFeatures(i,e,t){e===void 0&&(e=!1);var s=this.Ue(Pt),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(s&&!e)return i(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.N.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.Wt)==null||o.unregister(Pt),(a=this.Wt)==null||a.register({[Pt]:l}),i(l)}}})}Ye(){var i=this.getFlags(),e=this.getFlagVariants();return{flags:i.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,s)=>(t[s]=e[s],t)),{})}}Ve(i){var{flags:e,flagVariants:t}=this.Ye();this.featureFlagEventHandlers.forEach((s=>s(e,t,{errorsLoading:i})))}setPersonPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=this.Ue(Tt)||{};this._instance.register({[Tt]:m({},t,i)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Tt)}setGroupPropertiesForFlags(i,e){e===void 0&&(e=!0);var t=this.Ue(Ve)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((s=>{t[s]=m({},t[s],i[s]),delete i[s]})),this._instance.register({[Ve]:m({},t,i)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(i){if(i){var e=this.Ue(Ve)||{};this._instance.register({[Ve]:m({},e,{[i]:{}})})}else this._instance.unregister(Ve)}reset(){this.Ie=!1,this.Ce=!1,this.Fe=!1,this.Ae=!1,this.Me=!1,this.$anon_distinct_id=void 0,this.We(),this.Oe=!1}}},Xa={sessionRecording:class{get N(){return this._instance.config}get Wt(){return this._instance.persistence}get started(){var i;return!((i=this.Ge)==null||!i.isStarted)}get status(){var i,e;return this.Je===wt||this.Je===Xt?this.Je:(i=(e=this.Ge)==null?void 0:e.status)!==null&&i!==void 0?i:this.Je}constructor(i){if(this._forceAllowLocalhostNetworkCapture=!1,this.Je=cn,this.Ke=void 0,this._instance=i,!this._instance.sessionManager)throw Ae.error("started without valid sessionManager"),new Error(Js+" started without valid sessionManager. This is a bug.");if(this.N.cookieless_mode===be)throw new Error(Js+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get Xe(){var i,e=!((i=this._instance.get_property(zt))==null||!i.enabled),t=!this.N.disable_session_recording,s=this.N.disable_session_recording||this._instance.consent.isOptedOut();return d&&e&&t&&!s}startIfEnabledOrStop(i){var e;if(!this.Xe||(e=this.Ge)==null||!e.isStarted){var t=!E(Object.assign)&&!E(Array.from);this.Xe&&t?(this.Qe(i),Ae.info("starting")):(this.Je=cn,this.stopRecording())}}Qe(i){var e,t,s;this.Xe&&(this.Je!==wt&&this.Je!==Xt&&(this.Je=hn),$!=null&&(e=$.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=$.__PosthogExtensions__)!=null&&t.initSessionRecording?this.Ze(i):(s=$.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.tr,(r=>{if(r)return Ae.error("could not load recorder",r);this.Ze(i)})))}stopRecording(){var i,e;(i=this.Ke)==null||i.call(this),this.Ke=void 0,(e=this.Ge)==null||e.stop()}ir(){var i,e;(i=this.Ke)==null||i.call(this),this.Ke=void 0,(e=this.Ge)==null||e.discard()}er(){var i;(i=this.Wt)==null||i.unregister(Kn)}rr(i,e){if(M(i))return null;var t,s=ke(i)?i:parseFloat(i);return typeof(t=s)!="number"||!Number.isFinite(t)||0>t||t>1?(Ae.warn(e+" must be between 0 and 1. Ignoring invalid value:",i),null):s}sr(i){if(this.Wt){var e,t,s=this.Wt,r=()=>{var n,o=i.sessionRecording===!1?void 0:i.sessionRecording,a=this.rr((n=this.N.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.rr(o?.sampleRate,"remote config sampleRate"),c=a??l;M(c)&&this.er();var u=o?.minimumDurationMilliseconds;s.register({[zt]:m({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:m({capturePerformance:i.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:E(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.Ke)==null||e.call(this),this.Ke=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(i){return"sessionRecording"in i?i.sessionRecording===!1?(this.sr(i),void this.ir()):(this.sr(i),void this.startIfEnabledOrStop()):(this.Je===wt&&(this.Je=Xt,Ae.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(i,e){var t;e===void 0&&(e="log"),(t=this.Ge)!=null&&t.log?this.Ge.log(i,e):Ae.warn("log called before recorder was ready")}get tr(){var i,e,t=(i=this._instance)==null||(i=i.persistence)==null?void 0:i.get_property(zt);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}nr(){var i,e=this._instance.get_property(zt);if(!e)return!1;var t=(i=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&i!==void 0?i:Date.now();return 36e5>=Date.now()-t}Ze(i){var e,t;if((e=$.__PosthogExtensions__)==null||!e.initSessionRecording)return Ae.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.Ge||(this.Ge=(t=$.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.Ge._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.nr())return this.Je===Xt||this.Je===wt?void 0:(this.Je=wt,Ae.info("persisted remote config is stale, requesting fresh config before starting"),void new _i(this._instance).load());this.Je=hn,this.Ge.start(i)}onRRwebEmit(i){var e;(e=this.Ge)==null||e.onRRwebEmit==null||e.onRRwebEmit(i)}overrideLinkedFlag(){var i,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_linked_flag:!0}),(i=this.Ge)==null||i.overrideLinkedFlag()}overrideSampling(){var i,e;this.Ge||(e=this.Wt)==null||e.register({$replay_override_sampling:!0}),(i=this.Ge)==null||i.overrideSampling()}overrideTrigger(i){var e,t;this.Ge||(t=this.Wt)==null||t.register({[i==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.Ge)==null||e.overrideTrigger(i)}get sdkDebugProperties(){var i;return((i=this.Ge)==null?void 0:i.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(i,e){var t;return!((t=this.Ge)==null||!t.tryAddCustomEvent(i,e))}}},Za={autocapture:class{constructor(i){this.ar=!1,this.lr=null,this.ur=!1,this.instance=i,this.rageclicks=new ki(i.config.rageclick),this.hr=null}initialize(){this.startIfEnabled()}get N(){var i,e,t=K(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(i=t.url_allowlist)==null?void 0:i.map((s=>new RegExp(s))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),t}dr(){if(this.isBrowserSupported()){if(d&&y){var i=t=>{t=t||d?.event;try{this.vr(t)}catch(s){an.error("Failed to capture event",s)}};if(G(y,"submit",i,{capture:!0}),G(y,"change",i,{capture:!0}),G(y,"click",i,{capture:!0}),this.N.capture_copied_text){var e=t=>{this.vr(t=t||d?.event,Bi)};G(y,"copy",e,{capture:!0}),G(y,"cut",e,{capture:!0})}}}else an.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ar&&(this.dr(),this.ar=!0)}onRemoteConfig(i){i.elementsChainAsString&&(this.ur=i.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Fr]:!!i.autocapture_opt_out}),this.lr=!!i.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(i){this.hr=i}getElementSelectors(i){var e,t=[];return(e=this.hr)==null||e.forEach((s=>{var r=y?.querySelectorAll(s);r?.forEach((n=>{i===n&&t.push(s)}))})),t}get isEnabled(){var i,e,t=(i=this.instance.persistence)==null?void 0:i.props[Fr];if(Ie(this.lr)&&!$e(t)&&!this.instance.bt())return!1;var s=(e=this.lr)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!s}vr(i,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,s=en(i);bo(s)&&(s=s.parentNode||null),e==="$autocapture"&&i.type==="click"&&i instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,i.timeStamp||new Date().getTime())&&(function(h,v){if(!d||Gs(h))return!1;var g,_,p;if($e(v)?(g=!!v&&sn,_=void 0):(g=(p=v?.css_selector_ignorelist)!==null&&p!==void 0?p:sn,_=v?.content_ignorelist),g===!1)return!1;var{targetElementList:I}=rn(h,!1);return!(function(O,P){if(O===!1||E(O))return!1;var F;if(O===!0)F=Da;else{if(!L(O))return!1;if(O.length>10)return w.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;F=O.map((S=>S.toLowerCase()))}return P.some((S=>{var{safeText:x,ariaLabel:k}=S;return F.some((b=>x.includes(b)||k.includes(b)))}))})(_,I.map((O=>{var P;return{safeText:jt(O).toLowerCase(),ariaLabel:((P=O.getAttribute("aria-label"))==null?void 0:P.toLowerCase().trim())||""}})))&&!tn(I,g)})(s,this.instance.config.rageclick)&&this.vr(i,"$rageclick");var r=e===Bi;if(s&&(function(h,v,g,_,p){var I,O,P,F;if(g===void 0&&(g=void 0),!d||Gs(h)||(I=g)!=null&&I.url_allowlist&&!Qr(g.url_allowlist)||(O=g)!=null&&O.url_ignorelist&&Qr(g.url_ignorelist))return!1;if((P=g)!=null&&P.dom_event_allowlist){var S=g.dom_event_allowlist;if(S&&!S.some((T=>v.type===T)))return!1}var{parentIsUsefulElement:x,targetElementList:k}=rn(h,_);if(!(function(T,A){var N=A?.element_allowlist;if(E(N))return!0;var R,D=function(J){if(N.some((Z=>J.tagName.toLowerCase()===Z)))return{v:!0}};for(var U of T)if(R=D(U))return R.v;return!1})(k,g)||!tn(k,(F=g)==null?void 0:F.css_selector_allowlist))return!1;var b=d.getComputedStyle(h);if(b&&b.getPropertyValue("cursor")==="pointer"&&v.type==="click")return!0;var f=h.tagName.toLowerCase();switch(f){case"html":return!1;case"form":return(p||["submit"]).indexOf(v.type)>=0;case"input":case"select":case"textarea":return(p||["change","click"]).indexOf(v.type)>=0;default:return x?(p||["click"]).indexOf(v.type)>=0:(p||["click"]).indexOf(v.type)>=0&&(cr.indexOf(f)>-1||h.getAttribute("contenteditable")==="true")}})(s,i,this.N,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=Ba(s,{e:i,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.N.element_attribute_ignorelist,elementsChainAsString:this.ur});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===Bi){var l,c=Eo(d==null||(l=d.getSelection())==null?void 0:l.toString()),u=i.type||"clipboard";if(!c)return!1;n.$selected_content=c,n.$copy_type=u}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return Oe(y?.querySelectorAll)}},historyAutocapture:class{constructor(i){var e;this._instance=i,this.cr=(d==null||(e=d.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(w.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.pr&&this.pr(),this.pr=void 0,w.info("History API monitoring stopped")}monitorHistoryChanges(){var i,e;if(d&&d.history){var t=this;(i=d.history.pushState)!=null&&i.__posthog_wrapped__||ln(d.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),t._r("pushState")})),(e=d.history.replaceState)!=null&&e.__posthog_wrapped__||ln(d.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),t._r("replaceState")})),this.gr()}}_r(i){try{var e,t=d==null||(e=d.location)==null?void 0:e.pathname;if(!t)return;t!==this.cr&&this.isEnabled&&this._instance.capture(tt,{navigation_type:i}),this.cr=t}catch(s){w.error("Error capturing "+i+" pageview",s)}}gr(){if(!this.pr){var i=()=>{this._r("popstate")};G(d,"popstate",i),this.pr=()=>{d&&d.removeEventListener("popstate",i)}}}},heatmaps:class{get N(){return this.instance.config}constructor(i){var e;this.mr=!1,this.ar=!1,this.br=null,this.instance=i,this.mr=!((e=this.instance.persistence)==null||!e.props[gs]),this.rageclicks=new ki(i.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var i=5e3;return K(this.N.capture_heatmaps)&&this.N.capture_heatmaps.flush_interval_milliseconds&&(i=this.N.capture_heatmaps.flush_interval_milliseconds),i}get isEnabled(){return M(this.N.capture_heatmaps)?M(this.N.enable_heatmaps)?this.mr:this.N.enable_heatmaps:this.N.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ar)return;Ga.info("starting..."),this.yr(),this.wr()}else{var i;clearInterval((i=this.br)!==null&&i!==void 0?i:void 0),this.Er(),this.getAndClearBuffer()}}onRemoteConfig(i){if("heatmaps"in i){var e=!!i.heatmaps;this.instance.persistence&&this.instance.persistence.register({[gs]:e}),this.mr=e,this.startIfEnabled()}}getAndClearBuffer(){var i=this.I;return this.I=void 0,i}Sr(i){this.Tr(i.originalEvent,"deadclick")}wr(){this.br&&clearInterval(this.br),this.br=y?.visibilityState==="visible"?setInterval(this.At.bind(this),this.flushIntervalMilliseconds):null}yr(){d&&y&&(this.$r=this.At.bind(this),G(d,ui,this.$r),this.kr=i=>this.Tr(i||d?.event),G(y,"click",this.kr,{capture:!0}),this.Rr=i=>this.Pr(i||d?.event),G(y,"mousemove",this.Rr,{capture:!0}),this.Or=new ci(this.instance,_a,this.Sr.bind(this)),this.Or.startIfEnabledOrStop(),this.Ir=this.wr.bind(this),G(y,li,this.Ir),this.ar=!0)}Er(){var i;d&&y&&(this.$r&&d.removeEventListener(ui,this.$r),this.kr&&y.removeEventListener("click",this.kr,{capture:!0}),this.Rr&&y.removeEventListener("mousemove",this.Rr,{capture:!0}),this.Ir&&y.removeEventListener(li,this.Ir),clearTimeout(this.Cr),(i=this.Or)==null||i.stop(),this.ar=!1)}Fr(i,e){var t=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var c=o;c&&Ti(c)&&!je(c,"body");){if(c===l)return!1;if(C(a,d?.getComputedStyle(c).position))return!0;c=xo(c)}return!1})(en(i),["fixed","sticky"],r);return{x:i.clientX+(n?0:s),y:i.clientY+(n?0:t),target_fixed:n,type:e}}Tr(i,e){var t;if(e===void 0&&(e="click"),!Zr(i.target)&&dn(i)){var s=this.Fr(i,e);(t=this.rageclicks)!=null&&t.isRageClick(i.clientX,i.clientY,new Date().getTime())&&this.Ar(m({},s,{type:"rageclick"})),this.Ar(s)}}Pr(i){!Zr(i.target)&&dn(i)&&(clearTimeout(this.Cr),this.Cr=setTimeout((()=>{this.Ar(this.Fr(i,"mousemove"))}),500))}Ar(i){if(d){var e=d.location.href,t=this.N.custom_personal_data_properties,s=this.N.mask_personal_data_properties?[...ht,...t||[]]:[],r=Lt(e,s,Dt);this.I=this.I||{},this.I[r]||(this.I[r]=[]),this.I[r].push(i)}}At(){this.I&&!st(this.I)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ci,webVitalsAutocapture:class{constructor(i){var e;this.mr=!1,this.ar=!1,this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Mr=()=>{clearTimeout(this.Dr),this.I.metrics.length!==0&&(this._instance.capture("$web_vitals",this.I.metrics.reduce(((t,s)=>m({},t,{["$web_vitals_"+s.name+"_event"]:m({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.I={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Lr=t=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(E(r))Ne.error("Could not read session ID. Dropping metrics!");else{this.I=this.I||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Ur();E(n)||(M(t?.name)||M(t?.value)?Ne.error("Invalid metric received",t):!this.Nr||this.Nr>t.value?(this.I.url!==n&&(this.Mr(),this.Dr=setTimeout(this.Mr,this.flushToCaptureTimeoutMs)),E(this.I.url)&&(this.I.url=n),this.I.firstMetricTimestamp=E(this.I.firstMetricTimestamp)?Date.now():this.I.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.I.metrics.push(m({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.I.metrics.length===this.allowedMetrics.length&&this.Mr()):Ne.error("Ignoring metric with value >= "+this.Nr,t))}},this.jr=()=>{if(!this.ar){var t,s,r,n,o=$.__PosthogExtensions__;E(o)||E(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.Lr.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.Lr.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.Lr.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.Lr.bind(this)),this.ar=!0):Ne.error("web vitals callbacks not loaded - not starting")}},this._instance=i,this.mr=!((e=this._instance.persistence)==null||!e.props[Cr]),this.startIfEnabled()}get zr(){return this._instance.config.capture_performance}get allowedMetrics(){var i,e,t=K(this.zr)?(i=this.zr)==null?void 0:i.web_vitals_allowed_metrics:void 0;return M(t)?((e=this._instance.persistence)==null?void 0:e.props[Nr])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(K(this.zr)?this.zr.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var i=K(this.zr)?this.zr.web_vitals_attribution:void 0;return i!=null&&i}get Nr(){var i=K(this.zr)&&ke(this.zr.__web_vitals_max_value)?this.zr.__web_vitals_max_value:un;return i>0&&6e4>=i?un:i}get isEnabled(){var i=Q?.protocol;if(i!=="http:"&&i!=="https:")return Ne.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=K(this.zr)?this.zr.web_vitals:$e(this.zr)?this.zr:void 0;return $e(e)?e:this.mr}startIfEnabled(){this.isEnabled&&!this.ar&&(Ne.info("enabled, starting..."),this.Y(this.jr))}onRemoteConfig(i){if("capturePerformance"in i){var e=K(i.capturePerformance)&&!!i.capturePerformance.web_vitals,t=K(i.capturePerformance)?i.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Cr]:e}),this._instance.persistence.register({[Nr]:t})),this.mr=e,this.startIfEnabled()}}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(s=>{s?Ne.error("failed to load script",s):i()}))}Ur(){var i=d?d.location.href:void 0;if(i){var e=this._instance.config.custom_personal_data_properties,t=this._instance.config.mask_personal_data_properties?[...ht,...e||[]]:[];return Lt(i,t,Dt)}Ne.error("Could not determine current URL")}}},Qa={exceptionObserver:class{constructor(i){var e,t,s;this.jr=()=>{var r;if(d&&this.isEnabled&&(r=$.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=$.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=$.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=$.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Br&&this.N.capture_unhandled_errors&&(this.Br=n(this.captureException.bind(this))),!this.Hr&&this.N.capture_unhandled_rejections&&(this.Hr=o(this.captureException.bind(this))),!this.qr&&this.N.capture_console_errors&&(this.qr=a(this.captureException.bind(this)))}catch(l){bt.error("failed to start",l),this.Wr()}}},this._instance=i,this.Vr=!((e=this._instance.persistence)==null||!e.props[Ir]),this.Yr=new ts({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:bt}),this.N=this.Gr(),this.startIfEnabledOrStop()}Gr(){var i=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return K(i)?e=m({},e,i):(E(i)?this.Vr:i)&&(e=m({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.N.capture_console_errors||this.N.capture_unhandled_errors||this.N.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(bt.info("enabled"),this.Wr(),this.Y(this.jr)):this.Wr()}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&i(),(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return bt.error("failed to load script",s);i()}))}Wr(){var i,e,t;(i=this.Br)==null||i.call(this),this.Br=void 0,(e=this.Hr)==null||e.call(this),this.Hr=void 0,(t=this.qr)==null||t.call(this),this.qr=void 0}onRemoteConfig(i){"autocaptureExceptions"in i&&(this.Vr=!!i.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ir]:this.Vr}),this.N=this.Gr(),this.startIfEnabledOrStop())}onConfigChange(){this.N=this.Gr()}captureException(i){var e,t,s,r=(e=i==null||(t=i.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.Yr.consumeRateLimit(r)?bt.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(i)}},exceptions:class{constructor(i){var e,t;this.Jr=[],this.Kr=new ns([new as,new vs,new us,new ls,new ds,new hs,new cs,new ps],(function(s){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var c=[],u=a.split(`
3
- `),h=l;u.length>h;h++){var v=u[h];if(1024>=v.length){var g=Or.test(v)?v.replace(Or,"$1"):v;if(!g.match(/\S*Error: /)){for(var _ of n){var p=_(g,s);if(p){c.push(p);break}}if(c.length>=50)break}}}return(function(I){if(!I.length)return[];var O=Array.from(I);return O.reverse(),O.slice(0,50).map((P=>{return m({},P,{filename:P.filename||(F=O,F[F.length-1]||{}).filename,function:P.function||ct});var F}))})(c)}})("web:javascript",ta,ra)),this._instance=i,this.Jr=(e=(t=this._instance.persistence)==null?void 0:t.get_property(_s))!==null&&e!==void 0?e:[]}onRemoteConfig(i){var e,t,s;if("errorTracking"in i){var r=(e=(t=i.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(s=i.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Jr=r,this._instance.persistence&&this._instance.persistence.register({[_s]:this.Jr,[Rr]:n})}}get Xr(){var i,e=!!this._instance.get_property(Rr),t=this._instance.config.error_tracking.captureExtensionExceptions;return(i=t??e)!==null&&i!==void 0&&i}buildProperties(i,e){return this.Kr.buildFromUnknown(i,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(i){var e=i.$exception_list;if(this.Qr(e)){if(this.Zr(e))return void Xi.info("Skipping exception capture because a suppression rule matched");if(!this.Xr&&this.ts(e))return void Xi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.es(e))return void Xi.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Ui:!0})}Zr(i){if(i.length===0)return!1;var e=i.reduce(((t,s)=>{var{type:r,value:n}=s;return Y(r)&&r.length>0&&t.$exception_types.push(r),Y(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.Jr.some((t=>{var s=t.values.map((r=>{var n,o=_o[r.operator],a=L(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?s.some(Boolean):s.every(Boolean)}))}ts(i){return i.flatMap((e=>{var t,s;return(t=(s=e.stacktrace)==null?void 0:s.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}es(i){if(i.length>0){var e,t,s,r,n=(e=(t=i[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}Qr(i){return!M(i)&&L(i)}}},el=m({productTours:class{get Wt(){return this._instance.persistence}constructor(i){this.rs=null,this.ss=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){"productTours"in i&&(this.Wt&&this.Wt.register({[Mr]:!!i.productTours}),this.loadIfEnabled())}loadIfEnabled(){var i,e;this.rs||(i=this._instance).config.disable_product_tours||(e=i.persistence)==null||!e.get_property(Mr)||this.Y((()=>this.ns()))}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.generateProductTours?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(s=>{s?pn.error("Could not load product tours script",s):i()}))}ns(){var i;!this.rs&&(i=$.__PosthogExtensions__)!=null&&i.generateProductTours&&(this.rs=$.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(i,e){if(e===void 0&&(e=!1),!L(this.ss)||e){var t=this.Wt;if(t){var s=t.props[Gi];if(L(s)&&!e)return this.ss=s,void i(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return pn.error(o),void i([],{isLoaded:!1,error:o})}var a=L(r.json.product_tours)?r.json.product_tours:[];this.ss=a,t&&t.register({[Gi]:a}),i(a,{isLoaded:!0})}})}else i(this.ss,{isLoaded:!0})}getActiveProductTours(i){M(this.rs)?i([],{isLoaded:!1,error:"Product tours not loaded"}):this.rs.getActiveProductTours(i)}showProductTour(i){var e;(e=this.rs)==null||e.showTourById(i)}previewTour(i){this.rs?this.rs.previewTour(i):this.Y((()=>{var e;this.ns(),(e=this.rs)==null||e.previewTour(i)}))}dismissProductTour(){var i;(i=this.rs)==null||i.dismissTour("user_clicked_skip")}nextStep(){var i;(i=this.rs)==null||i.nextStep()}previousStep(){var i;(i=this.rs)==null||i.previousStep()}clearCache(){var i;this.ss=null,(i=this.Wt)==null||i.unregister(Gi)}resetTour(i){var e;(e=this.rs)==null||e.resetTour(i)}resetAllTours(){var i;(i=this.rs)==null||i.resetAllTours()}cancelPendingTour(i){var e;(e=this.rs)==null||e.cancelPendingTour(i)}}},Oi),tl={siteApps:class{constructor(i){this._instance=i,this.os=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ls(i,e){if(e){var t=this.globalsForEvent(e);this.os.push(t),this.os.length>1e3&&(this.os=this.os.slice(10))}}get siteAppLoaders(){var i;return(i=$._POSTHOG_REMOTE_CONFIG)==null||(i=i[this._instance.config.token])==null?void 0:i.siteApps}initialize(){if(this.isEnabled){var i=this._instance._addCaptureHook(this.ls.bind(this));this.us=()=>{i(),this.os=[],this.us=void 0}}}globalsForEvent(i){var e,t,s,r,n,o,a;if(!i)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[h,v]of Object.entries(u))l[h]={id:c[h],type:h,properties:v};var{$set_once:g,$set:_}=i;return{event:m({},kn(i,Ya),{properties:m({},i.properties,_?{$set:m({},(e=(t=i.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},_)}:{},g?{$set_once:m({},(s=(r=i.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},g)}:{}),elements_chain:(n=(o=i.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=i.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(i){var e=this.apps[i.id],t=()=>{var o;!e.errored&&this.os.length&&(Le.info("Processing "+this.os.length+" events for site app with id "+i.id),this.os.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.us)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Le.info("Site app with id "+i.id+" "+(o?"loaded":"errored")),s&&t()};try{var{processEvent:n}=i.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Le.error(vn+i.id,o),r(!1)}if(s&&e.loaded)try{t()}catch(o){Le.error("Error while processing buffered events PostHog app with config id "+i.id,o),e.errored=!0}}hs(){var i=this.siteAppLoaders||[];for(var e of i)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of i)this.setupSiteApp(t)}ds(i){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(i);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(s){Le.error("Error while processing event "+i.event+" for site app "+t.id,s)}}}onRemoteConfig(i){var e,t,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.hs(),void this._instance.on("eventCaptured",(l=>this.ds(l)))):void Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.us)==null||t.call(this),(s=i.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var c;$["__$$ph_site_app_"+l]=r._instance,(c=$.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(r._instance,a,(u=>{if(u)return Le.error(vn+l,u)}))};for(var{id:o,url:a}of i.siteApps)n(o)}else Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},il={tracingHeaders:class{constructor(i){this.vs=void 0,this.cs=void 0,this.jr=()=>{var e,t;E(this.vs)&&((e=$.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),E(this.cs)&&((t=$.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=i}initialize(){this.startIfEnabledOrStop()}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&i(),(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return Va.error("failed to load script",s);i()}))}startIfEnabledOrStop(){var i,e;this._instance.config.__add_tracing_headers?this.Y(this.jr):((i=this.vs)==null||i.call(this),(e=this.cs)==null||e.call(this),this.vs=void 0,this.cs=void 0)}}},sl=m({surveys:class{get N(){return this._instance.config}constructor(i){this.fs=void 0,this._surveyManager=null,this.ps=!1,this._s=[],this.gs=null,this._instance=i,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this.N.disable_surveys){var e=i.surveys;if(M(e))return j.warn("Flags not loaded yet. Not loading surveys.");var t=L(e);this.fs=t?e.length>0:e,j.info("flags response received, isSurveysEnabled: "+this.fs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(qs)||t!=null&&t.startsWith("inProgressSurvey_"))&&i.push(t)}i.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.ps)j.info("Already initializing surveys, skipping...");else if(this.N.disable_surveys)j.info(gn);else if(this.N.cookieless_mode&&this._instance.consent.isOptedOut())j.info("Not loading surveys in cookieless mode without consent.");else{var i=$?.__PosthogExtensions__;if(i){if(!E(this.fs)||this.N.advanced_enable_surveys){var e=this.fs||this.N.advanced_enable_surveys;this.ps=!0;try{var t=i.generateSurveys;if(t)return void this.bs(t,e);var s=i.loadExternalDependency;if(!s)return void this.ys(nr);s(this._instance,"surveys",(r=>{r||!i.generateSurveys?this.ys("Could not load surveys script",r):this.bs(i.generateSurveys,e)}))}catch(r){throw this.ys("Error initializing surveys",r),r}finally{this.ps=!1}}}else j.error("PostHog Extensions not found.")}}bs(i,e){this._surveyManager=i(this._instance,e),this._surveyEventReceiver=new Zs(this._instance),j.info("Surveys loaded successfully"),this.ws({isLoaded:!0})}ys(i,e){j.error(i,e),this.ws({isLoaded:!1,error:i})}onSurveysLoaded(i){return this._s.push(i),this._surveyManager&&this.ws({isLoaded:!0}),()=>{this._s=this._s.filter((e=>e!==i))}}getSurveys(i,e){if(e===void 0&&(e=!1),this.N.disable_surveys)return j.info(gn),i([]);var t,s=this._instance.get_property(ms);if(s&&!e)return i(s,{isLoaded:!0});typeof Promise<"u"&&this.gs?this.gs.then((r=>{var{surveys:n,context:o}=r;return i(n,o)})):(typeof Promise<"u"&&(this.gs=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.N.token),method:"GET",timeout:this.N.surveys_request_timeout_ms,callback:r=>{var n;this.gs=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;j.error(a);var l={isLoaded:!1,error:a};return i([],l),void(t==null||t({surveys:[],context:l}))}var c,u=r.json.surveys||[],h=u.filter((g=>(function(_){return!(!_.start_date||_.end_date)})(g)&&((function(_){var p;return!((p=_.conditions)==null||(p=p.events)==null||(p=p.values)==null||!p.length)})(g)||(function(_){var p;return!((p=_.conditions)==null||(p=p.actions)==null||(p=p.values)==null||!p.length)})(g))));h.length>0&&((c=this._surveyEventReceiver)==null||c.register(h)),(n=this._instance.persistence)==null||n.register({[ms]:u});var v={isLoaded:!0};i(u,v),t?.({surveys:u,context:v})}}))}ws(i){for(var e of this._s)try{if(!i.isLoaded)return e([],i);this.getSurveys(e)}catch(t){j.error("Error in survey callback",t)}}getActiveMatchingSurveys(i,e){if(e===void 0&&(e=!1),!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(i,e);j.warn("init was not called")}Es(i){var e=null;return this.getSurveys((t=>{var s;e=(s=t.find((r=>r.id===i)))!==null&&s!==void 0?s:null})),e}Ss(i){if(M(this._surveyManager))return{eligible:!1,reason:Yi};var e=typeof i=="string"?this.Es(i):i;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(i){if(M(this._surveyManager))return j.warn("init was not called"),{visible:!1,disabledReason:Yi};var e=this.Ss(i);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(i,e){return M(this._surveyManager)?(j.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Yi})):new Promise((t=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===i)))!==null&&r!==void 0?r:null;if(n){var o=this.Ss(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(i,e,t){var s;if(M(this._surveyManager))j.warn("init was not called");else{var r=typeof i=="string"?this.Es(i):i;if(r!=null&&r.id)if(Ca.includes(r.type)){var n=y?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(j.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;j.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),j.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);j.warn("Survey element not found")}else j.warn("Surveys of type "+r.type+" cannot be rendered in the app");else j.warn("Survey not found")}}displaySurvey(i,e){var t;if(M(this._surveyManager))j.warn("init was not called");else{var s=this.Es(i);if(s){var r=s;if((t=s.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=m({},s,{appearance:m({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Is.Popover&&e.initialResponses&&j.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void j.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Is.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else j.warn("Survey not found")}}cancelPendingSurvey(i){M(this._surveyManager)?j.warn("init was not called"):this._surveyManager.cancelSurvey(i)}handlePageUnload(){var i;(i=this._surveyManager)==null||i.handlePageUnload()}}},Oi),rl={toolbar:class{constructor(i){this.instance=i}xs(i){$.ph_toolbar_state=i}Ts(){var i;return(i=$.ph_toolbar_state)!==null&&i!==void 0?i:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,t){if(i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Zn(this.instance.config)||!d||!y)return!1;i=i??d.location,t=t??d.history;try{if(!e){try{d.localStorage.setItem("test","test"),d.localStorage.removeItem("test")}catch{return!1}e=d?.localStorage}var s,r=Ja||vi(i.hash,"__posthog")||vi(i.hash,"state"),n=r?Lr((()=>JSON.parse(atob(decodeURIComponent(r)))))||Lr((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?i.hash=n.desiredHash:t?t.replaceState(t.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(_n)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}$s(i){var e=$.ph_load_toolbar||$.ph_load_editor;!M(e)&&Oe(e)?e(i,this.instance):fn.warn("No toolbar load function found")}loadToolbar(i){var e=!(y==null||!y.getElementById(Xn));if(!d||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=m({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(d.localStorage.setItem(_n,JSON.stringify(m({},s,{source:void 0}))),this.Ts()===2)this.$s(s);else if(this.Ts()===0){var r;this.xs(1),(r=$.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return fn.error("[Toolbar] Failed to load",n),void this.xs(0);this.xs(2),this.$s(s)})),G(d,"turbolinks:load",(()=>{this.xs(0),this.loadToolbar(s)}))}return!0}ks(i){return this.loadToolbar(i)}maybeLoadEditor(i,e,t){return i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(i,e,t)}}},nl=m({experiments:Qs},Oi),ol={conversations:class{constructor(i){this.Rs=void 0,this._conversationsManager=null,this.Ps=!1,this.Os=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_conversations){var e=i.conversations;M(e)||($e(e)?this.Rs=e:(this.Rs=e.enabled,this.Os=e),this.loadIfEnabled())}}reset(){var i;(i=this._conversationsManager)==null||i.reset(),this._conversationsManager=null,this.Rs=void 0,this.Os=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ps||this._instance.config.disable_conversations||Zn(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var i=$?.__PosthogExtensions__;if(i&&!E(this.Rs)&&this.Rs)if(this.Os&&this.Os.token){this.Ps=!0;try{var e=i.initConversations;if(e)return this.Is(e),void(this.Ps=!1);var t=i.loadExternalDependency;if(!t)return void this.Cs(nr);t(this._instance,"conversations",(s=>{s||!i.initConversations?this.Cs("Could not load conversations script",s):this.Is(i.initConversations),this.Ps=!1}))}catch(s){this.Cs("Error initializing conversations",s),this.Ps=!1}}else pe.error("Conversations enabled but missing token in remote config.")}}Is(i){if(this.Os)try{this._conversationsManager=i(this.Os,this._instance),pe.info("Conversations loaded successfully")}catch(e){this.Cs("Error completing conversations initialization",e)}else pe.error("Cannot complete initialization: remote config is null")}Cs(i,e){pe.error(i,e),this._conversationsManager=null,this.Ps=!1}show(){this._conversationsManager?this._conversationsManager.show():pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rs===!0&&!Ie(this._conversationsManager)}isVisible(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&i!==void 0&&i}sendMessage(i,e,t){var s=this;return ye((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(i,e,t):(pe.warn(Be),null)}))()}getMessages(i,e){var t=this;return ye((function*(){return t._conversationsManager?t._conversationsManager.getMessages(i,e):(pe.warn(Be),null)}))()}markAsRead(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(i):(pe.warn(Be),null)}))()}getTickets(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.getTickets(i):(pe.warn(Be),null)}))()}requestRestoreLink(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(i):(pe.warn(Be),null)}))()}restoreFromToken(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(i):(pe.warn(Be),null)}))()}restoreFromUrlToken(){var i=this;return ye((function*(){return i._conversationsManager?i._conversationsManager.restoreFromUrlToken():(pe.warn(Be),null)}))()}getCurrentTicketId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&i!==void 0?i:null}getWidgetSessionId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&i!==void 0?i:null}}},al={logs:class{constructor(i){var e;this.Fs=!1,this.As=!1,this._instance=i,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Fs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(i){var e,t=(e=i.logs)==null?void 0:e.captureConsoleLogs;!M(t)&&t&&(this.Fs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Fs&&!this.As){var i=z("[logs]"),e=$?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(s=>{var r;s||(r=e.logs)==null||!r.initializeLogs?i.error("Could not load logs script",s):(e.logs.initializeLogs(this._instance),this.As=!0)})):i.error(nr)}else i.error("PostHog Extensions not found.")}}}},ll=m({},Oi,Xa,Za,Qa,el,tl,sl,il,rl,nl,ol,al);pt.__defaultExtensionClasses=m({},ll);var xn,Re=(xn=Ct[it]=new pt,(function(){function i(){i.done||(i.done=!0,yo=!1,W(Ct,(function(e){e._dom_loaded()})))}y!=null&&y.addEventListener?y.readyState==="complete"?i():G(y,"DOMContentLoaded",i,{capture:!1}):d&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),xn);var Je=class Je{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=mr("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(c=>{let u=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${u}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||_r();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:gr,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...s.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=fr.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};Re.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=typeof Re._isIdentified=="function"?Re._isIdentified():this.has_identified;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),Re.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),Re.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,country_of_residence:s})=>{if(!(!this.has_initialized||!e))try{let r=Re.get_property("$stored_person_properties")??{},n={};r.client_id||(n.client_id=e),t&&r.is_internal===void 0&&(n.is_internal=yr(t)),s&&!r.country_of_residence&&(n.country_of_residence=s),Object.keys(n).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:n}),Re.setPersonProperties(n)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:s})}catch(r){console.error("Posthog: Failed to backfill person properties",r)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),Re.capture(e,t)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.options=e,this.debug=t,this.init()}};Je.getPosthogInstance=(e,t=!1)=>(Je._instance||(Je._instance=new Je(e,t)),Je._instance);var Oo=Je;export{Oo as Posthog};
4
- //# sourceMappingURL=posthog-3C2BGC3K.mjs.map
3
+ `),h=l;u.length>h;h++){var v=u[h];if(1024>=v.length){var g=Or.test(v)?v.replace(Or,"$1"):v;if(!g.match(/\S*Error: /)){for(var _ of n){var p=_(g,s);if(p){c.push(p);break}}if(c.length>=50)break}}}return(function(I){if(!I.length)return[];var O=Array.from(I);return O.reverse(),O.slice(0,50).map((P=>{return m({},P,{filename:P.filename||(F=O,F[F.length-1]||{}).filename,function:P.function||ct});var F}))})(c)}})("web:javascript",ta,ra)),this._instance=i,this.Jr=(e=(t=this._instance.persistence)==null?void 0:t.get_property(_s))!==null&&e!==void 0?e:[]}onRemoteConfig(i){var e,t,s;if("errorTracking"in i){var r=(e=(t=i.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(s=i.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Jr=r,this._instance.persistence&&this._instance.persistence.register({[_s]:this.Jr,[Rr]:n})}}get Xr(){var i,e=!!this._instance.get_property(Rr),t=this._instance.config.error_tracking.captureExtensionExceptions;return(i=t??e)!==null&&i!==void 0&&i}buildProperties(i,e){return this.Kr.buildFromUnknown(i,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(i){var e=i.$exception_list;if(this.Qr(e)){if(this.Zr(e))return void Xi.info("Skipping exception capture because a suppression rule matched");if(!this.Xr&&this.ts(e))return void Xi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.es(e))return void Xi.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",Ui:!0})}Zr(i){if(i.length===0)return!1;var e=i.reduce(((t,s)=>{var{type:r,value:n}=s;return Y(r)&&r.length>0&&t.$exception_types.push(r),Y(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.Jr.some((t=>{var s=t.values.map((r=>{var n,o=_o[r.operator],a=L(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?s.some(Boolean):s.every(Boolean)}))}ts(i){return i.flatMap((e=>{var t,s;return(t=(s=e.stacktrace)==null?void 0:s.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}es(i){if(i.length>0){var e,t,s,r,n=(e=(t=i[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}Qr(i){return!M(i)&&L(i)}}},el=m({productTours:class{get Wt(){return this._instance.persistence}constructor(i){this.rs=null,this.ss=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){"productTours"in i&&(this.Wt&&this.Wt.register({[Mr]:!!i.productTours}),this.loadIfEnabled())}loadIfEnabled(){var i,e;this.rs||(i=this._instance).config.disable_product_tours||(e=i.persistence)==null||!e.get_property(Mr)||this.Y((()=>this.ns()))}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.generateProductTours?i():(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(s=>{s?pn.error("Could not load product tours script",s):i()}))}ns(){var i;!this.rs&&(i=$.__PosthogExtensions__)!=null&&i.generateProductTours&&(this.rs=$.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(i,e){if(e===void 0&&(e=!1),!L(this.ss)||e){var t=this.Wt;if(t){var s=t.props[Gi];if(L(s)&&!e)return this.ss=s,void i(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return pn.error(o),void i([],{isLoaded:!1,error:o})}var a=L(r.json.product_tours)?r.json.product_tours:[];this.ss=a,t&&t.register({[Gi]:a}),i(a,{isLoaded:!0})}})}else i(this.ss,{isLoaded:!0})}getActiveProductTours(i){M(this.rs)?i([],{isLoaded:!1,error:"Product tours not loaded"}):this.rs.getActiveProductTours(i)}showProductTour(i){var e;(e=this.rs)==null||e.showTourById(i)}previewTour(i){this.rs?this.rs.previewTour(i):this.Y((()=>{var e;this.ns(),(e=this.rs)==null||e.previewTour(i)}))}dismissProductTour(){var i;(i=this.rs)==null||i.dismissTour("user_clicked_skip")}nextStep(){var i;(i=this.rs)==null||i.nextStep()}previousStep(){var i;(i=this.rs)==null||i.previousStep()}clearCache(){var i;this.ss=null,(i=this.Wt)==null||i.unregister(Gi)}resetTour(i){var e;(e=this.rs)==null||e.resetTour(i)}resetAllTours(){var i;(i=this.rs)==null||i.resetAllTours()}cancelPendingTour(i){var e;(e=this.rs)==null||e.cancelPendingTour(i)}}},Oi),tl={siteApps:class{constructor(i){this._instance=i,this.os=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}ls(i,e){if(e){var t=this.globalsForEvent(e);this.os.push(t),this.os.length>1e3&&(this.os=this.os.slice(10))}}get siteAppLoaders(){var i;return(i=$._POSTHOG_REMOTE_CONFIG)==null||(i=i[this._instance.config.token])==null?void 0:i.siteApps}initialize(){if(this.isEnabled){var i=this._instance._addCaptureHook(this.ls.bind(this));this.us=()=>{i(),this.os=[],this.us=void 0}}}globalsForEvent(i){var e,t,s,r,n,o,a;if(!i)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[h,v]of Object.entries(u))l[h]={id:c[h],type:h,properties:v};var{$set_once:g,$set:_}=i;return{event:m({},kn(i,Ya),{properties:m({},i.properties,_?{$set:m({},(e=(t=i.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},_)}:{},g?{$set_once:m({},(s=(r=i.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},g)}:{}),elements_chain:(n=(o=i.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=i.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(i){var e=this.apps[i.id],t=()=>{var o;!e.errored&&this.os.length&&(Le.info("Processing "+this.os.length+" events for site app with id "+i.id),this.os.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.us)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Le.info("Site app with id "+i.id+" "+(o?"loaded":"errored")),s&&t()};try{var{processEvent:n}=i.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Le.error(vn+i.id,o),r(!1)}if(s&&e.loaded)try{t()}catch(o){Le.error("Error while processing buffered events PostHog app with config id "+i.id,o),e.errored=!0}}hs(){var i=this.siteAppLoaders||[];for(var e of i)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of i)this.setupSiteApp(t)}ds(i){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(i);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(s){Le.error("Error while processing event "+i.event+" for site app "+t.id,s)}}}onRemoteConfig(i){var e,t,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.hs(),void this._instance.on("eventCaptured",(l=>this.ds(l)))):void Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.us)==null||t.call(this),(s=i.siteApps)!=null&&s.length)if(this.isEnabled){var n=function(l){var c;$["__$$ph_site_app_"+l]=r._instance,(c=$.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(r._instance,a,(u=>{if(u)return Le.error(vn+l,u)}))};for(var{id:o,url:a}of i.siteApps)n(o)}else Le.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},il={tracingHeaders:class{constructor(i){this.vs=void 0,this.cs=void 0,this.jr=()=>{var e,t;E(this.vs)&&((e=$.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),E(this.cs)&&((t=$.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=i}initialize(){this.startIfEnabledOrStop()}Y(i){var e,t;(e=$.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&i(),(t=$.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return Va.error("failed to load script",s);i()}))}startIfEnabledOrStop(){var i,e;this._instance.config.__add_tracing_headers?this.Y(this.jr):((i=this.vs)==null||i.call(this),(e=this.cs)==null||e.call(this),this.vs=void 0,this.cs=void 0)}}},sl=m({surveys:class{get N(){return this._instance.config}constructor(i){this.fs=void 0,this._surveyManager=null,this.ps=!1,this._s=[],this.gs=null,this._instance=i,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this.N.disable_surveys){var e=i.surveys;if(M(e))return j.warn("Flags not loaded yet. Not loading surveys.");var t=L(e);this.fs=t?e.length>0:e,j.info("flags response received, isSurveysEnabled: "+this.fs),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var i=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(qs)||t!=null&&t.startsWith("inProgressSurvey_"))&&i.push(t)}i.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.ps)j.info("Already initializing surveys, skipping...");else if(this.N.disable_surveys)j.info(gn);else if(this.N.cookieless_mode&&this._instance.consent.isOptedOut())j.info("Not loading surveys in cookieless mode without consent.");else{var i=$?.__PosthogExtensions__;if(i){if(!E(this.fs)||this.N.advanced_enable_surveys){var e=this.fs||this.N.advanced_enable_surveys;this.ps=!0;try{var t=i.generateSurveys;if(t)return void this.bs(t,e);var s=i.loadExternalDependency;if(!s)return void this.ys(nr);s(this._instance,"surveys",(r=>{r||!i.generateSurveys?this.ys("Could not load surveys script",r):this.bs(i.generateSurveys,e)}))}catch(r){throw this.ys("Error initializing surveys",r),r}finally{this.ps=!1}}}else j.error("PostHog Extensions not found.")}}bs(i,e){this._surveyManager=i(this._instance,e),this._surveyEventReceiver=new Zs(this._instance),j.info("Surveys loaded successfully"),this.ws({isLoaded:!0})}ys(i,e){j.error(i,e),this.ws({isLoaded:!1,error:i})}onSurveysLoaded(i){return this._s.push(i),this._surveyManager&&this.ws({isLoaded:!0}),()=>{this._s=this._s.filter((e=>e!==i))}}getSurveys(i,e){if(e===void 0&&(e=!1),this.N.disable_surveys)return j.info(gn),i([]);var t,s=this._instance.get_property(ms);if(s&&!e)return i(s,{isLoaded:!0});typeof Promise<"u"&&this.gs?this.gs.then((r=>{var{surveys:n,context:o}=r;return i(n,o)})):(typeof Promise<"u"&&(this.gs=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.N.token),method:"GET",timeout:this.N.surveys_request_timeout_ms,callback:r=>{var n;this.gs=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;j.error(a);var l={isLoaded:!1,error:a};return i([],l),void(t==null||t({surveys:[],context:l}))}var c,u=r.json.surveys||[],h=u.filter((g=>(function(_){return!(!_.start_date||_.end_date)})(g)&&((function(_){var p;return!((p=_.conditions)==null||(p=p.events)==null||(p=p.values)==null||!p.length)})(g)||(function(_){var p;return!((p=_.conditions)==null||(p=p.actions)==null||(p=p.values)==null||!p.length)})(g))));h.length>0&&((c=this._surveyEventReceiver)==null||c.register(h)),(n=this._instance.persistence)==null||n.register({[ms]:u});var v={isLoaded:!0};i(u,v),t?.({surveys:u,context:v})}}))}ws(i){for(var e of this._s)try{if(!i.isLoaded)return e([],i);this.getSurveys(e)}catch(t){j.error("Error in survey callback",t)}}getActiveMatchingSurveys(i,e){if(e===void 0&&(e=!1),!M(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(i,e);j.warn("init was not called")}Es(i){var e=null;return this.getSurveys((t=>{var s;e=(s=t.find((r=>r.id===i)))!==null&&s!==void 0?s:null})),e}Ss(i){if(M(this._surveyManager))return{eligible:!1,reason:Yi};var e=typeof i=="string"?this.Es(i):i;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(i){if(M(this._surveyManager))return j.warn("init was not called"),{visible:!1,disabledReason:Yi};var e=this.Ss(i);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(i,e){return M(this._surveyManager)?(j.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Yi})):new Promise((t=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===i)))!==null&&r!==void 0?r:null;if(n){var o=this.Ss(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(i,e,t){var s;if(M(this._surveyManager))j.warn("init was not called");else{var r=typeof i=="string"?this.Es(i):i;if(r!=null&&r.id)if(Ca.includes(r.type)){var n=y?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(j.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;j.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),j.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);j.warn("Survey element not found")}else j.warn("Surveys of type "+r.type+" cannot be rendered in the app");else j.warn("Survey not found")}}displaySurvey(i,e){var t;if(M(this._surveyManager))j.warn("init was not called");else{var s=this.Es(i);if(s){var r=s;if((t=s.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=m({},s,{appearance:m({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Is.Popover&&e.initialResponses&&j.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void j.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Is.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else j.warn("Survey not found")}}cancelPendingSurvey(i){M(this._surveyManager)?j.warn("init was not called"):this._surveyManager.cancelSurvey(i)}handlePageUnload(){var i;(i=this._surveyManager)==null||i.handlePageUnload()}}},Oi),rl={toolbar:class{constructor(i){this.instance=i}xs(i){$.ph_toolbar_state=i}Ts(){var i;return(i=$.ph_toolbar_state)!==null&&i!==void 0?i:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(i,e,t){if(i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Zn(this.instance.config)||!d||!y)return!1;i=i??d.location,t=t??d.history;try{if(!e){try{d.localStorage.setItem("test","test"),d.localStorage.removeItem("test")}catch{return!1}e=d?.localStorage}var s,r=Ja||vi(i.hash,"__posthog")||vi(i.hash,"state"),n=r?Lr((()=>JSON.parse(atob(decodeURIComponent(r)))))||Lr((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?i.hash=n.desiredHash:t?t.replaceState(t.state,"",i.pathname+i.search):i.hash="")):((s=JSON.parse(e.getItem(_n)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}$s(i){var e=$.ph_load_toolbar||$.ph_load_editor;!M(e)&&Oe(e)?e(i,this.instance):fn.warn("No toolbar load function found")}loadToolbar(i){var e=!(y==null||!y.getElementById(Xn));if(!d||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=m({token:this.instance.config.token},i,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(d.localStorage.setItem(_n,JSON.stringify(m({},s,{source:void 0}))),this.Ts()===2)this.$s(s);else if(this.Ts()===0){var r;this.xs(1),(r=$.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return fn.error("[Toolbar] Failed to load",n),void this.xs(0);this.xs(2),this.$s(s)})),G(d,"turbolinks:load",(()=>{this.xs(0),this.loadToolbar(s)}))}return!0}ks(i){return this.loadToolbar(i)}maybeLoadEditor(i,e,t){return i===void 0&&(i=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(i,e,t)}}},nl=m({experiments:Qs},Oi),ol={conversations:class{constructor(i){this.Rs=void 0,this._conversationsManager=null,this.Ps=!1,this.Os=null,this._instance=i}initialize(){this.loadIfEnabled()}onRemoteConfig(i){if(!this._instance.config.disable_conversations){var e=i.conversations;M(e)||($e(e)?this.Rs=e:(this.Rs=e.enabled,this.Os=e),this.loadIfEnabled())}}reset(){var i;(i=this._conversationsManager)==null||i.reset(),this._conversationsManager=null,this.Rs=void 0,this.Os=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ps||this._instance.config.disable_conversations||Zn(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var i=$?.__PosthogExtensions__;if(i&&!E(this.Rs)&&this.Rs)if(this.Os&&this.Os.token){this.Ps=!0;try{var e=i.initConversations;if(e)return this.Is(e),void(this.Ps=!1);var t=i.loadExternalDependency;if(!t)return void this.Cs(nr);t(this._instance,"conversations",(s=>{s||!i.initConversations?this.Cs("Could not load conversations script",s):this.Is(i.initConversations),this.Ps=!1}))}catch(s){this.Cs("Error initializing conversations",s),this.Ps=!1}}else pe.error("Conversations enabled but missing token in remote config.")}}Is(i){if(this.Os)try{this._conversationsManager=i(this.Os,this._instance),pe.info("Conversations loaded successfully")}catch(e){this.Cs("Error completing conversations initialization",e)}else pe.error("Cannot complete initialization: remote config is null")}Cs(i,e){pe.error(i,e),this._conversationsManager=null,this.Ps=!1}show(){this._conversationsManager?this._conversationsManager.show():pe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Rs===!0&&!Ie(this._conversationsManager)}isVisible(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&i!==void 0&&i}sendMessage(i,e,t){var s=this;return ye((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(i,e,t):(pe.warn(Be),null)}))()}getMessages(i,e){var t=this;return ye((function*(){return t._conversationsManager?t._conversationsManager.getMessages(i,e):(pe.warn(Be),null)}))()}markAsRead(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(i):(pe.warn(Be),null)}))()}getTickets(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.getTickets(i):(pe.warn(Be),null)}))()}requestRestoreLink(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(i):(pe.warn(Be),null)}))()}restoreFromToken(i){var e=this;return ye((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(i):(pe.warn(Be),null)}))()}restoreFromUrlToken(){var i=this;return ye((function*(){return i._conversationsManager?i._conversationsManager.restoreFromUrlToken():(pe.warn(Be),null)}))()}getCurrentTicketId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&i!==void 0?i:null}getWidgetSessionId(){var i,e;return(i=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&i!==void 0?i:null}}},al={logs:class{constructor(i){var e;this.Fs=!1,this.As=!1,this._instance=i,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.Fs=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(i){var e,t=(e=i.logs)==null?void 0:e.captureConsoleLogs;!M(t)&&t&&(this.Fs=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Fs&&!this.As){var i=z("[logs]"),e=$?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(s=>{var r;s||(r=e.logs)==null||!r.initializeLogs?i.error("Could not load logs script",s):(e.logs.initializeLogs(this._instance),this.As=!0)})):i.error(nr)}else i.error("PostHog Extensions not found.")}}}},ll=m({},Oi,Xa,Za,Qa,el,tl,sl,il,rl,nl,ol,al);pt.__defaultExtensionClasses=m({},ll);var xn,Re=(xn=Ct[it]=new pt,(function(){function i(){i.done||(i.done=!0,yo=!1,W(Ct,(function(e){e._dom_loaded()})))}y!=null&&y.addEventListener?y.readyState==="complete"?i():G(y,"DOMContentLoaded",i,{capture:!1}):d&&w.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),xn);var Je=class Je{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=mr("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(c=>{let u=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${u}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||_r();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:gr,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...s.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=fr.some(c=>a.endsWith(`.${c}`)||a===c);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};Re.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=typeof Re._isIdentified=="function"?Re._isIdentified():this.has_identified;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),Re.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),Re.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=Re.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),t&&n.is_internal===void 0&&(o.is_internal=yr(t)),s&&!n.language&&(o.language=s),r&&!n.country_of_residence&&(o.country_of_residence=r),Object.keys(o).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:o}),Re.setPersonProperties(o)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:r})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),Re.capture(e,t)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.options=e,this.debug=t,this.init()}};Je.getPosthogInstance=(e,t=!1)=>(Je._instance||(Je._instance=new Je(e,t)),Je._instance);var Oo=Je;export{Oo as Posthog};
4
+ //# sourceMappingURL=posthog-OLSRFYED.mjs.map