posthog-js 1.310.2 → 1.312.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(){"use strict";function e(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function t(t){return function(){var i=this,s=arguments;return new Promise((function(r,n){var o=t.apply(i,s);function a(t){e(o,r,n,a,l,"next",t)}function l(t){e(o,r,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}var r="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:r;"undefined"==typeof self&&(n.self=n),"undefined"==typeof File&&(n.File=function(){});var o=Array.prototype,a=o.forEach,l=o.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.310.2"},m=["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"],y=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return m.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},b=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function w(e,t){return-1!==e.indexOf(t)}var E=function(e){return e.trim()},S=function(e){return e.replace(/^\$/,"")};var x=Array.isArray,k=Object.prototype,P=k.hasOwnProperty,I=k.toString,C=x||function(e){return"[object Array]"===I.call(e)},T=e=>"function"==typeof e,F=e=>e===Object(e)&&!C(e),R=e=>{if(F(e)){for(var t in e)if(P.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,M=e=>"[object String]"==I.call(e),O=e=>M(e)&&0===e.trim().length,A=e=>null===e,D=e=>L(e)||A(e),N=e=>"[object Number]"==I.call(e),q=e=>"[object Boolean]"===I.call(e),H=e=>e instanceof FormData,U=e=>w(b,e);function j(e){return null===e||"object"!=typeof e}function z(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function B(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var V=[!0,"true",1,"1","yes"],W=e=>w(V,e),G=[!1,"false",0,"0","no"];function Y(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),N(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Y(r||i,t,i,s))}class K{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Y(e.bucketSize,0,100,e._logger),this._refillRate=Y(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Y(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=t-e.lastAccess,s=Math.floor(i/this._refillInterval);if(s>0){var r=s*this._refillRate;e.tokens=Math.min(e.tokens+r,this._bucketSize),e.lastAccess=e.lastAccess+s*this._refillInterval}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):(r={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=r),0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var J="Mobile",X="iOS",Q="Android",Z="Tablet",ee=Q+" "+Z,te="iPad",ie="Apple",se=ie+" Watch",re="Safari",ne="BlackBerry",oe="Samsung",ae=oe+"Browser",le=oe+" Internet",ce="Chrome",ue=ce+" OS",de=ce+" "+X,_e="Internet Explorer",he=_e+" "+J,pe="Opera",ge=pe+" Mini",ve="Edge",fe="Microsoft "+ve,me="Firefox",ye=me+" "+X,be="Nintendo",we="PlayStation",Ee="Xbox",Se=Q+" "+J,xe=J+" "+re,ke="Windows",Pe=ke+" Phone",Ie="Nokia",Ce="Ouya",Te="Generic",Fe=Te+" "+J.toLowerCase(),Re=Te+" "+Z.toLowerCase(),$e="Konqueror",Le="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+Le),Oe=new RegExp(Ee,"i"),Ae=new RegExp(we+" \\w+","i"),De=new RegExp(be+" \\w+","i"),Ne=new RegExp(ne+"|PlayBook|BB10","i"),qe={"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"};var He,Ue,je,ze=(e,t)=>t&&w(t,ie)||function(e){return w(e,re)&&!w(e,ce)&&!w(e,Q)}(e),Be=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?ge:w(e," OPR/")?pe:Ne.test(e)?ne:w(e,"IE"+J)||w(e,"WPDesktop")?he:w(e,ae)?le:w(e,ve)||w(e,"Edg/")?fe:w(e,"FBIOS")?"Facebook "+J:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?de:w(e,"CrMo")||w(e,ce)?ce:w(e,Q)&&w(e,re)?Se:w(e,"FxiOS")?ye:w(e.toLowerCase(),$e.toLowerCase())?$e:ze(e,t)?w(e,J)?xe:re:w(e,me)?me:w(e,"MSIE")||w(e,"Trident/")?_e:w(e,"Gecko")?me:""},Ve={[he]:[new RegExp("rv:"+Le)],[fe]:[new RegExp(ve+"?\\/"+Le)],[ce]:[new RegExp("("+ce+"|CrMo)\\/"+Le)],[de]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[re]:[Me],[xe]:[Me],[pe]:[new RegExp("(Opera|OPR)\\/"+Le)],[me]:[new RegExp(me+"\\/"+Le)],[ye]:[new RegExp("FxiOS\\/"+Le)],[$e]:[new RegExp("Konqueror[:/]?"+Le,"i")],[ne]:[new RegExp(ne+" "+Le),Me],[Se]:[new RegExp("android\\s"+Le,"i")],[le]:[new RegExp(ae+"\\/"+Le)],[_e]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},We=function(e,t){var i=Be(e,t),s=Ve[i];if(L(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Ge=[[new RegExp(Ee+"; "+Ee+" (.*?)[);]","i"),e=>[Ee,e&&e[1]||""]],[new RegExp(be,"i"),[be,""]],[new RegExp(we,"i"),[we,""]],[Ne,[ne,""]],[new RegExp(ke,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Pe,""];if(new RegExp(J).test(t)&&!/IEMobile\b/.test(t))return[ke+" "+J,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=qe[s]||"";return/arm/i.test(t)&&(r="RT"),[ke,r]}return[ke,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[X,t.join(".")]}return[X,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Q+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Q+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Q,t.join(".")]}return[Q,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ue,""]],[/Linux|debian/i,["Linux",""]]],Ye=function(e){return De.test(e)?be:Ae.test(e)?we:Oe.test(e)?Ee:new RegExp(Ce,"i").test(e)?Ce:new RegExp("("+Pe+"|WPDesktop)","i").test(e)?Pe:/iPad/.test(e)?te:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?se:Ne.test(e)?ne:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ie,"i").test(e)?Ie:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(J).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Q:ee:new RegExp("(pda|"+J+")","i").test(e)?Fe:new RegExp(Z,"i").test(e)&&!new RegExp(Z+" pc","i").test(e)?Re:""},Ke=e=>e instanceof Error;function Je(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return je&&i.length===Ue||(Ue=i.length,je=i.reduce(((i,s)=>{He||(He={});var r=He[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[s];if(l&&c){i[l]=c,He[s]=[l,c];break}}return i}),{})),je}}class Xe{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&C(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s,r;return null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}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 i=this;return t((function*(){var t=e;for(var s of i.modifiers)t=yield s(t);return t}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(s=t.type)&&void 0!==s?s:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:Je(this.stackParser)}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(s<=4){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return i({},t,{syntheticException:0==s?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,s),next:e=>r(e,s+1)})}}var Qe="?";function Ze(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?Qe:i,in_app:!0};return L(s)||(n.lineno=s),L(r)||(n.colno=r),n}var et=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:Qe,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,it=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,st=/\((\S*)(?::(\d+))(?::(\d+))\)/,rt=(e,t)=>{var i=tt.exec(e);if(i){var[,s,r,n]=i;return Ze(t,s,Qe,+r,+n)}var o=it.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=st.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=et(o[1]||Qe,o[2]);return Ze(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},nt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ot=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,at=(e,t)=>{var i=nt.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=ot.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||Qe;return[n,r]=et(n,r),Ze(t,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},lt=/\(error: (.*)\)/,ct=50;function ut(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;r<t;r++)s[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;a<o.length;a++){var l=o[a];if(!(l.length>1024)){var c=lt.test(l)?l.replace(lt,"$1"):l;if(!c.match(/\S*Error: /)){for(var u of s){var d=u(c,e);if(d){n.push(d);break}}if(n.length>=ct)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ct).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||Qe});var s}))}(n)}}class dt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=M(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 z(e,"DOMException")}isDOMError(e){return z(e,"DOMError")}}class _t{match(e){return(e=>e 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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ht{constructor(){}match(e){return z(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var pt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class gt{match(e){return"string"==typeof e}coerce(e,t){var i,[s,r]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=r?r:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(pt);return s&&(t=s[1],i=s[2]),[t,i]}}var vt=["fatal","error","warning","log","info","debug"];function ft(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(!(r.length>t))return s===i.length||r.length<=t?r:r.slice(0,t)+"..."}return""}class mt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return B(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ft(e)}isSeverityLevel(e){return M(e)&&!O(e)&&vt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Ke(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class yt{match(e){return B(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ft(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class bt{match(e){return j(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class wt{match(e){return z(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return j(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(j(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Et=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,s={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG||i)&&!L(r.console)&&r.console){for(var s=("__rrweb_original__"in r.console[t]?r.console[t].__rrweb_original__:r.console[t]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];s(e,...o)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Et(e+" "+t,i)};return s},St=Et("[PostHog.js]"),xt=St.createLogger,kt={};function Pt(e,t,i){if(C(e))if(a&&e.forEach===a)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===kt)return}function It(e,t,i){if(!D(e)){if(C(e))return Pt(e,t,i);if(H(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===kt)return}else for(var r in e)if(P.call(e,r)&&t.call(i,e[r],r)===kt)return}}var Ct=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Pt(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Tt=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Pt(i,(function(t){Pt(t,(function(t){e.push(t)}))})),e};function Ft(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Rt=function(e){try{return e()}catch(e){return}},$t=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){St.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),St.critical(e)}}},Lt=function(e){var t={};return It(e,(function(e,i){(M(e)&&e.length>0||N(e))&&(t[i]=e)})),t};function Mt(e,t){return i=e,s=e=>M(e)&&!A(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],Pt(t,(t=>{n.push(e(t))}))):(n={},It(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var Ot=["herokuapp.com","vercel.app","netlify.app"];function At(e){var t=null==e?void 0:e.hostname;if(!M(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of Ot)if(i===s)return!1;return!0}function Dt(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Nt(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var qt="$people_distinct_id",Ht="__alias",Ut="__timers",jt="$autocapture_disabled_server_side",zt="$heatmaps_enabled_server_side",Bt="$exception_capture_enabled_server_side",Vt="$error_tracking_suppression_rules",Wt="$error_tracking_capture_extension_exceptions",Gt="$web_vitals_enabled_server_side",Yt="$dead_clicks_enabled_server_side",Kt="$product_tours_enabled_server_side",Jt="$web_vitals_allowed_metrics",Xt="$session_recording_remote_config",Qt="$sesid",Zt="$session_is_sampled",ei="$enabled_feature_flags",ti="$early_access_features",ii="$feature_flag_details",si="$stored_person_properties",ri="$stored_group_properties",ni="$surveys",oi="$flag_call_reported",ai="$user_state",li="$client_session_props",ci="$capture_rate_limit",ui="$initial_campaign_params",di="$initial_referrer_info",_i="$initial_person_info",hi="$epp",pi="__POSTHOG_TOOLBAR__",gi="$posthog_cookieless",vi=[qt,Ht,"__cmpns",Ut,"$session_recording_enabled_server_side",zt,Qt,ei,Vt,ai,ti,ii,ri,si,ni,oi,li,ci,ui,di,hi,_i,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function fi(e){return e instanceof Element&&(e.id===pi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function mi(e){return!!e&&1===e.nodeType}function yi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function bi(e){return!!e&&3===e.nodeType}function wi(e){return!!e&&11===e.nodeType}function Ei(e){return e?E(e).split(/\s+/):[]}function Si(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function xi(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Ei(t)}function ki(e){return D(e)?null:E(e).split(/(\s+)/).filter((e=>Wi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pi(e){var t="";return Ni(e)&&!qi(e)&&e.childNodes&&e.childNodes.length&&It(e.childNodes,(function(e){var i;bi(e)&&e.textContent&&(t+=null!==(i=ki(e.textContent))&&void 0!==i?i:"")})),E(t)}function Ii(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Ci=["a","button","form","input","select","textarea","label"];function Ti(e,t){if(L(t))return!0;var i,s=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function Fi(e){var t=e.parentNode;return!(!t||!mi(t))&&t}var Ri=["next","previous","prev",">","<"],$i=10;var Li=[".ph-no-rageclick",".ph-no-capture"];function Mi(e,t){if(!r||Oi(e))return!1;var i,s,n;q(t)?(i=!!t&&Li,s=void 0):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Li,s=null==t?void 0:t.content_ignorelist);if(!1===i)return!1;var{targetElementList:o}=Ai(e,!1);return!function(e,t){if(!1===e||L(e))return!1;var i;if(!0===e)i=Ri;else{if(!C(e))return!1;if(e.length>$i)return St.error("[PostHog] content_ignorelist array cannot exceed "+$i+" items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:s}=e;return i.some((e=>t.includes(e)||s.includes(e)))}))}(s,o.map((e=>{var t;return{safeText:Pi(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Ti(o,i)}var Oi=e=>!e||yi(e,"html")||!mi(e),Ai=(e,t)=>{if(!r||Oi(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!yi(n,"body");)if(wi(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Fi(n);if(!o)break;if(t||Ci.indexOf(o.tagName.toLowerCase())>-1)i=!0;else{var a=r.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}s.push(o),n=o}return{parentIsUsefulElement:i,targetElementList:s}};function Di(e,t,i,s,n){var o,a,l,c;if(void 0===i&&(i=void 0),!r||Oi(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!Si(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Si(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Ai(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var s,r=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(_,i))return!1;if(!Ti(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=r.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Ci.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Ni(e){for(var t=e;t.parentNode&&!yi(t,"body");t=t.parentNode){var i=xi(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(xi(e),"ph-include"))return!0;var s=e.type||"";if(M(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(M(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function qi(e){return!!(yi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||yi(e,"select")||yi(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Hi="(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})",Ui=new RegExp("^(?:"+Hi+")$"),ji=new RegExp(Hi),zi="\\d{3}-?\\d{2}-?\\d{4}",Bi=new RegExp("^("+zi+")$"),Vi=new RegExp("("+zi+")");function Wi(e,t){if(void 0===t&&(t=!0),D(e))return!1;if(M(e)){if(e=E(e),(t?Ui:ji).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bi:Vi).test(e))return!1}return!0}function Gi(e){var t=Pi(e);return Wi(t=(t+" "+Yi(e)).trim())?t:""}function Yi(e){var t="";return e&&e.childNodes&&e.childNodes.length&&It(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Pi(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Yi(e)).trim())}catch(e){St.error("[AutoCapture]",e)}})),t}function Ki(e){return function(e){var t=e.map((e=>{var t,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Ft(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[Ji(t.toString())]=Ji(i.toString())})),r+=":",r+=Ft(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Xi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ft(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Ji(e){return e.replace(/"|\\"/g,'\\"')}function Xi(e){var t=e.attr__class;return t?C(t)?t:Ei(t):void 0}class Qi{constructor(e){this.disabled=!1===e;var t=F(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}}var Zi="$copy_autocapture",es=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ts=e=>{var t=null==u?void 0:u.createElement("a");return L(t)?null:(t.href=e,t)},is=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return It(e,(function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)})),r.join(t)},ss=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){St.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},rs=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");C(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=a&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},ns=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},os=xt("[AutoCapture]");function as(e,t){return t.length>e?t.slice(0,e)+"...":t}function ls(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!mi(t));return t}function cs(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Ci.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=as(1024,Gi(e)):n.$el_text=as(1024,Pi(e)));var o=xi(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),It(e.attributes,(function(i){var r;if((!qi(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&Wi(i.value)&&(r=i.name,!M(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Ei(o).join(" ")),n["attr__"+i.name]=as(1024,o)}}));for(var a=1,l=1,c=e;c=ls(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function us(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!yi(d,"body");)wi(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(It(u,(e=>{var t=Ni(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Wi(g)&&g),w(xi(e),"ph-no-capture")&&(v=!0),h.push(cs(e,o,a,l));var i=function(e){if(!Ni(e))return{};var t={};return It(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Wi(s)&&(t[i]=s)}})),t}(e);Ct(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Gi(e):h[0].$el_text=Pi(e)),g){var f,m;h[0].attr__href=g;var y=null==(f=ts(g))?void 0:f.host,b=null==r||null==(m=r.location)?void 0:m.host;y&&b&&y!==b&&(_=g)}return{props:Ct({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Ki(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(s=h[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class ds{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new Qi(e.config.rageclick),this._elementSelectors=null}get _config(){var e,t,i=F(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(r&&u){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){os.error("Failed to capture event",e)}};if(Nt(u,"submit",e,{capture:!0}),Nt(u,"change",e,{capture:!0}),Nt(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,Zi)};Nt(u,"copy",t,{capture:!0}),Nt(u,"cut",t,{capture:!0})}}}else os.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[jt]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var s=null==u?void 0:u.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[jt],s=this._isDisabledServerSide;if(A(s)&&!q(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Ii(e);if(bi(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&Mi(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===Zi;if(s&&Di(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=us(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===Zi){var c,u=ki(null==r||null==(c=r.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return T(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var _s="0123456789abcdef";class hs{constructor(e){if(this.bytes=e,16!==e.length)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 r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new hs(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+_s.charAt(this.bytes[t]>>>4)+_s.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new hs(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class ps{constructor(){this._timestamp=0,this._counter=0,this._random=new fs}generate(){var e=this.generateOrAbort();if(L(e)){this._timestamp=0;var t=this.generateOrAbort();if(L(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return hs.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var gs,vs=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};r&&!L(r.crypto)&&crypto.getRandomValues&&(vs=e=>crypto.getRandomValues(e));class fs{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(vs(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var ms=()=>ys().toString(),ys=()=>(gs||(gs=new ps)).generate(),bs="";var ws=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Es(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),bs)return bs;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+ms();!bs&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",bs=n)}return bs}(e);if(!i){var s=(e=>{var t=e.match(ws);return t?t[0]:""})(e);s!==i&&St.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var Ss={_is_supported:()=>!!u,_error:function(e){St.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(Ss._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(u)try{var n="",o="",a=Es(u.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&St.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{Ss._set(e,"",-1,t)}catch(e){return}}},xs=null,ks={_is_supported:function(){if(!A(xs))return xs;var e=!0;if(L(r))e=!1;else try{var t="__mplssupport__";ks._set(t,"xyz"),'"xyz"'!==ks._get(t)&&(e=!1),ks._remove(t)}catch(t){e=!1}return e||St.error("localStorage unsupported; falling back to cookie store"),xs=e,e},_error:function(e){St.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){ks._error(e)}return null},_parse:function(e){try{return JSON.parse(ks._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){ks._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){ks._error(e)}}},Ps=["$device_id","distinct_id",Qt,Zt,hi,_i],Is=i({},ks,{_parse:function(e){try{var t={};try{t=Ss._parse(e)||{}}catch(e){}var i=Ct(t,JSON.parse(ks._get(e)||"{}"));return ks._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{ks._set(e,t,void 0,void 0,n);var o={};Ps.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Ss._set(e,o,i,s,r,n)}catch(e){ks._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),Ss._remove(e,t)}catch(e){ks._error(e)}}}),Cs={},Ts={_is_supported:function(){return!0},_error:function(e){St.error("memoryStorage error: "+e)},_get:function(e){return Cs[e]||null},_parse:function(e){return Cs[e]||null},_set:function(e,t){Cs[e]=t},_remove:function(e){delete Cs[e]}},Fs=null,Rs={_is_supported:function(){if(!A(Fs))return Fs;if(Fs=!0,L(r))Fs=!1;else try{var e="__support__";Rs._set(e,"xyz"),'"xyz"'!==Rs._get(e)&&(Fs=!1),Rs._remove(e)}catch(e){Fs=!1}return Fs},_error:function(e){St.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){Rs._error(e)}return null},_parse:function(e){try{return JSON.parse(Rs._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Rs._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){Rs._error(e)}}},$s=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Ls{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?$s.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===$s.DENIED||this.consent===$s.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===$s.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){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 _storedConsent(){var e=this._storage._get(this._storageKey);return W(e)?$s.GRANTED:w(G,e)?$s.DENIED:$s.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?ks:Ss;var t="localStorage"===e?Ss:ks;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(W(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!Dt([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>W(e)))}}var Ms=xt("[Dead Clicks]"),Os=()=>!0,As=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Yt)),s=e.instance.config.capture_dead_clicks;return q(s)?s:!!F(s)||i};class Ds{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Yt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Ms.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=F(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Ms.info("starting...")}}else Ms.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Ms.info("stopping..."))}}var Ns=xt("[ExceptionAutocapture]");class qs{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(r&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Ns.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Bt]),this._rateLimiter=new K({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,_logger:Ns}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return F(e)?t=i({},t,e):(L(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ns.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Ns.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Bt]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?Ns.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Hs(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return T(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class Us{constructor(e){var t;this._instance=e,this._lastPathname=(null==r||null==(t=r.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(St.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,St.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||Hs(r.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=r.history.replaceState)&&t.__posthog_wrapped__||Hs(r.history,"replaceState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==r||null==(t=r.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){St.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Nt(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}var js=xt("[SegmentIntegration]");function zs(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||ms();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(ai,"identified")),t()},r=i.user();"then"in r&&T(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||js.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(js.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(js.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var s=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},s,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var Bs="posthog-js";function Vs(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===o||o.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&e.exceptions.sendExceptionEvent(v),t}}class Ws{constructor(e,t,i,s,r,n){this.name=Bs,this.setupOnce=function(o){o(Vs(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Gs=null!=r&&r.location?ns(r.location.hash,"__posthog")||ns(location.hash,"state"):null,Ys="_postHogToolbarParams",Ks=xt("[Toolbar]"),Js=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Js||{});class Xs{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Js.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!r||!u)return!1;e=null!=e?e:r.location,i=null!=i?i:r.history;try{if(!t){try{r.localStorage.setItem("test","test"),r.localStorage.removeItem("test")}catch(e){return!1}t=null==r?void 0:r.localStorage}var s,n=Gs||ns(e.hash,"__posthog")||ns(e.hash,"state"),o=n?Rt((()=>JSON.parse(atob(decodeURIComponent(n)))))||Rt((()=>JSON.parse(decodeURIComponent(n)))):null;return o&&"ph_authorize"===o.action?((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(Ys)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!D(t)&&T(t)?t(e,this.instance):Ks.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(pi));if(!r||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(r.localStorage.setItem(Ys,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Js.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Js.UNINITIALIZED){var o;this._setToolbarState(Js.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ks.error("[Toolbar] Failed to load",e),void this._setToolbarState(Js.UNINITIALIZED);this._setToolbarState(Js.LOADED),this._callLoadToolbar(n)})),Nt(r,"turbolinks:load",(()=>{this._setToolbarState(Js.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Qs=xt("[TracingHeaders]");class Zs{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;L(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));L(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Qs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var er="https?://(.*)",tr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ir=Tt(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],tr),sr="<masked>",rr=["li_fat_id"];function nr(e,t,i){if(!u)return{};var s,r=t?Tt([],tr,i||[]):[],n=or(rs(u.URL,r,sr),e),o=(s={},It(rr,(function(e){var t=Ss._get(e);s[e]=t||null})),s);return Ct(o,n)}function or(e,t){var i=ir.concat(t||[]),s={};return It(i,(function(t){var i=ss(e,t);s[t]=i||null})),s}function ar(e){var t=function(e){return e?0===e.search(er+"google.([^/?]*)")?"google":0===e.search(er+"bing.com")?"bing":0===e.search(er+"yahoo.com")?"yahoo":0===e.search(er+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!A(t)){s.$search_engine=t;var r=u?ss(u.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function lr(){return navigator.language||navigator.userLanguage}function cr(){return(null==u?void 0:u.referrer)||"$direct"}function ur(e,t){var i=e?Tt([],tr,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:cr().substring(0,1e3),u:s?rs(s,i,sr):void 0}}function dr(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ts(i))?void 0:t.host};if(s){r.$current_url=s;var n=ts(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=or(s);Ct(r,o)}if(i){var a=ar(i);Ct(r,a)}return r}function _r(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function hr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function pr(e,t){if(!g)return{};var i,s,n,o=e?Tt([],tr,t||[]):[],[a,l]=function(e){for(var t=0;t<Ge.length;t++){var[i,s]=Ge[t],r=i.exec(e),n=r&&(T(s)?s(r,e):s);if(n)return n}return["",""]}(g);return Ct(Lt({$os:a,$os_version:l,$browser:Be(g,navigator.vendor),$device:Ye(g),$device_type:(s=g,n=Ye(s),n===te||n===ee||"Kobo"===n||"Kindle Fire"===n||n===Re?Z:n===be||n===Ee||n===we||n===Ce?"Console":n===se?"Wearable":n?J:"Desktop"),$timezone:_r(),$timezone_offset:hr()}),{$current_url:rs(null==d?void 0:d.href,o,sr),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:We(g,navigator.vendor),$browser_language:lr(),$browser_language_prefix:(i=lr(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==r?void 0:r.screen.height,$screen_width:null==r?void 0:r.screen.width,$viewport_height:null==r?void 0:r.innerHeight,$viewport_width:null==r?void 0:r.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var gr=xt("[Web Vitals]"),vr=9e5;class fr{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(s))gr.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!L(r))if(D(null==e?void 0:e.name)||D(null==e?void 0:e.value))gr.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)gr.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),L(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=L(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,s,r=v.__PosthogExtensions__;L(r)||L(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):gr.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Gt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=F(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return L(i)?(null==(t=this._instance.persistence)?void 0:t.props[Jt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(F(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=F(this._instance.config.capture_performance)&&N(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:vr;return 0<e&&e<=6e4?vr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return gr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=F(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:q(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return q(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(gr.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=F(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=F(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Gt]:t}),this._instance.persistence.register({[Jt]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?gr.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.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?Tt([],tr,i||[]):[];return rs(e,s,sr)}gr.error("Could not determine current URL")}}var mr=xt("[Heatmaps]");function yr(e){return F(e)&&"clientX"in e&&"clientY"in e&&N(e.clientX)&&N(e.clientY)}class br{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[zt]),this.rageclicks=new Qi(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return F(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 L(this.instance.config.capture_heatmaps)?L(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;mr.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[zt]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(u)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){r&&u&&(this._flushHandler=this._flush.bind(this),Nt(r,"beforeunload",this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==r?void 0:r.event)),Nt(u,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==r?void 0:r.event)),Nt(u,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ds(this.instance,Os,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Nt(u,"visibilitychange",this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;r&&u&&(this._flushHandler&&r.removeEventListener("beforeunload",this._flushHandler),this._onClickHandler&&u.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&u.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&u.removeEventListener("visibilitychange",this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&mi(s)&&!yi(s,"body");){if(s===i)return!1;if(w(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=Fi(s)}return!1}(Ii(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!fi(e.target)&&yr(e)){var r=this._getProperties(e,t);null!=(s=this.rageclicks)&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!fi(e.target)&&yr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?Tt([],tr,s||[]):[],o=rs(t,n,sr);this._buffer=this._buffer||{},this._buffer[o]||(this._buffer[o]=[]),this._buffer[o].push(e)}}_flush(){this._buffer&&!R(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class wr{constructor(e){this._instance=e}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==r?void 0:r.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:Y(o/n,0,1,St),_=n<=1?1:Y(a/n,0,1,St),h=l<=1?1:Y(c/l,0,1,St),p=l<=1?1:Y(u/l,0,1,St);s=Ct(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var Er=Uint8Array,Sr=Uint16Array,xr=Uint32Array,kr=new Er([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]),Pr=new Er([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]),Ir=new Er([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cr=function(e,t){for(var i=new Sr(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new xr(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Tr=Cr(kr,2),Fr=Tr[0],Rr=Tr[1];Fr[28]=258,Rr[258]=28;for(var $r=Cr(Pr,0)[1],Lr=new Sr(32768),Mr=0;Mr<32768;++Mr){var Or=(43690&Mr)>>>1|(21845&Mr)<<1;Or=(61680&(Or=(52428&Or)>>>2|(13107&Or)<<2))>>>4|(3855&Or)<<4,Lr[Mr]=((65280&Or)>>>8|(255&Or)<<8)>>>1}var Ar=function(e,t,i){for(var s=e.length,r=0,n=new Sr(t);r<s;++r)++n[e[r]-1];var o,a=new Sr(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Sr(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)o[Lr[d]>>>l]=c}else for(o=new Sr(s),r=0;r<s;++r)o[r]=Lr[a[e[r]-1]++]>>>15-e[r];return o},Dr=new Er(288);for(Mr=0;Mr<144;++Mr)Dr[Mr]=8;for(Mr=144;Mr<256;++Mr)Dr[Mr]=9;for(Mr=256;Mr<280;++Mr)Dr[Mr]=7;for(Mr=280;Mr<288;++Mr)Dr[Mr]=8;var Nr=new Er(32);for(Mr=0;Mr<32;++Mr)Nr[Mr]=5;var qr=Ar(Dr,9,0),Hr=Ar(Nr,5,0),Ur=function(e){return(e/8>>0)+(7&e&&1)},jr=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Sr?Sr:e instanceof xr?xr:Er)(i-t);return s.set(e.subarray(t,i)),s},zr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},Br=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Vr=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Er(0),0];if(1==r){var o=new Er(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;s<r;++s)n[s].s>_&&(_=n[s].s);var h=new Sr(_+1),p=Wr(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;h[y]<t?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new Er(h),p]},Wr=function(e,t,i){return-1==e.s?Math.max(Wr(e.l,t,i+1),Wr(e.r,t,i+1)):t[e.s]=i},Gr=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Sr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Yr=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Kr=function(e,t,i){var s=i.length,r=Ur(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Jr=function(e,t,i,s,r,n,o,a,l,c,u){zr(t,u++,i),++r[256];for(var d=Vr(r,15),_=d[0],h=d[1],p=Vr(n,15),g=p[0],v=p[1],f=Gr(_),m=f[0],y=f[1],b=Gr(g),w=b[0],E=b[1],S=new Sr(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Vr(S,7),P=k[0],I=k[1],C=19;C>4&&!P[Ir[C-1]];--C);var T,F,R,L,M=c+5<<3,O=Yr(r,Dr)+Yr(n,Nr)+o,A=Yr(r,_)+Yr(n,g)+o+14+3*C+Yr(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M<=O&&M<=A)return Kr(t,u,e.subarray(l,l+c));if(zr(t,u,1+(A<O)),u+=2,A<O){T=Ar(_,h,0),F=_,R=Ar(g,v,0),L=g;var D=Ar(P,I,0);zr(t,u,y-257),zr(t,u+5,E-1),zr(t,u+10,C-4),u+=14;for(x=0;x<C;++x)zr(t,u+3*x,P[Ir[x]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var H=N[q];for(x=0;x<H.length;++x){var U=31&H[x];zr(t,u,D[U]),u+=P[U],U>15&&(zr(t,u,H[x]>>>5&127),u+=H[x]>>>12)}}}else T=qr,F=Dr,R=Hr,L=Nr;for(x=0;x<a;++x)if(s[x]>255){U=s[x]>>>18&31;Br(t,u,T[U+257]),u+=F[U+257],U>7&&(zr(t,u,s[x]>>>23&31),u+=kr[U]);var j=31&s[x];Br(t,u,R[j]),u+=L[j],j>3&&(Br(t,u,s[x]>>>5&8191),u+=Pr[j])}else Br(t,u,T[s[x]]),u+=F[s[x]];return Br(t,u,T[256]),u+F[256]},Xr=new xr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qr=function(){for(var e=new xr(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Zr=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new Er(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Kr(l,c,e.subarray(u,d)):(l[u]=n,c=Kr(l,c,e.subarray(u,o)))}else{for(var _=Xr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new Sr(32768),f=new Sr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new xr(25e3),E=new Sr(288),S=new Sr(32),x=0,k=0,P=(u=0,0),I=0,C=0;u<o;++u){var T=b(u),F=32767&u,R=f[T];if(v[F]=R,f[T]=F,I<=u){var L=o-u;if((x>7e3||P>24576)&&L>423){c=Jr(e,l,0,w,E,S,k,P,C,u-C,c),P=x=k=0,C=u;for(var M=0;M<286;++M)E[M]=0;for(M=0;M<30;++M)S[M]=0}var O=2,A=0,D=p,N=F-R&32767;if(L>2&&T==b(u-N))for(var q=Math.min(h,L)-1,H=Math.min(32767,u),U=Math.min(258,L);N<=H&&--D&&F!=R;){if(e[u+O]==e[u+O-N]){for(var j=0;j<U&&e[u+j]==e[u+j-N];++j);if(j>O){if(O=j,A=N,j>q)break;var z=Math.min(N,j-2),B=0;for(M=0;M<z;++M){var V=u-N+M+32768&32767,W=V-v[V]+32768&32767;W>B&&(B=W,R=V)}}}N+=(F=R)-(R=v[F])+32768&32767}if(A){w[P++]=268435456|Rr[O]<<18|$r[A];var G=31&Rr[O],Y=31&$r[A];k+=kr[G]+Pr[Y],++E[257+G],++S[Y],I=u+O,++x}else w[P++]=e[u],++E[e[u]]}}c=Jr(e,l,n,w,E,S,k,P,C,u-C,c)}return jr(a,0,s+Ur(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!0)},en=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function tn(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Qr[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n=Zr(e,t,10+((r=t).filename&&r.filename.length+1||0),8),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&en(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}}(n,t),en(n,o-8,i.d()),en(n,o-4,s),n}var sn=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++: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),A(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},rn=!!h||!!_,nn="text/plain",on=function(e,t,s){var r;void 0===s&&(s=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(r=null==o?void 0:o.split("&").map((e=>{var t,[i,r]=e.split("="),n=s&&null!==(t=a[i])&&void 0!==t?t:r;return delete a[i],i+"="+n})))&&void 0!==r?r:[],c=is(a);return c&&l.push(c),n+"?"+l.join("&")},an=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),ln=e=>{var{data:t,compression:i}=e;if(t){if(i===es.GZipJS){var s=tn(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Er(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new Er(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return jr(s,0,r)}(an(t)),{mtime:0}),r=new Blob([s],{type:nn});return{contentType:nn,body:r,estimatedSize:r.size}}if(i===es.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=sn(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(an(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:an(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=an(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},cn=[];_&&cn.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=ln(e))&&void 0!==t?t:{},a=new Headers;It(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null==(s=c)?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){St.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{St.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&cn.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=ln(e))&&void 0!==t?t:{};It(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(r)}}),null!=c&&c.sendBeacon&&cn.push({transport:"sendBeacon",method:e=>{var t=on(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=ln(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;c.sendBeacon(t,n)}catch(e){}}});var un=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function dn(e,t,i){return an({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var _n={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>un(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!un(t,e))))),icontains:(e,t)=>t.map(hn).some((t=>e.map(hn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(hn).every((t=>e.map(hn).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},hn=e=>e.toLowerCase();function pn(e,t){return!e||Object.entries(e).every((e=>{var[i,s]=e,r=null==t?void 0:t[i];if(L(r)||A(r))return!1;var n=[String(r)],o=_n[s.operator];return!!o&&o(s.values,n)}))}var gn=xt("[Error tracking]");class vn{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new Xe([new dt,new wt,new ht,new _t,new yt,new mt,new gt,new bt],ut("web:javascript",rt,at)),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Vt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,s,r=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(s=e.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[Vt]:this._suppressionRules,[Wt]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Wt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return void gn.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return void gn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return void gn.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return M(i)&&i.length>0&&e.$exception_types.push(i),M(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,s=_n[e.operator],r=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return r.length>0&&s(r,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(s=null==o||null==(r=o.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!D(e)&&C(e)}}var fn=xt("[FeatureFlags]"),mn=xt("[FeatureFlags]",{debugEnabled:!0}),yn="$active_feature_flags",bn="$override_feature_flags",wn="$feature_flag_payloads",En="$override_feature_flag_payloads",Sn="$feature_flag_request_id",xn="$feature_flag_evaluated_at",kn=e=>{var t={};for(var[i,s]of Ft(e||{}))s&&(t[i]=s);return t},Pn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):fn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},In=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class Cn{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||fn.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(ii),t=this._instance.get_property(bn),s=this._instance.get_property(En);if(!s&&!t)return e||{};var r=Ct({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,c=r[o],u=null==t?void 0:t[o],d=L(u)?null!==(a=null==c?void 0:c.enabled)&&void 0!==a&&a:!!u,_=L(u)?c.variant:"string"==typeof u?u:void 0,h=null==s?void 0:s[o],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(fn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(ei),t=this._instance.get_property(bn);if(!t)return e||{};for(var i=Ct({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(fn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(wn),t=this._instance.get_property(En);if(!t)return e||{};for(var i=Ct({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(fn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s=this._instance.config.token,r=this._instance.get_property("$device_id"),n={token:s,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(si)||{}),group_properties:this._instance.get_property(ri)};A(r)||L(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_environments=this._getValidEvaluationEnvironments());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(n.timezone=_r()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:c,data:n,compression:this._instance.config.disable_compression?void 0:es.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!n.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!s,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(In.FeatureFlags))fn.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 r;if(!n.disable_flags)this.receivedFeatureFlags(null!==(r=e.json)&&void 0!==r?r:{},s);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],s=""+i,r=this._instance.get_property(Sn)||void 0,n=this._instance.get_property(xn)||void 0,o=this._instance.get_property(oi)||{};if((t.send_event||!("send_event"in t))&&(!(e in o)||!o[e].includes(s))){var a,l,c,u,d,_,h,p,g;C(o[e])?o[e].push(s):o[e]=[s],null==(a=this._instance.persistence)||a.register({[oi]:o});var v=this.getFeatureFlagDetails(e),f={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:r,$feature_flag_evaluated_at:n,$feature_flag_bootstrapped_response:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlags)?void 0:l[e])||null,$feature_flag_bootstrapped_payload:(null==(c=this._instance.config.bootstrap)||null==(c=c.featureFlagPayloads)?void 0:c[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};L(null==v||null==(u=v.metadata)?void 0:u.version)||(f.$feature_flag_version=v.metadata.version);var m,y=null!==(d=null==v||null==(_=v.reason)?void 0:_.description)&&void 0!==d?d:null==v||null==(h=v.reason)?void 0:h.code;if(y&&(f.$feature_flag_reason=y),null!=v&&null!=(p=v.metadata)&&p.id&&(f.$feature_flag_id=v.metadata.id),L(null==v?void 0:v.original_variant)&&L(null==v?void 0:v.original_enabled)||(f.$feature_flag_original_response=L(v.original_variant)?v.original_enabled:v.original_variant),null!=v&&null!=(g=v.metadata)&&g.original_payload)f.$feature_flag_original_payload=null==v||null==(m=v.metadata)?void 0:m.original_payload;this._instance.capture("$feature_flag_called",f)}return i}fn.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:es.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null==(s=i.json)?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}fn.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._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,s,r,n){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var o=Pn(e),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(l){var u=e.requestId,d=e.evaluatedAt;if(C(l)){fn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(l)for(var h=0;h<l.length;h++)_[l[h]]=!0;t&&t.register({[yn]:l,[ei]:_})}else{var p=l,g=c,v=a;e.errorsWhileComputingFlags&&(p=i({},s,p),g=i({},r,g),v=i({},n,v)),t&&t.register(i({[yn]:Object.keys(kn(p)),[ei]:p||{},[wn]:g||{},[ii]:v||{}},u?{[Sn]:u}:{},d?{[xn]:d}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),fn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return fn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(bn),this._instance.persistence.unregister(En),this._fireFeatureFlagsCallbacks(),mn.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(bn),mn.info("Flag overrides cleared");else if(i.flags){if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[bn]:s})}else this._instance.persistence.register({[bn]:i.flags});mn.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(En),mn.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[En]:i.payloads}),mn.info("Payload overrides set",{payloads:i.payloads}))),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var r,n=(this._instance.get_property(ti)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),s&&(a.$feature_enrollment_stage=s),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[yn]:Object.keys(kn(l)),[ei]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(ti),r=i?"&"+i.map((e=>"stage="+e)).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+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(ti),null==(s=this._instance.persistence)||s.register({[ti]:r}),e(r)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(si)||{};this._instance.register({[si]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(si)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(ri)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[ri]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ri)||{};this._instance.register({[ri]:i({},t,{[e]:{}})})}else this._instance.unregister(ri)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var Tn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Fn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&St.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Tn.indexOf(e.persistence.toLowerCase())&&(St.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&ks._is_supported()?ks:"localstorage+cookie"===t&&Is._is_supported()?Is:"sessionstorage"===t&&Rs._is_supported()?Rs:"memory"===t?Ts:"cookie"===t?Ss:Is._is_supported()?Is:Ss}properties(){var e={};return It(this.props,(function(t,i){if(i===ei&&F(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/"+s[r]]=t[s[r]];else o=i,a=!1,(A(n=vi)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(It(n,(function(e){if(a||(a=e===o))return kt})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Ct({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(F(e)){L(t)&&(t="None"),this._expire_days=L(i)?this._default_expiry:i;var s=!1;if(It(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(F(e)){this._expire_days=L(t)?this._default_expiry:t;var i=!1;if(It(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,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._campaign_params_saved){var e=nr(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);R(Lt(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?ar(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cr(),$referring_domain:null!=u&&u.referrer&&(null==(e=ts(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ui]||this.props[di]||this.register_once({[_i]:ur(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};It([di,ui],(t=>{var i=this.props[t];i&&It(i,(function(t,i){e["$initial_"+S(i)]=t}))}));var t,i,s=this.props[_i];if(s){var r=(t=dr(s),i={},It(t,(function(e,t){i["$initial_"+S(t)]=e})),i);Ct(e,r)}return e}safe_merge(e){return It(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=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){var s=this._buildStorage(e),r=this.props;this.clear(),this._storage=s,this.props=r,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[Ut]||{};i[e]=t,this.props[Ut]=i,this.save()}remove_event_timer(e){var t=(this.props[Ut]||{})[e];return L(t)||(delete this.props[Ut][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var Rn=xt("[Product Tours]"),$n="ph_product_tours";class Ln{constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Kt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this._productTourManager||((e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Kt))||this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Rn.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=v.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!C(this._cachedTours)||t){var i=this._instance.persistence;if(i){var s=i.props[$n];if(C(s)&&!t)return this._cachedTours=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:t=>{var s=t.statusCode;if(200!==s||!t.json){var r="Product Tours API could not be loaded, status: "+s;return Rn.error(r),void e([],{isLoaded:!1,error:r})}var n=C(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[$n]:n}),e(n,{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){D(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._instance.persistence)||e.unregister($n)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}var Mn=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({}),On=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),An=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),Dn=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e}({}),Nn=function(e){return e.Popover="popover",e.Inline="inline",e}({}),qn=xt("[Surveys]");var Hn="seenSurvey_",Un=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},jn=e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Hn,e),zn=[On.Popover,On.Widget,On.API],Bn={ignoreConditions:!1,ignoreDelay:!1,displayType:Nn.Popover};class Vn{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}}function Wn(e,t,i){if(D(e))return!1;switch(i){case"exact":return e===t;case"contains":var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Gn{constructor(e){this._debugEventEmitter=new Vn,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!L(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null==(s=this._instance)||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!Wn(s,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&(!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t))}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some((e=>Wn(e.href,t.href,t.href_matching||"exact")));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Wn((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some((e=>Wn(e.text,t.text,t.text_matching||"exact")||Wn(e.$el_text,t.text,t.text_matching||"exact")));var r,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(r=function(e){for(var t,i=[],s=/(?::|")text="(.*?)"/g;!D(t=s.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",r.some((e=>Wn(e,n,o))))}_checkStepSelector(e,t){var i,s;if(null==t||!t.selector)return!0;var r=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=r&&r.includes(t.selector))return!0;var n=(null==e||null==(s=e.properties)?void 0:s.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||pn(t.properties.reduce(((e,t)=>{var i=C(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e}),{}),null==e?void 0:e.properties)}}class Yn{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&pn(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var s;null==(s=e.conditions)||null==(s=s[t])||null==(s=s.values)||s.forEach((t=>{if(null!=t&&t.name){var s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}}))})),i}_getMatchingItems(e,t,i){var s=(i===Mn.Activation?this._eventToItems:this._cancelEventToItems).get(e),r=[];return this._getItems((e=>{r=e.filter((e=>null==s?void 0:s.includes(e.id)))})),r.filter((s=>{var r,n=null==(r=s.conditions)||null==(r=r[i])||null==(r=r.values)?void 0:r.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Gn(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)?void 0:s.length)>0&&(null==(r=this._actionMatcher)||r.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))}))}}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),s=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));if(0!==i.length||0!==s.length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Mn.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,Mn.Cancellation)}}onEvent(e,t){var i,s=this._getLogger(),r=this._getActivatedKey(),n=this._getShownEventName(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[r])||[];if(n===e&&t&&o.length>0){var a,l;s.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this._updateActivatedItems(o))}}else{if(this._cancelEventToItems.has(e)){var d=this._getMatchingItems(e,t,Mn.Cancellation);d.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this._cancelPendingItem(e.id)})),this._updateActivatedItems(o))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var _=this._getMatchingItems(e,t,Mn.Activation);this._updateActivatedItems(o.concat(_.map((e=>e.id))||[]))}}}onAction(e){var t,i=this._getActivatedKey(),s=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this._actionToItems.has(e)&&this._updateActivatedItems(s.concat(this._actionToItems.get(e)||[]))}_updateActivatedItems(e){var t,i=this._getLogger(),s=this._getActivatedKey(),r=[...new Set(e)].filter((e=>!this._isItemPermanentlyIneligible(e)));i.info("updating activated items",{activatedItems:r}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[s]:r})}getActivatedIds(){var e,t=this._getActivatedKey(),i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class Kn extends Yn{constructor(e){super(e)}_getActivatedKey(){return"$surveys_activated"}_getShownEventName(){return An.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return qn}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class Jn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(D(t))return qn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this._isSurveysEnabled=i?t.length>0:t,qn.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Hn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)qn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)qn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())qn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!L(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var s=e.loadExternalDependency;if(!s)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else qn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Kn(this._instance),qn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){qn.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return qn.info("Disabled. Not loading surveys."),e([]);var i,s=this._instance.get_property(ni);if(s&&!t)return e(s,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:s}=t;return e(i,s)})):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),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:t=>{var s;this._getSurveysInFlightPromise=null;var r=t.statusCode;if(200!==r||!t.json){var n="Surveys API could not be loaded, status: "+r;qn.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c));null==(s=this._instance.persistence)||s.register({[ni]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){qn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);qn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var s;t=null!==(s=i.find((t=>t.id===e)))&&void 0!==s?s:null})),t}_checkSurveyEligibility(e){if(D(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(D(this._surveyManager))return qn.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return D(this._surveyManager)?(qn.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((t=>{var s,r=null!==(s=t.find((t=>t.id===e)))&&void 0!==s?s:null;if(r){var n=this._checkSurveyEligibility(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(D(this._surveyManager))qn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(zn.includes(s.type)){var r=null==u?void 0:u.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(qn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;qn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,r),qn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);qn.warn("Survey element not found")}else qn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else qn.warn("Survey not found")}}displaySurvey(e,t){var s;if(D(this._surveyManager))qn.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},r,{appearance:i({},r.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void qn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Nn.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else qn.warn("Survey not found")}}cancelPendingSurvey(e){D(this._surveyManager)?qn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var Xn=xt("[Conversations]");class Qn{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;D(t)||(q(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!this._conversationsManager&&!this._isInitializing&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==v?void 0:v.__PosthogExtensions__;if(e&&!L(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){if(function(e){var t;if(!e||0===e.length)return!0;var i=null==r||null==(t=r.location)?void 0:t.hostname;return!i||e.some((e=>{var t=function(e){var t=e.replace(/^https?:\/\//,"");return(t=t.split("/")[0].split("?")[0].split(":")[0])||null}(e);if(!t)return!1;if(t.startsWith("*.")){var s=t.slice(2);return i.endsWith("."+s)||i===s}return i===t}))}(this._remoteConfig.domains)){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1}))}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}}else Xn.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Xn.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Xn.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Xn.error(e,t),this._conversationsManager=null,this._isInitializing=!1}enable(){this._conversationsManager?this._conversationsManager.enable():Xn.warn("Conversations not loaded yet.")}disable(){this._conversationsManager&&this._conversationsManager.disable()}isLoaded(){return!A(this._conversationsManager)}isEnabled(){return!0===this._isConversationsEnabled}}var Zn=xt("[RateLimiter]");class eo{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Zn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Zn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(ci))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||e||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null==(s=this.instance.persistence)||s.set_property(ci,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var to=xt("[RemoteConfig]");class io{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(to.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(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 to.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void to.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return to.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){to.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):to.info("__preview_remote_config is disabled. Logging config instead",e):to.error("Failed to fetch remote config from PostHog.")}}var so=3e3;class ro{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Y((null==t?void 0:t.flush_interval_ms)||so,250,5e3,St.createLogger("flush interval"),so),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&C(i.data)&&It(i.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e._sendRequest(i)};for(var s in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return It(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;L(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var no=["retriesPerformedSoFar"];class oo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!L(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Nt(r,"online",this._onlineListener),Nt(r,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,no);N(t)&&t>0&&(r.url=on(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},r)):null==r.callback||r.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),St.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,L(r)||(this._onlineListener&&(r.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(r.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){St.error(e)}this._queue=[]}}class ao{constructor(e){this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Nt(r,"scroll",this._updateScrollData,{capture:!0}),Nt(r,"scrollend",this._updateScrollData,{capture:!0}),Nt(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=C(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=null==r?void 0:r.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 r&&(r.scrollY||r.pageYOffset||r.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return r&&(r.scrollX||r.pageXOffset||r.document.documentElement.scrollLeft)||0}}var lo=e=>ur(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class co{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[li]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||lo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[li]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?dr(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 It(Lt(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+S(i)]=t})),e}}var uo=xt("[SessionId]");class _o{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new Vn,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||ms,this._windowIdGenerator=i||ms;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Y(n,60,36e3,uo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=Rs._parse(this._window_id_storage_key),a=Rs._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:Rs._remove(this._window_id_storage_key),Rs._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){uo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Rs._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Rs._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Rs._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[Qt]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[Qt];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}destroy(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&r&&(r.removeEventListener("beforeunload",this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&Rs._remove(this._primary_window_exists_storage_key)},Nt(r,"beforeunload",this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=N(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!c&&!e&&this._sessionHasBeenIdleTooLong(i,s);c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),uo.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,_=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var ho=["$set_once","$set"],po=xt("[SiteApps]");class go{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,ho),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(r=e.properties)?void 0:r.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(po.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,po.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){po.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){po.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){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)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){po.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void po.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(s=e.siteApps)&&s.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=r._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return po.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else po.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var vo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&y(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>y(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},fo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),mo="i.posthog.com";class yo{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+mo,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=fo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=fo.EU:this._regionCache[this.apiHost]=fo.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===fo.CUSTOM)return this.apiHost+t;var i=mo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var bo={icontains:(e,t)=>!!r&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!r&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!r&&un(t.href,e),not_regex:(e,t)=>!!r&&!un(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class wo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{wo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)wo._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var s=t._instance.getFeatureFlag(e.feature_flag_key);M(s)&&e.variants[s]&&t._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];wo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())wo._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(D(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();wo._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=wo.getWindowLocation();if(null!=e&&e.search){var t=ss(null==e?void 0:e.search,"__experiment_id"),i=ss(null==e?void 0:e.search,"__experiment_variant");t&&i&&(wo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!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:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(wo._logInfo("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this._applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static _matchesTestVariant(e){return!D(e.conditions)&&(wo._matchUrlConditions(e)&&wo._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=wo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||bo[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==r?void 0:r.location}static _matchUTMConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.utm))return!0;var i=nr();if(i.utm_source){var s,r,n,o,a,l,c,u,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];St.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?wo._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;wo._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var r=null==(s=document)?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):wo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?vo(c,this._instance.config.custom_blocked_useragents):void 0}}var Eo=xt("[PostHog ExternalIntegrations]"),So={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class xo{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Eo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;(!s||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(So[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,s]of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;t(i)}}}var ko="[SessionRecording]",Po=xt(ko);class Io{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Po.error("started without valid sessionManager"),new Error(ko+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(ko+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Xt))||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return r&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Po.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=v.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Po.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(Zt)}_persistRemoteConfig(e){if(this._instance.persistence){var t,s,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,s=null==t?void 0:t.sampleRate,n=D(s)?null:parseFloat(s);D(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[Xt]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:L(o)?null:o,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:Po.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):Po.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(Xt);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||(null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}));null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||(null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}));null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||(null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}));null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var Co={},To=()=>{},Fo="posthog",Ro=!rn&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),$o=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:At(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:To,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:d&&M(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==r||null==(t=r.location)?void 0:t.protocol),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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;St.error(t)},get_device_id:e=>e,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:so},error_tracking:{},_onCapture:To,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(e))},Lo=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=Ct({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:St.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class Mo{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){St.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Oo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new Mo,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new Vn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=$o(),this.SentryIntegration=Ws,this.sentryIntegration=e=>function(e,t){var i=Vs(e,t);return{name:Bs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new Cn(this),this.toolbar=new Xs(this),this.scrollManager=new ao(this),this.pageViewManager=new wr(this),this.surveys=new Jn(this),this.conversations=new Qn(this),this.experiments=new wo(this),this.exceptions=new vn(this),this.rateLimiter=new eo(this),this.requestRouter=new yo(this),this.consent=new Ls(this),this.externalIntegrations=new xo(this),this.people={set:(e,t,i)=>{var s=M(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=M(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>St.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Fo){var s,r=null!==(s=Co[i])&&void 0!==s?s:new Oo;return r._init(e,t,i),Co[i]=r,Co[Fo][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n;if(void 0===t&&(t={}),L(e)||O(e))return St.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._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Ct({},$o(t.defaults),Lo(t),{name:s,token:e})),this.config.on_xhr_error&&St.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:es.GZipJS;var o=this._is_persistence_disabled();this.persistence=new Fn(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Fn(i({},this.config,{persistence:"sessionStorage"}),o);var a=i({},this.persistence.props),l=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new ro((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new oo(this),this.__request_queue=[];var c="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(c||(this.sessionManager=new _o(this),this.sessionPropsManager=new co(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(St.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(St.info("Initializing extensions synchronously"),this._initExtensions(c)),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&St.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:a,s:l}),void 0!==(null==(n=t.bootstrap)?void 0:n.distinctID)){var u,d,_=this.config.get_device_id(ms()),h=null!=(u=t.bootstrap)&&u.isIdentifiedID?_:t.bootstrap.distinctID;this.persistence.set_property(ai,null!=(d=t.bootstrap)&&d.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var p,g,v=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var s;return e[i]=(null==(s=t.bootstrap)||null==(s=s.featureFlags)?void 0:s[i])||!1,e}),{}),m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter((e=>v[e])).reduce(((e,i)=>{var s,r;null!=(s=t.bootstrap)&&null!=(s=s.featureFlagPayloads)&&s[i]&&(e[i]=null==(r=t.bootstrap)||null==(r=r.featureFlagPayloads)?void 0:r[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(c)this.register_once({distinct_id:gi,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(ms());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(ai,"anonymous")}return Nt(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?zs(this,(()=>this._loaded())):this._loaded(),T(this.config._onCapture)&&this.config._onCapture!==To&&(St.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&St.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}_initExtensions(e){var t=performance.now();this.historyAutocapture=new Us(this),this.historyAutocapture.startIfEnabled();var i=[];i.push((()=>{new Zs(this).startIfEnabledOrStop()})),i.push((()=>{var e;this.siteApps=new go(this),null==(e=this.siteApps)||e.init()})),e||i.push((()=>{this.sessionRecording=new Io(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.push((()=>{this.autocapture=new ds(this),this.autocapture.startIfEnabled()})),i.push((()=>{this.surveys.loadIfEnabled()})),i.push((()=>{this.conversations.loadIfEnabled()})),i.push((()=>{this.productTours=new Ln(this),this.productTours.loadIfEnabled()})),i.push((()=>{this.heatmaps=new br(this),this.heatmaps.startIfEnabled()})),i.push((()=>{this.webVitalsAutocapture=new fr(this)})),i.push((()=>{this.exceptionObserver=new qs(this),this.exceptionObserver.startIfEnabledOrStop()})),i.push((()=>{this.deadClicksAutocapture=new Ds(this,As),this.deadClicksAutocapture.startIfEnabled()})),i.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(i,t)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions)if(performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){St.error("Error initializing extension:",e)}}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&&St.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t,i,s,r,n,o,a,l,c;if(!u||!u.body)return St.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,es.GZipJS)?es.GZipJS:w(e.supportedCompression,es.Base64)?es.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(s=this.sessionRecording)||s.onRemoteConfig(e),null==(r=this.autocapture)||r.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){St.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new io(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Pt(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Ro?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=on(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?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,(e=>{var t,s,r,n=i({},e);n.timeout=n.timeout||6e4,n.url=on(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=cn.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=Dt(a,(e=>e.transport===o)))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,s;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(s=this.config).on_request_error)||i.call(s,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];Pt(e,(e=>{e&&(t=e[0],C(t)?r.push(e):T(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&T(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Pt(e,(function(e){if(C(e[0])){var i=t;It(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!L(e)&&M(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==o||!o.isRateLimited){null!=t&&t.$current_url&&!M(null==t?void 0:t.$current_url)&&(St.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(null==s?void 0:s.timestamp)||a,c=ms(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var d,_="$groupidentify"!==e,h=this._calculate_set_once_properties(null==s?void 0:s.$set_once,_);if(h&&(u.$set_once=h),(u=Mt(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,L(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===An.DISMISSED||e===An.SENT){var p=null==t?void 0:t[Dn.SURVEY_ID],g=null==t?void 0:t[Dn.SURVEY_ITERATION];d={id:p,current_iteration:g},localStorage.getItem(jn(d))||localStorage.setItem(jn(d),"true"),u.$set=i({},u.$set,{[Un({id:p,current_iteration:g},e===An.SENT?"responded":"dismissed")]:!0})}var v=i({},u.properties.$set,u.$set);if(R(v)||this.setPersonPropertiesForFlags(v),!D(this.config.before_send)){var f=this._runBeforeSend(u);if(!f)return;u=f}this._internalEventEmitter.emit("eventCaptured",u);var m={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(m):this._requestQueue.enqueue(m),u}St.critical("This capture call is ignored due to client rate limiting.")}}else St.error("No event name provided to posthog.capture")}else St.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=i({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!M(a.distinct_id)&&!N(a.distinct_id)||O(a.distinct_id))&&St.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=pr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=_,a.$window_id=h}this.sessionPropsManager&&Ct(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Ct(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===fo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=Ct(a,c),"$pageview"===e&&u&&(a.title=u.title),!L(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ct({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?It(this.config.property_denylist,(function(e){delete a[e]})):St.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(St.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this._hasPersonProcessing();return a.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var s=this.persistence.get_initial_props(),r=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),n=Ct({},s,r||{},e||{}),o=this.config.sanitize_properties;return o&&(St.error("sanitize_properties is deprecated. Use before_send instead"),n=o(n,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),R(n)?void 0:n}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=Bn),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,s){if(!this.__loaded||!this.persistence)return St.uninitializedWarning("posthog.identify");if(N(e)&&(e=e.toString(),St.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()))St.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!==gi){if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Ht)&&(this.unregister(Ht),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(ai)||"anonymous");e!==r&&o?(this.persistence.set_property(ai,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=dn(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(oi))}}else St.critical('The string "'+gi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else St.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=dn(this.get_distinct_id(),e,t);this._cachedPersonProperties!==s?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=s):St.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}else St.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(St.info("reset"),!this.__loaded)return St.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(s=this.persistence)||s.set_property(ai,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:gi,$device_id:null},"");else{var o=this.config.get_device_id(ms());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?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(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property(qt)?(St.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Ht,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(St.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(F(e)){var s,r,n,o,a,l,c;Ct(this.config,Lo(e));var u=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,u),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Fn(i({},this.config,{persistence:"sessionStorage"}),u);var d=this._checkLocalStorageForDebug(this.config.debug);q(d)&&(this.config.debug=d),q(this.config.debug)&&(this.config.debug?(f.DEBUG=!0,ks._is_supported()&&ks._set("ph_debug","true"),St.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(f.DEBUG=!1,ks._is_supported()&&ks._remove("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(o=this.autocapture)||o.startIfEnabled(),null==(a=this.heatmaps)||a.startIfEnabled(),null==(l=this.exceptionObserver)||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(c=this.externalIntegrations)||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null==(s=this.sessionManager)||s.checkAndGetSessionAndWindowId(),i.sampling)null==(r=this.sessionRecording)||r.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("url");if(i.event_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:Fo;return t!==Fo&&(t=Fo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ai))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ai))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&R(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Ht])&&(null==(t=this.persistence)||null==(t=t.props)||!t[hi]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(St.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(hi,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==r&&(null==(i=this.persistence)||i.set_disabled(r));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==r&&(null==(s=this.sessionPersistence)||s.set_disabled(r));return r}opt_in_capturing(e){var t;if("always"!==this.config.cookieless_mode){var i,s;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())this.reset(!0),null==(i=this.sessionManager)||i.destroy(),this.sessionManager=new _o(this),this.persistence&&(this.sessionPropsManager=new co(this,this.sessionManager,this.persistence)),this.sessionRecording=new Io(this),this.sessionRecording.startIfEnabledOrStop();if(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(s=null==e?void 0:e.captureEventName)&&void 0!==s?s:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else St.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:gi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):St.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===$s.GRANTED?"granted":e===$s.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?vo(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Nt(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==r||r.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}))}_shouldDisableFlags(){var e,t,i,s,r,n,o,a=this._originalUserConfig||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(St.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,r=St,n=(t="advanced_disable_flags")in(e=a)&&!L(e[t]),o=i in e&&!L(e[i]),n?e[t]:o?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}_runBeforeSend(e){if(D(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),D(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return U(e.event)?St.warn(r+". This can cause unexpected behavior."):St.info(r),null}i.properties&&!R(i.properties)||St.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?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)})}_checkLocalStorageForDebug(e){var t=q(e)&&!e,i=ks._is_supported()&&"true"===ks._get("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=$t(e.prototype[t[i]])}(Oo,["identify"]);var Ao,Do;Ao=Co[Fo]=new Oo,(Do=v.posthog)&&It(Do._i,(function(e){if(e&&C(e)){var t=Ao.init(e[0],e[1],e[2]),i=Do[e[2]]||Do;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),v.posthog=Ao,function(){function e(){e.done||(e.done=!0,Ro=!1,It(Co,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():Nt(u,"DOMContentLoaded",e,{capture:!1}):r&&St.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}();
1
+ !function(){"use strict";function e(e,t,i,s,r,n,o){try{var a=e[n](o),l=a.value}catch(e){return void i(e)}a.done?t(l):Promise.resolve(l).then(s,r)}function t(t){return function(){var i=this,s=arguments;return new Promise((function(r,n){var o=t.apply(i,s);function a(t){e(o,r,n,a,l,"next",t)}function l(t){e(o,r,n,a,l,"throw",t)}a(void 0)}))}}function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var s in i)({}).hasOwnProperty.call(i,s)&&(e[s]=i[s])}return e},i.apply(null,arguments)}function s(e,t){if(null==e)return{};var i={};for(var s in e)if({}.hasOwnProperty.call(e,s)){if(-1!==t.indexOf(s))continue;i[s]=e[s]}return i}var r="undefined"!=typeof window?window:void 0,n="undefined"!=typeof globalThis?globalThis:r;"undefined"==typeof self&&(n.self=n),"undefined"==typeof File&&(n.File=function(){});var o=Array.prototype,a=o.forEach,l=o.indexOf,c=null==n?void 0:n.navigator,u=null==n?void 0:n.document,d=null==n?void 0:n.location,_=null==n?void 0:n.fetch,h=null!=n&&n.XMLHttpRequest&&"withCredentials"in new n.XMLHttpRequest?n.XMLHttpRequest:void 0,p=null==n?void 0:n.AbortController,g=null==c?void 0:c.userAgent,v=null!=r?r:{},f={DEBUG:!1,LIB_VERSION:"1.312.0"},m=["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"],y=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return m.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},b=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function w(e,t){return-1!==e.indexOf(t)}var E=function(e){return e.trim()},S=function(e){return e.replace(/^\$/,"")};var x=Array.isArray,k=Object.prototype,P=k.hasOwnProperty,I=k.toString,C=x||function(e){return"[object Array]"===I.call(e)},F=e=>"function"==typeof e,T=e=>e===Object(e)&&!C(e),R=e=>{if(T(e)){for(var t in e)if(P.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,M=e=>"[object String]"==I.call(e),O=e=>M(e)&&0===e.trim().length,A=e=>null===e,D=e=>L(e)||A(e),N=e=>"[object Number]"==I.call(e),q=e=>"[object Boolean]"===I.call(e),H=e=>e instanceof FormData,j=e=>w(b,e);function U(e){return null===e||"object"!=typeof e}function z(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function B(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var V=[!0,"true",1,"1","yes"],W=e=>w(V,e),G=[!1,"false",0,"0","no"];function Y(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),N(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),Y(r||i,t,i,s))}class K{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=Y(e.bucketSize,0,100,e._logger),this._refillRate=Y(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=Y(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=t-e.lastAccess,s=Math.floor(i/this._refillInterval);if(s>0){var r=s*this._refillRate;e.tokens=Math.min(e.tokens+r,this._bucketSize),e.lastAccess=e.lastAccess+s*this._refillInterval}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):(r={tokens:this._bucketSize,lastAccess:i},this._buckets[s]=r),0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var J="Mobile",X="iOS",Q="Android",Z="Tablet",ee=Q+" "+Z,te="iPad",ie="Apple",se=ie+" Watch",re="Safari",ne="BlackBerry",oe="Samsung",ae=oe+"Browser",le=oe+" Internet",ce="Chrome",ue=ce+" OS",de=ce+" "+X,_e="Internet Explorer",he=_e+" "+J,pe="Opera",ge=pe+" Mini",ve="Edge",fe="Microsoft "+ve,me="Firefox",ye=me+" "+X,be="Nintendo",we="PlayStation",Ee="Xbox",Se=Q+" "+J,xe=J+" "+re,ke="Windows",Pe=ke+" Phone",Ie="Nokia",Ce="Ouya",Fe="Generic",Te=Fe+" "+J.toLowerCase(),Re=Fe+" "+Z.toLowerCase(),$e="Konqueror",Le="(\\d+(\\.\\d+)?)",Me=new RegExp("Version/"+Le),Oe=new RegExp(Ee,"i"),Ae=new RegExp(we+" \\w+","i"),De=new RegExp(be+" \\w+","i"),Ne=new RegExp(ne+"|PlayBook|BB10","i"),qe={"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"};var He,je,Ue,ze=(e,t)=>t&&w(t,ie)||function(e){return w(e,re)&&!w(e,ce)&&!w(e,Q)}(e),Be=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?ge:w(e," OPR/")?pe:Ne.test(e)?ne:w(e,"IE"+J)||w(e,"WPDesktop")?he:w(e,ae)?le:w(e,ve)||w(e,"Edg/")?fe:w(e,"FBIOS")?"Facebook "+J:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?de:w(e,"CrMo")||w(e,ce)?ce:w(e,Q)&&w(e,re)?Se:w(e,"FxiOS")?ye:w(e.toLowerCase(),$e.toLowerCase())?$e:ze(e,t)?w(e,J)?xe:re:w(e,me)?me:w(e,"MSIE")||w(e,"Trident/")?_e:w(e,"Gecko")?me:""},Ve={[he]:[new RegExp("rv:"+Le)],[fe]:[new RegExp(ve+"?\\/"+Le)],[ce]:[new RegExp("("+ce+"|CrMo)\\/"+Le)],[de]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[re]:[Me],[xe]:[Me],[pe]:[new RegExp("(Opera|OPR)\\/"+Le)],[me]:[new RegExp(me+"\\/"+Le)],[ye]:[new RegExp("FxiOS\\/"+Le)],[$e]:[new RegExp("Konqueror[:/]?"+Le,"i")],[ne]:[new RegExp(ne+" "+Le),Me],[Se]:[new RegExp("android\\s"+Le,"i")],[le]:[new RegExp(ae+"\\/"+Le)],[_e]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},We=function(e,t){var i=Be(e,t),s=Ve[i];if(L(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Ge=[[new RegExp(Ee+"; "+Ee+" (.*?)[);]","i"),e=>[Ee,e&&e[1]||""]],[new RegExp(be,"i"),[be,""]],[new RegExp(we,"i"),[we,""]],[Ne,[ne,""]],[new RegExp(ke,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Pe,""];if(new RegExp(J).test(t)&&!/IEMobile\b/.test(t))return[ke+" "+J,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=qe[s]||"";return/arm/i.test(t)&&(r="RT"),[ke,r]}return[ke,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[X,t.join(".")]}return[X,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Q+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Q+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Q,t.join(".")]}return[Q,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ue,""]],[/Linux|debian/i,["Linux",""]]],Ye=function(e){return De.test(e)?be:Ae.test(e)?we:Oe.test(e)?Ee:new RegExp(Ce,"i").test(e)?Ce:new RegExp("("+Pe+"|WPDesktop)","i").test(e)?Pe:/iPad/.test(e)?te:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?se:Ne.test(e)?ne:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Ie,"i").test(e)?Ie:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(J).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Q:ee:new RegExp("(pda|"+J+")","i").test(e)?Te:new RegExp(Z,"i").test(e)&&!new RegExp(Z+" pc","i").test(e)?Re:""},Ke=e=>e instanceof Error;function Je(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return Ue&&i.length===je||(je=i.length,Ue=i.reduce(((i,s)=>{He||(He={});var r=He[s];if(r)i[r[0]]=r[1];else for(var n=e(s),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[s];if(l&&c){i[l]=c,He[s]=[l,c];break}}return i}),{})),Ue}}class Xe{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),r=this.buildParsingContext(),n=this.parseStacktrace(s,r);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var i=this;return t((function*(){for(var t of e)t.stacktrace&&t.stacktrace.frames&&C(t.stacktrace.frames)&&(t.stacktrace.frames=yield i.applyModifiers(t.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var s,r;return null!=e.cause&&(s=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),i({},e,{cause:s,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}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 i=this;return t((function*(){var t=e;for(var s of i.modifiers)t=yield s(t);return t}))()}convertToExceptionList(e,t){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:null!==(s=t.type)&&void 0!==s?s:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(n=e.synthetic)&&void 0!==n&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return null!=e.cause&&a.push(...this.convertToExceptionList(e.cause,i({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:Je(this.stackParser)}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(s<=4){var r=this.buildCoercingContext(e,t,s);return this.applyCoercers(i,r)}};return i({},t,{syntheticException:0==s?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,s),next:e=>r(e,s+1)})}}var Qe="?";function Ze(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?Qe:i,in_app:!0};return L(s)||(n.lineno=s),L(r)||(n.colno=r),n}var et=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),s=-1!==e.indexOf("safari-web-extension");return i||s?[-1!==e.indexOf("@")?e.split("@")[0]:Qe,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,it=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,st=/\((\S*)(?::(\d+))(?::(\d+))\)/,rt=(e,t)=>{var i=tt.exec(e);if(i){var[,s,r,n]=i;return Ze(t,s,Qe,+r,+n)}var o=it.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=st.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=et(o[1]||Qe,o[2]);return Ze(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},nt=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ot=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,at=(e,t)=>{var i=nt.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=ot.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||Qe;return[n,r]=et(n,r),Ze(t,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},lt=/\(error: (.*)\)/,ct=50;function ut(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;r<t;r++)s[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;a<o.length;a++){var l=o[a];if(!(l.length>1024)){var c=lt.test(l)?l.replace(lt,"$1"):l;if(!c.match(/\S*Error: /)){for(var u of s){var d=u(c,e);if(d){n.push(d);break}}if(n.length>=ct)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,ct).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||Qe});var s}))}(n)}}class dt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=M(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 z(e,"DOMException")}isDOMError(e){return z(e,"DOMError")}}class _t{match(e){return(e=>e 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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ht{constructor(){}match(e){return z(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var pt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class gt{match(e){return"string"==typeof e}coerce(e,t){var i,[s,r]=this.getInfos(e);return{type:null!=s?s:"Error",value:null!=r?r:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(pt);return s&&(t=s[1],i=s[2]),[t,i]}}var vt=["fatal","error","warning","log","info","debug"];function ft(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(!(r.length>t))return s===i.length||r.length<=t?r:r.slice(0,t)+"..."}return""}class mt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return B(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ft(e)}isSeverityLevel(e){return M(e)&&!O(e)&&vt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Ke(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class yt{match(e){return B(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ft(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class bt{match(e){return U(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class wt{match(e){return z(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return U(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(U(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Et=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,s={_log:function(t){if(r&&(f.DEBUG||v.POSTHOG_DEBUG||i)&&!L(r.console)&&r.console){for(var s=("__rrweb_original__"in r.console[t]?r.console[t].__rrweb_original__:r.console[t]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;a<n;a++)o[a-1]=arguments[a];s(e,...o)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];s._log("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Et(e+" "+t,i)};return s},St=Et("[PostHog.js]"),xt=St.createLogger,kt={};function Pt(e,t,i){if(C(e))if(a&&e.forEach===a)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===kt)return}function It(e,t,i){if(!D(e)){if(C(e))return Pt(e,t,i);if(H(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===kt)return}else for(var r in e)if(P.call(e,r)&&t.call(i,e[r],r)===kt)return}}var Ct=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Pt(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},Ft=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return Pt(i,(function(t){Pt(t,(function(t){e.push(t)}))})),e};function Tt(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Rt=function(e){try{return e()}catch(e){return}},$t=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){St.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),St.critical(e)}}},Lt=function(e){var t={};return It(e,(function(e,i){(M(e)&&e.length>0||N(e))&&(t[i]=e)})),t};function Mt(e,t){return i=e,s=e=>M(e)&&!A(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],Pt(t,(t=>{n.push(e(t))}))):(n={},It(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var Ot=["herokuapp.com","vercel.app","netlify.app"];function At(e){var t=null==e?void 0:e.hostname;if(!M(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of Ot)if(i===s)return!1;return!0}function Dt(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Nt(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var qt="$people_distinct_id",Ht="__alias",jt="__timers",Ut="$autocapture_disabled_server_side",zt="$heatmaps_enabled_server_side",Bt="$exception_capture_enabled_server_side",Vt="$error_tracking_suppression_rules",Wt="$error_tracking_capture_extension_exceptions",Gt="$web_vitals_enabled_server_side",Yt="$dead_clicks_enabled_server_side",Kt="$product_tours_enabled_server_side",Jt="$web_vitals_allowed_metrics",Xt="$session_recording_remote_config",Qt="$sesid",Zt="$session_is_sampled",ei="$enabled_feature_flags",ti="$early_access_features",ii="$feature_flag_details",si="$stored_person_properties",ri="$stored_group_properties",ni="$surveys",oi="$flag_call_reported",ai="$user_state",li="$client_session_props",ci="$capture_rate_limit",ui="$initial_campaign_params",di="$initial_referrer_info",_i="$initial_person_info",hi="$epp",pi="__POSTHOG_TOOLBAR__",gi="$posthog_cookieless",vi=[qt,Ht,"__cmpns",jt,"$session_recording_enabled_server_side",zt,Qt,ei,Vt,ai,ti,ii,ri,si,ni,oi,li,ci,ui,di,hi,_i,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function fi(e){return e instanceof Element&&(e.id===pi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function mi(e){return!!e&&1===e.nodeType}function yi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function bi(e){return!!e&&3===e.nodeType}function wi(e){return!!e&&11===e.nodeType}function Ei(e){return e?E(e).split(/\s+/):[]}function Si(e){var t=null==r?void 0:r.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function xi(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Ei(t)}function ki(e){return D(e)?null:E(e).split(/(\s+)/).filter((e=>Wi(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Pi(e){var t="";return Ni(e)&&!qi(e)&&e.childNodes&&e.childNodes.length&&It(e.childNodes,(function(e){var i;bi(e)&&e.textContent&&(t+=null!==(i=ki(e.textContent))&&void 0!==i?i:"")})),E(t)}function Ii(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var Ci=["a","button","form","input","select","textarea","label"];function Fi(e,t){if(L(t))return!0;var i,s=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var r of e)if(i=s(r))return i.v;return!1}function Ti(e){var t=e.parentNode;return!(!t||!mi(t))&&t}var Ri=["next","previous","prev",">","<"],$i=10;var Li=[".ph-no-rageclick",".ph-no-capture"];function Mi(e,t){if(!r||Oi(e))return!1;var i,s,n;q(t)?(i=!!t&&Li,s=void 0):(i=null!==(n=null==t?void 0:t.css_selector_ignorelist)&&void 0!==n?n:Li,s=null==t?void 0:t.content_ignorelist);if(!1===i)return!1;var{targetElementList:o}=Ai(e,!1);return!function(e,t){if(!1===e||L(e))return!1;var i;if(!0===e)i=Ri;else{if(!C(e))return!1;if(e.length>$i)return St.error("[PostHog] content_ignorelist array cannot exceed "+$i+" items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map((e=>e.toLowerCase()))}return t.some((e=>{var{safeText:t,ariaLabel:s}=e;return i.some((e=>t.includes(e)||s.includes(e)))}))}(s,o.map((e=>{var t;return{safeText:Pi(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Fi(o,i)}var Oi=e=>!e||yi(e,"html")||!mi(e),Ai=(e,t)=>{if(!r||Oi(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],n=e;n.parentNode&&!yi(n,"body");)if(wi(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Ti(n);if(!o)break;if(t||Ci.indexOf(o.tagName.toLowerCase())>-1)i=!0;else{var a=r.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}s.push(o),n=o}return{parentIsUsefulElement:i,targetElementList:s}};function Di(e,t,i,s,n){var o,a,l,c;if(void 0===i&&(i=void 0),!r||Oi(e))return!1;if(null!=(o=i)&&o.url_allowlist&&!Si(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Si(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:d,targetElementList:_}=Ai(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var s,r=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(s=r(n))return s.v;return!1}(_,i))return!1;if(!Fi(_,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var h=r.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var p=e.tagName.toLowerCase();switch(p){case"html":return!1;case"form":return(n||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(t.type)>=0;default:return d?(n||["click"]).indexOf(t.type)>=0:(n||["click"]).indexOf(t.type)>=0&&(Ci.indexOf(p)>-1||"true"===e.getAttribute("contenteditable"))}}function Ni(e){for(var t=e;t.parentNode&&!yi(t,"body");t=t.parentNode){var i=xi(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(xi(e),"ph-include"))return!0;var s=e.type||"";if(M(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(M(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function qi(e){return!!(yi(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||yi(e,"select")||yi(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Hi="(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})",ji=new RegExp("^(?:"+Hi+")$"),Ui=new RegExp(Hi),zi="\\d{3}-?\\d{2}-?\\d{4}",Bi=new RegExp("^("+zi+")$"),Vi=new RegExp("("+zi+")");function Wi(e,t){if(void 0===t&&(t=!0),D(e))return!1;if(M(e)){if(e=E(e),(t?ji:Ui).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Bi:Vi).test(e))return!1}return!0}function Gi(e){var t=Pi(e);return Wi(t=(t+" "+Yi(e)).trim())?t:""}function Yi(e){var t="";return e&&e.childNodes&&e.childNodes.length&&It(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Pi(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Yi(e)).trim())}catch(e){St.error("[AutoCapture]",e)}})),t}function Ki(e){return function(e){var t=e.map((e=>{var t,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+="."+n.replace(/"/g,"");var o=i({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return Tt(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[Ji(t.toString())]=Ji(i.toString())})),r+=":",r+=Tt(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Xi(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Tt(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function Ji(e){return e.replace(/"|\\"/g,'\\"')}function Xi(e){var t=e.attr__class;return t?C(t)?t:Ei(t):void 0}class Qi{constructor(e){this.disabled=!1===e;var t=T(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}}var Zi="$copy_autocapture",es=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),ts=e=>{var t=null==u?void 0:u.createElement("a");return L(t)?null:(t.href=e,t)},is=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return It(e,(function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),s=encodeURIComponent(t),r[r.length]=s+"="+i)})),r.join(t)},ss=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){St.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},rs=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var _=c[d].split("=");C(_)&&(t.includes(_[0])?u.push(_[0]+"="+i):u.push(c[d]))}var h=l;return null!=a&&(h+="?"+u.join("&")),null!=n&&(h+="#"+n),h},ns=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},os=xt("[AutoCapture]");function as(e,t){return t.length>e?t.slice(0,e)+"...":t}function ls(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!mi(t));return t}function cs(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Ci.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=as(1024,Gi(e)):n.$el_text=as(1024,Pi(e)));var o=xi(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),It(e.attributes,(function(i){var r;if((!qi(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&Wi(i.value)&&(r=i.name,!M(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Ei(o).join(" ")),n["attr__"+i.name]=as(1024,o)}}));for(var a=1,l=1,c=e;c=ls(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function us(e,t){for(var i,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!yi(d,"body");)wi(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var _,h=[],p={},g=!1,v=!1;if(It(u,(e=>{var t=Ni(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&Wi(g)&&g),w(xi(e),"ph-no-capture")&&(v=!0),h.push(cs(e,o,a,l));var i=function(e){if(!Ni(e))return{};var t={};return It(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&Wi(s)&&(t[i]=s)}})),t}(e);Ct(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=Gi(e):h[0].$el_text=Pi(e)),g){var f,m;h[0].attr__href=g;var y=null==(f=ts(g))?void 0:f.host,b=null==r||null==(m=r.location)?void 0:m.host;y&&b&&y!==b&&(_=g)}return{props:Ct({$event_type:n.type,$ce_version:1},c?{}:{$elements:h},{$elements_chain:Ki(h)},null!=(i=h[0])&&i.$el_text?{$el_text:null==(s=h[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},p)}}class ds{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new Qi(e.config.rageclick),this._elementSelectors=null}get _config(){var e,t,i=T(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(r&&u){var e=e=>{e=e||(null==r?void 0:r.event);try{this._captureEvent(e)}catch(e){os.error("Failed to capture event",e)}};if(Nt(u,"submit",e,{capture:!0}),Nt(u,"change",e,{capture:!0}),Nt(u,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{e=e||(null==r?void 0:r.event),this._captureEvent(e,Zi)};Nt(u,"copy",t,{capture:!0}),Nt(u,"cut",t,{capture:!0})}}}else os.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ut]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null==(t=this._elementSelectors)||t.forEach((t=>{var s=null==u?void 0:u.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[Ut],s=this._isDisabledServerSide;if(A(s)&&!q(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Ii(e);if(bi(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&Mi(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var n=t===Zi;if(s&&Di(s,e,this._config,n,n?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=us(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this._config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===Zi){var c,u=ki(null==r||null==(c=r.getSelection())?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return F(null==u?void 0:u.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return N(e)&&isFinite(e)&&Math.floor(e)===e});var _s="0123456789abcdef";class hs{constructor(e){if(this.bytes=e,16!==e.length)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 r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new hs(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+_s.charAt(this.bytes[t]>>>4)+_s.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new hs(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class ps{constructor(){this._timestamp=0,this._counter=0,this._random=new fs}generate(){var e=this.generateOrAbort();if(L(e)){this._timestamp=0;var t=this.generateOrAbort();if(L(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this._timestamp)this._timestamp=e,this._resetCounter();else{if(!(e+1e4>this._timestamp))return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return hs.fromFieldsV7(this._timestamp,Math.trunc(this._counter/Math.pow(2,30)),this._counter&Math.pow(2,30)-1,this._random.nextUint32())}_resetCounter(){this._counter=1024*this._random.nextUint32()+(1023&this._random.nextUint32())}}var gs,vs=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};r&&!L(r.crypto)&&crypto.getRandomValues&&(vs=e=>crypto.getRandomValues(e));class fs{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._cursor>=this._buffer.length&&(vs(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var ms=()=>ys().toString(),ys=()=>(gs||(gs=new ps)).generate(),bs="";var ws=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Es(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=u),bs)return bs;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+ms();!bs&&s--;){var n=i.slice(s).join("."),o=r+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(r)&&(t.cookie=o+";max-age=0",bs=n)}return bs}(e);if(!i){var s=(e=>{var t=e.match(ws);return t?t[0]:""})(e);s!==i&&St.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var Ss={_is_supported:()=>!!u,_error:function(e){St.error("cookieStore error: "+e)},_get:function(e){if(u){try{for(var t=e+"=",i=u.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},_parse:function(e){var t;try{t=JSON.parse(Ss._get(e))||{}}catch(e){}return t},_set:function(e,t,i,s,r){if(u)try{var n="",o="",a=Es(u.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&St.warn("cookieStore warning: large cookie, len="+c.length),u.cookie=c,c}catch(e){return}},_remove:function(e,t){if(null!=u&&u.cookie)try{Ss._set(e,"",-1,t)}catch(e){return}}},xs=null,ks={_is_supported:function(){if(!A(xs))return xs;var e=!0;if(L(r))e=!1;else try{var t="__mplssupport__";ks._set(t,"xyz"),'"xyz"'!==ks._get(t)&&(e=!1),ks._remove(t)}catch(t){e=!1}return e||St.error("localStorage unsupported; falling back to cookie store"),xs=e,e},_error:function(e){St.error("localStorage error: "+e)},_get:function(e){try{return null==r?void 0:r.localStorage.getItem(e)}catch(e){ks._error(e)}return null},_parse:function(e){try{return JSON.parse(ks._get(e))||{}}catch(e){}return null},_set:function(e,t){try{null==r||r.localStorage.setItem(e,JSON.stringify(t))}catch(e){ks._error(e)}},_remove:function(e){try{null==r||r.localStorage.removeItem(e)}catch(e){ks._error(e)}}},Ps=["$device_id","distinct_id",Qt,Zt,hi,_i],Is=i({},ks,{_parse:function(e){try{var t={};try{t=Ss._parse(e)||{}}catch(e){}var i=Ct(t,JSON.parse(ks._get(e)||"{}"));return ks._set(e,i),i}catch(e){}return null},_set:function(e,t,i,s,r,n){try{ks._set(e,t,void 0,void 0,n);var o={};Ps.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Ss._set(e,o,i,s,r,n)}catch(e){ks._error(e)}},_remove:function(e,t){try{null==r||r.localStorage.removeItem(e),Ss._remove(e,t)}catch(e){ks._error(e)}}}),Cs={},Fs={_is_supported:function(){return!0},_error:function(e){St.error("memoryStorage error: "+e)},_get:function(e){return Cs[e]||null},_parse:function(e){return Cs[e]||null},_set:function(e,t){Cs[e]=t},_remove:function(e){delete Cs[e]}},Ts=null,Rs={_is_supported:function(){if(!A(Ts))return Ts;if(Ts=!0,L(r))Ts=!1;else try{var e="__support__";Rs._set(e,"xyz"),'"xyz"'!==Rs._get(e)&&(Ts=!1),Rs._remove(e)}catch(e){Ts=!1}return Ts},_error:function(e){St.error("sessionStorage error: ",e)},_get:function(e){try{return null==r?void 0:r.sessionStorage.getItem(e)}catch(e){Rs._error(e)}return null},_parse:function(e){try{return JSON.parse(Rs._get(e))||null}catch(e){}return null},_set:function(e,t){try{null==r||r.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Rs._error(e)}},_remove:function(e){try{null==r||r.sessionStorage.removeItem(e)}catch(e){Rs._error(e)}}},$s=function(e){return e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED",e}({});class Ls{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?$s.DENIED:this._storedConsent}isOptedOut(){return"always"===this._config.cookieless_mode||(this.consent===$s.DENIED||this.consent===$s.PENDING&&(this._config.opt_out_capturing_by_default||"on_reject"===this._config.cookieless_mode))}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===$s.DENIED}optInOut(e){this._storage._set(this._storageKey,e?1:0,this._config.cookie_expiration,this._config.cross_subdomain_cookie,this._config.secure_cookie)}reset(){this._storage._remove(this._storageKey,this._config.cross_subdomain_cookie)}get _storageKey(){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 _storedConsent(){var e=this._storage._get(this._storageKey);return W(e)?$s.GRANTED:w(G,e)?$s.DENIED:$s.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?ks:Ss;var t="localStorage"===e?Ss:ks;t._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(W(t._get(this._storageKey))),t._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!Dt([null==c?void 0:c.doNotTrack,null==c?void 0:c.msDoNotTrack,v.doNotTrack],(e=>W(e)))}}var Ms=xt("[Dead Clicks]"),Os=()=>!0,As=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Yt)),s=e.instance.config.capture_dead_clicks;return q(s)?s:!!T(s)||i};class Ds{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Yt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?Ms.error("failed to load script",t):e()}))}_start(){var e;if(u){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=T(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(u),Ms.info("starting...")}}else Ms.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,Ms.info("stopping..."))}}var Ns=xt("[ExceptionAutocapture]");class qs{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(r&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this._config.capture_unhandled_errors&&(this._unwrapOnError=t(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this._config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=i(this.captureException.bind(this))),!this._unwrapConsoleError&&this._config.capture_console_errors&&(this._unwrapConsoleError=s(this.captureException.bind(this)))}catch(e){Ns.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[Bt]),this._rateLimiter=new K({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==s?s:10,refillInterval:1e4,_logger:Ns}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}_requiredConfig(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return T(e)?t=i({},t,e):(L(e)?this._remoteEnabled:e)&&(t=i({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this._config.capture_console_errors||this._config.capture_unhandled_errors||this._config.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ns.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return Ns.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;null==(e=this._unwrapOnError)||e.call(this),this._unwrapOnError=void 0,null==(t=this._unwrapUnhandledRejection)||t.call(this),this._unwrapUnhandledRejection=void 0,null==(i=this._unwrapConsoleError)||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this._remoteEnabled=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Bt]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop()}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?Ns.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Hs(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return F(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}class js{constructor(e){var t;this._instance=e,this._lastPathname=(null==r||null==(t=r.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(St.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,St.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(r&&r.history){var i=this;null!=(e=r.history.pushState)&&e.__posthog_wrapped__||Hs(r.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=r.history.replaceState)&&t.__posthog_wrapped__||Hs(r.history,"replaceState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var t,i=null==r||null==(t=r.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=i}catch(t){St.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Nt(r,"popstate",e),this._popstateListener=()=>{r&&r.removeEventListener("popstate",e)}}}}var Us=xt("[SegmentIntegration]");function zs(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||ms();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(ai,"identified")),t()},r=i.user();"then"in r&&F(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Us.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Us.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Us.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var s=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},s,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var Bs="posthog-js";function Vs(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,c,u,d,_;if(!("*"===o||o.includes(t.level))||!e.__loaded)return t;t.tags||(t.tags={});var h=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(l=t.exception)?void 0:l.values)||[],g=p.map((e=>i({},e,{stacktrace:e.stacktrace?i({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>i({},e,{platform:"web:javascript"})))}):void 0}))),v={$exception_message:(null==(c=p[0])?void 0:c.value)||t.message,$exception_type:null==(u=p[0])?void 0:u.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=p[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=p[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(v.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&e.exceptions.sendExceptionEvent(v),t}}class Ws{constructor(e,t,i,s,r,n){this.name=Bs,this.setupOnce=function(o){o(Vs(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}var Gs=null!=r&&r.location?ns(r.location.hash,"__posthog")||ns(location.hash,"state"):null,Ys="_postHogToolbarParams",Ks=xt("[Toolbar]"),Js=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Js||{});class Xs{constructor(e){this.instance=e}_setToolbarState(e){v.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=v.ph_toolbar_state)&&void 0!==e?e:Js.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!r||!u)return!1;e=null!=e?e:r.location,i=null!=i?i:r.history;try{if(!t){try{r.localStorage.setItem("test","test"),r.localStorage.removeItem("test")}catch(e){return!1}t=null==r?void 0:r.localStorage}var s,n=Gs||ns(e.hash,"__posthog")||ns(e.hash,"state"),o=n?Rt((()=>JSON.parse(atob(decodeURIComponent(n)))))||Rt((()=>JSON.parse(decodeURIComponent(n)))):null;return o&&"ph_authorize"===o.action?((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(Ys)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=v.ph_load_toolbar||v.ph_load_editor;!D(t)&&F(t)?t(e,this.instance):Ks.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==u||!u.getElementById(pi));if(!r||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(r.localStorage.setItem(Ys,JSON.stringify(i({},n,{source:void 0}))),this._getToolbarState()===Js.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Js.UNINITIALIZED){var o;this._setToolbarState(Js.LOADING),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Ks.error("[Toolbar] Failed to load",e),void this._setToolbarState(Js.UNINITIALIZED);this._setToolbarState(Js.LOADED),this._callLoadToolbar(n)})),Nt(r,"turbolinks:load",(()=>{this._setToolbarState(Js.UNINITIALIZED),this.loadToolbar(n)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Qs=xt("[TracingHeaders]");class Zs{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t;L(this._restoreXHRPatch)&&(null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager));L(this._restoreFetchPatch)&&(null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Qs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null==(e=this._restoreXHRPatch)||e.call(this),null==(t=this._restoreFetchPatch)||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var er="https?://(.*)",tr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ir=Ft(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],tr),sr="<masked>",rr=["li_fat_id"];function nr(e,t,i){if(!u)return{};var s,r=t?Ft([],tr,i||[]):[],n=or(rs(u.URL,r,sr),e),o=(s={},It(rr,(function(e){var t=Ss._get(e);s[e]=t||null})),s);return Ct(o,n)}function or(e,t){var i=ir.concat(t||[]),s={};return It(i,(function(t){var i=ss(e,t);s[t]=i||null})),s}function ar(e){var t=function(e){return e?0===e.search(er+"google.([^/?]*)")?"google":0===e.search(er+"bing.com")?"bing":0===e.search(er+"yahoo.com")?"yahoo":0===e.search(er+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!A(t)){s.$search_engine=t;var r=u?ss(u.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function lr(){return navigator.language||navigator.userLanguage}function cr(){return(null==u?void 0:u.referrer)||"$direct"}function ur(e,t){var i=e?Ft([],tr,t||[]):[],s=null==d?void 0:d.href.substring(0,1e3);return{r:cr().substring(0,1e3),u:s?rs(s,i,sr):void 0}}function dr(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=ts(i))?void 0:t.host};if(s){r.$current_url=s;var n=ts(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=or(s);Ct(r,o)}if(i){var a=ar(i);Ct(r,a)}return r}function _r(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function hr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function pr(e,t){if(!g)return{};var i,s,n,o=e?Ft([],tr,t||[]):[],[a,l]=function(e){for(var t=0;t<Ge.length;t++){var[i,s]=Ge[t],r=i.exec(e),n=r&&(F(s)?s(r,e):s);if(n)return n}return["",""]}(g);return Ct(Lt({$os:a,$os_version:l,$browser:Be(g,navigator.vendor),$device:Ye(g),$device_type:(s=g,n=Ye(s),n===te||n===ee||"Kobo"===n||"Kindle Fire"===n||n===Re?Z:n===be||n===Ee||n===we||n===Ce?"Console":n===se?"Wearable":n?J:"Desktop"),$timezone:_r(),$timezone_offset:hr()}),{$current_url:rs(null==d?void 0:d.href,o,sr),$host:null==d?void 0:d.host,$pathname:null==d?void 0:d.pathname,$raw_user_agent:g.length>1e3?g.substring(0,997)+"...":g,$browser_version:We(g,navigator.vendor),$browser_language:lr(),$browser_language_prefix:(i=lr(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==r?void 0:r.screen.height,$screen_width:null==r?void 0:r.screen.width,$viewport_height:null==r?void 0:r.innerHeight,$viewport_width:null==r?void 0:r.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var gr=xt("[Web Vitals]"),vr=9e5;class fr{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0},this._flushToCapture=()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>i({},e,{["$web_vitals_"+t.name+"_event"]:i({},t),["$web_vitals_"+t.name+"_value"]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this._addToBuffer=e=>{var t,s=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(s))gr.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!L(r))if(D(null==e?void 0:e.name)||D(null==e?void 0:e.value))gr.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)gr.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),L(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=L(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(i({},e,{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}},this._startCapturing=()=>{var e,t,i,s,r=v.__PosthogExtensions__;L(r)||L(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):gr.error("web vitals callbacks not loaded - not starting")},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[Gt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=T(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return L(i)?(null==(t=this._instance.persistence)?void 0:t.props[Jt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(T(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=T(this._instance.config.capture_performance)&&N(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:vr;return 0<e&&e<=6e4?vr:e}get isEnabled(){var e=null==d?void 0:d.protocol;if("http:"!==e&&"https:"!==e)return gr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=T(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:q(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return q(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(gr.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){var t=T(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=T(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Gt]:t}),this._instance.persistence.register({[Jt]:i})),this._enabledServerSide=t,this.startIfEnabled()}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks&&e(),null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"web-vitals",(t=>{t?gr.error("failed to load script",t):e()}))}_currentURL(){var e=r?r.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?Ft([],tr,i||[]):[];return rs(e,s,sr)}gr.error("Could not determine current URL")}}var mr=xt("[Heatmaps]");function yr(e){return T(e)&&"clientX"in e&&"clientY"in e&&N(e.clientX)&&N(e.clientY)}class br{constructor(e){var t;this._enabledServerSide=!1,this._initialized=!1,this._flushInterval=null,this.instance=e,this._enabledServerSide=!(null==(t=this.instance.persistence)||!t.props[zt]),this.rageclicks=new Qi(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return T(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 L(this.instance.config.capture_heatmaps)?L(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;mr.info("starting..."),this._setupListeners(),this._onVisibilityChange()}else{var e;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),this._removeListeners(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[zt]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this._buffer;return this._buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_onVisibilityChange(){this._flushInterval&&clearInterval(this._flushInterval),this._flushInterval=function(e){return"visible"===(null==e?void 0:e.visibilityState)}(u)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){r&&u&&(this._flushHandler=this._flush.bind(this),Nt(r,"beforeunload",this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==r?void 0:r.event)),Nt(u,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==r?void 0:r.event)),Nt(u,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new Ds(this.instance,Os,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Nt(u,"visibilitychange",this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;r&&u&&(this._flushHandler&&r.removeEventListener("beforeunload",this._flushHandler),this._onClickHandler&&u.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&u.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&u.removeEventListener("visibilitychange",this._onVisibilityChange_handler),clearTimeout(this._mouseMoveTimeout),null==(e=this._deadClicksCapture)||e.stop(),this._initialized=!1)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&mi(s)&&!yi(s,"body");){if(s===i)return!1;if(w(t,null==r?void 0:r.getComputedStyle(s).position))return!0;s=Ti(s)}return!1}(Ii(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!fi(e.target)&&yr(e)){var r=this._getProperties(e,t);null!=(s=this.rageclicks)&&s.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},r,{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!fi(e.target)&&yr(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(r){var t=r.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?Ft([],tr,s||[]):[],o=rs(t,n,sr);this._buffer=this._buffer||{},this._buffer[o]||(this._buffer[o]=[]),this._buffer[o].push(e)}}_flush(){this._buffer&&!R(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class wr{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(St.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this._currentPageview=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this._setupSessionRotationHandler()}_setupSessionRotationHandler(){var e;this._unsubscribeSessionId=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this._onSessionIdChange)}destroy(){var e;null==(e=this._unsubscribeSessionId)||e.call(this),this._unsubscribeSessionId=void 0}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==r?void 0:r.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null==(t=this._currentPageview)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this._currentPageview)?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:Y(o/n,0,1,St),_=n<=1?1:Y(a/n,0,1,St),h=l<=1?1:Y(c/l,0,1,St),p=l<=1?1:Y(u/l,0,1,St);s=Ct(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var Er=Uint8Array,Sr=Uint16Array,xr=Uint32Array,kr=new Er([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]),Pr=new Er([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]),Ir=new Er([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cr=function(e,t){for(var i=new Sr(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new xr(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Fr=Cr(kr,2),Tr=Fr[0],Rr=Fr[1];Tr[28]=258,Rr[258]=28;for(var $r=Cr(Pr,0)[1],Lr=new Sr(32768),Mr=0;Mr<32768;++Mr){var Or=(43690&Mr)>>>1|(21845&Mr)<<1;Or=(61680&(Or=(52428&Or)>>>2|(13107&Or)<<2))>>>4|(3855&Or)<<4,Lr[Mr]=((65280&Or)>>>8|(255&Or)<<8)>>>1}var Ar=function(e,t,i){for(var s=e.length,r=0,n=new Sr(t);r<s;++r)++n[e[r]-1];var o,a=new Sr(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Sr(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,_=d|(1<<u)-1;d<=_;++d)o[Lr[d]>>>l]=c}else for(o=new Sr(s),r=0;r<s;++r)o[r]=Lr[a[e[r]-1]++]>>>15-e[r];return o},Dr=new Er(288);for(Mr=0;Mr<144;++Mr)Dr[Mr]=8;for(Mr=144;Mr<256;++Mr)Dr[Mr]=9;for(Mr=256;Mr<280;++Mr)Dr[Mr]=7;for(Mr=280;Mr<288;++Mr)Dr[Mr]=8;var Nr=new Er(32);for(Mr=0;Mr<32;++Mr)Nr[Mr]=5;var qr=Ar(Dr,9,0),Hr=Ar(Nr,5,0),jr=function(e){return(e/8>>0)+(7&e&&1)},Ur=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Sr?Sr:e instanceof xr?xr:Er)(i-t);return s.set(e.subarray(t,i)),s},zr=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},Br=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Vr=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new Er(0),0];if(1==r){var o=new Er(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;s<r;++s)n[s].s>_&&(_=n[s].s);var h=new Sr(_+1),p=Wr(i[u-1],h,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(h[m]>t))break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;h[y]<t?g-=1<<t-h[y]++-1:++s}for(;s>=0&&g;--s){var b=n[s].s;h[b]==t&&(--h[b],++g)}p=t}return[new Er(h),p]},Wr=function(e,t,i){return-1==e.s?Math.max(Wr(e.l,t,i+1),Wr(e.r,t,i+1)):t[e.s]=i},Gr=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Sr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Yr=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Kr=function(e,t,i){var s=i.length,r=jr(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Jr=function(e,t,i,s,r,n,o,a,l,c,u){zr(t,u++,i),++r[256];for(var d=Vr(r,15),_=d[0],h=d[1],p=Vr(n,15),g=p[0],v=p[1],f=Gr(_),m=f[0],y=f[1],b=Gr(g),w=b[0],E=b[1],S=new Sr(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Vr(S,7),P=k[0],I=k[1],C=19;C>4&&!P[Ir[C-1]];--C);var F,T,R,L,M=c+5<<3,O=Yr(r,Dr)+Yr(n,Nr)+o,A=Yr(r,_)+Yr(n,g)+o+14+3*C+Yr(S,P)+(2*S[16]+3*S[17]+7*S[18]);if(M<=O&&M<=A)return Kr(t,u,e.subarray(l,l+c));if(zr(t,u,1+(A<O)),u+=2,A<O){F=Ar(_,h,0),T=_,R=Ar(g,v,0),L=g;var D=Ar(P,I,0);zr(t,u,y-257),zr(t,u+5,E-1),zr(t,u+10,C-4),u+=14;for(x=0;x<C;++x)zr(t,u+3*x,P[Ir[x]]);u+=3*C;for(var N=[m,w],q=0;q<2;++q){var H=N[q];for(x=0;x<H.length;++x){var j=31&H[x];zr(t,u,D[j]),u+=P[j],j>15&&(zr(t,u,H[x]>>>5&127),u+=H[x]>>>12)}}}else F=qr,T=Dr,R=Hr,L=Nr;for(x=0;x<a;++x)if(s[x]>255){j=s[x]>>>18&31;Br(t,u,F[j+257]),u+=T[j+257],j>7&&(zr(t,u,s[x]>>>23&31),u+=kr[j]);var U=31&s[x];Br(t,u,R[U]),u+=L[U],U>3&&(Br(t,u,s[x]>>>5&8191),u+=Pr[U])}else Br(t,u,F[s[x]]),u+=T[s[x]];return Br(t,u,F[256]),u+T[256]},Xr=new xr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qr=function(){for(var e=new xr(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Zr=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new Er(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Kr(l,c,e.subarray(u,d)):(l[u]=n,c=Kr(l,c,e.subarray(u,o)))}else{for(var _=Xr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new Sr(32768),f=new Sr(g+1),m=Math.ceil(i/3),y=2*m,b=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&g},w=new xr(25e3),E=new Sr(288),S=new Sr(32),x=0,k=0,P=(u=0,0),I=0,C=0;u<o;++u){var F=b(u),T=32767&u,R=f[F];if(v[T]=R,f[F]=T,I<=u){var L=o-u;if((x>7e3||P>24576)&&L>423){c=Jr(e,l,0,w,E,S,k,P,C,u-C,c),P=x=k=0,C=u;for(var M=0;M<286;++M)E[M]=0;for(M=0;M<30;++M)S[M]=0}var O=2,A=0,D=p,N=T-R&32767;if(L>2&&F==b(u-N))for(var q=Math.min(h,L)-1,H=Math.min(32767,u),j=Math.min(258,L);N<=H&&--D&&T!=R;){if(e[u+O]==e[u+O-N]){for(var U=0;U<j&&e[u+U]==e[u+U-N];++U);if(U>O){if(O=U,A=N,U>q)break;var z=Math.min(N,U-2),B=0;for(M=0;M<z;++M){var V=u-N+M+32768&32767,W=V-v[V]+32768&32767;W>B&&(B=W,R=V)}}}N+=(T=R)-(R=v[T])+32768&32767}if(A){w[P++]=268435456|Rr[O]<<18|$r[A];var G=31&Rr[O],Y=31&$r[A];k+=kr[G]+Pr[Y],++E[257+G],++S[Y],I=u+O,++x}else w[P++]=e[u],++E[e[u]]}}c=Jr(e,l,n,w,E,S,k,P,C,u-C,c)}return Ur(a,0,s+jr(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!0)},en=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function tn(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Qr[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n=Zr(e,t,10+((r=t).filename&&r.filename.length+1||0),8),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&en(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}}(n,t),en(n,o-8,i.d()),en(n,o-4,s),n}var sn=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++: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),A(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},rn=!!h||!!_,nn="text/plain",on=function(e,t,s){var r;void 0===s&&(s=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(r=null==o?void 0:o.split("&").map((e=>{var t,[i,r]=e.split("="),n=s&&null!==(t=a[i])&&void 0!==t?t:r;return delete a[i],i+"="+n})))&&void 0!==r?r:[],c=is(a);return c&&l.push(c),n+"?"+l.join("&")},an=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),ln=e=>{var{data:t,compression:i}=e;if(t){if(i===es.GZipJS){var s=tn(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new Er(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new Er(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Ur(s,0,r)}(an(t)),{mtime:0}),r=new Blob([s],{type:nn});return{contentType:nn,body:r,estimatedSize:r.size}}if(i===es.Base64){var n=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=sn(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(an(t)),o=(e=>"data="+encodeURIComponent("string"==typeof e?e:an(e)))(n);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=an(t);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},cn=[];_&&cn.push({transport:"fetch",method:e=>{var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=ln(e))&&void 0!==t?t:{},a=new Headers;It(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(p){var u=new p;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null==(s=c)?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s={statusCode:t.status,text:i};if(200===t.status)try{s.json=JSON.parse(i)}catch(e){St.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{St.error(t),null==e.callback||e.callback({statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),h&&cn.push({transport:"XHR",method:e=>{var t,i=new h;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=ln(e))&&void 0!==t?t:{};It(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(e){}null==e.callback||e.callback(t)}},i.send(r)}}),null!=c&&c.sendBeacon&&cn.push({transport:"sendBeacon",method:e=>{var t=on(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=ln(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;c.sendBeacon(t,n)}catch(e){}}});var un=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};function dn(e,t,i){return an({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var _n={exact:(e,t)=>t.some((t=>e.some((e=>t===e)))),is_not:(e,t)=>t.every((t=>e.every((e=>t!==e)))),regex:(e,t)=>t.some((t=>e.some((e=>un(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!un(t,e))))),icontains:(e,t)=>t.map(hn).some((t=>e.map(hn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(hn).every((t=>e.map(hn).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var i=parseFloat(t);return!isNaN(i)&&e.some((e=>i<parseFloat(e)))}))},hn=e=>e.toLowerCase();function pn(e,t){return!e||Object.entries(e).every((e=>{var[i,s]=e,r=null==t?void 0:t[i];if(L(r)||A(r))return!1;var n=[String(r)],o=_n[s.operator];return!!o&&o(s.values,n)}))}var gn=xt("[Error tracking]");class vn{constructor(e){var t,i;this._suppressionRules=[],this._errorPropertiesBuilder=new Xe([new dt,new wt,new ht,new _t,new yt,new mt,new gt,new bt],ut("web:javascript",rt,at)),this._instance=e,this._suppressionRules=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Vt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,s,r=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(s=e.errorTracking)?void 0:s.captureExtensionExceptions;this._suppressionRules=r,this._instance.persistence&&this._instance.persistence.register({[Vt]:this._suppressionRules,[Wt]:n})}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(Wt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this._errorPropertiesBuilder.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return void gn.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return void gn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return void gn.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return M(i)&&i.length>0&&e.$exception_types.push(i),M(s)&&s.length>0&&e.$exception_values.push(s),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,s=_n[e.operator],r=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return r.length>0&&s(r,n)}));return"OR"===e.type?i.some(Boolean):i.every(Boolean)}))}_isExtensionException(e){return e.flatMap((e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}_isPostHogException(e){if(e.length>0){var t,i,s,r,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(s=null==o||null==(r=o.filename)?void 0:r.includes("posthog.com/static"))&&void 0!==s&&s}return!1}_isExceptionList(e){return!D(e)&&C(e)}}var fn=xt("[FeatureFlags]"),mn=xt("[FeatureFlags]",{debugEnabled:!0}),yn="$active_feature_flags",bn="$override_feature_flags",wn="$feature_flag_payloads",En="$override_feature_flag_payloads",Sn="$feature_flag_request_id",xn="$feature_flag_evaluated_at",kn=e=>{var t={};for(var[i,s]of Tt(e||{}))s&&(t[i]=s);return t},Pn=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload})).map((e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]})))):fn.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e},In=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class Cn{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this._instance=e,this.featureFlagEventHandlers=[]}_getValidEvaluationEnvironments(){var e=this._instance.config.evaluation_environments;return null!=e&&e.length?e.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||fn.error("Invalid evaluation environment found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}flags(){if(this._instance.config.__preview_remote_config)this._flagsCalled=!0;else{var e=!this._reloadDebouncer&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this._callFlagsEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(ii),t=this._instance.get_property(bn),s=this._instance.get_property(En);if(!s&&!t)return e||{};var r=Ct({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,c=r[o],u=null==t?void 0:t[o],d=L(u)?null!==(a=null==c?void 0:c.enabled)&&void 0!==a&&a:!!u,_=L(u)?c.variant:"string"==typeof u?u:void 0,h=null==s?void 0:s[o],p=i({},c,{enabled:d,variant:d?null!=_?_:null==c?void 0:c.variant:void 0});if(d!==(null==c?void 0:c.enabled)&&(p.original_enabled=null==c?void 0:c.enabled),_!==(null==c?void 0:c.variant)&&(p.original_variant=null==c?void 0:c.variant),h)p.metadata=i({},null==c?void 0:c.metadata,{payload:h,original_payload:null==c||null==(l=c.metadata)?void 0:l.payload});r[o]=p}return this._override_warning||(fn.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(ei),t=this._instance.get_property(bn);if(!t)return e||{};for(var i=Ct({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(fn.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._instance.get_property(wn),t=this._instance.get_property(En);if(!t)return e||{};for(var i=Ct({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(fn.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callFlagsEndpoint()}),5))}_clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callFlagsEndpoint(e){var t;if(this._clearDebouncer(),!this._instance._shouldDisableFlags())if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s=this._instance.config.token,r=this._instance.get_property("$device_id"),n={token:s,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(si)||{}),group_properties:this._instance.get_property(ri)};A(r)||L(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_environments=this._getValidEvaluationEnvironments());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(n.timezone=_r()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:c,data:n,compression:this._instance.config.disable_compression?void 0:es.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,this._flagsCalled)||(this._flagsCalled=!0,this._instance._onRemoteConfig(null!==(i=e.json)&&void 0!==i?i:{}));if(!n.disable_flags||this._additionalReloadRequested)if(this._flagsLoadedFromRemote=!s,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(In.FeatureFlags))fn.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 r;if(!n.disable_flags)this.receivedFeatureFlags(null!==(r=e.json)&&void 0!==r?r:{},s);this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants()[e],s=""+i,r=this._instance.get_property(Sn)||void 0,n=this._instance.get_property(xn)||void 0,o=this._instance.get_property(oi)||{};if((t.send_event||!("send_event"in t))&&(!(e in o)||!o[e].includes(s))){var a,l,c,u,d,_,h,p,g;C(o[e])?o[e].push(s):o[e]=[s],null==(a=this._instance.persistence)||a.register({[oi]:o});var v=this.getFeatureFlagDetails(e),f={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:r,$feature_flag_evaluated_at:n,$feature_flag_bootstrapped_response:(null==(l=this._instance.config.bootstrap)||null==(l=l.featureFlags)?void 0:l[e])||null,$feature_flag_bootstrapped_payload:(null==(c=this._instance.config.bootstrap)||null==(c=c.featureFlagPayloads)?void 0:c[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};L(null==v||null==(u=v.metadata)?void 0:u.version)||(f.$feature_flag_version=v.metadata.version);var m,y=null!==(d=null==v||null==(_=v.reason)?void 0:_.description)&&void 0!==d?d:null==v||null==(h=v.reason)?void 0:h.code;if(y&&(f.$feature_flag_reason=y),null!=v&&null!=(p=v.metadata)&&p.id&&(f.$feature_flag_id=v.metadata.id),L(null==v?void 0:v.original_variant)&&L(null==v?void 0:v.original_enabled)||(f.$feature_flag_original_response=L(v.original_variant)?v.original_enabled:v.original_variant),null!=v&&null!=(g=v.metadata)&&g.original_payload)f.$feature_flag_original_payload=null==v||null==(m=v.metadata)?void 0:m.original_payload;this._instance.capture("$feature_flag_called",f)}return i}fn.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_environments=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:es.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null==(s=i.json)?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}fn.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._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t,s,r,n){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var o=Pn(e),a=o.flags,l=o.featureFlags,c=o.featureFlagPayloads;if(l){var u=e.requestId,d=e.evaluatedAt;if(C(l)){fn.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var _={};if(l)for(var h=0;h<l.length;h++)_[l[h]]=!0;t&&t.register({[yn]:l,[ei]:_})}else{var p=l,g=c,v=a;e.errorsWhileComputingFlags&&(p=i({},s,p),g=i({},r,g),v=i({},n,v)),t&&t.register(i({[yn]:Object.keys(kn(p)),[ei]:p||{},[wn]:g||{},[ii]:v||{}},u?{[Sn]:u}:{},d?{[xn]:d}:{}))}}}(e,this._instance.persistence,s,r,n),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),fn.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return fn.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(bn),this._instance.persistence.unregister(En),this._fireFeatureFlagsCallbacks(),mn.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(bn),mn.info("Flag overrides cleared");else if(i.flags){if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this._instance.persistence.register({[bn]:s})}else this._instance.persistence.register({[bn]:i.flags});mn.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(En),mn.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[En]:i.payloads}),mn.info("Payload overrides set",{payloads:i.payloads}))),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,s){var r,n=(this._instance.get_property(ti)||[]).find((t=>t.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};n&&(a.$early_access_feature_name=n.name),s&&(a.$feature_enrollment_stage=s),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[yn]:Object.keys(kn(l)),[ei]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._instance.get_property(ti),r=i?"&"+i.map((e=>"stage="+e)).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+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(ti),null==(s=this._instance.persistence)||s.register({[ti]:r}),e(r)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(si)||{};this._instance.register({[si]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(si)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._instance.get_property(ri)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[ri]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ri)||{};this._instance.register({[ri]:i({},t,{[e]:{}})})}else this._instance.unregister(ri)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsCalled=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}var Fn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Tn{constructor(e,t){this._config=e,this.props={},this._campaign_params_saved=!1,this._name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this._storage=this._buildStorage(e),this.load(),e.debug&&St.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Fn.indexOf(e.persistence.toLowerCase())&&(St.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&ks._is_supported()?ks:"localstorage+cookie"===t&&Is._is_supported()?Is:"sessionstorage"===t&&Rs._is_supported()?Rs:"memory"===t?Fs:"cookie"===t?Ss:Is._is_supported()?Is:Ss}properties(){var e={};return It(this.props,(function(t,i){if(i===ei&&T(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/"+s[r]]=t[s[r]];else o=i,a=!1,(A(n=vi)?a:l&&n.indexOf===l?-1!=n.indexOf(o):(It(n,(function(e){if(a||(a=e===o))return kt})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Ct({},e))}}save(){this._disabled||this._storage._set(this._name,this.props,this._expire_days,this._cross_subdomain,this._secure,this._config.debug)}remove(){this._storage._remove(this._name,!1),this._storage._remove(this._name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(T(e)){L(t)&&(t="None"),this._expire_days=L(i)?this._default_expiry:i;var s=!1;if(It(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(T(e)){this._expire_days=L(t)?this._default_expiry:t;var i=!1;if(It(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,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._campaign_params_saved){var e=nr(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);R(Lt(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==u?void 0:u.referrer)?ar(e):{})}update_referrer_info(){var e;this.register_once({$referrer:cr(),$referring_domain:null!=u&&u.referrer&&(null==(e=ts(u.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ui]||this.props[di]||this.register_once({[_i]:ur(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};It([di,ui],(t=>{var i=this.props[t];i&&It(i,(function(t,i){e["$initial_"+S(i)]=t}))}));var t,i,s=this.props[_i];if(s){var r=(t=dr(s),i={},It(t,(function(e,t){i["$initial_"+S(t)]=e})),i);Ct(e,r)}return e}safe_merge(e){return It(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._default_expiry=this._expire_days=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){var s=this._buildStorage(e),r=this.props;this.clear(),this._storage=s,this.props=r,this.save()}}set_disabled(e){this._disabled=e,this._disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this._cross_subdomain&&(this._cross_subdomain=e,this.remove(),this.save())}set_secure(e){e!==this._secure&&(this._secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[jt]||{};i[e]=t,this.props[jt]=i,this.save()}remove_event_timer(e){var t=(this.props[jt]||{})[e];return L(t)||(delete this.props[jt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var Rn=xt("[Product Tours]"),$n="ph_product_tours";class Ln{constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Kt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this._productTourManager||((e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Kt))||this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Rn.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=v.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!C(this._cachedTours)||t){var i=this._instance.persistence;if(i){var s=i.props[$n];if(C(s)&&!t)return this._cachedTours=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:t=>{var s=t.statusCode;if(200!==s||!t.json){var r="Product Tours API could not be loaded, status: "+s;return Rn.error(r),void e([],{isLoaded:!1,error:r})}var n=C(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[$n]:n}),e(n,{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){D(this._productTourManager)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this._productTourManager.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this._productTourManager)||t.showTourById(e)}previewTour(e){this._productTourManager?this._productTourManager.previewTour(e):this._loadScript((()=>{var t;this._startProductTours(),null==(t=this._productTourManager)||t.previewTour(e)}))}dismissProductTour(){var e;null==(e=this._productTourManager)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this._productTourManager)||e.nextStep()}previousStep(){var e;null==(e=this._productTourManager)||e.previousStep()}clearCache(){var e;this._cachedTours=null,null==(e=this._instance.persistence)||e.unregister($n)}resetTour(e){var t;null==(t=this._productTourManager)||t.resetTour(e)}resetAllTours(){var e;null==(e=this._productTourManager)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this._productTourManager)||t.cancelPendingTour(e)}}var Mn=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({}),On=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({}),An=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),Dn=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e}({}),Nn=function(e){return e.Popover="popover",e.Inline="inline",e}({}),qn=xt("[Surveys]");var Hn="seenSurvey_",jn=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},Un=e=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(Hn,e),zn=[On.Popover,On.Widget,On.API],Bn={ignoreConditions:!1,ignoreDelay:!1,displayType:Nn.Popover};class Vn{constructor(){this._events={},this._events={}}on(e,t){return this._events[e]||(this._events[e]=[]),this._events[e].push(t),()=>{this._events[e]=this._events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this._events[e]||[])i(t);for(var s of this._events["*"]||[])s(e,t)}}function Wn(e,t,i){if(D(e))return!1;switch(i){case"exact":return e===t;case"contains":var s=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Gn{constructor(e){this._debugEventEmitter=new Vn,this._checkStep=(e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t)&&this._checkStepProperties(e,t),this._checkStepEvent=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this._actionEvents=new Set,this._actionRegistry=new Set}init(){var e;if(!L(null==(e=this._instance)?void 0:e._addCaptureHook)){var t;null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null==(t=this._actionRegistry)||t.add(e),null==(i=e.steps)||i.forEach((e=>{var t;null==(t=this._actionEvents)||t.add((null==e?void 0:e.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null==(s=this._instance)||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this._actionEvents.has(e)||this._actionEvents.has(null==t?void 0:t.event))&&this._actionRegistry&&(null==(i=this._actionRegistry)?void 0:i.size)>0&&this._actionRegistry.forEach((e=>{this._checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}_checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this._checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}_checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!Wn(s,t.url,t.url_matching||"contains"))return!1}return!0}_checkStepElement(e,t){return!!this._checkStepHref(e,t)&&(!!this._checkStepText(e,t)&&!!this._checkStepSelector(e,t))}_checkStepHref(e,t){var i;if(null==t||!t.href)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some((e=>Wn(e.href,t.href,t.href_matching||"exact")));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Wn((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var s=this._getElementsList(e);if(s.length>0)return s.some((e=>Wn(e.text,t.text,t.text_matching||"exact")||Wn(e.$el_text,t.text,t.text_matching||"exact")));var r,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(r=function(e){for(var t,i=[],s=/(?::|")text="(.*?)"/g;!D(t=s.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",r.some((e=>Wn(e,n,o))))}_checkStepSelector(e,t){var i,s;if(null==t||!t.selector)return!0;var r=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=r&&r.includes(t.selector))return!0;var n=(null==e||null==(s=e.properties)?void 0:s.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(e){return!1}return!1}_getElementsList(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}_checkStepProperties(e,t){return null==t||!t.properties||0===t.properties.length||pn(t.properties.reduce(((e,t)=>{var i=C(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e}),{}),null==e?void 0:e.properties)}}class Yn{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&pn(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var s;null==(s=e.conditions)||null==(s=s[t])||null==(s=s.values)||s.forEach((t=>{if(null!=t&&t.name){var s=i.get(t.name)||[];s.push(e.id),i.set(t.name,s)}}))})),i}_getMatchingItems(e,t,i){var s=(i===Mn.Activation?this._eventToItems:this._cancelEventToItems).get(e),r=[];return this._getItems((e=>{r=e.filter((e=>null==s?void 0:s.includes(e.id)))})),r.filter((s=>{var r,n=null==(r=s.conditions)||null==(r=r[i])||null==(r=r.values)?void 0:r.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this._setupEventBasedItems(e),this._setupActionBasedItems(e))}_setupActionBasedItems(e){var t=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Gn(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(s=e.conditions)||null==(s=s.actions)||null==(s=s.values)?void 0:s.length)>0&&(null==(r=this._actionMatcher)||r.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((t=>{if(t&&t.name){var i=this._actionToItems.get(t.name);i&&i.push(e.id),this._actionToItems.set(t.name,i||[e.id])}})))}))}}_setupEventBasedItems(e){var t,i=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),s=e.filter((e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));if(0!==i.length||0!==s.length){null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Mn.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,Mn.Cancellation)}}onEvent(e,t){var i,s=this._getLogger(),r=this._getActivatedKey(),n=this._getShownEventName(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[r])||[];if(n===e&&t&&o.length>0){var a,l;s.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this._updateActivatedItems(o))}}else{if(this._cancelEventToItems.has(e)){var d=this._getMatchingItems(e,t,Mn.Cancellation);d.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:d.map((e=>e.id))}),d.forEach((e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this._cancelPendingItem(e.id)})),this._updateActivatedItems(o))}if(this._eventToItems.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var _=this._getMatchingItems(e,t,Mn.Activation);this._updateActivatedItems(o.concat(_.map((e=>e.id))||[]))}}}onAction(e){var t,i=this._getActivatedKey(),s=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this._actionToItems.has(e)&&this._updateActivatedItems(s.concat(this._actionToItems.get(e)||[]))}_updateActivatedItems(e){var t,i=this._getLogger(),s=this._getActivatedKey(),r=[...new Set(e)].filter((e=>!this._isItemPermanentlyIneligible(e)));i.info("updating activated items",{activatedItems:r}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[s]:r})}getActivatedIds(){var e,t=this._getActivatedKey(),i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class Kn extends Yn{constructor(e){super(e)}_getActivatedKey(){return"$surveys_activated"}_getShownEventName(){return An.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return qn}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class Jn{constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(D(t))return qn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this._isSurveysEnabled=i?t.length>0:t,qn.info("flags response received, isSurveysEnabled: "+this._isSurveysEnabled),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(null!=i&&i.startsWith(Hn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)qn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)qn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())qn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==v?void 0:v.__PosthogExtensions__;if(e){if(!L(this._isSurveysEnabled)||this._instance.config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._instance.config.advanced_enable_surveys;this._isInitializingSurveys=!0;try{var i=e.generateSurveys;if(i)return void this._completeSurveyInitialization(i,t);var s=e.loadExternalDependency;if(!s)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(i=>{i||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",i):this._completeSurveyInitialization(e.generateSurveys,t)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}}else qn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Kn(this._instance),qn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){qn.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e,t){if(void 0===t&&(t=!1),this._instance.config.disable_surveys)return qn.info("Disabled. Not loading surveys."),e([]);var i,s=this._instance.get_property(ni);if(s&&!t)return e(s,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:s}=t;return e(i,s)})):("undefined"!=typeof Promise&&(this._getSurveysInFlightPromise=new Promise((e=>{i=e}))),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:t=>{var s;this._getSurveysInFlightPromise=null;var r=t.statusCode;if(200!==r||!t.json){var n="Surveys API could not be loaded, status: "+r;qn.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e))));c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c));null==(s=this._instance.persistence)||s.register({[ni]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){qn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!D(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);qn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var s;t=null!==(s=i.find((t=>t.id===e)))&&void 0!==s?s:null})),t}_checkSurveyEligibility(e){if(D(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(D(this._surveyManager))return qn.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return D(this._surveyManager)?(qn.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((t=>{var s,r=null!==(s=t.find((t=>t.id===e)))&&void 0!==s?s:null;if(r){var n=this._checkSurveyEligibility(r);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){var i;if(D(this._surveyManager))qn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(zn.includes(s.type)){var r=null==u?void 0:u.querySelector(t);if(r)return null!=(i=s.appearance)&&i.surveyPopupDelaySeconds?(qn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;qn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,r),qn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,r);qn.warn("Survey element not found")}else qn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else qn.warn("Survey not found")}}displaySurvey(e,t){var s;if(D(this._surveyManager))qn.warn("init was not called");else{var r=this._getSurveyById(e);if(r){var n=r;if(null!=(s=r.appearance)&&s.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},r,{appearance:i({},r.appearance,{surveyPopupDelaySeconds:0})})),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void qn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==Nn.Inline?this._surveyManager.handlePopoverSurvey(n):this.renderSurvey(n,t.selector)}else qn.warn("Survey not found")}}cancelPendingSurvey(e){D(this._surveyManager)?qn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var Xn=xt("[Conversations]");class Qn{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;D(t)||(q(t)?this._isConversationsEnabled=t:(this._isConversationsEnabled=t.enabled,this._remoteConfig=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||e.reset(),this._conversationsManager=null,this._isConversationsEnabled=void 0,this._remoteConfig=null}loadIfEnabled(){if(!this._conversationsManager&&!this._isInitializing&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==v?void 0:v.__PosthogExtensions__;if(e&&!L(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){if(function(e){var t;if(!e||0===e.length)return!0;var i=null==r||null==(t=r.location)?void 0:t.hostname;return!i||e.some((e=>{var t=function(e){var t=e.replace(/^https?:\/\//,"");return(t=t.split("/")[0].split("?")[0].split(":")[0])||null}(e);if(!t)return!1;if(t.startsWith("*.")){var s=t.slice(2);return i.endsWith("."+s)||i===s}return i===t}))}(this._remoteConfig.domains)){this._isInitializing=!0;try{var t=e.initConversations;if(t)return this._completeInitialization(t),void(this._isInitializing=!1);var i=e.loadExternalDependency;if(!i)return void this._handleLoadError("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(t=>{t||!e.initConversations?this._handleLoadError("Could not load conversations script",t):this._completeInitialization(e.initConversations),this._isInitializing=!1}))}catch(e){this._handleLoadError("Error initializing conversations",e),this._isInitializing=!1}}}else Xn.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),Xn.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else Xn.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){Xn.error(e,t),this._conversationsManager=null,this._isInitializing=!1}enable(){this._conversationsManager?this._conversationsManager.enable():Xn.warn("Conversations not loaded yet.")}disable(){this._conversationsManager&&this._conversationsManager.disable()}isLoaded(){return!A(this._conversationsManager)}isEnabled(){return!0===this._isConversationsEnabled}}var Zn=xt("[RateLimiter]");class eo{constructor(e){var t,i;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Zn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Zn.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.captureEventsPerSecond=(null==(t=e.config.rate_limiting)?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null==(i=e.config.rate_limiting)?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var r=(new Date).getTime(),n=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(ci))&&void 0!==t?t:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||e||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null==(s=this.instance.persistence)||s.set_property(ci,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var to=xt("[RemoteConfig]");class io{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=v.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(to.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(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 to.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance._shouldDisableFlags())return void to.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return to.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e)}));this._onRemoteConfig(e)}))}catch(e){to.error("Error loading remote config",e)}}_onRemoteConfig(e){e?this._instance.config.__preview_remote_config?(this._instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):to.info("__preview_remote_config is disabled. Logging config instead",e):to.error("Failed to fetch remote config from PostHog.")}}var so=3e3;class ro{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=Y((null==t?void 0:t.flush_interval_ms)||so,250,5e3,St.createLogger("flush interval"),so),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e);[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))].map((e=>{this._sendRequest(i({},e,{transport:"sendBeacon"}))}))}enable(){this._isPaused=!1,this._setFlushTimeout()}_setFlushTimeout(){var e=this;this._isPaused||(this._flushTimeout=setTimeout((()=>{if(this._clearFlushTimeout(),this._queue.length>0){var t=this._formatQueue(),i=function(){var i=t[s],r=(new Date).getTime();i.data&&C(i.data)&&It(i.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e._sendRequest(i)};for(var s in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return It(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;L(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var no=["retriesPerformedSoFar"];class oo{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!L(r)&&"onLine"in r.navigator&&(this._areWeOnline=r.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Nt(r,"online",this._onlineListener),Nt(r,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,no);N(t)&&t>0&&(r.url=on(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(i({retriesPerformedSoFar:t},r)):null==r.callback||r.callback(e)}}))}_enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this._queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in "+i;navigator.onLine||(r+=" (Browser is offline)"),St.warn(r),this._isPolling||(this._isPolling=!0,this._poll())}_poll(){if(this._poller&&clearTimeout(this._poller),0===this._queue.length)return this._isPolling=!1,void(this._poller=void 0);this._poller=setTimeout((()=>{this._areWeOnline&&this._queue.length>0&&this._flush(),this._poll()}),this._pollIntervalMs)}_flush(){var e=Date.now(),t=[],i=this._queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this._queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,L(r)||(this._onlineListener&&(r.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(r.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){St.error(e)}this._queue=[]}}class ao{constructor(e){this._updateScrollData=()=>{var e,t,i,s;this._context||(this._context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this._context.lastScrollY=Math.ceil(n),this._context.maxScrollY=Math.max(n,null!==(e=this._context.maxScrollY)&&void 0!==e?e:0),this._context.maxScrollHeight=Math.max(o,null!==(t=this._context.maxScrollHeight)&&void 0!==t?t:0),this._context.lastContentY=a,this._context.maxContentY=Math.max(a,null!==(i=this._context.maxContentY)&&void 0!==i?i:0),this._context.maxContentHeight=Math.max(l,null!==(s=this._context.maxContentHeight)&&void 0!==s?s:0)},this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Nt(r,"scroll",this._updateScrollData,{capture:!0}),Nt(r,"scrollend",this._updateScrollData,{capture:!0}),Nt(r,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==r?void 0:r.document.documentElement;var e=C(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=null==r?void 0:r.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 r&&(r.scrollY||r.pageYOffset||r.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return r&&(r.scrollX||r.pageXOffset||r.document.documentElement.scrollLeft)||0}}var lo=e=>ur(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class co{constructor(e,t,i,s){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[li]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||lo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[li]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?dr(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 It(Lt(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+S(i)]=t})),e}}var uo=xt("[SessionId]");class _o{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var s;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new Vn,this._sessionHasBeenIdleTooLong=(e,t)=>Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this._config=e.config,this._persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||ms,this._windowIdGenerator=i||ms;var r=this._config.persistence_name||this._config.token,n=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Y(n,60,36e3,uo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+r+"_window_id",this._primary_window_exists_storage_key="ph_"+r+"_primary_window_exists",this._canUseSessionStorage()){var o=Rs._parse(this._window_id_storage_key),a=Rs._parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:Rs._remove(this._window_id_storage_key),Rs._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var l=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this._config.bootstrap.sessionID);this._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),l)}catch(e){uo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this._config.persistence&&!this._persistence._disabled&&Rs._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Rs._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Rs._parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this._persistence.register({[Qt]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[Qt];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}destroy(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=void 0,this._beforeUnloadListener&&r&&(r.removeEventListener("beforeunload",this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&Rs._remove(this._primary_window_exists_storage_key)},Nt(r,"beforeunload",this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this._config.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=N(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!c&&!e&&this._sessionHasBeenIdleTooLong(i,s);c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),uo.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,_=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{var[e]=this._getSessionId();if(this._sessionHasBeenIdleTooLong((new Date).getTime(),e)){var t=this._sessionId;this.resetSessionId(),this._eventEmitter.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var ho=["$set_once","$set"],po=xt("[SiteApps]");class go{constructor(e){this._instance=e,this._bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}_eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this._bufferedInvocations.push(i),this._bufferedInvocations.length>1e3&&(this._bufferedInvocations=this._bufferedInvocations.slice(10))}}get siteAppLoaders(){var e;return null==(e=v._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this._eventCollector.bind(this));this._stopBuffering=()=>{e(),this._bufferedInvocations=[],this._stopBuffering=void 0}}}globalsForEvent(e){var t,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))u[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,ho),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(r=e.properties)?void 0:r.$set)&&void 0!==t?t:{},v)}:{},g?{$set_once:i({},null!==(n=null==(o=e.properties)?void 0:o.$set_once)&&void 0!==n?n:{},g)}:{}),elements_chain:null!==(a=null==(l=e.properties)?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(c=e.properties)?void 0:c.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(po.info("Processing "+this._bufferedInvocations.length+" events for site app with id "+e.id),this._bufferedInvocations.forEach((e=>null==t.processEvent?void 0:t.processEvent(e))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null==(i=this._stopBuffering)||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,po.info("Site app with id "+e.id+" "+(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){po.error("Error while initializing PostHog app with config id "+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){po.error("Error while processing buffered events PostHog app with config id "+e.id,i),t.errored=!0}}_setupSiteApps(){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)}_onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(t){po.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void po.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(s=e.siteApps)&&s.length)if(this.isEnabled){var n=function(e){var t;v["__$$ph_site_app_"+e]=r._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return po.error("Error while initializing PostHog app with config id "+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else po.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var vo=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&y(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>y(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},fo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),mo="i.posthog.com";class yo{constructor(e){this._regionCache={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+mo,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=fo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=fo.EU:this._regionCache[this.apiHost]=fo.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===fo.CUSTOM)return this.apiHost+t;var i=mo+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var bo={icontains:(e,t)=>!!r&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!r&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!r&&un(t.href,e),not_regex:(e,t)=>!!r&&!un(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class wo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{wo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)wo._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e);var s=t._instance.getFeatureFlag(e.feature_flag_key);M(s)&&e.variants[s]&&t._applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];wo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())wo._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(D(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();wo._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,s=this._instance.getFeatureFlag(e),r=null==(i=this._flagToExperiments)?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this._applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=wo.getWindowLocation();if(null!=e&&e.search){var t=ss(null==e?void 0:e.search,"__experiment_id"),i=ss(null==e?void 0:e.search,"__experiment_variant");t&&i&&(wo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!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:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(wo._logInfo("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this._applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static _matchesTestVariant(e){return!D(e.conditions)&&(wo._matchUrlConditions(e)&&wo._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=wo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||bo[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==r?void 0:r.location}static _matchUTMConditions(e){var t;if(D(e.conditions)||D(null==(t=e.conditions)?void 0:t.utm))return!0;var i=nr();if(i.utm_source){var s,r,n,o,a,l,c,u,d=null==(s=e.conditions)||null==(s=s.utm)||!s.utm_campaign||(null==(r=e.conditions)||null==(r=r.utm)?void 0:r.utm_campaign)==i.utm_campaign,_=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,h=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,p=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return d&&h&&p&&_}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];St.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?wo._logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;wo._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var r=null==(s=document)?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):wo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return c&&this._instance?vo(c,this._instance.config.custom_blocked_useragents):void 0}}var Eo=xt("[PostHog ExternalIntegrations]"),So={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class xo{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Eo.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;(!s||null!=(i=v.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(So[t],(()=>{var i;null==(i=v.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t])&&(null==(n=v.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,s]of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;t(i)}}}var ko="[SessionRecording]",Po=xt(ko);class Io{get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){return this._lazyLoadedSessionRecording?this._lazyLoadedSessionRecording.status:this._receivedFlags&&!this._isRecordingEnabled?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._receivedFlags=!1,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Po.error("started without valid sessionManager"),new Error(ko+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(ko+' cannot be used with cookieless_mode="always"')}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(Xt))||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return r&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Po.info("starting")):this.stopRecording()}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(null!=v&&null!=(t=v.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=v.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Po.error("could not load recorder",t);this._onScriptLoaded(e)})))}stopRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.stop()}_resetSampling(){var e;null==(e=this._instance.persistence)||e.unregister(Zt)}_persistRemoteConfig(e){if(this._instance.persistence){var t,s,r=this._instance.persistence,n=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,s=null==t?void 0:t.sampleRate,n=D(s)?null:parseFloat(s);D(n)&&this._resetSampling();var o=null==t?void 0:t.minimumDurationMilliseconds;r.register({[Xt]:i({enabled:!!t},t,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:n,minimumDurationMilliseconds:L(o)?null:o,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this._persistRemoteConfig(e),this._receivedFlags=!0,this.startIfEnabledOrStop()):this._receivedFlags=!0:Po.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):Po.warn("log called before recorder was ready")}get _scriptName(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(Xt);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_onScriptLoaded(e){var t,i;if(null==(t=v.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture);this._lazyLoadedSessionRecording.start(e)}onRRwebEmit(e){var t;null==(t=this._lazyLoadedSessionRecording)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this._lazyLoadedSessionRecording||(null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}));null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||(null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}));null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||(null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}));null==(t=this._lazyLoadedSessionRecording)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this._lazyLoadedSessionRecording)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this._lazyLoadedSessionRecording)||!i.tryAddCustomEvent(e,t))}}var Co={},Fo=()=>{},To="posthog",Ro=!rn&&-1===(null==g?void 0:g.indexOf("MSIE"))&&-1===(null==g?void 0:g.indexOf("Mozilla")),$o=e=>{var t;return i({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:At(null==u?void 0:u.location),persistence:"localStorage+cookie",persistence_name:"",loaded:Fo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:d&&M(null==d?void 0:d.search)&&-1!==d.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==r||null==(t=r.location)?void 0:t.protocol),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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;St.error(t)},get_device_id:e=>e,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:so},error_tracking:{},_onCapture:Fo,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(e))},Lo=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=Ct({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:St.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class Mo{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){St.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Oo{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new Mo,this._personProcessingSetOncePropertiesSent=!1,this.version=f.LIB_VERSION,this._internalEventEmitter=new Vn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=$o(),this.SentryIntegration=Ws,this.sentryIntegration=e=>function(e,t){var i=Vs(e,t);return{name:Bs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._visibilityStateListener=null,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new Cn(this),this.toolbar=new Xs(this),this.scrollManager=new ao(this),this.pageViewManager=new wr(this),this.surveys=new Jn(this),this.conversations=new Qn(this),this.experiments=new wo(this),this.exceptions=new vn(this),this.rateLimiter=new eo(this),this.requestRouter=new yo(this),this.consent=new Ls(this),this.externalIntegrations=new xo(this),this.people={set:(e,t,i)=>{var s=M(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=M(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>St.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==To){var s,r=null!==(s=Co[i])&&void 0!==s?s:new Oo;return r._init(e,t,i),Co[i]=r,Co[To][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var n;if(void 0===t&&(t={}),L(e)||O(e))return St.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._checkLocalStorageForDebug(t.debug),this._originalUserConfig=t,this._triggered_notifs=[],t.person_profiles&&(this._initialPersonProfilesConfig=t.person_profiles),this.set_config(Ct({},$o(t.defaults),Lo(t),{name:s,token:e})),this.config.on_xhr_error&&St.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:es.GZipJS;var o=this._is_persistence_disabled();this.persistence=new Tn(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Tn(i({},this.config,{persistence:"sessionStorage"}),o);var a=i({},this.persistence.props),l=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new ro((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new oo(this),this.__request_queue=[];var c="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(c||(this.sessionManager=new _o(this),this.sessionPropsManager=new co(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(St.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(St.info("Initializing extensions synchronously"),this._initExtensions(c)),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&St.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:a,s:l}),void 0!==(null==(n=t.bootstrap)?void 0:n.distinctID)){var u,d,_=this.config.get_device_id(ms()),h=null!=(u=t.bootstrap)&&u.isIdentifiedID?_:t.bootstrap.distinctID;this.persistence.set_property(ai,null!=(d=t.bootstrap)&&d.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var p,g,v=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter((e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])})).reduce(((e,i)=>{var s;return e[i]=(null==(s=t.bootstrap)||null==(s=s.featureFlags)?void 0:s[i])||!1,e}),{}),m=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter((e=>v[e])).reduce(((e,i)=>{var s,r;null!=(s=t.bootstrap)&&null!=(s=s.featureFlagPayloads)&&s[i]&&(e[i]=null==(r=t.bootstrap)||null==(r=r.featureFlagPayloads)?void 0:r[i]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(c)this.register_once({distinct_id:gi,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(ms());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(ai,"anonymous")}return Nt(r,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?zs(this,(()=>this._loaded())):this._loaded(),F(this.config._onCapture)&&this.config._onCapture!==Fo&&(St.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&St.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}_initExtensions(e){var t=performance.now();this.historyAutocapture=new js(this),this.historyAutocapture.startIfEnabled();var i=[];i.push((()=>{new Zs(this).startIfEnabledOrStop()})),i.push((()=>{var e;this.siteApps=new go(this),null==(e=this.siteApps)||e.init()})),e||i.push((()=>{this.sessionRecording=new Io(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.push((()=>{this.autocapture=new ds(this),this.autocapture.startIfEnabled()})),i.push((()=>{this.surveys.loadIfEnabled()})),i.push((()=>{this.conversations.loadIfEnabled()})),i.push((()=>{this.productTours=new Ln(this),this.productTours.loadIfEnabled()})),i.push((()=>{this.heatmaps=new br(this),this.heatmaps.startIfEnabled()})),i.push((()=>{this.webVitalsAutocapture=new fr(this)})),i.push((()=>{this.exceptionObserver=new qs(this),this.exceptionObserver.startIfEnabledOrStop()})),i.push((()=>{this.deadClicksAutocapture=new Ds(this,As),this.deadClicksAutocapture.startIfEnabled()})),i.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(i,t)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions)if(performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this._processInitTaskQueue(e,t)}),0);var i=e.shift();if(i)try{i()}catch(e){St.error("Error initializing extension:",e)}}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&&St.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t,i,s,r,n,o,a,l,c;if(!u||!u.body)return St.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.config.__preview_deferred_init_extensions&&(this._pendingRemoteConfig=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,es.GZipJS)?es.GZipJS:w(e.supportedCompression,es.Base64)?es.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(s=this.sessionRecording)||s.onRemoteConfig(e),null==(r=this.autocapture)||r.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){St.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this._captureInitialPageview()}),1),new io(this).load(),this.featureFlags.flags()}_start_queue_if_opted_in(){var e;this.is_capturing()&&(this.config.request_batching&&(null==(e=this._requestQueue)||e.enable()))}_dom_loaded(){this.is_capturing()&&Pt(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null==(e=this._requestQueue)||e.unload(),null==(t=this._retryQueue)||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Ro?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=on(e.url,{ip:this.config.ip?1:0}),e.headers=i({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?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,(e=>{var t,s,r,n=i({},e);n.timeout=n.timeout||6e4,n.url=on(n.url,{_:(new Date).getTime().toString(),ver:f.LIB_VERSION,compression:n.compression});var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=cn.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=Dt(a,(e=>e.transport===o)))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");l(n)})(i({},e,{callback:t=>{var i,s;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null==(i=(s=this.config).on_request_error)||i.call(s,t));null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];Pt(e,(e=>{e&&(t=e[0],C(t)?r.push(e):F(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&F(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Pt(e,(function(e){if(C(e[0])){var i=t;It(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!L(e)&&M(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var o=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==o||!o.isRateLimited){null!=t&&t.$current_url&&!M(null==t?void 0:t.$current_url)&&(St.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(null==s?void 0:s.timestamp)||a,c=ms(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),(null==s?void 0:s.$set)&&(u.$set=null==s?void 0:s.$set);var d,_="$groupidentify"!==e,h=this._calculate_set_once_properties(null==s?void 0:s.$set_once,_);if(h&&(u.$set_once=h),(u=Mt(u,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,L(null==s?void 0:s.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===An.DISMISSED||e===An.SENT){var p=null==t?void 0:t[Dn.SURVEY_ID],g=null==t?void 0:t[Dn.SURVEY_ITERATION];d={id:p,current_iteration:g},localStorage.getItem(Un(d))||localStorage.setItem(Un(d),"true"),u.$set=i({},u.$set,{[jn({id:p,current_iteration:g},e===An.SENT?"responded":"dismissed")]:!0})}var v=i({},u.properties.$set,u.$set);if(R(v)||this.setPersonPropertiesForFlags(v),!D(this.config.before_send)){var f=this._runBeforeSend(u);if(!f)return;u=f}this._internalEventEmitter.emit("eventCaptured",u);var m={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(m):this._requestQueue.enqueue(m),u}St.critical("This capture call is ignored due to client rate limiting.")}}else St.error("No event name provided to posthog.capture")}else St.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=i({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=i({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!M(a.distinct_id)&&!N(a.distinct_id)||O(a.distinct_id))&&St.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,d=pr(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(n,s.getTime());a.$session_id=_,a.$window_id=h}this.sessionPropsManager&&Ct(a,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Ct(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){a.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===fo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||n?"$pageleave"!==e||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=Ct(a,c),"$pageview"===e&&u&&(a.title=u.title),!L(o)){var v=s.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}g&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ct({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?It(this.config.property_denylist,(function(e){delete a[e]})):St.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(St.error("sanitize_properties is deprecated. Use before_send instead"),a=f(a,e));var m=this._hasPersonProcessing();return a.$process_person_profile=m,m&&!n&&this._requirePersonProcessing("_calculate_event_properties"),a}_calculate_set_once_properties(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var s=this.persistence.get_initial_props(),r=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),n=Ct({},s,r||{},e||{}),o=this.config.sanitize_properties;return o&&(St.error("sanitize_properties is deprecated. Use before_send instead"),n=o(n,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),R(n)?void 0:n}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var s;null==(s=this.persistence)||s.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,s){var r=null!=s&&s.merge?this.featureFlags.getFlagVariants():{},n=null!=s&&s.merge?this.featureFlags.getFlagPayloads():{},o=i({},r,e),a=i({},n,t),l={};for(var[c,u]of Object.entries(o)){var d="string"==typeof u;l[c]={key:c,enabled:!!d||Boolean(u),variant:d?u:void 0,reason:void 0,metadata:L(null==a?void 0:a[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=Bn),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,s){if(!this.__loaded||!this.persistence)return St.uninitializedWarning("posthog.identify");if(N(e)&&(e=e.toString(),St.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()))St.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!==gi){if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(Ht)&&(this.unregister(Ht),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(ai)||"anonymous");e!==r&&o?(this.persistence.set_property(ai,"identified"),this.setPersonPropertiesForFlags(i({},s||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:s||{}}),this._cachedPersonProperties=dn(e,t,s),this.featureFlags.setAnonymousDistinctId(r)):(t||s)&&this.setPersonProperties(t,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(oi))}}else St.critical('The string "'+gi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else St.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var s=dn(this.get_distinct_id(),e,t);this._cachedPersonProperties!==s?(this.setPersonPropertiesForFlags(i({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=s):St.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,s){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===t||s||this.reloadFeatureFlags()}else St.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(St.info("reset"),!this.__loaded)return St.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(s=this.persistence)||s.set_property(ai,"anonymous"),null==(r=this.sessionManager)||r.resetSessionId(),this._cachedPersonProperties=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:gi,$device_id:null},"");else{var o=this.config.get_device_id(ms());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?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(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;s+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return s}alias(e,t){return e===this.get_property(qt)?(St.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Ht,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(St.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(T(e)){var s,r,n,o,a,l,c;Ct(this.config,Lo(e));var u=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,u),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Tn(i({},this.config,{persistence:"sessionStorage"}),u);var d=this._checkLocalStorageForDebug(this.config.debug);q(d)&&(this.config.debug=d),q(this.config.debug)&&(this.config.debug?(f.DEBUG=!0,ks._is_supported()&&ks._set("ph_debug","true"),St.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(f.DEBUG=!1,ks._is_supported()&&ks._remove("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(o=this.autocapture)||o.startIfEnabled(),null==(a=this.heatmaps)||a.startIfEnabled(),null==(l=this.exceptionObserver)||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(c=this.externalIntegrations)||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null==(s=this.sessionManager)||s.checkAndGetSessionAndWindowId(),i.sampling)null==(r=this.sessionRecording)||r.overrideSampling();if(i.linked_flag)null==(n=this.sessionRecording)||n.overrideLinkedFlag();if(i.url_trigger)null==(o=this.sessionRecording)||o.overrideTrigger("url");if(i.event_trigger)null==(a=this.sessionRecording)||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:To;return t!==To&&(t=To+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ai))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ai))}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&R(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Ht])&&(null==(t=this.persistence)||null==(t=t.props)||!t[hi]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(St.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(hi,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();(null==(e=this.persistence)?void 0:e._disabled)!==r&&(null==(i=this.persistence)||i.set_disabled(r));(null==(t=this.sessionPersistence)?void 0:t._disabled)!==r&&(null==(s=this.sessionPersistence)||s.set_disabled(r));return r}opt_in_capturing(e){var t;if("always"!==this.config.cookieless_mode){var i,s,r;if("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(s=this.pageViewManager)||s.destroy(),this.sessionManager=new _o(this),this.pageViewManager=new wr(this),this.persistence&&(this.sessionPropsManager=new co(this,this.sessionManager,this.persistence)),this.sessionRecording=new Io(this),this.sessionRecording.startIfEnabledOrStop();if(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)this.capture(null!==(r=null==e?void 0:e.captureEventName)&&void 0!==r?r:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}else St.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:gi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(i=this.sessionRecording)||i.stopRecording(),this.sessionRecording=void 0,this._captureInitialPageview())):St.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===$s.GRANTED?"granted":e===$s.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return c?vo(c,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){u&&("visible"===u.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:u.title},{send_instantly:!0}),this._visibilityStateListener&&(u.removeEventListener("visibilitychange",this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Nt(u,"visibilitychange",this._visibilityStateListener)))}debug(e){!1===e?(null==r||r.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==r||r.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}))}_shouldDisableFlags(){var e,t,i,s,r,n,o,a=this._originalUserConfig||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(St.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,r=St,n=(t="advanced_disable_flags")in(e=a)&&!L(e[t]),o=i in e&&!L(e[i]),n?e[t]:o?(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}_runBeforeSend(e){if(D(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),D(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return j(e.event)?St.warn(r+". This can cause unexpected behavior."):St.info(r),null}i.properties&&!R(i.properties)||St.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager._currentPageview)?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)})}_checkLocalStorageForDebug(e){var t=q(e)&&!e,i=ks._is_supported()&&"true"===ks._get("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=$t(e.prototype[t[i]])}(Oo,["identify"]);var Ao,Do;Ao=Co[To]=new Oo,(Do=v.posthog)&&It(Do._i,(function(e){if(e&&C(e)){var t=Ao.init(e[0],e[1],e[2]),i=Do[e[2]]||Do;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),v.posthog=Ao,function(){function e(){e.done||(e.done=!0,Ro=!1,It(Co,(function(e){e._dom_loaded()})))}null!=u&&u.addEventListener?"complete"===u.readyState?e():Nt(u,"DOMContentLoaded",e,{capture:!1}):r&&St.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}();
2
2
  //# sourceMappingURL=array.no-external.js.map