@deriv-com/analytics 1.38.7 → 1.38.9

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