posthog-js 1.372.1 → 1.372.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/array.full.es5.js +1 -1
  2. package/dist/array.full.js +1 -1
  3. package/dist/array.full.no-external.js +1 -1
  4. package/dist/array.js +1 -1
  5. package/dist/array.no-external.js +1 -1
  6. package/dist/conversations.js +1 -1
  7. package/dist/conversations.js.map +1 -1
  8. package/dist/customizations.full.js +1 -1
  9. package/dist/default-extensions.js +1 -1
  10. package/dist/extension-bundles.js +1 -1
  11. package/dist/lazy-recorder.js +1 -1
  12. package/dist/main.js +1 -1
  13. package/dist/module.full.js +1 -1
  14. package/dist/module.full.no-external.js +1 -1
  15. package/dist/module.js +1 -1
  16. package/dist/module.no-external.js +1 -1
  17. package/dist/module.slim.js +1 -1
  18. package/dist/module.slim.no-external.js +1 -1
  19. package/dist/posthog-recorder.js +1 -1
  20. package/dist/src/extensions/conversations/external/components/ConversationsWidget.d.ts +0 -2
  21. package/dist/src/extensions/conversations/external/components/MessagesView.d.ts +1 -2
  22. package/dist/src/extensions/conversations/external/components/styles.d.ts +1 -1
  23. package/lib/package.json +1 -1
  24. package/lib/src/extensions/conversations/external/components/ConversationsWidget.d.ts +0 -2
  25. package/lib/src/extensions/conversations/external/components/ConversationsWidget.js +3 -12
  26. package/lib/src/extensions/conversations/external/components/ConversationsWidget.js.map +1 -1
  27. package/lib/src/extensions/conversations/external/components/MessagesView.d.ts +1 -2
  28. package/lib/src/extensions/conversations/external/components/MessagesView.js +2 -2
  29. package/lib/src/extensions/conversations/external/components/MessagesView.js.map +1 -1
  30. package/lib/src/extensions/conversations/external/components/OpenChatButton.js +0 -2
  31. package/lib/src/extensions/conversations/external/components/OpenChatButton.js.map +1 -1
  32. package/lib/src/extensions/conversations/external/components/styles.d.ts +1 -1
  33. package/lib/src/extensions/conversations/external/components/styles.js +2 -2
  34. package/lib/src/extensions/conversations/external/components/styles.js.map +1 -1
  35. package/lib/src/extensions/conversations/external/index.js +3 -1
  36. package/lib/src/extensions/conversations/external/index.js.map +1 -1
  37. package/package.json +3 -3
@@ -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;arguments.length>t;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="1.372.1",n={DEBUG:!1,LIB_VERSION:r,LIB_NAME:"web",JS_SDK_VERSION:r},o="$people_distinct_id",a="$device_id",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",h="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_override_sampling",w="$replay_override_linked_flag",x="$replay_override_url_trigger",E="$replay_override_event_trigger",S="$sesid",k="$session_is_sampled",C="$enabled_feature_flags",P="$active_feature_flags",I="$early_access_features",F="$feature_flag_details",T="$feature_flag_payloads",R="$feature_flag_request_id",L="$override_feature_flags",M="$override_feature_flag_payloads",O="$stored_person_properties",A="$stored_group_properties",D="$surveys",q="$surveys_activated",z="ph_product_tours",H="$flag_call_reported",N="$flag_call_reported_session_id",j="$feature_flag_errors",B="$feature_flag_evaluated_at",U="$user_state",W="$client_session_props",V="$capture_rate_limit",G="$initial_campaign_params",K="$initial_referrer_info",J="$initial_person_info",Y="$epp",X="__POSTHOG_TOOLBAR__",Q="$posthog_cookieless",Z="$sdk_debug_extensions_init_method",ee="$sdk_debug_extensions_init_time_ms",te="$sdk_debug_recording_script_not_loaded",ie="PostHog loadExternalDependency extension not found.",se="on_reject",re="always",ne="anonymous",oe="identified",ae="identified_only",le="visibilitychange",ue="beforeunload",ce="$pageview",de="$pageleave",_e="$identify",he="$groupidentify",pe="undefined"!=typeof window?window:void 0,ge="undefined"!=typeof globalThis?globalThis:pe;"undefined"==typeof self&&(ge.self=ge),"undefined"==typeof File&&(ge.File=function(){});var ve=null==ge?void 0:ge.navigator,fe=null==ge?void 0:ge.document,me=null==ge?void 0:ge.location,ye=null==ge?void 0:ge.fetch,be=null!=ge&&ge.XMLHttpRequest&&"withCredentials"in new ge.XMLHttpRequest?ge.XMLHttpRequest:void 0,we=null==ge?void 0:ge.AbortController,xe=null==ge?void 0:ge.CompressionStream,Ee=null==ve?void 0:ve.userAgent,Se=null!=pe?pe:{};function ke(){return ke=t((function*(e,i,s){void 0===i&&(i=!0);try{var r=new CompressionStream("gzip"),n=r.writable.getWriter(),o=n.write((new TextEncoder).encode(e)).then((()=>n.close())).catch(function(){var e=t((function*(e){try{yield n.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),a=new Response(r.readable).blob(),[l]=yield Promise.all([a,o]);return l}catch(e){if(null!=s&&s.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ke.apply(this,arguments)}var Ce=["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"],Pe=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ce.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},Ie=["$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 Fe(e,t){return-1!==e.indexOf(t)}var Te=function(e){return e.trim()},Re=function(e){return e.replace(/^\$/,"")},Le=Object.prototype,$e=Le.hasOwnProperty,Me=Le.toString,Oe=Array.isArray||function(e){return"[object Array]"===Me.call(e)},Ae=e=>"function"==typeof e,De=e=>e===Object(e)&&!Oe(e),qe=e=>{if(De(e)){for(var t in e)if($e.call(e,t))return!1;return!0}return!1},ze=e=>void 0===e,He=e=>"[object String]"==Me.call(e),Ne=e=>He(e)&&0===e.trim().length,je=e=>null===e,Be=e=>ze(e)||je(e),Ue=e=>"[object Number]"==Me.call(e)&&e==e,We=e=>Ue(e)&&e>0,Ve=e=>"[object Boolean]"===Me.call(e),Ge=e=>e instanceof FormData,Ke=e=>Fe(Ie,e);function Je(e){return null===e||"object"!=typeof e}function Ye(e,t){return{}.toString.call(e)==="[object "+t+"]"}function Xe(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var Qe=[!0,"true",1,"1","yes"],Ze=e=>Fe(Qe,e),et=[!1,"false",0,"0","no"];function tt(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),Ue(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(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),tt(r||i,t,i,s))}class it{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=tt(e.bucketSize,0,100,e._logger),this._refillRate=tt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=tt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):this._buckets[s]=r={tokens:this._bucketSize,lastAccess:i},0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var st,rt,nt,ot="Mobile",at="iOS",lt="Android",ut="Tablet",ct=lt+" "+ut,dt="iPad",_t="Apple",ht=_t+" Watch",pt="Safari",gt="BlackBerry",vt="Samsung",ft=vt+"Browser",mt=vt+" Internet",yt="Chrome",bt=yt+" OS",wt=yt+" "+at,xt="Internet Explorer",Et=xt+" "+ot,St="Opera",kt=St+" Mini",Ct="Edge",Pt="Microsoft "+Ct,It="Firefox",Ft=It+" "+at,Tt="Nintendo",Rt="PlayStation",Lt="Xbox",$t=lt+" "+ot,Mt=ot+" "+pt,Ot="Windows",At=Ot+" Phone",Dt="Nokia",qt="Ouya",zt="Generic",Ht=zt+" "+ot.toLowerCase(),Nt=zt+" "+ut.toLowerCase(),jt="Konqueror",Bt="(\\d+(\\.\\d+)?)",Ut=new RegExp("Version/"+Bt),Wt=new RegExp(Lt,"i"),Vt=new RegExp(Rt+" \\w+","i"),Gt=new RegExp(Tt+" \\w+","i"),Kt=new RegExp(gt+"|PlayBook|BB10","i"),Jt={"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"},Yt=function(e,t){return t=t||"",Fe(e," OPR/")&&Fe(e,"Mini")?kt:Fe(e," OPR/")?St:Kt.test(e)?gt:Fe(e,"IE"+ot)||Fe(e,"WPDesktop")?Et:Fe(e,ft)?mt:Fe(e,Ct)||Fe(e,"Edg/")?Pt:Fe(e,"FBIOS")?"Facebook "+ot:Fe(e,"UCWEB")||Fe(e,"UCBrowser")?"UC Browser":Fe(e,"CriOS")?wt:Fe(e,"CrMo")||Fe(e,yt)?yt:Fe(e,lt)&&Fe(e,pt)?$t:Fe(e,"FxiOS")?Ft:Fe(e.toLowerCase(),jt.toLowerCase())?jt:((e,t)=>t&&Fe(t,_t)||function(e){return Fe(e,pt)&&!Fe(e,yt)&&!Fe(e,lt)}(e))(e,t)?Fe(e,ot)?Mt:pt:Fe(e,It)?It:Fe(e,"MSIE")||Fe(e,"Trident/")?xt:Fe(e,"Gecko")?It:""},Xt={[Et]:[new RegExp("rv:"+Bt)],[Pt]:[new RegExp(Ct+"?\\/"+Bt)],[yt]:[new RegExp("("+yt+"|CrMo)\\/"+Bt)],[wt]:[new RegExp("CriOS\\/"+Bt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Bt)],[pt]:[Ut],[Mt]:[Ut],[St]:[new RegExp("(Opera|OPR)\\/"+Bt)],[It]:[new RegExp(It+"\\/"+Bt)],[Ft]:[new RegExp("FxiOS\\/"+Bt)],[jt]:[new RegExp("Konqueror[:/]?"+Bt,"i")],[gt]:[new RegExp(gt+" "+Bt),Ut],[$t]:[new RegExp("android\\s"+Bt,"i")],[mt]:[new RegExp(ft+"\\/"+Bt)],[xt]:[new RegExp("(rv:|MSIE )"+Bt)],Mozilla:[new RegExp("rv:"+Bt)]},Qt=function(e,t){var i=Yt(e,t),s=Xt[i];if(ze(s))return null;for(var r=0;s.length>r;r++){var n=e.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Zt=[[new RegExp(Lt+"; "+Lt+" (.*?)[);]","i"),e=>[Lt,e&&e[1]||""]],[new RegExp(Tt,"i"),[Tt,""]],[new RegExp(Rt,"i"),[Rt,""]],[Kt,[gt,""]],[new RegExp(Ot,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[At,""];if(new RegExp(ot).test(t)&&!/IEMobile\b/.test(t))return[Ot+" "+ot,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=Jt[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[Ot,s]}return[Ot,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[at,[e[3],e[4],e[5]||"0"].join(".")]:[at,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ze(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+lt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+lt+")","i"),e=>e&&e[2]?[lt,[e[2],e[3],e[4]||"0"].join(".")]:[lt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bt,""]],[/Linux|debian/i,["Linux",""]]],ei=function(e){return Gt.test(e)?Tt:Vt.test(e)?Rt:Wt.test(e)?Lt:new RegExp(qt,"i").test(e)?qt:new RegExp("("+At+"|WPDesktop)","i").test(e)?At:/iPad/.test(e)?dt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ht:Kt.test(e)?gt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dt,"i").test(e)?Dt:/(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(ot).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)?lt:ct:new RegExp("(pda|"+ot+")","i").test(e)?Ht:new RegExp(ut,"i").test(e)&&!new RegExp(ut+" pc","i").test(e)?Nt:""},ti=e=>e instanceof Error,ii={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},si=ii.info;function ri(e){if(Ve(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(Oe(e))return{arrayValue:{values:e.map((e=>ri(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function ni(e){var t=[];for(var i in e){var s=e[i];je(s)||ze(s)||t.push({key:i,value:ri(s)})}return t}function oi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return nt&&i.length===rt||(rt=i.length,nt=i.reduce(((i,s)=>{st||(st={});var r=st[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,u=t[s];if(l&&u){i[l]=u,st[s]=[l,u];break}}return i}),{})),nt}}class ai{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(t),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&&Oe(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?t.skipFirstLines: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(e){var t;return{chunkIdMap:oi(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(4>=s){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 li="?";function ui(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?li:i,in_app:!0};return ze(s)||(n.lineno=s),ze(r)||(n.colno=r),n}var ci=(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]:li,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},di=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,_i=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,hi=/\((\S*)(?::(\d+))(?::(\d+))\)/,pi=(e,t)=>{var i=di.exec(e);if(i){var[,s,r,n]=i;return ui(t,s,li,+r,+n)}var o=_i.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=hi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=ci(o[1]||li,o[2]);return ui(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},gi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,vi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fi=(e,t)=>{var i=gi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=vi.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]||li;return[n,r]=ci(n,r),ui(t,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},mi=/\(error: (.*)\)/;class yi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=He(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 Ye(e,"DOMException")}isDOMError(e){return Ye(e,"DOMError")}}class bi{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 String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class wi{constructor(){}match(e){return Ye(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var xi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Ei{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(xi);return s&&(t=s[1],i=s[2]),[t,i]}}var Si=["fatal","error","warning","log","info","debug"];function ki(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(t>=r.length)return s===i.length?r:r.length>t?r.slice(0,t)+"...":r}return""}class Ci{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 Xe(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: "+ki(e)}isSeverityLevel(e){return He(e)&&!Ne(e)&&Si.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ti(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class Pi{match(e){return Xe(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ki(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ii{match(e){return Je(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 Fi{match(e){return Ye(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Xe(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Je(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){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Ti="$message",Ri="$timestamp",Li=new Set([Ti,Ri]),$i={enabled:!0,max_bytes:32768};function Mi(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:$i.enabled,max_bytes:Ai(e.max_bytes,$i.max_bytes)}:i({},$i)}class Oi{constructor(e){this._entries=[],this._totalBytes=0,this._config=Mi(e)}setConfig(e){this._config=Mi(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!De(i))return;var s=i,r=s[Ti],n=s[Ri];if(!He(r)||0===r.trim().length)return;if(!He(n)&&!Ue(n))return;return{step:s,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,s=0;t.length>s;s++)"%"===t[s]?(i+=1,s+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function Ai(e,t){if(!Ue(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Di=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,s={_log(t){if(pe&&(n.DEBUG||Se.POSTHOG_DEBUG||i)&&!ze(pe.console)&&pe.console){for(var s=("__rrweb_original__"in pe.console[t]?pe.console[t].__rrweb_original__:pe.console[t]),r=arguments.length,o=new Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];s(e,...o)}},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Di(e+" "+t,i)};return s},qi=Di("[PostHog.js]"),zi=qi.createLogger;function Hi(e,t){Oe(e)&&e.forEach(t)}function Ni(e,t){if(!Be(e))if(Oe(e))e.forEach(t);else if(Ge(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)$e.call(e,i)&&t(e[i],i)}var ji=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e};function Bi(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 Ui=function(e){try{return e()}catch(e){return}},Wi=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){qi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),qi.critical(e)}}},Vi=function(e){var t={};return Ni(e,(function(e,i){(He(e)&&e.length>0||Ue(e))&&(t[i]=e)})),t};var Gi=["herokuapp.com","vercel.app","netlify.app"];function Ki(e){var t=null==e?void 0:e.hostname;if(!He(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of Gi)if(i===s)return!1;return!0}function Ji(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}function Yi(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ue(e)&&isFinite(e)&&Math.floor(e)===e});class Xi{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)||0>e||0>t||0>i||0>s||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 Xi(r)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),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 Xi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Qi{constructor(){this._timestamp=0,this._counter=0,this._random=new ts}generate(){var e=this.generateOrAbort();if(ze(e)){this._timestamp=0;var t=this.generateOrAbort();if(ze(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(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Xi.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 Zi,es=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};pe&&!ze(pe.crypto)&&crypto.getRandomValues&&(es=e=>crypto.getRandomValues(e));class ts{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(es(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var is=()=>ss().toString(),ss=()=>(Zi||(Zi=new Qi)).generate(),rs="",ns=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var os={_is_supported:()=>!!fe,_error(e){qi.error("cookieStore error: "+e)},_get(e){if(fe){try{for(var t=e+"=",i=fe.cookie.split(";").filter((e=>e.length)),s=0;i.length>s;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(e){var t;try{t=JSON.parse(os._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(fe)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=fe),rs)return rs;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_"+is();!rs&&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",rs=n)}return rs}(e);if(!i){var s=(e=>{var t=e.match(ns);return t?t[0]:""})(e);s!==i&&qi.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(fe.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&qi.warn("cookieStore warning: large cookie, len="+u.length),fe.cookie=u,u}catch(e){return}},_remove(e,t){if(null!=fe&&fe.cookie)try{os._set(e,"",-1,t)}catch(e){return}}},as=null,ls={_is_supported(){if(!je(as))return as;var e=!0;if(ze(pe))e=!1;else try{var t="__mplssupport__";ls._set(t,"xyz"),'"xyz"'!==ls._get(t)&&(e=!1),ls._remove(t)}catch(t){e=!1}return e||qi.error("localStorage unsupported; falling back to cookie store"),as=e,e},_error(e){qi.error("localStorage error: "+e)},_get(e){try{return null==pe?void 0:pe.localStorage.getItem(e)}catch(e){ls._error(e)}return null},_parse(e){try{return JSON.parse(ls._get(e))||{}}catch(e){}return null},_set(e,t){try{null==pe||pe.localStorage.setItem(e,JSON.stringify(t))}catch(e){ls._error(e)}},_remove(e){try{null==pe||pe.localStorage.removeItem(e)}catch(e){ls._error(e)}}},us=[a,"distinct_id",S,k,Y,J,U],cs={},ds={_is_supported:()=>!0,_error(e){qi.error("memoryStorage error: "+e)},_get:e=>cs[e]||null,_parse:e=>cs[e]||null,_set(e,t){cs[e]=t},_remove(e){delete cs[e]}},_s=null,hs={_is_supported(){if(!je(_s))return _s;if(_s=!0,ze(pe))_s=!1;else try{var e="__support__";hs._set(e,"xyz"),'"xyz"'!==hs._get(e)&&(_s=!1),hs._remove(e)}catch(e){_s=!1}return _s},_error(e){qi.error("sessionStorage error: ",e)},_get(e){try{return null==pe?void 0:pe.sessionStorage.getItem(e)}catch(e){hs._error(e)}return null},_parse(e){try{return JSON.parse(hs._get(e))||null}catch(e){}return null},_set(e,t){try{null==pe||pe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){hs._error(e)}},_remove(e){try{null==pe||pe.sessionStorage.removeItem(e)}catch(e){hs._error(e)}}};class ps{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===re||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===se}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}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 Ze(e)?1:Fe(et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ls:os;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?os:ls;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Ze(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==ve?void 0:ve.doNotTrack,null==ve?void 0:ve.msDoNotTrack,Se.doNotTrack].some((e=>Ze(e)))}}var gs=zi("[Dead Clicks]"),vs=()=>!0,fs=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),s=e.instance.config.capture_dead_clicks;return Ve(s)?s:!!De(s)||i};class ms{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[v]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?gs.error("failed to load script",t):e()}))}_start(){var e;if(fe){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Se.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=De(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Se.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(fe),gs.info("starting...")}}else gs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,gs.info("stopping..."))}}var ys=zi("[SegmentIntegration]");var bs="posthog-js";function ws(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,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,g=(null==(l=t.exception)?void 0:l.values)||[],v=g.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}))),f={$exception_message:(null==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=g[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class xs{constructor(e,t,i,s,r,n){this.name=bs,this.setupOnce=function(o){o(ws(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}class Es{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(qi.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==pe?void 0:pe.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:u,maxContentY:c}=r;if(!(ze(n)||ze(o)||ze(a)||ze(l)||ze(u)||ze(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?tt(o/n,0,1,qi):1,_=n>1?tt(a/n,0,1,qi):1,h=l>1?tt(u/l,0,1,qi):1,p=l>1?tt(c/l,0,1,qi):1;s=ji(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:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$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 Ss={[o]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[_]:{exposure:"event"},[h]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[S]:{exposure:"hidden"},[k]:{exposure:"event"},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},[C]:{exposure:"derived",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!De(e))return{};for(var t={},i=Object.keys(e),s=0;i.length>s;s++)t["$feature/"+i[s]]=e[i[s]];return t}},[P]:{exposure:"event"},[I]:{exposure:"hidden"},[F]:{exposure:"hidden"},[T]:{exposure:"event"},[R]:{exposure:"event"},[L]:{exposure:"event"},[M]:{exposure:"hidden"},[O]:{exposure:"hidden"},[A]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"event"},[z]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[H]:{exposure:"hidden"},[N]:{exposure:"hidden"},[j]:{exposure:"hidden"},[B]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"hidden"},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[Z]:{exposure:"event"},[ee]:{exposure:"event"},[te]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},ks=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Cs=e=>{var t=null==fe?void 0:fe.createElement("a");return ze(t)?null:(t.href=e,t)},Ps=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!Oe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){qi.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Is=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Oe(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=r&&(_+="#"+r),_},Fs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ts="https?://(.*)",Rs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ls=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Rs],$s="<masked>",Ms=["li_fat_id"];function Os(e,t,i){if(!fe)return{};var s,r=t?[...Rs,...i||[]]:[],n=As(Is(fe.URL,r,$s),e),o=(s={},Ni(Ms,(function(e){var t=os._get(e);s[e]=t||null})),s);return ji(o,n)}function As(e,t){var i=Ls.concat(t||[]),s={};return Ni(i,(function(t){var i=Ps(e,t);s[t]=i||null})),s}function Ds(e){var t=function(e){return e?0===e.search(Ts+"google.([^/?]*)")?"google":0===e.search(Ts+"bing.com")?"bing":0===e.search(Ts+"yahoo.com")?"yahoo":0===e.search(Ts+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!je(t)){s.$search_engine=t;var r=fe?Ps(fe.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function qs(){return navigator.language||navigator.userLanguage}var zs="$direct";function Hs(){return(null==fe?void 0:fe.referrer)||zs}function Ns(e,t){var i=e?[...Rs,...t||[]]:[],s=null==me?void 0:me.href.substring(0,1e3);return{r:Hs().substring(0,1e3),u:s?Is(s,i,$s):void 0}}function js(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:i==zs?zs:null==(t=Cs(i))?void 0:t.host};if(s){r.$current_url=s;var n=Cs(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=As(s);ji(r,o)}if(i){var a=Ds(i);ji(r,a)}return r}function Bs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Us(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Ws=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Vs{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&&qi.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Ws.indexOf(e.persistence.toLowerCase())&&(qi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...us,...e];return i({},ls,{_parse(e){try{var t={};try{t=os._parse(e)||{}}catch(e){}var i=ji(t,JSON.parse(ls._get(e)||"{}"));return ls._set(e,i),i}catch(e){}return null},_set(e,i,s,r,n,o){try{ls._set(e,i,void 0,void 0,o);var a={};t.forEach((e=>{i[e]&&(a[e]=i[e])})),Object.keys(a).length&&os._set(e,a,s,r,n,o)}catch(e){ls._error(e)}},_remove(e,t){try{null==pe||pe.localStorage.removeItem(e),os._remove(e,t)}catch(e){ls._error(e)}}})}(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return"localstorage"===s&&ls._is_supported()?ls:"localstorage+cookie"===s&&t._is_supported()?t:"sessionstorage"===s&&hs._is_supported()?hs:"memory"===s?ds:"cookie"===s?os:t._is_supported()?t:os}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[B];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Ni(this.props,((t,i)=>{var s=(e=>{var t=Ss[e];if(t)return t;for(var[i,s]of ks)if(0===e.indexOf(i))return s})(i);if("derived"===(null==s?void 0:s.exposure)){if(null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;s.transformToEventProperties&&ji(e,s.transformToEventProperties(t))}else s&&"event"!==s.exposure||(e[i]=t)})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=ji({},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(De(e)){ze(t)&&(t="None"),this._expire_days=ze(i)?this._default_expiry:i;var s=!1;if(Ni(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(De(e)){this._expire_days=ze(t)?this._default_expiry:t;var i=!1;if(Ni(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this._setProp(s,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=Os(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);qe(Vi(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==fe?void 0:fe.referrer)?Ds(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Hs(),$referring_domain:null!=fe&&fe.referrer&&(null==(e=Cs(fe.referrer))?void 0:e.host)||zs},void 0)}set_initial_person_info(){this.props[G]||this.props[K]||this.register_once({[J]:Ns(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Ni([K,G],(t=>{var i=this.props[t];i&&Ni(i,(function(t,i){e["$initial_"+Re(i)]=t}))}));var t,i,s=this.props[J];if(s){var r=(t=js(s),i={},Ni(t,(function(e,t){i["$initial_"+Re(t)]=e})),i);ji(e,r)}return e}safe_merge(e){return Ni(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||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every(((e,t)=>e===s[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){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[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return ze(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){this.props[e]=t}_deleteProp(e){delete this.props[e]}}var Gs="events",Ks="cancelEvents",Js="survey shown",Ys="survey sent",Xs="popover",Qs=zi("[RateLimiter]");class Zs{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Qs.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Qs.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var{captureEventsBurstLimit:r,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(V))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(V,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var er=zi("[RemoteConfig]");class tr{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Se._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):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 er.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void er.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return er.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){er.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){this._instance._shouldDisableFlags()||"hidden"===(null==fe?void 0:fe.visibilityState)||this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e){var t;e||er.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var ir="gzip-js",sr="base64",rr=Uint8Array,nr=Uint16Array,or=Uint32Array,ar=new rr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),lr=new rr([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]),ur=new rr([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 nr(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new or(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},dr=cr(ar,2),_r=dr[1];dr[0][28]=258,_r[258]=28;for(var hr=cr(lr,0)[1],pr=new nr(32768),gr=0;32768>gr;++gr){var vr=(43690&gr)>>>1|(21845&gr)<<1;pr[gr]=((65280&(vr=(61680&(vr=(52428&vr)>>>2|(13107&vr)<<2))>>>4|(3855&vr)<<4))>>>8|(255&vr)<<8)>>>1}var fr=function(e,t,i){for(var s=e.length,r=0,n=new nr(t);s>r;++r)++n[e[r]-1];var o,a=new nr(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new nr(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[pr[d]>>>l]=u}else for(o=new nr(s),r=0;s>r;++r)o[r]=pr[a[e[r]-1]++]>>>15-e[r];return o},mr=new rr(288);for(gr=0;144>gr;++gr)mr[gr]=8;for(gr=144;256>gr;++gr)mr[gr]=9;for(gr=256;280>gr;++gr)mr[gr]=7;for(gr=280;288>gr;++gr)mr[gr]=8;var yr=new rr(32);for(gr=0;32>gr;++gr)yr[gr]=5;var br=fr(mr,9,0),wr=fr(yr,5,0),xr=function(e){return(e/8>>0)+(7&e&&1)},Er=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof nr?nr:e instanceof or?or:rr)(i-t);return s.set(e.subarray(t,i)),s},Sr=function(e,t,i){var s=t/8>>0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},kr=function(e,t,i){var s=t/8>>0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Cr=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new rr(0),0];if(1==r){var o=new rr(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;r>s;++s)n[s].s>_&&(_=n[s].s);var h=new nr(_+1),p=Pr(i[c-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}));r>s;++s){var m=n[s].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>h[y]?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 rr(h),p]},Pr=function(e,t,i){return-1==e.s?Math.max(Pr(e.l,t,i+1),Pr(e.r,t,i+1)):t[e.s]=i},Ir=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new nr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++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]},Fr=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},Tr=function(e,t,i){var s=i.length,r=xr(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;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Rr=function(e,t,i,s,r,n,o,a,l,u,c){Sr(t,c++,i),++r[256];for(var d=Cr(r,15),_=d[0],h=d[1],p=Cr(n,15),g=p[0],v=p[1],f=Ir(_),m=f[0],y=f[1],b=Ir(g),w=b[0],x=b[1],E=new nr(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=Cr(E,7),C=k[0],P=k[1],I=19;I>4&&!C[ur[I-1]];--I);var F,T,R,L,M=u+5<<3,O=Fr(r,mr)+Fr(n,yr)+o,A=Fr(r,_)+Fr(n,g)+o+14+3*I+Fr(E,C)+(2*E[16]+3*E[17]+7*E[18]);if(O>=M&&A>=M)return Tr(t,c,e.subarray(l,l+u));if(Sr(t,c,1+(O>A)),c+=2,O>A){F=fr(_,h,0),T=_,R=fr(g,v,0),L=g;var D=fr(C,P,0);for(Sr(t,c,y-257),Sr(t,c+5,x-1),Sr(t,c+10,I-4),c+=14,S=0;I>S;++S)Sr(t,c+3*S,C[ur[S]]);c+=3*I;for(var q=[m,w],z=0;2>z;++z){var H=q[z];for(S=0;H.length>S;++S)Sr(t,c,D[N=31&H[S]]),c+=C[N],N>15&&(Sr(t,c,H[S]>>>5&127),c+=H[S]>>>12)}}else F=br,T=mr,R=wr,L=yr;for(S=0;a>S;++S)if(s[S]>255){var N;kr(t,c,F[257+(N=s[S]>>>18&31)]),c+=T[N+257],N>7&&(Sr(t,c,s[S]>>>23&31),c+=ar[N]);var j=31&s[S];kr(t,c,R[j]),c+=L[j],j>3&&(kr(t,c,s[S]>>>5&8191),c+=lr[j])}else kr(t,c,F[s[S]]),c+=T[s[S]];return kr(t,c,F[256]),c+T[256]},Lr=new or([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$r=function(){for(var e=new or(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Mr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Or(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=$r[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new rr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Tr(l,u,e.subarray(c,d)):(l[c]=!0,u=Tr(l,u,e.subarray(c,o)))}else{for(var _=Lr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new nr(32768),f=new nr(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 or(25e3),x=new nr(288),E=new nr(32),S=0,k=0,C=(c=0,0),P=0,I=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=P){var L=o-c;if((S>7e3||C>24576)&&L>423){u=Rr(e,l,0,w,x,E,k,C,I,c-I,u),C=S=k=0,I=c;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)E[M]=0}var O=2,A=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var z=Math.min(h,L)-1,H=Math.min(32767,c),N=Math.min(258,L);H>=q&&--D&&T!=R;){if(e[c+O]==e[c+O-q]){for(var j=0;N>j&&e[c+j]==e[c+j-q];++j);if(j>O){if(O=j,A=q,j>z)break;var B=Math.min(q,j-2),U=0;for(M=0;B>M;++M){var W=c-q+M+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}q+=(T=R)-(R=v[T])+32768&32767}if(A){w[C++]=268435456|_r[O]<<18|hr[A];var G=31&_r[O],K=31&hr[A];k+=ar[G]+lr[K],++x[257+G],++E[K],P=c+O,++S}else w[C++]=e[c],++x[e[c]]}}u=Rr(e,l,!0,w,x,E,k,C,I,c-I,u)}return Er(a,0,s+xr(u)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Mr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Mr(u,c-8,i.d()),Mr(u,c-4,s),u}var Ar=!!be||!!ye,Dr="text/plain",qr=!1,zr=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:[],u=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Ni(e,(function(e,t){ze(e)||ze(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)}(a);return u&&l.push(u),n+"?"+l.join("&")},Hr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Nr=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===ir){var s=Or(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new rr(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;i>o;++o){if(r+5>s.length){var a=new rr(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(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 Er(s,0,r)}(Hr(t)),{mtime:0});return{contentType:Dr,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===sr){var r=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(Hr(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:Hr(e)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Hr(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},jr=function(){var e=t((function*(e){var t=Hr(e.data),s=yield function(e,t,i){return ke.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return i({},e,{_encodedBody:{contentType:Dr,body:r,estimatedSize:r.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Br=(e,t)=>zr(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),Ur=[];ye&&Ur.push({transport:"fetch",method(e){var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=Nr(e))&&void 0!==t?t:{},a=new Headers;Ni(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,u=null;if(we){var c=new we;u={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}ye(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&52428.8>(o||0),body:n,signal:null==(s=u)?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){qi.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{qi.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),be&&Ur.push({transport:"XHR",method(e){var t,i=new be;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=Nr(e))&&void 0!==t?t:{};Ni(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!=ve&&ve.sendBeacon&&Ur.push({transport:"sendBeacon",method(e){var t=zr(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Nr(e))&&void 0!==i?i:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:s});ve.sendBeacon(t,n)}catch(e){}}});var Wr=3e3;class Vr{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=tt((null==t?void 0:t.flush_interval_ms)||Wr,250,5e3,qi.createLogger("flush interval"),Wr),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&&Oe(i.data)&&Ni(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 Ni(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;ze(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var Gr=["retriesPerformedSoFar"];class Kr{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!ze(pe)&&"onLine"in pe.navigator&&(this._areWeOnline=pe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Ji(pe,"online",this._onlineListener),Ji(pe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,Gr);We(t)&&(r.url=zr(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200===e.statusCode||e.statusCode>=400&&500>e.statusCode||(null!=t?t:0)>=10?null==r.callback||r.callback(e):this._enqueue(i({retriesPerformedSoFar:t},r))}}))}_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;return Math.ceil(s+r*(s-i))}(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)"),qi.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=>e>i.retryAt||(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,ze(pe)||(this._onlineListener&&(pe.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(pe.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){qi.error(e)}this._queue=[]}}class Jr{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}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Ji(pe,"scroll",this._updateScrollData,{capture:!0}),Ji(pe,"scrollend",this._updateScrollData,{capture:!0}),Ji(pe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==pe?void 0:pe.document.documentElement;var e=Oe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==pe?void 0:pe.document.querySelector(t);if(i)return i}}scrollY(){if(this._scrollRoot){var e=this.scrollElement();return e&&e.scrollTop||0}return pe&&(pe.scrollY||pe.pageYOffset||pe.document.documentElement.scrollTop)||0}scrollX(){if(this._scrollRoot){var e=this.scrollElement();return e&&e.scrollLeft||0}return pe&&(pe.scrollX||pe.pageXOffset||pe.document.documentElement.scrollLeft)||0}}var Yr=e=>Ns(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Xr{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({[W]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Yr,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[W]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?js(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 Ni(Vi(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Re(i)]=t})),e}}class Qr{constructor(){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)}}var Zr=zi("[SessionId]");class en{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 Qr,this._sessionHasBeenIdleTooLong=(e,t)=>!(!We(e)||!We(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===re)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||is,this._windowIdGenerator=i||is;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*tt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zr.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 n=hs._parse(this._window_id_storage_key),o=hs._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:hs._remove(this._window_id_storage_key),hs._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.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._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Zr.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ze(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&&hs._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&hs._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?hs._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({[S]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[S];return Oe(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&&pe&&(pe.removeEventListener(ue,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&hs._remove(this._primary_window_exists_storage_key)},Ji(pe,ue,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===re)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=We(n)&&Math.abs(i-n)>864e5,l=!1,u=!r,c=!u&&!e&&this._sessionHasBeenIdleTooLong(i,s);u||c||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Zr.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=We(s)&&e&&!a?s:i,_=We(n)?n:(new Date).getTime();return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,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 tn=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Pe(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>Pe(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},sn=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 rn(e,t,i){return Hr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var nn={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=>sn(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!sn(t,e))))),icontains:(e,t)=>t.map(on).some((t=>e.map(on).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(on).every((t=>e.map(on).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)))}))},on=e=>e.toLowerCase();function an(e,t){return!e||Object.entries(e).every((e=>{var[i,s]=e,r=null==t?void 0:t[i];if(ze(r)||je(r))return!1;var n=[String(r)],o=nn[s.operator];return!!o&&o(s.values,n)}))}var ln="custom",un="i.posthog.com",cn=/^\/static\//;class dn{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("."+un,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":ln),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if("string"==typeof t&&cn.test(e))return t.trim().replace(/\/$/,"")||void 0}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("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===ln)return this.apiHost+t;var s=un+t;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}}var _n=zi("[Surveys]"),hn="seenSurvey_",pn=["popover","widget","api"],gn={ignoreConditions:!1,ignoreDelay:!1,displayType:Xs},vn=zi("[PostHog ExternalIntegrations]"),fn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class mn{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return vn.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;!s||null!=(i=Se.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(fn[t],(()=>{var i;null==(i=Se.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=Se.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t]&&(null==(n=Se.__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 yn,bn={},wn=0,xn=()=>{},En='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Sn="Surveys module not available",kn="sanitize_properties is deprecated. Use before_send instead",Cn="Invalid value for property_denylist config: ",Pn="posthog",In=!Ar&&-1===(null==Ee?void 0:Ee.indexOf("MSIE"))&&-1===(null==Ee?void 0:Ee.indexOf("Mozilla")),Fn=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:Ki(null==fe?void 0:fe.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:xn,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,__preview_external_dependency_versioned_paths:!1,debug:me&&He(null==me?void 0:me.search)&&-1!==me.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:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==pe||null==(t=pe.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_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){qi.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ae,before_send:void 0,request_queue_config:{flush_interval_ms:Wr},error_tracking:{},_onCapture:xn,__preview_eager_load_replay:!1},(e=>({rageclick:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},Tn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Rn=e=>{var t={};for(var[i,s]of Tn)ze(e[i])||(t[s]=e[i]);var r=ji({},t,e);return Oe(e.property_blacklist)&&(ze(e.property_denylist)?r.property_denylist=e.property_blacklist:Oe(e.property_denylist)?r.property_denylist=[...e.property_blacklist,...e.property_denylist]:qi.error(Cn+e.property_denylist)),r};class Ln{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){qi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class $n{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===re||this.config.cookieless_mode===se&&this.consent.isRejected()}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(){var e;this.webPerformance=new Ln,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new Qr,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fn(),this.SentryIntegration=xs,this.sentryIntegration=e=>function(e,t){var i=ws(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.scrollManager=new Jr(this),this.pageViewManager=new Es(this),this.rateLimiter=new Zs(this),this.requestRouter=new dn(this),this.consent=new ps(this),this.externalIntegrations=new mn(this);var t=null!==(e=$n.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var s=He(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=He(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>qi.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Pn){var s,r=null!==(s=bn[i])&&void 0!==s?s:new $n;return r._init(e,t,i),bn[i]=r,bn[Pn][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var r,o;if(void 0===t&&(t={}),ze(e)||Ne(e))return qi.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:t.process_person&&(this._initialPersonProfilesConfig=t.process_person),this.set_config(ji({},Fn(t.defaults),Rn(t),{name:s,token:e})),this.config.on_xhr_error&&qi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ir;var a=this._is_persistence_disabled();this.persistence=new Vs(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Vs(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),u=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Vr((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Kr(this),this.__request_queue=[];var c=this._inCookielessMode();if(c||(this.sessionManager=new en(this),this.sessionPropsManager=new Xr(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(qi.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(qi.info("Initializing extensions synchronously"),this._initExtensions(c)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&qi.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d=t.bootstrap.distinctID,_=this.get_distinct_id(),h=this.persistence.get_property(U);if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===ne)this.identify(d);else if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===oe)qi.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var p=this.config.get_device_id(is()),g=t.bootstrap.isIdentifiedID?p:d;this.persistence.set_property(U,t.bootstrap.isIdentifiedID?oe:ne),this.register({distinct_id:d,$device_id:g})}}if(c)this.register_once({distinct_id:Q,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(is());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(U,ne)}return Ji(pe,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(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()||is();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(U,oe)),t()},r=i.user();"then"in r&&Ae(r.then)?r.then(s):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||ys.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()||(ys.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(ys.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,ce),identify:e=>t(e,_e),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Ae(this.config._onCapture)&&this.config._onCapture!==xn&&(qi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&qi.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,s,r,n,o,a,l,u=performance.now(),c=i({},$n.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(s=this.exceptions)&&void 0!==s?s:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,fs)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&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){qi.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[Z]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ee]:s}),this.config.__preview_deferred_init_extensions&&qi.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!fe||!fe.body)return qi.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._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Fe(e.supportedCompression,ir)?ir:Fe(e.supportedCompression,sr)?sr:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ae}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){qi.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=me&&me.hostname){var e=me.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()}),1),this._remoteConfigLoader=new tr(this),this._remoteConfigLoader.load()}_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()&&Hi(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s;null==(e=this.surveys)||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(de),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(s=this._retryQueue)||s.unload()):this._shouldCapturePageleave()&&this.capture(de,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(In?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=zr(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=Br(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=Ur.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===ir&&xe&&!qr?jr(n).then((e=>{l(e)})).catch((t=>{if((e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""))(t))return qr=!0,void l(i({},n,{compression:void 0,url:Br(e.url,void 0)}));l(n)})):l(n)})(i({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),400>t.statusCode||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){wn++;try{var t,i=[],s=[],r=[];Hi(e,(e=>{e&&(Oe(t=e[0])?r.push(e):Ae(e)?e.call(this):Oe(e)&&"alias"===t?i.push(e):Oe(e)&&-1!==t.indexOf("capture")&&Ae(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Hi(e,(function(e){if(Oe(e[0])){var i=t;Ni(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};n(i,this),n(s,this),n(r,this)}finally{wn--}}push(e){if(wn>0&&Oe(e)&&He(e[0])){var t=$n.prototype[e[0]];Ae(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!ze(e)&&He(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!He(null==t?void 0:t.$current_url)&&(qi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=s&&s._originatedFromCaptureException||qi.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,_=(null==s?void 0:s.timestamp)||d,h=is(),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===ce&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==s?void 0:s.$set)&&(p.$set=null==s?void 0:s.$set);var g,v,f,m=this._calculate_set_once_properties(null==s?void 0:s.$set_once,e!==he,e===_e);if(m&&(p.$set_once=m),null!=s&&s._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>He(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Oe(t)?(s=[],Hi(t,(t=>{s.push(e(t))}))):(s={},Ni(t,((t,i)=>{l.has(t)||(s[i]=e(t,i))}))),s);var s}(o)),p.timestamp=_,ze(null==s?void 0:s.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),"survey dismissed"===e||e===Ys){var y=null==t?void 0:t.$survey_id,b=null==t?void 0:t.$survey_iteration;(e=>{try{var t=(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))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){_n.error("Failed to persist survey seen state",e)}})({id:y,current_iteration:b}),p.$set=i({},p.$set,{[(g={id:y,current_iteration:b},v=e===Ys?"responded":"dismissed",f="$survey_"+v+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(f="$survey_"+v+"/"+g.id+"/"+g.current_iteration),f)]:!0})}else e===Js&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var w=null==t?void 0:t.$product_tour_type;w&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+w]:(new Date).toISOString()}))}var x=i({},p.properties.$set,p.$set);if(qe(x)||this.setPersonPropertiesForFlags(x),!Be(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;p=E}this._internalEventEmitter.emit("eventCaptured",p);var S={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,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(S):this._requestQueue.enqueue(S),p}qi.critical("This capture call is ignored due to client rate limiting.")}}else qi.error("No event name provided to posthog.capture")}else qi.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,o){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!He(l.distinct_id)&&!Ue(l.distinct_id)||Ne(l.distinct_id))&&qi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t){var i,s,r,o;if(!Ee)return{};var a,l,u,c,d,_,h,p,g=e?[...Rs,...t||[]]:[],[v,f]=function(e){for(var t=0;Zt.length>t;t++){var[i,s]=Zt[t],r=i.exec(e),n=r&&(Ae(s)?s(r,e):s);if(n)return n}return["",""]}(Ee);return ji(Vi({$os:v,$os_version:f,$browser:Yt(Ee,navigator.vendor),$device:ei(Ee),$device_type:(l=Ee,u={userAgentDataPlatform:null==(i=navigator)||null==(i=i.userAgentData)?void 0:i.platform,maxTouchPoints:null==(s=navigator)?void 0:s.maxTouchPoints,screenWidth:null==pe||null==(r=pe.screen)?void 0:r.width,screenHeight:null==pe||null==(o=pe.screen)?void 0:o.height,devicePixelRatio:null==pe?void 0:pe.devicePixelRatio},p=ei(l),p===dt||p===ct||"Kobo"===p||"Kindle Fire"===p||p===Nt?ut:p===Tt||p===Lt||p===Rt||p===qt?"Console":p===ht?"Wearable":p?ot:"Android"===(null==u?void 0:u.userAgentDataPlatform)&&(null!==(c=null==u?void 0:u.maxTouchPoints)&&void 0!==c?c:0)>0?600>Math.min(null!==(d=null==u?void 0:u.screenWidth)&&void 0!==d?d:0,null!==(_=null==u?void 0:u.screenHeight)&&void 0!==_?_:0)/(null!==(h=null==u?void 0:u.devicePixelRatio)&&void 0!==h?h:1)?ot:ut:"Desktop"),$timezone:Bs(),$timezone_offset:Us()}),{$current_url:Is(null==me?void 0:me.href,g,$s),$host:null==me?void 0:me.host,$pathname:null==me?void 0:me.pathname,$raw_user_agent:Ee.length>1e3?Ee.substring(0,997)+"...":Ee,$browser_version:Qt(Ee,navigator.vendor),$browser_language:qs(),$browser_language_prefix:(a=qs(),"string"==typeof a?a.split("-")[0]:void 0),$screen_height:null==pe?void 0:pe.screen.height,$screen_width:null==pe?void 0:pe.screen.width,$viewport_height:null==pe?void 0:pe.innerHeight,$viewport_width:null==pe?void 0:pe.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,s.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&ji(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&ji(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ln&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ce||o?e!==de||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),l=ji(l,c),e===ce&&fe&&(l.title=fe.title),!ze(a)){var g=s.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Ee&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=ji({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Oe(this.config.property_denylist)?Ni(this.config.property_denylist,(function(e){delete l[e]})):qi.error(Cn+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(qi.error(kn),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=this.persistence.get_initial_props(),n=null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps(),o=ji({},r,n||{},e||{}),a=this.config.sanitize_properties;return a&&(qi.error(kn),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),qe(o)?void 0:o}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){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Sn}),()=>{})}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?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Sn})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Sn})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=gn),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Sn}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Sn})}_validateIdentifyId(e){return!e||Ne(e)?(qi.critical("Unique user id has not been set in posthog.identify"),!1):e===Q?(qi.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(qi.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return qi.uninitializedWarning("posthog.identify");if(Ue(e)&&(e=e.toString(),qi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var s=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var r,n=(this.persistence.get_property(U)||ne)===ne;e!==s&&n?(this.persistence.set_property(U,oe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(_e,{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=rn(e,t,i),null==(r=this.featureFlags)||r.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(H))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=rn(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):qi.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(),n=r[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),n||s){var o={$group_type:e,$group_key:t};s&&(o.$group_set=s),this.capture(he,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),n&&!s&&this.reloadFeatureFlags()}else qi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r,n,o,l,u;if(qi.info("reset"),!this.__loaded)return qi.uninitializedWarning("posthog.reset");var c=this.get_property(a);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),null==(s=this.surveys)||s.reset(),null==(r=this._remoteConfigLoader)||r.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.persistence)||l.set_property(U,ne),null==(u=this.sessionManager)||u.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===re)this.register_once({distinct_id:Q,$device_id:null},"");else{var d=this.config.get_device_id(is());this.register_once({distinct_id:d,$device_id:e?d:c},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}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(o)?(qi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(ze(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(qi.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(De(e)){var s,r,o,a,l,u,c,d,_,h;ji(this.config,Rn(e));var p=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Vs(i({},this.config,{persistence:"sessionStorage"}),p);var g=this._checkLocalStorageForDebug(this.config.debug);Ve(g)&&(this.config.debug=g),Ve(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,ls._is_supported()&&ls._set("ph_debug",!0),qi.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,ls._is_supported()&&ls._remove("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(u=this.heatmaps)||u.startIfEnabled(),null==(c=this.exceptionObserver)||c.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(_=this.surveys)||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(h=this.externalIntegrations)||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){n.LIB_NAME=e,n.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.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){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:$n._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}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:Pn;return t!==Pn&&(t=Pn+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(U))===oe||(null==(t=this.sessionPersistence)?void 0:t.get_property(U))===oe}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ae&&!this._isIdentified()&&qe(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[Y]))}_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({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(qi.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Y,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==se)}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();return(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)),r}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==re){if(this._inCookielessMode()){var i,s,r,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(s=this.pageViewManager)||s.destroy(),this.sessionManager=new en(this),this.pageViewManager=new Es(this),this.persistence&&(this.sessionPropsManager=new Xr(this,this.sessionManager,this.persistence));var a,l=null!==(r=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==r?r:null==(o=$n.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==se&&(null==(u=this.surveys)||u.loadIfEnabled()),(ze(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else qi.warn(En)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==re?(this.config.cookieless_mode===se&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===se&&(this.register({distinct_id:Q,$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())):qi.warn(En)}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 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===re||(this.config.cookieless_mode===se?this.consent.isRejected()||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 ve?tn(ve,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){fe&&("visible"===fe.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ce,{title:fe.title},{send_instantly:!0}),this._visibilityStateListener&&(fe.removeEventListener(le,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Ji(fe,le,this._visibilityStateListener)))}debug(e){!1===e?(null==pe||pe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==pe||pe.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=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(qi.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",!1,s=qi,r=(t="advanced_disable_flags")in(e=o)&&!Be(e[t]),n=i in e&&!Be(e[i]),r?e[t]:!!n&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){if(Be(this.config.before_send))return e;var t=Oe(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),Be(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return Ke(e.event)?qi.warn(r+". This can cause unexpected behavior."):qi.info(r),null}i.properties&&!qe(i.properties)||qi.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=Ve(e)&&!e,i=ls._is_supported()&&"true"===ls._get("ph_debug");return!t&&(!!i||e)}}function Mn(e){return e instanceof Element&&(e.id===X||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function On(e){return!!e&&1===e.nodeType}function An(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Dn(e){return!!e&&3===e.nodeType}function qn(e){return!!e&&11===e.nodeType}function zn(e){return e?Te(e).split(/\s+/):[]}function Hn(e){var t=null==pe?void 0:pe.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Nn(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 zn(t)}function jn(e){return Be(e)?null:Te(e).split(/(\s+)/).filter((e=>oo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Bn(e){var t="";return Qn(e)&&!Zn(e)&&e.childNodes&&e.childNodes.length&&Ni(e.childNodes,(function(e){var i;Dn(e)&&e.textContent&&(t+=null!==(i=jn(e.textContent))&&void 0!==i?i:"")})),Te(t)}function Un(e){return ze(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}$n.__defaultExtensionClasses={},$n._noopLogger={trace:yn=()=>{},debug:yn,info:yn,warn:yn,error:yn,fatal:yn},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Wi(e.prototype[t[i]])}($n,["identify"]);var Wn=["a","button","form","input","select","textarea","label"];function Vn(e,t){if(ze(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 Gn(e){var t=e.parentNode;return!(!t||!On(t))&&t}var Kn=["next","previous","prev",">","<"],Jn=[".ph-no-rageclick",".ph-no-capture"];var Yn=e=>!e||An(e,"html")||!On(e),Xn=(e,t)=>{if(!pe||Yn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],r=e;r.parentNode&&!An(r,"body");)if(qn(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Gn(r);if(!n)break;if(t||Wn.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=pe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};function Qn(e){for(var t=e;t.parentNode&&!An(t,"body");t=t.parentNode){var i=Nn(t);if(Fe(i,"ph-sensitive")||Fe(i,"ph-no-capture"))return!1}if(Fe(Nn(e),"ph-include"))return!0;var s=e.type||"";if(He(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";return!He(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function Zn(e){return!!(An(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||An(e,"select")||An(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var eo="(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})",to=new RegExp("^(?:"+eo+")$"),io=new RegExp(eo),so="\\d{3}-?\\d{2}-?\\d{4}",ro=new RegExp("^("+so+")$"),no=new RegExp("("+so+")");function oo(e,t){if(void 0===t&&(t=!0),Be(e))return!1;if(He(e)){if(e=Te(e),(t?to:io).test((e||"").replace(/[- ]/g,"")))return!1;if((t?ro:no).test(e))return!1}return!0}function ao(e){var t=Bn(e);return oo(t=(t+" "+lo(e)).trim())?t:""}function lo(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Ni(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Bn(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+lo(e)).trim())}catch(e){qi.error("[AutoCapture]",e)}})),t}function uo(e){return e.replace(/"|\\"/g,'\\"')}function co(e){var t=e.attr__class;return t?Oe(t)?t:zn(t):void 0}class _o{constructor(e){this.disabled=!1===e;var t=De(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&&this.timeoutMs>i-s.timestamp){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 ho="$copy_autocapture",po=zi("[AutoCapture]");function go(e,t){return t.length>e?t.slice(0,e)+"...":t}function vo(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!On(t));return t}function fo(e,t){for(var s,r,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t,c=[e],d=e;d.parentNode&&!An(d,"body");)qn(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var _,h,p=[],g={},v=!1,f=!1;if(Ni(c,(e=>{var t=Qn(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&oo(v)&&v),Fe(Nn(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Wn.indexOf(r)>-1&&!i&&(n.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?go(1024,ao(e)):go(1024,Bn(e)));var o=Nn(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Ni(e.attributes,(function(i){var r;if((!Zn(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==s||!s.includes(i.name))&&!t&&oo(i.value)&&(!He(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){var o=i.value;"class"===i.name&&(o=zn(o).join(" ")),n["attr__"+i.name]=go(1024,o)}}));for(var a=1,l=1,u=e;u=vo(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var i=function(e){if(!Qn(e))return{};var t={};return Ni(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&&oo(s)&&(t[i]=s)}})),t}(e);ji(g,i)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text="a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?ao(e):Bn(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Cs(v))?void 0:m.host,w=null==pe||null==(y=pe.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:ji({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return 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 Bi(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[uo(t.toString())]=uo(i.toString())})),(r+=":")+Bi(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).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:co(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Bi(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(h)))},null!=(s=p[0])&&s.$el_text?{$el_text:null==(r=p[0])?void 0:r.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var mo=zi("[ExceptionAutocapture]");function yo(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return Ae(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}var bo=zi("[TracingHeaders]"),wo=zi("[Web Vitals]"),xo=9e5,Eo="disabled",So="lazy_loading",ko="awaiting_config",Co="missing_config";zi("[SessionRecording]"),zi("[SessionRecording]");var Po="[SessionRecording]",Io=zi(Po),Fo=zi("[Heatmaps]");function To(e){return De(e)&&"clientX"in e&&"clientY"in e&&Ue(e.clientX)&&Ue(e.clientY)}var Ro=zi("[Product Tours]"),Lo=["$set_once","$set"],$o=zi("[SiteApps]"),Mo="Error while initializing PostHog app with config id ";function Oo(e,t,i){if(Be(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 Ao{constructor(e){this._debugEventEmitter=new Qr,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,t;ze(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!ze(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(!Oo(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=>Oo(e.href,t.href,t.href_matching||"exact")));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Oo((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=>Oo(e.text,t.text,t.text_matching||"exact")||Oo(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;!Be(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=>Oo(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||an(t.properties.reduce(((e,t)=>{var i=Oe(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 Do{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&an(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===Gs?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;ze(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}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new Ao(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}));0===i.length&&0===s.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Gs),this._cancelEventToItems=this._buildEventToItemMap(e,Ks))}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 u=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(u){var c=o.indexOf(u);0>c||(o.splice(c,1),this._updateActivatedItems(o))}}else{if(this._cancelEventToItems.has(e)){var d=this._getMatchingItems(e,t,Ks);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);0>t||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,Gs);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=this._getLogger(),i=[...new Set(e)].filter((e=>!this._isItemPermanentlyIneligible(e)));t.info("updating activated items",{activatedItems:i}),this._setActivatedItems(i)}getActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class qo extends Do{constructor(e){super(e)}_getActivatedKey(){return q}_getShownEventName(){return Js}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return _n}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[q]:e})}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var zo="SDK is not enabled or survey functionality is not yet loaded",Ho="Disabled. Not loading surveys.",No=null!=pe&&pe.location?Fs(pe.location.hash,"__posthog")||Fs(location.hash,"state"):null,jo="_postHogToolbarParams",Bo=zi("[Toolbar]"),Uo=zi("[FeatureFlags]"),Wo=zi("[FeatureFlags]",{debugEnabled:!0}),Vo="\" failed. Feature flags didn't load in time.",Go=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Ko=e=>{var t={};for(var[i,s]of Bi(e||{}))s&&(t[i]=s);return t},Jo=zi("[Error tracking]"),Yo="Refusing to render web experiment since the viewer is a likely bot",Xo={icontains:(e,t)=>!!pe&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!pe&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!pe&&sn(t.href,e),not_regex:(e,t)=>!!pe&&!sn(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Qo{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Qo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Qo._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);He(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];Qo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Qo._logInfo(Yo);else if(!this._config.disable_web_experiments){if(Be(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Qo._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=Qo.getWindowLocation();if(null!=e&&e.search){var t=Ps(null==e?void 0:e.search,"__experiment_id"),i=Ps(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Qo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._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._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(Qo._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!Be(e.conditions)&&Qo._matchUrlConditions(e)&&Qo._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=Qo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||Xo[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==pe?void 0:pe.location}static _matchUTMConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Os();if(i.utm_source){var s,r,n,o,a,l,u,c,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==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.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;t>s;s++)i[s-1]=arguments[s];qi.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Qo._logInfo(Yo):"control"!==t?i.forEach((i=>{if(i.selector){var s;Qo._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)}))}})):Qo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ve&&this._instance?tn(ve,this._config.custom_blocked_useragents):void 0}}var Zo,ea,ta=zi("[Conversations]"),ia="Conversations not available yet.",sa={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,Uo.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(Uo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Uo.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}initialize(){var e,t,{config:i}=this._instance,s=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var r,n,o=null!==(r=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==r?r:{},a=Object.keys(s).filter((e=>!!s[e])).reduce(((e,t)=>(e[t]=s[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,s){var r=null!=s&&s.merge?this.getFlagVariants():{},n=null!=s&&s.merge?this.getFlagPayloads():{},o=i({},r,e),a=i({},n,t),l={};for(var[u,c]of Object.entries(o)){var d="string"==typeof c;l[u]={key:u,enabled:!!d||Boolean(c),variant:d?c:void 0,reason:void 0,metadata:ze(null==a?void 0:a[u])?void 0:{id:0,version:void 0,description:void 0,payload:a[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(F),t=this._prop(L),s=this._prop(M);if(!s&&!t)return e||{};var r=ji({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=r[o],c=null==t?void 0:t[o],d=ze(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=ze(c)?u.variant:"string"==typeof c?c:void 0,h=null==s?void 0:s[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),r[o]=p}return this._override_warning||(Uo.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._prop(C),t=this._prop(L);if(!t)return e||{};for(var i=ji({},e),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(Uo.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(T),t=this._prop(M);if(!t)return e||{};for(var i=ji({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(Uo.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),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._config.token,r=this._prop(a),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._persistence)?void 0:t.get_initial_props())||{},this._prop(O)||{}),group_properties:this._prop(A),timezone:Bs()};je(r)||ze(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:o,data:n,compression:this._config.disable_compression?void 0:sr,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s,r=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),r=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!r;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,l=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(l&&o.push("quota_limited"),null==(s=this._persistence)||s.register({[j]:o}),l)Uo.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 n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},r,{partialResponse:!!this._config.advanced_only_evaluate_survey_feature_flags}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}}else Uo.warn('getFeatureFlag for key "'+e+Vo)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),s=e in i,r=i[e],n=this.getFlagPayloads()[e],o=String(r),a=this._prop(R)||void 0,l=this._prop(B)||void 0,u=this._prop(H)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(N);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[H]:u,[N]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,x;Oe(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[H]:u});var E=this.getFeatureFlagDetails(e),S=[...null!==(p=this._prop(j))&&void 0!==p?p:[]];ze(r)&&S.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};ze(null==E||null==(f=E.metadata)?void 0:f.version)||(k.$feature_flag_version=E.metadata.version);var C,P=null!==(m=null==E||null==(y=E.reason)?void 0:y.description)&&void 0!==m?m:null==E||null==(b=E.reason)?void 0:b.code;P&&(k.$feature_flag_reason=P),null!=E&&null!=(w=E.metadata)&&w.id&&(k.$feature_flag_id=E.metadata.id),ze(null==E?void 0:E.original_variant)&&ze(null==E?void 0:E.original_enabled)||(k.$feature_flag_original_response=ze(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(x=E.metadata)&&x.original_payload&&(k.$feature_flag_original_payload=null==E||null==(C=E.metadata)?void 0:C.original_payload),S.length&&(k.$feature_flag_error=S.join(",")),this._instance.capture("$feature_flag_called",k)}if(s){var I=n;if(!ze(n))try{I=JSON.parse(n)}catch(e){}return{key:e,enabled:!!r,variant:"string"==typeof r?r:void 0,payload:I}}}}else Uo.warn('getFeatureFlagResult for key "'+e+Vo)}getRemoteConfigPayload(e,t){var i=this._config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_contexts=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this._config.disable_compression?void 0:sr,timeout:this._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={}),!t.fresh||this._flagsLoadedFromRemote){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return ze(i)?void 0:!!i}Uo.warn('isFeatureEnabled for key "'+e+Vo)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,s){if(this._persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,s,r,n,o){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var a=(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]})))):Uo.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,_=e.evaluatedAt;if(Oe(u)){Uo.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[P]:u,[C]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},s,g),v=i({},r,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},s,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},r,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},s,g),v=i({},r,v),f=i({},n,f);t&&t.register(i({[P]:Object.keys(Ko(g)),[C]:g||{},[T]:v||{},[F]:f||{}},d?{[R]:d}:{},_?{[B]:_}:{}))}}}(e,this._persistence,r,n,o,s),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Uo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Uo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(L),this._persistence.unregister(M),this._fireFeatureFlagsCallbacks(),Wo.info("All overrides cleared");if(Oe(e)){var t=Go(e);return this._persistence.register({[L]:t}),this._fireFeatureFlagsCallbacks(),Wo.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,s=e;if(this._override_warning=Boolean(null!==(i=s.suppressWarning)&&void 0!==i&&i),"flags"in s)if(!1===s.flags)this._persistence.unregister(L),Wo.info("Flag overrides cleared");else if(s.flags){if(Oe(s.flags)){var r=Go(s.flags);this._persistence.register({[L]:r})}else this._persistence.register({[L]:s.flags});Wo.info("Flag overrides set",{flags:s.flags})}return"payloads"in s&&(!1===s.payloads?(this._persistence.unregister(M),Wo.info("Payload overrides cleared")):s.payloads&&(this._persistence.register({[M]:s.payloads}),Wo.info("Payload overrides set",{payloads:s.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[L]:e}),this._fireFeatureFlagsCallbacks(),Wo.info("Flag overrides set",{flags:e});Uo.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}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._prop(I)||[]).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._persistence)||r.register({[P]:Object.keys(Ko(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._prop(I),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._config.token+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(I),null==(s=this._persistence)||s.register({[I]: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._prop(O)||{},r=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in s||(o[a]=n[a]));this._instance.register({[O]:i({},s,o,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(O)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._prop(A)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[A]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(A)||{};this._instance.register({[A]:i({},t,{[e]:{}})})}else this._instance.unregister(A)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}},ra={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===ko||this._recordingStatus===Co?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Eo,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Io.error("started without valid sessionManager"),new Error(Po+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===re)throw new Error(Po+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return pe&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!ze(Object.assign)&&!ze(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Io.info("starting")):(this._recordingStatus=Eo,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(this._recordingStatus!==ko&&this._recordingStatus!==Co&&(this._recordingStatus=So),null!=Se&&null!=(t=Se.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Se.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=Se.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Io.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()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e;null==(e=this._persistence)||e.unregister(k)}_validateSampleRate(e,t){if(Be(e))return null;var i,s=Ue(e)?e:parseFloat(e);return"number"!=typeof(i=s)||!Number.isFinite(i)||0>i||i>1?(Io.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):s}_persistRemoteConfig(e){if(this._persistence){var t,s,r=this._persistence,n=()=>{var t,s=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==s?void 0:s.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Be(a)&&this._resetSampling();var l=null==s?void 0:s.minimumDurationMilliseconds;r.register({[y]:i({cache_timestamp:Date.now(),enabled:!!s},s,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==s?void 0:s.networkPayloadCapture),canvasRecording:{enabled:null==s?void 0:s.recordCanvas,fps:null==s?void 0:s.canvasFps,quality:null==s?void 0:s.canvasQuality},sampleRate:a,minimumDurationMilliseconds:ze(l)?null:l,endpoint:null==s?void 0:s.endpoint,triggerMatchType:null==s?void 0:s.triggerMatchType,masking:null==s?void 0:s.masking,urlTriggers:null==s?void 0:s.urlTriggers,version:null==s?void 0:s.version,triggerGroups:null==s?void 0:s.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===ko&&(this._recordingStatus=Co,Io.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):Io.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(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t=this._instance.get_property(y);if(!t)return!1;var i=null!==(e=("object"==typeof t?t:JSON.parse(t)).cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-i}_onScriptLoaded(e){var t,i;if(null==(t=Se.__PosthogExtensions__)||!t.initSessionRecording)return Io.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[te]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Se.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Co||this._recordingStatus===ko)return;return this._recordingStatus=ko,Io.info("persisted remote config is stale, requesting fresh config before starting"),void new tr(this._instance).load()}this._recordingStatus=So,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._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[b]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?x:E]:!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))}}},na={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new _o(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=De(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(pe&&fe){var e=e=>{e=e||(null==pe?void 0:pe.event);try{this._captureEvent(e)}catch(e){po.error("Failed to capture event",e)}};if(Ji(fe,"submit",e,{capture:!0}),Ji(fe,"change",e,{capture:!0}),Ji(fe,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{this._captureEvent(e=e||(null==pe?void 0:pe.event),ho)};Ji(fe,"copy",t,{capture:!0}),Ji(fe,"cut",t,{capture:!0})}}}else po.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({[c]:!!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==fe?void 0:fe.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[c];if(je(this._isDisabledServerSide)&&!Ve(i)&&!this.instance._shouldDisableFlags())return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Un(e);Dn(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())&&function(e,t){if(!pe||Yn(e))return!1;var i,s,r;if(Ve(t)?(i=!!t&&Jn,s=void 0):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Jn,s=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Xn(e,!1);return!function(e,t){if(!1===e||ze(e))return!1;var i;if(!0===e)i=Kn;else{if(!Oe(e))return!1;if(e.length>10)return qi.error("[PostHog] content_ignorelist array cannot exceed 10 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,n.map((e=>{var t;return{safeText:Bn(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Vn(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var r=t===ho;if(s&&function(e,t,i,s,r){var n,o,a,l;if(void 0===i&&(i=void 0),!pe||Yn(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!Hn(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&Hn(i.url_ignorelist))return!1;if(null!=(a=i)&&a.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:c,targetElementList:d}=Xn(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(ze(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}(d,i))return!1;if(!Vn(d,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var _=pe.getComputedStyle(e);if(_&&"pointer"===_.getPropertyValue("cursor")&&"click"===t.type)return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return c?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(Wn.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this._config,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=fo(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(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),t===ho){var l,u=jn(null==pe||null==(l=pe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Ae(null==fe?void 0:fe.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==pe||null==(t=pe.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(qi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,qi.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(pe&&pe.history){var i=this;null!=(e=pe.history.pushState)&&e.__posthog_wrapped__||yo(pe.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=pe.history.replaceState)&&t.__posthog_wrapped__||yo(pe.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==pe||null==(t=pe.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(ce,{navigation_type:e}),this._lastPathname=i}catch(t){qi.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Ji(pe,"popstate",e),this._popstateListener=()=>{pe&&pe.removeEventListener("popstate",e)}}}},heatmaps:class{get _config(){return this.instance.config}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[d]),this.rageclicks=new _o(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return De(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Be(this._config.capture_heatmaps)?Be(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Fo.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){if("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]: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)}(fe)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){pe&&fe&&(this._flushHandler=this._flush.bind(this),Ji(pe,ue,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==pe?void 0:pe.event)),Ji(fe,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==pe?void 0:pe.event)),Ji(fe,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new ms(this.instance,vs,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Ji(fe,le,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;pe&&fe&&(this._flushHandler&&pe.removeEventListener(ue,this._flushHandler),this._onClickHandler&&fe.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&fe.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&fe.removeEventListener(le,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(),r=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var s=e;s&&On(s)&&!An(s,"body");){if(s===i)return!1;if(Fe(t,null==pe?void 0:pe.getComputedStyle(s).position))return!0;s=Gn(s)}return!1}(Un(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:s),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!Mn(e.target)&&To(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){!Mn(e.target)&&To(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(pe){var t=pe.location.href,i=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Rs,...i||[]]:[],r=Is(t,s,$s);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(e)}}_flush(){this._buffer&&!qe(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ms,webVitalsAutocapture:class{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(ze(s))wo.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();ze(r)||(Be(null==e?void 0:e.name)||Be(null==e?void 0:e.value)?wo.error("Invalid metric received",e):!this._maxAllowedValue||this._maxAllowedValue>e.value?(this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),ze(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=ze(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()):wo.error("Ignoring metric with value >= "+this._maxAllowedValue,e))}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,s,r=Se.__PosthogExtensions__;ze(r)||ze(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):wo.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=De(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return Be(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(De(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=De(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=De(this._perfConfig)&&Ue(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:xo;return e>0&&6e4>=e?xo:e}get isEnabled(){var e=null==me?void 0:me.protocol;if("http:"!==e&&"https:"!==e)return wo.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=De(this._perfConfig)?this._perfConfig.web_vitals:Ve(this._perfConfig)?this._perfConfig:void 0;return Ve(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(wo.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=De(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=De(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:t}),this._instance.persistence.register({[m]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?wo.error("failed to load script",t):e()}))}_currentURL(){var e=pe?pe.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Rs,...t||[]]:[];return Is(e,i,$s)}wo.error("Could not determine current URL")}}},oa={exceptionObserver:class{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(pe&&this.isEnabled&&null!=(e=Se.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Se.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Se.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=Se.__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){mo.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new it({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:mo}),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 De(e)?t=i({},t,e):(ze(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?(mo.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return mo.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){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,s,r=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(r)?mo.info("Skipping exception capture because of client rate limiting.",{exception:r}):null==(s=this._instance.exceptions)||s.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,s;this._suppressionRules=[],this._errorPropertiesBuilder=new ai([new yi,new Fi,new wi,new bi,new Pi,new Ci,new Ei,new Ii],function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;t>r;r++)s[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=mi.test(l)?l.replace(mi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of s){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||li});var s}))}(n)}}("web:javascript",pi,fi)),this._instance=e,this._suppressionRules=null!==(t=null==(s=this._instance.persistence)?void 0:s.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Oi(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if("errorTracking"in e){var 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({[h]:this._suppressionRules,[p]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),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}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!He(e)||0===e.trim().length)return void Jo.warn("Ignoring exception step because message must be a non-empty string");var s=this._coerceExceptionStepProperties(t),{sanitizedProperties:r,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,s)=>Li.has(s)?(t.push(s),i):(i[s]=e[s],i)),{}),droppedKeys:t}}(s);n.length>0&&Jo.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[Ti]:e,[Ri]:(new Date).toISOString()},r))}catch(e){Jo.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Jo.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Jo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Jo.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&Be(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this._exceptionStepsBuffer.clear(),s}catch(e){return Jo.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Jo.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Jo.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ti]:e,[Ri]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return De(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return He(i)&&i.length>0&&e.$exception_types.push(i),He(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=nn[e.operator],r=Oe(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!Be(e)&&Oe(e)}}},aa=i({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){"productTours"in e&&(this._persistence&&this._persistence.register({[f]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this._productTourManager||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(f)||this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Ro.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Se.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Se.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Oe(this._cachedTours)||t){var i=this._persistence;if(i){var s=i.props[z];if(Oe(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 Ro.error(r),void e([],{isLoaded:!1,error:r})}var n=Oe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[z]:n}),e(n,{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){Be(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._persistence)||e.unregister(z)}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)}}},sa),la={siteApps:class{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=Se._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){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,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,Lo),{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==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&($o.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,$o.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){$o.error(Mo+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){$o.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){$o.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 $o.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;Se["__$$ph_site_app_"+e]=r._instance,null==(t=Se.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return $o.error(Mo+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else $o.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ua={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t,i=this._getConfiguredHostnames()||[];ze(this._restoreXHRPatch)&&(null==(e=Se.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),ze(this._restoreFetchPatch)&&(null==(t=Se.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(i,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return bo.error("failed to load script",t);e()}))}_getConfiguredHostnames(){var e;return null!==(e=this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this._getConfiguredHostnames()?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)}}},ca=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(Be(t))return _n.warn("Flags not loaded yet. Not loading surveys.");var i=Oe(t);this._isSurveysEnabled=i?t.length>0:t,_n.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)_n.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)_n.info(Ho);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())_n.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Se?void 0:Se.__PosthogExtensions__;if(e){if(!ze(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._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(ie);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 _n.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new qo(this._instance),_n.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){_n.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._config.disable_surveys)return _n.info(Ho),e([]);var i,s=this._instance.get_property(D);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._config.token),method:"GET",timeout:this._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;_n.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],u=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))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(s=this._instance.persistence)||s.register({[D]:l});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){_n.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Be(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);_n.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(Be(this._surveyManager))return{eligible:!1,reason:zo};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Be(this._surveyManager))return _n.warn("init was not called"),{visible:!1,disabledReason:zo};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Be(this._surveyManager)?(_n.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:zo})):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,i){var s;if(Be(this._surveyManager))_n.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(pn.includes(r.type)){var n=null==fe?void 0:fe.querySelector(t);if(n)return null!=(s=r.appearance)&&s.surveyPopupDelaySeconds?(_n.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;_n.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,n,i),_n.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,i);_n.warn("Survey element not found")}else _n.warn("Surveys of type "+r.type+" cannot be rendered in the app");else _n.warn("Survey not found")}}displaySurvey(e,t){var s;if(Be(this._surveyManager))_n.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})})),t.displayType!==Xs&&t.initialResponses&&_n.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void _n.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else _n.warn("Survey not found")}}cancelPendingSurvey(e){Be(this._surveyManager)?_n.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},sa),da={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Se.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Se.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Yi(this.instance.config))return!1;if(!pe||!fe)return!1;e=null!=e?e:pe.location,i=null!=i?i:pe.history;try{if(!t){try{pe.localStorage.setItem("test","test"),pe.localStorage.removeItem("test")}catch(e){return!1}t=null==pe?void 0:pe.localStorage}var s,r=No||Fs(e.hash,"__posthog")||Fs(e.hash,"state"),n=r?Ui((()=>JSON.parse(atob(decodeURIComponent(r)))))||Ui((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&"ph_authorize"===n.action?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(jo)||"{}")).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=Se.ph_load_toolbar||Se.ph_load_editor;!Be(t)&&Ae(t)?t(e,this.instance):Bo.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==fe||!fe.getElementById(X));if(!pe||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(pe.localStorage.setItem(jo,JSON.stringify(i({},r,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Se.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Bo.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)})),Ji(pe,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(r)}))}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)}}},_a=i({experiments:Qo},sa),ha={conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;Be(t)||(Ve(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||Yi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Se?void 0:Se.__PosthogExtensions__;if(e&&!ze(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){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(ie);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 ta.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),ta.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else ta.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){ta.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():ta.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!je(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,s){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,i,s):(ta.warn(ia),null)}))()}getMessages(e,i){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,i):(ta.warn(ia),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(ta.warn(ia),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(ta.warn(ia),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(ta.warn(ia),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(ta.warn(ia),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ta.warn(ia),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},pa={logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=zi("[logs]"),this._logBuffer=[],this._intervalLogCount=0,this._intervalWindowStart=0,this._droppedWarned=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!Be(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}reset(){this._logBuffer=[],this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0),this._intervalLogCount=0,this._intervalWindowStart=0,this._droppedWarned=!1}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Se?void 0:Se.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(ie)}else this._logger.error("PostHog Extensions not found.")}}captureLog(e){var t,s,r,n,o,a;if(this._instance.is_capturing())if(e&&e.body){var l=null!==(t=null==(s=this._instance.config.logs)?void 0:s.flushIntervalMs)&&void 0!==t?t:3e3,u=null!==(r=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==r?r:1e3,c=Date.now();if(l>c-this._intervalWindowStart||(this._intervalWindowStart=c,this._intervalLogCount=0,this._droppedWarned=!1),u>this._intervalLogCount){this._intervalLogCount++;var d=function(e,t){var s=e.level||"info",{text:r,number:n}=ii[s]||si,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:r,body:{stringValue:e.body},attributes:ni(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),ze(e.trace_flags)||(u.flags=e.trace_flags),u}(e,this._getSdkContext());this._logBuffer.push({record:d}),(null!==(o=null==(a=this._instance.config.logs)?void 0:a.maxBufferSize)&&void 0!==o?o:100)>this._logBuffer.length?this._scheduleFlush():this.flushLogs()}else this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this._droppedWarned=!0)}else this._logger.warn("captureLog requires a body")}get logger(){return this._logger_instance||(this._logger_instance={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._logger_instance}flushLogs(e){if(this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0),0!==this._logBuffer.length){var t=this._logBuffer;this._logBuffer=[];var s=this._instance.config.logs,r=i({"service.name":(null==s?void 0:s.serviceName)||"unknown_service"},(null==s?void 0:s.environment)&&{"deployment.environment":s.environment},(null==s?void 0:s.serviceVersion)&&{"service.version":s.serviceVersion},null==s?void 0:s.resourceAttributes),o=function(e,t,i,s){return{resourceLogs:[{resource:{attributes:ni(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}(t.map((e=>e.record)),r,n.LIB_NAME,n.LIB_VERSION),a=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance._send_retriable_request({method:"POST",url:a,data:o,compression:"best-available",batchKey:"logs",transport:e})}}_scheduleFlush(){var e,t;this._flushTimeout||(this._flushTimeout=setTimeout((()=>{this._flushTimeout=void 0,this.flushLogs()}),null!==(e=null==(t=this._instance.config.logs)?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3))}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i}if(null!=Se&&null!=(e=Se.location)&&e.href&&(t.currentUrl=Se.location.href),this._instance.featureFlags){var s=this._instance.featureFlags.getFlags();s&&s.length>0&&(t.activeFeatureFlags=s)}return t}}},ga=i({},sa,ra,na,oa,aa,la,ca,ua,da,_a,ha,pa);$n.__defaultExtensionClasses=i({},ga),Zo=bn[Pn]=new $n,(ea=Se.posthog)&&Ni(ea._i,(function(e){if(e&&Oe(e)){var t=Zo.init(e[0],e[1],e[2]),i=ea[e[2]]||ea;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),Se.posthog=Zo,function(){function e(){e.done||(e.done=!0,In=!1,Ni(bn,(function(e){e._dom_loaded()})))}null!=fe&&fe.addEventListener?"complete"===fe.readyState?e():Ji(fe,"DOMContentLoaded",e,{capture:!1}):pe&&qi.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;arguments.length>t;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="1.372.2",n={DEBUG:!1,LIB_VERSION:r,LIB_NAME:"web",JS_SDK_VERSION:r},o="$people_distinct_id",a="$device_id",l="__alias",u="__timers",c="$autocapture_disabled_server_side",d="$heatmaps_enabled_server_side",_="$exception_capture_enabled_server_side",h="$error_tracking_suppression_rules",p="$error_tracking_capture_extension_exceptions",g="$web_vitals_enabled_server_side",v="$dead_clicks_enabled_server_side",f="$product_tours_enabled_server_side",m="$web_vitals_allowed_metrics",y="$session_recording_remote_config",b="$replay_override_sampling",w="$replay_override_linked_flag",x="$replay_override_url_trigger",E="$replay_override_event_trigger",S="$sesid",k="$session_is_sampled",C="$enabled_feature_flags",P="$active_feature_flags",I="$early_access_features",F="$feature_flag_details",T="$feature_flag_payloads",R="$feature_flag_request_id",L="$override_feature_flags",M="$override_feature_flag_payloads",O="$stored_person_properties",A="$stored_group_properties",D="$surveys",q="$surveys_activated",z="ph_product_tours",H="$flag_call_reported",N="$flag_call_reported_session_id",j="$feature_flag_errors",B="$feature_flag_evaluated_at",U="$user_state",W="$client_session_props",V="$capture_rate_limit",G="$initial_campaign_params",K="$initial_referrer_info",J="$initial_person_info",Y="$epp",X="__POSTHOG_TOOLBAR__",Q="$posthog_cookieless",Z="$sdk_debug_extensions_init_method",ee="$sdk_debug_extensions_init_time_ms",te="$sdk_debug_recording_script_not_loaded",ie="PostHog loadExternalDependency extension not found.",se="on_reject",re="always",ne="anonymous",oe="identified",ae="identified_only",le="visibilitychange",ue="beforeunload",ce="$pageview",de="$pageleave",_e="$identify",he="$groupidentify",pe="undefined"!=typeof window?window:void 0,ge="undefined"!=typeof globalThis?globalThis:pe;"undefined"==typeof self&&(ge.self=ge),"undefined"==typeof File&&(ge.File=function(){});var ve=null==ge?void 0:ge.navigator,fe=null==ge?void 0:ge.document,me=null==ge?void 0:ge.location,ye=null==ge?void 0:ge.fetch,be=null!=ge&&ge.XMLHttpRequest&&"withCredentials"in new ge.XMLHttpRequest?ge.XMLHttpRequest:void 0,we=null==ge?void 0:ge.AbortController,xe=null==ge?void 0:ge.CompressionStream,Ee=null==ve?void 0:ve.userAgent,Se=null!=pe?pe:{};function ke(){return ke=t((function*(e,i,s){void 0===i&&(i=!0);try{var r=new CompressionStream("gzip"),n=r.writable.getWriter(),o=n.write((new TextEncoder).encode(e)).then((()=>n.close())).catch(function(){var e=t((function*(e){try{yield n.abort(e)}catch(e){}throw e}));return function(t){return e.apply(this,arguments)}}()),a=new Response(r.readable).blob(),[l]=yield Promise.all([a,o]);return l}catch(e){if(null!=s&&s.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ke.apply(this,arguments)}var Ce=["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"],Pe=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ce.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},Ie=["$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 Fe(e,t){return-1!==e.indexOf(t)}var Te=function(e){return e.trim()},Re=function(e){return e.replace(/^\$/,"")},Le=Object.prototype,$e=Le.hasOwnProperty,Me=Le.toString,Oe=Array.isArray||function(e){return"[object Array]"===Me.call(e)},Ae=e=>"function"==typeof e,De=e=>e===Object(e)&&!Oe(e),qe=e=>{if(De(e)){for(var t in e)if($e.call(e,t))return!1;return!0}return!1},ze=e=>void 0===e,He=e=>"[object String]"==Me.call(e),Ne=e=>He(e)&&0===e.trim().length,je=e=>null===e,Be=e=>ze(e)||je(e),Ue=e=>"[object Number]"==Me.call(e)&&e==e,We=e=>Ue(e)&&e>0,Ve=e=>"[object Boolean]"===Me.call(e),Ge=e=>e instanceof FormData,Ke=e=>Fe(Ie,e);function Je(e){return null===e||"object"!=typeof e}function Ye(e,t){return{}.toString.call(e)==="[object "+t+"]"}function Xe(e){return"undefined"!=typeof Event&&function(e,t){try{return e instanceof t}catch(e){return!1}}(e,Event)}var Qe=[!0,"true",1,"1","yes"],Ze=e=>Fe(Qe,e),et=[!1,"false",0,"0","no"];function tt(e,t,i,s,r){return t>i&&(s.warn("min cannot be greater than max."),t=i),Ue(e)?e>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(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),tt(r||i,t,i,s))}class it{constructor(e){this._buckets={},this._onBucketRateLimited=e._onBucketRateLimited,this._bucketSize=tt(e.bucketSize,0,100,e._logger),this._refillRate=tt(e.refillRate,0,this._bucketSize,e._logger),this._refillInterval=tt(e.refillInterval,0,864e5,e._logger)}_applyRefill(e,t){var i=Math.floor((t-e.lastAccess)/this._refillInterval);i>0&&(e.tokens=Math.min(e.tokens+i*this._refillRate,this._bucketSize),e.lastAccess=e.lastAccess+i*this._refillInterval)}consumeRateLimit(e){var t,i=Date.now(),s=String(e),r=this._buckets[s];return r?this._applyRefill(r,i):this._buckets[s]=r={tokens:this._bucketSize,lastAccess:i},0===r.tokens||(r.tokens--,0===r.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===r.tokens)}stop(){this._buckets={}}}var st,rt,nt,ot="Mobile",at="iOS",lt="Android",ut="Tablet",ct=lt+" "+ut,dt="iPad",_t="Apple",ht=_t+" Watch",pt="Safari",gt="BlackBerry",vt="Samsung",ft=vt+"Browser",mt=vt+" Internet",yt="Chrome",bt=yt+" OS",wt=yt+" "+at,xt="Internet Explorer",Et=xt+" "+ot,St="Opera",kt=St+" Mini",Ct="Edge",Pt="Microsoft "+Ct,It="Firefox",Ft=It+" "+at,Tt="Nintendo",Rt="PlayStation",Lt="Xbox",$t=lt+" "+ot,Mt=ot+" "+pt,Ot="Windows",At=Ot+" Phone",Dt="Nokia",qt="Ouya",zt="Generic",Ht=zt+" "+ot.toLowerCase(),Nt=zt+" "+ut.toLowerCase(),jt="Konqueror",Bt="(\\d+(\\.\\d+)?)",Ut=new RegExp("Version/"+Bt),Wt=new RegExp(Lt,"i"),Vt=new RegExp(Rt+" \\w+","i"),Gt=new RegExp(Tt+" \\w+","i"),Kt=new RegExp(gt+"|PlayBook|BB10","i"),Jt={"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"},Yt=function(e,t){return t=t||"",Fe(e," OPR/")&&Fe(e,"Mini")?kt:Fe(e," OPR/")?St:Kt.test(e)?gt:Fe(e,"IE"+ot)||Fe(e,"WPDesktop")?Et:Fe(e,ft)?mt:Fe(e,Ct)||Fe(e,"Edg/")?Pt:Fe(e,"FBIOS")?"Facebook "+ot:Fe(e,"UCWEB")||Fe(e,"UCBrowser")?"UC Browser":Fe(e,"CriOS")?wt:Fe(e,"CrMo")||Fe(e,yt)?yt:Fe(e,lt)&&Fe(e,pt)?$t:Fe(e,"FxiOS")?Ft:Fe(e.toLowerCase(),jt.toLowerCase())?jt:((e,t)=>t&&Fe(t,_t)||function(e){return Fe(e,pt)&&!Fe(e,yt)&&!Fe(e,lt)}(e))(e,t)?Fe(e,ot)?Mt:pt:Fe(e,It)?It:Fe(e,"MSIE")||Fe(e,"Trident/")?xt:Fe(e,"Gecko")?It:""},Xt={[Et]:[new RegExp("rv:"+Bt)],[Pt]:[new RegExp(Ct+"?\\/"+Bt)],[yt]:[new RegExp("("+yt+"|CrMo)\\/"+Bt)],[wt]:[new RegExp("CriOS\\/"+Bt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Bt)],[pt]:[Ut],[Mt]:[Ut],[St]:[new RegExp("(Opera|OPR)\\/"+Bt)],[It]:[new RegExp(It+"\\/"+Bt)],[Ft]:[new RegExp("FxiOS\\/"+Bt)],[jt]:[new RegExp("Konqueror[:/]?"+Bt,"i")],[gt]:[new RegExp(gt+" "+Bt),Ut],[$t]:[new RegExp("android\\s"+Bt,"i")],[mt]:[new RegExp(ft+"\\/"+Bt)],[xt]:[new RegExp("(rv:|MSIE )"+Bt)],Mozilla:[new RegExp("rv:"+Bt)]},Qt=function(e,t){var i=Yt(e,t),s=Xt[i];if(ze(s))return null;for(var r=0;s.length>r;r++){var n=e.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Zt=[[new RegExp(Lt+"; "+Lt+" (.*?)[);]","i"),e=>[Lt,e&&e[1]||""]],[new RegExp(Tt,"i"),[Tt,""]],[new RegExp(Rt,"i"),[Rt,""]],[Kt,[gt,""]],[new RegExp(Ot,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[At,""];if(new RegExp(ot).test(t)&&!/IEMobile\b/.test(t))return[Ot+" "+ot,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=Jt[i[1]]||"";return/arm/i.test(t)&&(s="RT"),[Ot,s]}return[Ot,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[at,[e[3],e[4],e[5]||"0"].join(".")]:[at,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=ze(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+lt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+lt+")","i"),e=>e&&e[2]?[lt,[e[2],e[3],e[4]||"0"].join(".")]:[lt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||"0"].join(".")),t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[bt,""]],[/Linux|debian/i,["Linux",""]]],ei=function(e){return Gt.test(e)?Tt:Vt.test(e)?Rt:Wt.test(e)?Lt:new RegExp(qt,"i").test(e)?qt:new RegExp("("+At+"|WPDesktop)","i").test(e)?At:/iPad/.test(e)?dt:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?ht:Kt.test(e)?gt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Dt,"i").test(e)?Dt:/(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(ot).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)?lt:ct:new RegExp("(pda|"+ot+")","i").test(e)?Ht:new RegExp(ut,"i").test(e)&&!new RegExp(ut+" pc","i").test(e)?Nt:""},ti=e=>e instanceof Error,ii={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},si=ii.info;function ri(e){if(Ve(e))return{boolValue:e};if("number"==typeof e)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if("string"==typeof e)return{stringValue:e};if(Oe(e))return{arrayValue:{values:e.map((e=>ri(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function ni(e){var t=[];for(var i in e){var s=e[i];je(s)||ze(s)||t.push({key:i,value:ri(s)})}return t}function oi(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return nt&&i.length===rt||(rt=i.length,nt=i.reduce(((i,s)=>{st||(st={});var r=st[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,u=t[s];if(l&&u){i[l]=u,st[s]=[l,u];break}}return i}),{})),nt}}class ai{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(t),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&&Oe(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?t.skipFirstLines: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(e){var t;return{chunkIdMap:oi(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,s){void 0===s&&(s=0);var r=(i,s)=>{if(4>=s){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 li="?";function ui(e,t,i,s,r){var n={platform:e,filename:t,function:"<anonymous>"===i?li:i,in_app:!0};return ze(s)||(n.lineno=s),ze(r)||(n.colno=r),n}var ci=(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]:li,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},di=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,_i=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,hi=/\((\S*)(?::(\d+))(?::(\d+))\)/,pi=(e,t)=>{var i=di.exec(e);if(i){var[,s,r,n]=i;return ui(t,s,li,+r,+n)}var o=_i.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=hi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=ci(o[1]||li,o[2]);return ui(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},gi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,vi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,fi=(e,t)=>{var i=gi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=vi.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]||li;return[n,r]=ci(n,r),ui(t,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},mi=/\(error: (.*)\)/;class yi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=He(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 Ye(e,"DOMException")}isDOMError(e){return Ye(e,"DOMError")}}class bi{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 String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}}class wi{constructor(){}match(e){return Ye(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var xi=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Ei{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(xi);return s&&(t=s[1],i=s[2]),[t,i]}}var Si=["fatal","error","warning","log","info","debug"];function ki(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(t>=r.length)return s===i.length?r:r.length>t?r.slice(0,t)+"...":r}return""}class Ci{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 Xe(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: "+ki(e)}isSeverityLevel(e){return He(e)&&!Ne(e)&&Si.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ti(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(e){return}}}class Pi{match(e){return Xe(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+ki(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ii{match(e){return Je(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 Fi{match(e){return Ye(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!Xe(e))return!1;try{var t=e.detail;return null!=t&&"object"==typeof t&&"reason"in t}catch(e){return!1}}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Je(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){try{if("reason"in e)return e.reason;if("detail"in e&&null!=e.detail&&"object"==typeof e.detail&&"reason"in e.detail)return e.detail.reason}catch(e){}return e}}var Ti="$message",Ri="$timestamp",Li=new Set([Ti,Ri]),$i={enabled:!0,max_bytes:32768};function Mi(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:$i.enabled,max_bytes:Ai(e.max_bytes,$i.max_bytes)}:i({},$i)}class Oi{constructor(e){this._entries=[],this._totalBytes=0,this._config=Mi(e)}setConfig(e){this._config=Mi(e),this._trimToMaxBytes()}add(e){var t=function(e){var t=function(e){var t=new WeakSet;try{return JSON.stringify(e,((e,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(t.has(i))return"[Circular]";t.add(i)}return i}}))}catch(e){return}}(e);if(t)try{var i=JSON.parse(t);if(!De(i))return;var s=i,r=s[Ti],n=s[Ri];if(!He(r)||0===r.trim().length)return;if(!He(n)&&!Ue(n))return;return{step:s,json:t}}catch(e){return}}(e);if(t){var i=function(e){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e).length;for(var t=encodeURIComponent(e),i=0,s=0;t.length>s;s++)"%"===t[s]?(i+=1,s+=2):i+=1;return i}(t.json);i>this._config.max_bytes||(this._entries.push({step:t.step,bytes:i}),this._totalBytes+=i,this._trimToMaxBytes())}}getAttachable(){return this._entries.map((e=>e.step))}clear(){this._entries=[],this._totalBytes=0}size(){return this._entries.length}_trimToMaxBytes(){for(;this._totalBytes>this._config.max_bytes&&this._entries.length>0;){var e=this._entries.shift();e&&(this._totalBytes-=e.bytes)}}}function Ai(e,t){if(!Ue(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Di=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,s={_log(t){if(pe&&(n.DEBUG||Se.POSTHOG_DEBUG||i)&&!ze(pe.console)&&pe.console){for(var s=("__rrweb_original__"in pe.console[t]?pe.console[t].__rrweb_original__:pe.console[t]),r=arguments.length,o=new Array(r>1?r-1:0),a=1;r>a;a++)o[a-1]=arguments[a];s(e,...o)}},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];s._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning(e){s.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Di(e+" "+t,i)};return s},qi=Di("[PostHog.js]"),zi=qi.createLogger;function Hi(e,t){Oe(e)&&e.forEach(t)}function Ni(e,t){if(!Be(e))if(Oe(e))e.forEach(t);else if(Ge(e))e.forEach(((e,i)=>t(e,i)));else for(var i in e)$e.call(e,i)&&t(e[i],i)}var ji=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;t>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)void 0!==r[n]&&(e[n]=r[n]);return e};function Bi(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 Ui=function(e){try{return e()}catch(e){return}},Wi=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;t>s;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){qi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),qi.critical(e)}}},Vi=function(e){var t={};return Ni(e,(function(e,i){(He(e)&&e.length>0||Ue(e))&&(t[i]=e)})),t};var Gi=["herokuapp.com","vercel.app","netlify.app"];function Ki(e){var t=null==e?void 0:e.hostname;if(!He(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of Gi)if(i===s)return!1;return!0}function Ji(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}function Yi(e){return"ph_toolbar_internal"===e.name}Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return Ue(e)&&isFinite(e)&&Math.floor(e)===e});class Xi{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)||0>e||0>t||0>i||0>s||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 Xi(r)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),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 Xi(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class Qi{constructor(){this._timestamp=0,this._counter=0,this._random=new ts}generate(){var e=this.generateOrAbort();if(ze(e)){this._timestamp=0;var t=this.generateOrAbort();if(ze(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(this._timestamp>=e+1e4)return;this._counter++,this._counter>4398046511103&&(this._timestamp++,this._resetCounter())}return Xi.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 Zi,es=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};pe&&!ze(pe.crypto)&&crypto.getRandomValues&&(es=e=>crypto.getRandomValues(e));class ts{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(es(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var is=()=>ss().toString(),ss=()=>(Zi||(Zi=new Qi)).generate(),rs="",ns=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var os={_is_supported:()=>!!fe,_error(e){qi.error("cookieStore error: "+e)},_get(e){if(fe){try{for(var t=e+"=",i=fe.cookie.split(";").filter((e=>e.length)),s=0;i.length>s;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(e){var t;try{t=JSON.parse(os._get(e))||{}}catch(e){}return t},_set(e,t,i,s,r){if(fe)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=fe),rs)return rs;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_"+is();!rs&&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",rs=n)}return rs}(e);if(!i){var s=(e=>{var t=e.match(ns);return t?t[0]:""})(e);s!==i&&qi.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(fe.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&qi.warn("cookieStore warning: large cookie, len="+u.length),fe.cookie=u,u}catch(e){return}},_remove(e,t){if(null!=fe&&fe.cookie)try{os._set(e,"",-1,t)}catch(e){return}}},as=null,ls={_is_supported(){if(!je(as))return as;var e=!0;if(ze(pe))e=!1;else try{var t="__mplssupport__";ls._set(t,"xyz"),'"xyz"'!==ls._get(t)&&(e=!1),ls._remove(t)}catch(t){e=!1}return e||qi.error("localStorage unsupported; falling back to cookie store"),as=e,e},_error(e){qi.error("localStorage error: "+e)},_get(e){try{return null==pe?void 0:pe.localStorage.getItem(e)}catch(e){ls._error(e)}return null},_parse(e){try{return JSON.parse(ls._get(e))||{}}catch(e){}return null},_set(e,t){try{null==pe||pe.localStorage.setItem(e,JSON.stringify(t))}catch(e){ls._error(e)}},_remove(e){try{null==pe||pe.localStorage.removeItem(e)}catch(e){ls._error(e)}}},us=[a,"distinct_id",S,k,Y,J,U],cs={},ds={_is_supported:()=>!0,_error(e){qi.error("memoryStorage error: "+e)},_get:e=>cs[e]||null,_parse:e=>cs[e]||null,_set(e,t){cs[e]=t},_remove(e){delete cs[e]}},_s=null,hs={_is_supported(){if(!je(_s))return _s;if(_s=!0,ze(pe))_s=!1;else try{var e="__support__";hs._set(e,"xyz"),'"xyz"'!==hs._get(e)&&(_s=!1),hs._remove(e)}catch(e){_s=!1}return _s},_error(e){qi.error("sessionStorage error: ",e)},_get(e){try{return null==pe?void 0:pe.sessionStorage.getItem(e)}catch(e){hs._error(e)}return null},_parse(e){try{return JSON.parse(hs._get(e))||null}catch(e){}return null},_set(e,t){try{null==pe||pe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){hs._error(e)}},_remove(e){try{null==pe||pe.sessionStorage.removeItem(e)}catch(e){hs._error(e)}}};class ps{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?0:this._storedConsent}isOptedOut(){return this._config.cookieless_mode===re||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===se}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this._config.opt_out_capturing_by_default}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 Ze(e)?1:Fe(et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ls:os;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?os:ls;i._get(this._storageKey)&&(this._persistentStore._get(this._storageKey)||this.optInOut(Ze(i._get(this._storageKey))),i._remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&[null==ve?void 0:ve.doNotTrack,null==ve?void 0:ve.msDoNotTrack,Se.doNotTrack].some((e=>Ze(e)))}}var gs=zi("[Dead Clicks]"),vs=()=>!0,fs=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),s=e.instance.config.capture_dead_clicks;return Ve(s)?s:!!De(s)||i};class ms{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[v]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this._loadScript((()=>{this._start()})):this.stop()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?gs.error("failed to load script",t):e()}))}_start(){var e;if(fe){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=Se.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=De(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=Se.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(fe),gs.info("starting...")}}else gs.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,gs.info("stopping..."))}}var ys=zi("[SegmentIntegration]");var bs="posthog-js";function ws(e,t){var{organization:s,projectId:r,prefix:n,severityAllowList:o=["error"],sendExceptionsToPostHog:a=!0}=void 0===t?{}:t;return t=>{var l,u,c,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,g=(null==(l=t.exception)?void 0:l.values)||[],v=g.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}))),f={$exception_message:(null==(u=g[0])?void 0:u.value)||t.message,$exception_type:null==(c=g[0])?void 0:c.type,$exception_level:t.level,$exception_list:v,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(d=g[0])?void 0:d.value)||t.message,$sentry_exception_type:null==(_=g[0])?void 0:_.type,$sentry_tags:t.tags};return s&&r&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+s+"/issues/?project="+r+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class xs{constructor(e,t,i,s,r,n){this.name=bs,this.setupOnce=function(o){o(ws(e,{organization:t,projectId:i,prefix:s,severityAllowList:r,sendExceptionsToPostHog:null==n||n}))}}}class Es{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(qi.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==pe?void 0:pe.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:u,maxContentY:c}=r;if(!(ze(n)||ze(o)||ze(a)||ze(l)||ze(u)||ze(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=n>1?tt(o/n,0,1,qi):1,_=n>1?tt(a/n,0,1,qi):1,h=l>1?tt(u/l,0,1,qi):1,p=l>1?tt(c/l,0,1,qi):1;s=ji(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:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$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 Ss={[o]:{exposure:"hidden"},[l]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[u]:{exposure:"hidden"},[c]:{exposure:"event"},[d]:{exposure:"hidden"},[_]:{exposure:"event"},[h]:{exposure:"hidden"},[p]:{exposure:"event"},[g]:{exposure:"event"},[v]:{exposure:"event"},[f]:{exposure:"hidden"},[m]:{exposure:"event"},[y]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[S]:{exposure:"hidden"},[k]:{exposure:"event"},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},[C]:{exposure:"derived",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!De(e))return{};for(var t={},i=Object.keys(e),s=0;i.length>s;s++)t["$feature/"+i[s]]=e[i[s]];return t}},[P]:{exposure:"event"},[I]:{exposure:"hidden"},[F]:{exposure:"hidden"},[T]:{exposure:"event"},[R]:{exposure:"event"},[L]:{exposure:"event"},[M]:{exposure:"hidden"},[O]:{exposure:"hidden"},[A]:{exposure:"hidden"},[D]:{exposure:"hidden"},[q]:{exposure:"event"},[z]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[H]:{exposure:"hidden"},[N]:{exposure:"hidden"},[j]:{exposure:"hidden"},[B]:{exposure:"hidden"},[U]:{exposure:"hidden"},[W]:{exposure:"hidden"},[V]:{exposure:"hidden"},[G]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"event"},[x]:{exposure:"event"},[E]:{exposure:"event"},[Z]:{exposure:"event"},[ee]:{exposure:"event"},[te]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},ks=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Cs=e=>{var t=null==fe?void 0:fe.createElement("a");return ze(t)?null:(t.href=e,t)},Ps=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!Oe(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){qi.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Is=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Oe(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=r&&(_+="#"+r),_},Fs=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Ts="https?://(.*)",Rs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Ls=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Rs],$s="<masked>",Ms=["li_fat_id"];function Os(e,t,i){if(!fe)return{};var s,r=t?[...Rs,...i||[]]:[],n=As(Is(fe.URL,r,$s),e),o=(s={},Ni(Ms,(function(e){var t=os._get(e);s[e]=t||null})),s);return ji(o,n)}function As(e,t){var i=Ls.concat(t||[]),s={};return Ni(i,(function(t){var i=Ps(e,t);s[t]=i||null})),s}function Ds(e){var t=function(e){return e?0===e.search(Ts+"google.([^/?]*)")?"google":0===e.search(Ts+"bing.com")?"bing":0===e.search(Ts+"yahoo.com")?"yahoo":0===e.search(Ts+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",s={};if(!je(t)){s.$search_engine=t;var r=fe?Ps(fe.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function qs(){return navigator.language||navigator.userLanguage}var zs="$direct";function Hs(){return(null==fe?void 0:fe.referrer)||zs}function Ns(e,t){var i=e?[...Rs,...t||[]]:[],s=null==me?void 0:me.href.substring(0,1e3);return{r:Hs().substring(0,1e3),u:s?Is(s,i,$s):void 0}}function js(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:i==zs?zs:null==(t=Cs(i))?void 0:t.host};if(s){r.$current_url=s;var n=Cs(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=As(s);ji(r,o)}if(i){var a=Ds(i);ji(r,a)}return r}function Bs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Us(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Ws=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Vs{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&&qi.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Ws.indexOf(e.persistence.toLowerCase())&&(qi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...us,...e];return i({},ls,{_parse(e){try{var t={};try{t=os._parse(e)||{}}catch(e){}var i=ji(t,JSON.parse(ls._get(e)||"{}"));return ls._set(e,i),i}catch(e){}return null},_set(e,i,s,r,n,o){try{ls._set(e,i,void 0,void 0,o);var a={};t.forEach((e=>{i[e]&&(a[e]=i[e])})),Object.keys(a).length&&os._set(e,a,s,r,n,o)}catch(e){ls._error(e)}},_remove(e,t){try{null==pe||pe.localStorage.removeItem(e),os._remove(e,t)}catch(e){ls._error(e)}}})}(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return"localstorage"===s&&ls._is_supported()?ls:"localstorage+cookie"===s&&t._is_supported()?t:"sessionstorage"===s&&hs._is_supported()?hs:"memory"===s?ds:"cookie"===s?os:t._is_supported()?t:os}_isFeatureFlagCacheStale(e){var t=null!=e?e:this._config.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[B];return!i||"number"!=typeof i||Date.now()-i>t}properties(){var e={};return Ni(this.props,((t,i)=>{var s=(e=>{var t=Ss[e];if(t)return t;for(var[i,s]of ks)if(0===e.indexOf(i))return s})(i);if("derived"===(null==s?void 0:s.exposure)){if(null!=s.shouldSkipFromEventProperties&&s.shouldSkipFromEventProperties(t,i===C?()=>this._isFeatureFlagCacheStale():()=>!1))return;s.transformToEventProperties&&ji(e,s.transformToEventProperties(t))}else s&&"event"!==s.exposure||(e[i]=t)})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=ji({},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(De(e)){ze(t)&&(t="None"),this._expire_days=ze(i)?this._default_expiry:i;var s=!1;if(Ni(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(De(e)){this._expire_days=ze(t)?this._default_expiry:t;var i=!1;if(Ni(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this._setProp(s,t),i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(this._deleteProp(e),this.save())}update_campaign_params(){if(!this._campaign_params_saved){var e=Os(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);qe(Vi(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==fe?void 0:fe.referrer)?Ds(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Hs(),$referring_domain:null!=fe&&fe.referrer&&(null==(e=Cs(fe.referrer))?void 0:e.host)||zs},void 0)}set_initial_person_info(){this.props[G]||this.props[K]||this.register_once({[J]:Ns(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};Ni([K,G],(t=>{var i=this.props[t];i&&Ni(i,(function(t,i){e["$initial_"+Re(i)]=t}))}));var t,i,s=this.props[J];if(s){var r=(t=js(s),i={},Ni(t,(function(e,t){i["$initial_"+Re(t)]=e})),i);ji(e,r)}return e}safe_merge(e){return Ni(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||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),s=[...t].sort();return i.every(((e,t)=>e===s[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){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[u]||{};i[e]=t,this._setProp(u,i),this.save()}remove_event_timer(e){var t=this.props[u]||{},i=t[e];return ze(i)||(delete t[e],this._setProp(u,t),this.save()),i}get_property(e){return this.props[e]}set_property(e,t){this._setProp(e,t),this.save()}_setProp(e,t){this.props[e]=t}_deleteProp(e){delete this.props[e]}}var Gs="events",Ks="cancelEvents",Js="survey shown",Ys="survey sent",Xs="popover",Qs=zi("[RateLimiter]");class Zs{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Qs.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Qs.warn('could not rate limit - continuing. Error: "'+(null==e?void 0:e.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;void 0===e&&(e=!1);var{captureEventsBurstLimit:r,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(V))&&void 0!==t?t:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(s=this.instance.persistence)||s.set_property(V,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var er=zi("[RemoteConfig]");class tr{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=Se._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):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 er.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void er.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return er.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this._onRemoteConfig(e),this._startRefreshInterval()}));this._onRemoteConfig(e),this._startRefreshInterval()}))}catch(e){er.error("Error loading remote config",e)}}stop(){this._refreshInterval&&(clearInterval(this._refreshInterval),this._refreshInterval=void 0)}refresh(){this._instance._shouldDisableFlags()||"hidden"===(null==fe?void 0:fe.visibilityState)||this._instance.reloadFeatureFlags()}_startRefreshInterval(){var e;if(!this._refreshInterval){var t=null!==(e=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==e?e:3e5;0!==t&&(this._refreshInterval=setInterval((()=>{this.refresh()}),t))}}_onRemoteConfig(e){var t;e||er.error("Failed to fetch remote config from PostHog."),this._instance._onRemoteConfig(null!=e?e:{}),!1!==(null==e?void 0:e.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(t=this._instance.featureFlags)||t.ensureFlagsLoaded())}}var ir="gzip-js",sr="base64",rr=Uint8Array,nr=Uint16Array,or=Uint32Array,ar=new rr([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),lr=new rr([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]),ur=new rr([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 nr(31),s=0;31>s;++s)i[s]=t+=1<<e[s-1];var r=new or(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},dr=cr(ar,2),_r=dr[1];dr[0][28]=258,_r[258]=28;for(var hr=cr(lr,0)[1],pr=new nr(32768),gr=0;32768>gr;++gr){var vr=(43690&gr)>>>1|(21845&gr)<<1;pr[gr]=((65280&(vr=(61680&(vr=(52428&vr)>>>2|(13107&vr)<<2))>>>4|(3855&vr)<<4))>>>8|(255&vr)<<8)>>>1}var fr=function(e,t,i){for(var s=e.length,r=0,n=new nr(t);s>r;++r)++n[e[r]-1];var o,a=new nr(t);for(r=0;t>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new nr(1<<t);var l=15-t;for(r=0;s>r;++r)if(e[r])for(var u=r<<4|e[r],c=t-e[r],d=a[e[r]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[pr[d]>>>l]=u}else for(o=new nr(s),r=0;s>r;++r)o[r]=pr[a[e[r]-1]++]>>>15-e[r];return o},mr=new rr(288);for(gr=0;144>gr;++gr)mr[gr]=8;for(gr=144;256>gr;++gr)mr[gr]=9;for(gr=256;280>gr;++gr)mr[gr]=7;for(gr=280;288>gr;++gr)mr[gr]=8;var yr=new rr(32);for(gr=0;32>gr;++gr)yr[gr]=5;var br=fr(mr,9,0),wr=fr(yr,5,0),xr=function(e){return(e/8>>0)+(7&e&&1)},Er=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof nr?nr:e instanceof or?or:rr)(i-t);return s.set(e.subarray(t,i)),s},Sr=function(e,t,i){var s=t/8>>0;e[s]|=i<<=7&t,e[s+1]|=i>>>8},kr=function(e,t,i){var s=t/8>>0;e[s]|=i<<=7&t,e[s+1]|=i>>>8,e[s+2]|=i>>>16},Cr=function(e,t){for(var i=[],s=0;e.length>s;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new rr(0),0];if(1==r){var o=new rr(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],u=0,c=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=c&&i[d].f>i[u].f?u++:d++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var _=n[0].s;for(s=1;r>s;++s)n[s].s>_&&(_=n[s].s);var h=new nr(_+1),p=Pr(i[c-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}));r>s;++s){var m=n[s].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[s].s;t>h[y]?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 rr(h),p]},Pr=function(e,t,i){return-1==e.s?Math.max(Pr(e.l,t,i+1),Pr(e.r,t,i+1)):t[e.s]=i},Ir=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new nr(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;t>=a;++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]},Fr=function(e,t){for(var i=0,s=0;t.length>s;++s)i+=e[s]*t[s];return i},Tr=function(e,t,i){var s=i.length,r=xr(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;s>n;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Rr=function(e,t,i,s,r,n,o,a,l,u,c){Sr(t,c++,i),++r[256];for(var d=Cr(r,15),_=d[0],h=d[1],p=Cr(n,15),g=p[0],v=p[1],f=Ir(_),m=f[0],y=f[1],b=Ir(g),w=b[0],x=b[1],E=new nr(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=Cr(E,7),C=k[0],P=k[1],I=19;I>4&&!C[ur[I-1]];--I);var F,T,R,L,M=u+5<<3,O=Fr(r,mr)+Fr(n,yr)+o,A=Fr(r,_)+Fr(n,g)+o+14+3*I+Fr(E,C)+(2*E[16]+3*E[17]+7*E[18]);if(O>=M&&A>=M)return Tr(t,c,e.subarray(l,l+u));if(Sr(t,c,1+(O>A)),c+=2,O>A){F=fr(_,h,0),T=_,R=fr(g,v,0),L=g;var D=fr(C,P,0);for(Sr(t,c,y-257),Sr(t,c+5,x-1),Sr(t,c+10,I-4),c+=14,S=0;I>S;++S)Sr(t,c+3*S,C[ur[S]]);c+=3*I;for(var q=[m,w],z=0;2>z;++z){var H=q[z];for(S=0;H.length>S;++S)Sr(t,c,D[N=31&H[S]]),c+=C[N],N>15&&(Sr(t,c,H[S]>>>5&127),c+=H[S]>>>12)}}else F=br,T=mr,R=wr,L=yr;for(S=0;a>S;++S)if(s[S]>255){var N;kr(t,c,F[257+(N=s[S]>>>18&31)]),c+=T[N+257],N>7&&(Sr(t,c,s[S]>>>23&31),c+=ar[N]);var j=31&s[S];kr(t,c,R[j]),c+=L[j],j>3&&(kr(t,c,s[S]>>>5&8191),c+=lr[j])}else kr(t,c,F[s[S]]),c+=T[s[S]];return kr(t,c,F[256]),c+T[256]},Lr=new or([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),$r=function(){for(var e=new or(256),t=0;256>t;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Mr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Or(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,s=0;t.length>s;++s)i=$r[255&i^t[s]]^i>>>8;e=i},d(){return 4294967295^e}}}(),s=e.length;i.p(e);var r,n,o,a,l,u=(a=10+((r=t).filename&&r.filename.length+1||0),l=8,function(e,t,i,s,r,n){var o=e.length,a=new rr(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=Tr(l,u,e.subarray(c,d)):(l[c]=!0,u=Tr(l,u,e.subarray(c,o)))}else{for(var _=Lr[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new nr(32768),f=new nr(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 or(25e3),x=new nr(288),E=new nr(32),S=0,k=0,C=(c=0,0),P=0,I=0;o>c;++c){var F=b(c),T=32767&c,R=f[F];if(v[T]=R,f[F]=T,c>=P){var L=o-c;if((S>7e3||C>24576)&&L>423){u=Rr(e,l,0,w,x,E,k,C,I,c-I,u),C=S=k=0,I=c;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)E[M]=0}var O=2,A=0,D=p,q=T-R&32767;if(L>2&&F==b(c-q))for(var z=Math.min(h,L)-1,H=Math.min(32767,c),N=Math.min(258,L);H>=q&&--D&&T!=R;){if(e[c+O]==e[c+O-q]){for(var j=0;N>j&&e[c+j]==e[c+j-q];++j);if(j>O){if(O=j,A=q,j>z)break;var B=Math.min(q,j-2),U=0;for(M=0;B>M;++M){var W=c-q+M+32768&32767,V=W-v[W]+32768&32767;V>U&&(U=V,R=W)}}}q+=(T=R)-(R=v[T])+32768&32767}if(A){w[C++]=268435456|_r[O]<<18|hr[A];var G=31&_r[O],K=31&hr[A];k+=ar[G]+lr[K],++x[257+G],++E[K],P=c+O,++S}else w[C++]=e[c],++x[e[c]]}}u=Rr(e,l,!0,w,x,E,k,C,I,c-I,u)}return Er(a,0,s+xr(u)+r)}(n=e,null==(o=t).level?6:o.level,null==o.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),c=u.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Mr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;i.length>=s;++s)e[s+10]=i.charCodeAt(s)}}(u,t),Mr(u,c-8,i.d()),Mr(u,c-4,s),u}var Ar=!!be||!!ye,Dr="text/plain",qr=!1,zr=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:[],u=function(e,t){var i,s;void 0===t&&(t="&");var r=[];return Ni(e,(function(e,t){ze(e)||ze(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)}(a);return u&&l.push(u),n+"?"+l.join("&")},Hr=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Nr=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===ir){var s=Or(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new rr(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;i>o;++o){if(r+5>s.length){var a=new rr(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);128>l?n(l):2048>l?(n(192|l>>>6),n(128|63&l)):l>55295&&57344>l?(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 Er(s,0,r)}(Hr(t)),{mtime:0});return{contentType:Dr,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===sr){var r=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(Hr(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:Hr(e)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Hr(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},jr=function(){var e=t((function*(e){var t=Hr(e.data),s=yield function(e,t,i){return ke.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return i({},e,{_encodedBody:{contentType:Dr,body:r,estimatedSize:r.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Br=(e,t)=>zr(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),Ur=[];ye&&Ur.push({transport:"fetch",method(e){var t,s,{contentType:r,body:n,estimatedSize:o}=null!==(t=Nr(e))&&void 0!==t?t:{},a=new Headers;Ni(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,u=null;if(we){var c=new we;u={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}ye(l,i({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&52428.8>(o||0),body:n,signal:null==(s=u)?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){qi.error(e)}null==e.callback||e.callback(s)})))).catch((t=>{qi.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),be&&Ur.push({transport:"XHR",method(e){var t,i=new be;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=Nr(e))&&void 0!==t?t:{};Ni(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!=ve&&ve.sendBeacon&&Ur.push({transport:"sendBeacon",method(e){var t=zr(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Nr(e))&&void 0!==i?i:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:s});ve.sendBeacon(t,n)}catch(e){}}});var Wr=3e3;class Vr{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=tt((null==t?void 0:t.flush_interval_ms)||Wr,250,5e3,qi.createLogger("flush interval"),Wr),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&&Oe(i.data)&&Ni(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 Ni(this._queue,(t=>{var s,r=t,n=(r?r.batchKey:null)||r.url;ze(e[n])&&(e[n]=i({},r,{data:[]})),null==(s=e[n].data)||s.push(r.data)})),this._queue=[],e}}var Gr=["retriesPerformedSoFar"];class Kr{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!ze(pe)&&"onLine"in pe.navigator&&(this._areWeOnline=pe.navigator.onLine,this._onlineListener=()=>{this._areWeOnline=!0,this._flush()},this._offlineListener=()=>{this._areWeOnline=!1},Ji(pe,"online",this._onlineListener),Ji(pe,"offline",this._offlineListener))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=s(e,Gr);We(t)&&(r.url=zr(r.url,{retry_count:t})),this._instance._send_request(i({},r,{callback:e=>{200===e.statusCode||e.statusCode>=400&&500>e.statusCode||(null!=t?t:0)>=10?null==r.callback||r.callback(e):this._enqueue(i({retriesPerformedSoFar:t},r))}}))}_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;return Math.ceil(s+r*(s-i))}(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)"),qi.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=>e>i.retryAt||(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,ze(pe)||(this._onlineListener&&(pe.removeEventListener("online",this._onlineListener),this._onlineListener=void 0),this._offlineListener&&(pe.removeEventListener("offline",this._offlineListener),this._offlineListener=void 0)),this._queue))try{this._instance._send_request(i({},e,{transport:"sendBeacon"}))}catch(e){qi.error(e)}this._queue=[]}}class Jr{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}get _scrollRoot(){return this._instance.config.scroll_root_selector}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){Ji(pe,"scroll",this._updateScrollData,{capture:!0}),Ji(pe,"scrollend",this._updateScrollData,{capture:!0}),Ji(pe,"resize",this._updateScrollData)}scrollElement(){if(!this._scrollRoot)return null==pe?void 0:pe.document.documentElement;var e=Oe(this._scrollRoot)?this._scrollRoot:[this._scrollRoot];for(var t of e){var i=null==pe?void 0:pe.document.querySelector(t);if(i)return i}}scrollY(){if(this._scrollRoot){var e=this.scrollElement();return e&&e.scrollTop||0}return pe&&(pe.scrollY||pe.pageYOffset||pe.document.documentElement.scrollTop)||0}scrollX(){if(this._scrollRoot){var e=this.scrollElement();return e&&e.scrollLeft||0}return pe&&(pe.scrollX||pe.pageXOffset||pe.document.documentElement.scrollLeft)||0}}var Yr=e=>Ns(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Xr{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({[W]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=s||Yr,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[W]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?js(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 Ni(Vi(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Re(i)]=t})),e}}class Qr{constructor(){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)}}var Zr=zi("[SessionId]");class en{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 Qr,this._sessionHasBeenIdleTooLong=(e,t)=>!(!We(e)||!We(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===re)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||is,this._windowIdGenerator=i||is;var r=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*tt(this._config.session_idle_timeout_seconds||1800,60,36e3,Zr.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 n=hs._parse(this._window_id_storage_key),o=hs._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:hs._remove(this._window_id_storage_key),hs._set(this._primary_window_exists_storage_key,!0)}if(null!=(s=this._config.bootstrap)&&s.sessionID)try{var a=(e=>{var t=this._config.bootstrap.sessionID.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._setSessionId(this._config.bootstrap.sessionID,(new Date).getTime(),a)}catch(e){Zr.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return ze(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&&hs._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&hs._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?hs._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({[S]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[S];return Oe(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&&pe&&(pe.removeEventListener(ue,this._beforeUnloadListener,{capture:!1}),this._beforeUnloadListener=void 0),this._sessionIdChangedHandlers=[]}_listenToReloadWindow(){this._beforeUnloadListener=()=>{this._canUseSessionStorage()&&hs._remove(this._primary_window_exists_storage_key)},Ji(pe,ue,this._beforeUnloadListener,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),this._config.cookieless_mode===re)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=We(n)&&Math.abs(i-n)>864e5,l=!1,u=!r,c=!u&&!e&&this._sessionHasBeenIdleTooLong(i,s);u||c||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),Zr.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=We(s)&&e&&!a?s:i,_=We(n)?n:(new Date).getTime();return this._setWindowId(o),this._setSessionId(r,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,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 tn=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Pe(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>Pe(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},sn=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 rn(e,t,i){return Hr({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var nn={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=>sn(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!sn(t,e))))),icontains:(e,t)=>t.map(on).some((t=>e.map(on).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(on).every((t=>e.map(on).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)))}))},on=e=>e.toLowerCase();function an(e,t){return!e||Object.entries(e).every((e=>{var[i,s]=e,r=null==t?void 0:t[i];if(ze(r)||je(r))return!1;var n=[String(r)],o=nn[s.operator];return!!o&&o(s.values,n)}))}var ln="custom",un="i.posthog.com",cn=/^\/static\//;class dn{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("."+un,".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(this._regionCache[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":ln),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if("string"==typeof t&&cn.test(e))return t.trim().replace(/\/$/,"")||void 0}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("assets"===e){var i=this._staticAssetHostOverride(t);if(i)return""+i+t}if(this.region===ln)return this.apiHost+t;var s=un+t;switch(e){case"assets":return"https://"+this.region+"-assets."+s;case"api":return"https://"+this.region+"."+s}}}var _n=zi("[Surveys]"),hn="seenSurvey_",pn=["popover","widget","api"],gn={ignoreConditions:!1,ignoreDelay:!1,displayType:Xs},vn=zi("[PostHog ExternalIntegrations]"),fn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class mn{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return vn.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,r,n;!s||null!=(i=Se.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(fn[t],(()=>{var i;null==(i=Se.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!s&&null!=(r=Se.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[t]&&(null==(n=Se.__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 yn,bn={},wn=0,xn=()=>{},En='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Sn="Surveys module not available",kn="sanitize_properties is deprecated. Use before_send instead",Cn="Invalid value for property_denylist config: ",Pn="posthog",In=!Ar&&-1===(null==Ee?void 0:Ee.indexOf("MSIE"))&&-1===(null==Ee?void 0:Ee.indexOf("Mozilla")),Fn=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:Ki(null==fe?void 0:fe.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:xn,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,__preview_external_dependency_versioned_paths:!1,debug:me&&He(null==me?void 0:me.search)&&-1!==me.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:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==pe||null==(t=pe.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_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(e){qi.error("Bad HTTP status: "+e.statusCode+" "+e.text)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:ae,before_send:void 0,request_queue_config:{flush_interval_ms:Wr},error_tracking:{},_onCapture:xn,__preview_eager_load_replay:!1},(e=>({rageclick:!e||"2025-11-30">e||{content_ignorelist:!0},capture_pageview:!e||"2025-05-24">e||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},Tn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Rn=e=>{var t={};for(var[i,s]of Tn)ze(e[i])||(t[s]=e[i]);var r=ji({},t,e);return Oe(e.property_blacklist)&&(ze(e.property_denylist)?r.property_denylist=e.property_blacklist:Oe(e.property_denylist)?r.property_denylist=[...e.property_blacklist,...e.property_denylist]:qi.error(Cn+e.property_denylist)),r};class Ln{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){qi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class $n{_replaceExtension(e,t){if(e){var i=this._extensions.indexOf(e);-1!==i&&this._extensions.splice(i,1)}return this._extensions.push(t),null==t.initialize||t.initialize(),t}_inCookielessMode(){return this.config.cookieless_mode===re||this.config.cookieless_mode===se&&this.consent.isRejected()}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(){var e;this.webPerformance=new Ln,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new Qr,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fn(),this.SentryIntegration=xs,this.sentryIntegration=e=>function(e,t){var i=ws(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.scrollManager=new Jr(this),this.pageViewManager=new Es(this),this.rateLimiter=new Zs(this),this.requestRouter=new dn(this),this.consent=new ps(this),this.externalIntegrations=new mn(this);var t=null!==(e=$n.__defaultExtensionClasses)&&void 0!==e?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(e,t,i)=>{var s=He(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=He(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>qi.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Pn){var s,r=null!==(s=bn[i])&&void 0!==s?s:new $n;return r._init(e,t,i),bn[i]=r,bn[Pn][i]=r,r}return this._init(e,t,i)}_init(e,t,s){var r,o;if(void 0===t&&(t={}),ze(e)||Ne(e))return qi.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:t.process_person&&(this._initialPersonProfilesConfig=t.process_person),this.set_config(ji({},Fn(t.defaults),Rn(t),{name:s,token:e})),this.config.on_xhr_error&&qi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ir;var a=this._is_persistence_disabled();this.persistence=new Vs(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Vs(i({},this.config,{persistence:"sessionStorage"}),a);var l=i({},this.persistence.props),u=i({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this._requestQueue=new Vr((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Kr(this),this.__request_queue=[];var c=this._inCookielessMode();if(c||(this.sessionManager=new en(this),this.sessionPropsManager=new Xr(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(qi.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(qi.info("Initializing extensions synchronously"),this._initExtensions(c)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&qi.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),!this.config.identity_distinct_id||null!=(r=t.bootstrap)&&r.distinctID||(t.bootstrap=i({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(o=t.bootstrap)?void 0:o.distinctID)){var d=t.bootstrap.distinctID,_=this.get_distinct_id(),h=this.persistence.get_property(U);if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===ne)this.identify(d);else if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===oe)qi.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var p=this.config.get_device_id(is()),g=t.bootstrap.isIdentifiedID?p:d;this.persistence.set_property(U,t.bootstrap.isIdentifiedID?oe:ne),this.register({distinct_id:d,$device_id:g})}}if(c)this.register_once({distinct_id:Q,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(is());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(U,ne)}return Ji(pe,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?function(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()||is();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(U,oe)),t()},r=i.user();"then"in r&&Ae(r.then)?r.then(s):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||ys.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()||(ys.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(ys.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,ce),identify:e=>t(e,_e),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}(this,(()=>this._loaded())):this._loaded(),Ae(this.config._onCapture)&&this.config._onCapture!==xn&&(qi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&qi.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,s,r,n,o,a,l,u=performance.now(),c=i({},$n.__defaultExtensionClasses,this.config.__extensionClasses),d=[];c.featureFlags&&this._extensions.push(this.featureFlags=null!==(t=this.featureFlags)&&void 0!==t?t:new c.featureFlags(this)),c.exceptions&&this._extensions.push(this.exceptions=null!==(s=this.exceptions)&&void 0!==s?s:new c.exceptions(this)),c.historyAutocapture&&this._extensions.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this._extensions.push(new c.tracingHeaders(this)),c.siteApps&&this._extensions.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this._extensions.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this._extensions.push(this.autocapture=new c.autocapture(this)),c.surveys&&this._extensions.push(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new c.surveys(this)),c.logs&&this._extensions.push(this.logs=null!==(n=this.logs)&&void 0!==n?n:new c.logs(this)),c.conversations&&this._extensions.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new c.conversations(this)),c.productTours&&this._extensions.push(this.productTours=new c.productTours(this)),c.heatmaps&&this._extensions.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this._extensions.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this._extensions.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this._extensions.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,fs)),c.toolbar&&this._extensions.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new c.toolbar(this)),c.experiments&&this._extensions.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new c.experiments(this)),this._extensions.forEach((e=>{e.initialize&&d.push((()=>{null==e.initialize||e.initialize()}))})),d.push((()=>{if(this._pendingRemoteConfig){var e=this._pendingRemoteConfig;this._pendingRemoteConfig=void 0,this._onRemoteConfig(e)}})),this._processInitTaskQueue(d,u)}_processInitTaskQueue(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&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){qi.error("Error initializing extension:",e)}}var s=Math.round(performance.now()-t);this.register_for_session({[Z]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ee]:s}),this.config.__preview_deferred_init_extensions&&qi.info("PostHog extensions initialized ("+s+"ms)")}_onRemoteConfig(e){var t;if(!fe||!fe.body)return qi.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._lastRemoteConfig=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Fe(e.supportedCompression,ir)?ir:Fe(e.supportedCompression,sr)?sr:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:ae}),this._extensions.forEach((t=>null==t.onRemoteConfig?void 0:t.onRemoteConfig(e)))}_loaded(){try{this.config.loaded(this)}catch(e){qi.critical("`loaded` function failed",e)}if(this._start_queue_if_opted_in(),this.config.internal_or_test_user_hostname&&null!=me&&me.hostname){var e=me.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this._inCookielessMode())&&this._captureInitialPageview()}),1),this._remoteConfigLoader=new tr(this),this._remoteConfigLoader.load()}_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()&&Hi(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t,i,s;null==(e=this.surveys)||e.handlePageUnload(),this.config.request_batching?(this._shouldCapturePageleave()&&this.capture(de),null==(t=this.logs)||t.flushLogs("sendBeacon"),null==(i=this._requestQueue)||i.unload(),null==(s=this._retryQueue)||s.unload()):this._shouldCapturePageleave()&&this.capture(de,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(In?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=zr(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=Br(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=Ur.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(s=null==(r=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:r.method)&&void 0!==s?s:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===ir&&xe&&!qr?jr(n).then((e=>{l(e)})).catch((t=>{if((e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""))(t))return qr=!0,void l(i({},n,{compression:void 0,url:Br(e.url,void 0)}));l(n)})):l(n)})(i({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),400>t.statusCode||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){wn++;try{var t,i=[],s=[],r=[];Hi(e,(e=>{e&&(Oe(t=e[0])?r.push(e):Ae(e)?e.call(this):Oe(e)&&"alias"===t?i.push(e):Oe(e)&&-1!==t.indexOf("capture")&&Ae(this[t])?r.push(e):s.push(e))}));var n=function(e,t){Hi(e,(function(e){if(Oe(e[0])){var i=t;Ni(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}))};n(i,this),n(s,this),n(r,this)}finally{wn--}}push(e){if(wn>0&&Oe(e)&&He(e[0])){var t=$n.prototype[e[0]];Ae(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,s){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!ze(e)&&He(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!He(null==t?void 0:t.$current_url)&&(qi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),"$exception"!==e||null!=s&&s._originatedFromCaptureException||qi.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var d=new Date,_=(null==s?void 0:s.timestamp)||d,h=is(),p={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},_,h)};e===ce&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),(null==s?void 0:s.$set)&&(p.$set=null==s?void 0:s.$set);var g,v,f,m=this._calculate_set_once_properties(null==s?void 0:s.$set_once,e!==he,e===_e);if(m&&(p.$set_once=m),null!=s&&s._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>He(e)?e.slice(0,n):e,l=new Set,p=function e(t,i){return t!==Object(t)?a?a(t):t:l.has(t)?void 0:(l.add(t),Oe(t)?(s=[],Hi(t,(t=>{s.push(e(t))}))):(s={},Ni(t,((t,i)=>{l.has(t)||(s[i]=e(t,i))}))),s);var s}(o)),p.timestamp=_,ze(null==s?void 0:s.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),"survey dismissed"===e||e===Ys){var y=null==t?void 0:t.$survey_id,b=null==t?void 0:t.$survey_iteration;(e=>{try{var t=(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))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){_n.error("Failed to persist survey seen state",e)}})({id:y,current_iteration:b}),p.$set=i({},p.$set,{[(g={id:y,current_iteration:b},v=e===Ys?"responded":"dismissed",f="$survey_"+v+"/"+g.id,g.current_iteration&&g.current_iteration>0&&(f="$survey_"+v+"/"+g.id+"/"+g.current_iteration),f)]:!0})}else e===Js&&(p.$set=i({},p.$set,{$survey_last_seen_date:(new Date).toISOString()}));if("product tour shown"===e){var w=null==t?void 0:t.$product_tour_type;w&&(p.$set=i({},p.$set,{["$product_tour_last_seen_date/"+w]:(new Date).toISOString()}))}var x=i({},p.properties.$set,p.$set);if(qe(x)||this.setPersonPropertiesForFlags(x),!Be(this.config.before_send)){var E=this._runBeforeSend(p);if(!E)return;p=E}this._internalEventEmitter.emit("eventCaptured",p);var S={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,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(S):this._requestQueue.enqueue(S),p}qi.critical("This capture call is ignored due to client rate limiting.")}}else qi.error("No event name provided to posthog.capture")}else qi.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,s,r,o){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return t;var a=o?void 0:this.persistence.remove_event_timer(e),l=i({},t);if(l.token=this.config.token,l.$config_defaults=this.config.defaults,this._inCookielessMode()&&(l.$cookieless_mode=!0),"$snapshot"===e){var u=i({},this.persistence.properties(),this.sessionPersistence.properties());return l.distinct_id=u.distinct_id,(!He(l.distinct_id)&&!Ue(l.distinct_id)||Ne(l.distinct_id))&&qi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t){var i,s,r,o;if(!Ee)return{};var a,l,u,c,d,_,h,p,g=e?[...Rs,...t||[]]:[],[v,f]=function(e){for(var t=0;Zt.length>t;t++){var[i,s]=Zt[t],r=i.exec(e),n=r&&(Ae(s)?s(r,e):s);if(n)return n}return["",""]}(Ee);return ji(Vi({$os:v,$os_version:f,$browser:Yt(Ee,navigator.vendor),$device:ei(Ee),$device_type:(l=Ee,u={userAgentDataPlatform:null==(i=navigator)||null==(i=i.userAgentData)?void 0:i.platform,maxTouchPoints:null==(s=navigator)?void 0:s.maxTouchPoints,screenWidth:null==pe||null==(r=pe.screen)?void 0:r.width,screenHeight:null==pe||null==(o=pe.screen)?void 0:o.height,devicePixelRatio:null==pe?void 0:pe.devicePixelRatio},p=ei(l),p===dt||p===ct||"Kobo"===p||"Kindle Fire"===p||p===Nt?ut:p===Tt||p===Lt||p===Rt||p===qt?"Console":p===ht?"Wearable":p?ot:"Android"===(null==u?void 0:u.userAgentDataPlatform)&&(null!==(c=null==u?void 0:u.maxTouchPoints)&&void 0!==c?c:0)>0?600>Math.min(null!==(d=null==u?void 0:u.screenWidth)&&void 0!==d?d:0,null!==(_=null==u?void 0:u.screenHeight)&&void 0!==_?_:0)/(null!==(h=null==u?void 0:u.devicePixelRatio)&&void 0!==h?h:1)?ot:ut:"Desktop"),$timezone:Bs(),$timezone_offset:Us()}),{$current_url:Is(null==me?void 0:me.href,g,$s),$host:null==me?void 0:me.host,$pathname:null==me?void 0:me.pathname,$raw_user_agent:Ee.length>1e3?Ee.substring(0,997)+"...":Ee,$browser_version:Qt(Ee,navigator.vendor),$browser_language:qs(),$browser_language_prefix:(a=qs(),"string"==typeof a?a.split("-")[0]:void 0),$screen_height:null==pe?void 0:pe.screen.height,$screen_width:null==pe?void 0:pe.screen.width,$viewport_height:null==pe?void 0:pe.innerHeight,$viewport_width:null==pe?void 0:pe.innerWidth,$lib:n.LIB_NAME,$lib_version:n.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:_,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId(o,s.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&ji(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&ji(l,this.sessionRecording.sdkDebugProperties),l.$sdk_debug_retry_queue_size=null==(p=this._retryQueue)?void 0:p.length}catch(e){l.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ln&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ce||o?e!==de||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),l=ji(l,c),e===ce&&fe&&(l.title=fe.title),!ze(a)){var g=s.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Ee&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=ji({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Oe(this.config.property_denylist)?Ni(this.config.property_denylist,(function(e){delete l[e]})):qi.error(Cn+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(qi.error(kn),l=v(l,e));var f=this._hasPersonProcessing();return l.$process_person_profile=f,f&&!o&&this._requirePersonProcessing("_calculate_event_properties"),l}_calculate_set_once_properties(e,t,i){var s;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var r=this.persistence.get_initial_props(),n=null==(s=this.sessionPropsManager)?void 0:s.getSetOnceProps(),o=ji({},r,n||{},e||{}),a=this.config.sanitize_properties;return a&&(qi.error(kn),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),qe(o)?void 0:o}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){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return null==(t=this.featureFlags)?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return null==(i=this.featureFlags)?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;null==(e=this.featureFlags)||e.reloadFeatureFlags()}updateFlags(e,t,i){var s;null==(s=this.featureFlags)||s.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var s;null==(s=this.featureFlags)||s.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var s;return void 0===t&&(t=!1),null==(s=this.featureFlags)?void 0:s.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Sn}),()=>{})}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?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Sn})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Sn})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=gn),null==(i=this.surveys)||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;null==(t=this.surveys)||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return null!==(t=null==(i=this.surveys)?void 0:i.canRenderSurvey(e))&&void 0!==t?t:{visible:!1,disabledReason:Sn}}canRenderSurveyAsync(e,t){var i,s;return void 0===t&&(t=!1),null!==(i=null==(s=this.surveys)?void 0:s.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Sn})}_validateIdentifyId(e){return!e||Ne(e)?(qi.critical("Unique user id has not been set in posthog.identify"),!1):e===Q?(qi.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(qi.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return qi.uninitializedWarning("posthog.identify");if(Ue(e)&&(e=e.toString(),qi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this._validateIdentifyId(e)&&this._requirePersonProcessing("posthog.identify")){var s=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:s},""),e!==s&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var r,n=(this.persistence.get_property(U)||ne)===ne;e!==s&&n?(this.persistence.set_property(U,oe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(_e,{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=rn(e,t,i),null==(r=this.featureFlags)||r.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(H))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=rn(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):qi.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(),n=r[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},r,{[e]:t})}),n||s){var o={$group_type:e,$group_key:t};s&&(o.$group_set=s),this.capture(he,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),n&&!s&&this.reloadFeatureFlags()}else qi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;void 0===t&&(t=!0),this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;null==(t=this.featureFlags)||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r,n,o,l,u;if(qi.info("reset"),!this.__loaded)return qi.uninitializedWarning("posthog.reset");var c=this.get_property(a);if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),null==(s=this.surveys)||s.reset(),null==(r=this._remoteConfigLoader)||r.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.persistence)||l.set_property(U,ne),null==(u=this.sessionManager)||u.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===re)this.register_once({distinct_id:Q,$device_id:null},"");else{var d=this.config.get_device_id(is());this.register_once({distinct_id:d,$device_id:e?d:c},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),null==(i=this.conversations)||i._onIdentityChanged()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(e=this.conversations)||e._onIdentityCleared()}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(o)?(qi.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(ze(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(qi.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=i({},this.config);if(De(e)){var s,r,o,a,l,u,c,d,_,h;ji(this.config,Rn(e));var p=this._is_persistence_disabled();null==(s=this.persistence)||s.update_config(this.config,t,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Vs(i({},this.config,{persistence:"sessionStorage"}),p);var g=this._checkLocalStorageForDebug(this.config.debug);Ve(g)&&(this.config.debug=g),Ve(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,ls._is_supported()&&ls._set("ph_debug",!0),qi.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,ls._is_supported()&&ls._remove("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(o=this.exceptions)||o.onConfigChange(),null==(a=this.sessionRecording)||a.startIfEnabledOrStop(),null==(l=this.autocapture)||l.startIfEnabled(),null==(u=this.heatmaps)||u.startIfEnabled(),null==(c=this.exceptionObserver)||c.startIfEnabledOrStop(),null==(d=this.deadClicksAutocapture)||d.startIfEnabledOrStop(),null==(_=this.surveys)||_.loadIfEnabled(),this._sync_opt_out_with_persistence(),null==(h=this.externalIntegrations)||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){n.LIB_NAME=e,n.LIB_VERSION=t}startSessionRecording(e){var t,i,s,r,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(s=this.sessionRecording)||s.overrideLinkedFlag()),a.url_trigger&&(null==(r=this.sessionRecording)||r.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.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){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(i({},r,t))}}addExceptionStep(e,t){var i;null==(i=this.exceptions)||i.addExceptionStep(e,t)}captureLog(e){var t;null==(t=this.logs)||t.captureLog(e)}get logger(){var e,t;return null!==(e=null==(t=this.logs)?void 0:t.logger)&&void 0!==e?e:$n._noopLogger}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return null!==(t=null==(i=this.toolbar)?void 0:i.loadToolbar(e))&&void 0!==t&&t}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:Pn;return t!==Pn&&(t=Pn+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(U))===oe||(null==(t=this.sessionPersistence)?void 0:t.get_property(U))===oe}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ae&&!this._isIdentified()&&qe(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[Y]))}_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({},{})}setInternalOrTestUser(){this._requirePersonProcessing("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(qi.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Y,!0),!0)}_is_persistence_disabled(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==se)}_sync_opt_out_with_persistence(){var e,t,i,s,r=this._is_persistence_disabled();return(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)),r}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==re){if(this._inCookielessMode()){var i,s,r,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(s=this.pageViewManager)||s.destroy(),this.sessionManager=new en(this),this.pageViewManager=new Es(this),this.persistence&&(this.sessionPropsManager=new Xr(this,this.sessionManager,this.persistence));var a,l=null!==(r=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==r?r:null==(o=$n.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this._replaceExtension(this.sessionRecording,new l(this)),this._lastRemoteConfig&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this._lastRemoteConfig)))}var u,c;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),this._start_queue_if_opted_in(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),this.config.cookieless_mode==se&&(null==(u=this.surveys)||u.loadIfEnabled()),(ze(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(c=null==e?void 0:e.captureEventName)&&void 0!==c?c:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}else qi.warn(En)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==re?(this.config.cookieless_mode===se&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===se&&(this.register({distinct_id:Q,$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())):qi.warn(En)}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 1===e?"granted":0===e?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===re||(this.config.cookieless_mode===se?this.consent.isRejected()||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 ve?tn(ve,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){fe&&("visible"===fe.visibilityState?this._initialPageviewCaptured||(this._initialPageviewCaptured=!0,this.capture(ce,{title:fe.title},{send_instantly:!0}),this._visibilityStateListener&&(fe.removeEventListener(le,this._visibilityStateListener),this._visibilityStateListener=null)):this._visibilityStateListener||(this._visibilityStateListener=this._captureInitialPageview.bind(this),Ji(fe,le,this._visibilityStateListener)))}debug(e){!1===e?(null==pe||pe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==pe||pe.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=this._originalUserConfig||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(qi.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",!1,s=qi,r=(t="advanced_disable_flags")in(e=o)&&!Be(e[t]),n=i in e&&!Be(e[i]),r?e[t]:!!n&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){if(Be(this.config.before_send))return e;var t=Oe(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),Be(i)){var r="Event '"+e.event+"' was rejected in beforeSend function";return Ke(e.event)?qi.warn(r+". This can cause unexpected behavior."):qi.info(r),null}i.properties&&!qe(i.properties)||qi.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=Ve(e)&&!e,i=ls._is_supported()&&"true"===ls._get("ph_debug");return!t&&(!!i||e)}}function Mn(e){return e instanceof Element&&(e.id===X||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function On(e){return!!e&&1===e.nodeType}function An(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Dn(e){return!!e&&3===e.nodeType}function qn(e){return!!e&&11===e.nodeType}function zn(e){return e?Te(e).split(/\s+/):[]}function Hn(e){var t=null==pe?void 0:pe.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Nn(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 zn(t)}function jn(e){return Be(e)?null:Te(e).split(/(\s+)/).filter((e=>oo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Bn(e){var t="";return Qn(e)&&!Zn(e)&&e.childNodes&&e.childNodes.length&&Ni(e.childNodes,(function(e){var i;Dn(e)&&e.textContent&&(t+=null!==(i=jn(e.textContent))&&void 0!==i?i:"")})),Te(t)}function Un(e){return ze(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}$n.__defaultExtensionClasses={},$n._noopLogger={trace:yn=()=>{},debug:yn,info:yn,warn:yn,error:yn,fatal:yn},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Wi(e.prototype[t[i]])}($n,["identify"]);var Wn=["a","button","form","input","select","textarea","label"];function Vn(e,t){if(ze(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 Gn(e){var t=e.parentNode;return!(!t||!On(t))&&t}var Kn=["next","previous","prev",">","<"],Jn=[".ph-no-rageclick",".ph-no-capture"];var Yn=e=>!e||An(e,"html")||!On(e),Xn=(e,t)=>{if(!pe||Yn(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[e],r=e;r.parentNode&&!An(r,"body");)if(qn(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Gn(r);if(!n)break;if(t||Wn.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=pe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};function Qn(e){for(var t=e;t.parentNode&&!An(t,"body");t=t.parentNode){var i=Nn(t);if(Fe(i,"ph-sensitive")||Fe(i,"ph-no-capture"))return!1}if(Fe(Nn(e),"ph-include"))return!0;var s=e.type||"";if(He(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";return!He(r)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,""))}function Zn(e){return!!(An(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||An(e,"select")||An(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var eo="(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})",to=new RegExp("^(?:"+eo+")$"),io=new RegExp(eo),so="\\d{3}-?\\d{2}-?\\d{4}",ro=new RegExp("^("+so+")$"),no=new RegExp("("+so+")");function oo(e,t){if(void 0===t&&(t=!0),Be(e))return!1;if(He(e)){if(e=Te(e),(t?to:io).test((e||"").replace(/[- ]/g,"")))return!1;if((t?ro:no).test(e))return!1}return!0}function ao(e){var t=Bn(e);return oo(t=(t+" "+lo(e)).trim())?t:""}function lo(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Ni(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var s=Bn(e);t=(t+" "+s).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+lo(e)).trim())}catch(e){qi.error("[AutoCapture]",e)}})),t}function uo(e){return e.replace(/"|\\"/g,'\\"')}function co(e){var t=e.attr__class;return t?Oe(t)?t:zn(t):void 0}class _o{constructor(e){this.disabled=!1===e;var t=De(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&&this.timeoutMs>i-s.timestamp){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 ho="$copy_autocapture",po=zi("[AutoCapture]");function go(e,t){return t.length>e?t.slice(0,e)+"...":t}function vo(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!On(t));return t}function fo(e,t){for(var s,r,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t,c=[e],d=e;d.parentNode&&!An(d,"body");)qn(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var _,h,p=[],g={},v=!1,f=!1;if(Ni(c,(e=>{var t=Qn(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&oo(v)&&v),Fe(Nn(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};Wn.indexOf(r)>-1&&!i&&(n.$el_text="a"===r.toLowerCase()||"button"===r.toLowerCase()?go(1024,ao(e)):go(1024,Bn(e)));var o=Nn(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),Ni(e.attributes,(function(i){var r;if((!Zn(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==s||!s.includes(i.name))&&!t&&oo(i.value)&&(!He(r=i.name)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7))){var o=i.value;"class"===i.name&&(o=zn(o).join(" ")),n["attr__"+i.name]=go(1024,o)}}));for(var a=1,l=1,u=e;u=vo(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var i=function(e){if(!Qn(e))return{};var t={};return Ni(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&&oo(s)&&(t[i]=s)}})),t}(e);ji(g,i)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text="a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?ao(e):Bn(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Cs(v))?void 0:m.host,w=null==pe||null==(y=pe.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:ji({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return 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 Bi(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[uo(t.toString())]=uo(i.toString())})),(r+=":")+Bi(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).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:co(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Bi(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(h)))},null!=(s=p[0])&&s.$el_text?{$el_text:null==(r=p[0])?void 0:r.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var mo=zi("[ExceptionAutocapture]");function yo(e,t,i){try{if(!(t in e))return()=>{};var s=e[t],r=i(s);return Ae(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=r,()=>{e[t]=s}}catch(e){return()=>{}}}var bo=zi("[TracingHeaders]"),wo=zi("[Web Vitals]"),xo=9e5,Eo="disabled",So="lazy_loading",ko="awaiting_config",Co="missing_config";zi("[SessionRecording]"),zi("[SessionRecording]");var Po="[SessionRecording]",Io=zi(Po),Fo=zi("[Heatmaps]");function To(e){return De(e)&&"clientX"in e&&"clientY"in e&&Ue(e.clientX)&&Ue(e.clientY)}var Ro=zi("[Product Tours]"),Lo=["$set_once","$set"],$o=zi("[SiteApps]"),Mo="Error while initializing PostHog app with config id ";function Oo(e,t,i){if(Be(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 Ao{constructor(e){this._debugEventEmitter=new Qr,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,t;ze(null==(e=this._instance)?void 0:e._addCaptureHook)||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.on(e,t)})))}register(e){var t,i;if(!ze(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(!Oo(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=>Oo(e.href,t.href,t.href_matching||"exact")));var r,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Oo((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=>Oo(e.text,t.text,t.text_matching||"exact")||Oo(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;!Be(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=>Oo(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||an(t.properties.reduce(((e,t)=>{var i=Oe(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 Do{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&an(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===Gs?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;ze(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}));0!==t.length&&(null==this._actionMatcher&&(this._actionMatcher=new Ao(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}));0===i.length&&0===s.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Gs),this._cancelEventToItems=this._buildEventToItemMap(e,Ks))}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 u=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(u){var c=o.indexOf(u);0>c||(o.splice(c,1),this._updateActivatedItems(o))}}else{if(this._cancelEventToItems.has(e)){var d=this._getMatchingItems(e,t,Ks);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);0>t||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,Gs);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=this._getLogger(),i=[...new Set(e)].filter((e=>!this._isItemPermanentlyIneligible(e)));t.info("updating activated items",{activatedItems:i}),this._setActivatedItems(i)}getActivatedIds(){var e,t=this._getActivatedKey();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this._eventToItems}_getActionMatcher(){return this._actionMatcher}}class qo extends Do{constructor(e){super(e)}_getActivatedKey(){return q}_getShownEventName(){return Js}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return _n}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[q]:e})}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var zo="SDK is not enabled or survey functionality is not yet loaded",Ho="Disabled. Not loading surveys.",No=null!=pe&&pe.location?Fs(pe.location.hash,"__posthog")||Fs(location.hash,"state"):null,jo="_postHogToolbarParams",Bo=zi("[Toolbar]"),Uo=zi("[FeatureFlags]"),Wo=zi("[FeatureFlags]",{debugEnabled:!0}),Vo="\" failed. Feature flags didn't load in time.",Go=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},Ko=e=>{var t={};for(var[i,s]of Bi(e||{}))s&&(t[i]=s);return t},Jo=zi("[Error tracking]"),Yo="Refusing to render web experiment since the viewer is a likely bot",Xo={icontains:(e,t)=>!!pe&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!pe&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!pe&&sn(t.href,e),not_regex:(e,t)=>!!pe&&!sn(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class Qo{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{Qo._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(Qo._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);He(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];Qo._matchesTestVariant(n)&&t._applyTransforms(e.name,r,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())Qo._logInfo(Yo);else if(!this._config.disable_web_experiments){if(Be(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Qo._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=Qo.getWindowLocation();if(null!=e&&e.search){var t=Ps(null==e?void 0:e.search,"__experiment_id"),i=Ps(null==e?void 0:e.search,"__experiment_variant");t&&i&&(Qo._logInfo("previewing web experiments "+t+" && "+i),this.getWebExperiments((e=>{this._showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this._config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._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._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(Qo._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!Be(e.conditions)&&Qo._matchUrlConditions(e)&&Qo._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.url))return!0;var i,s,r,n=Qo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||Xo[null!==(s=null==(r=e.conditions)?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==pe?void 0:pe.location}static _matchUTMConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Os();if(i.utm_source){var s,r,n,o,a,l,u,c,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==(u=e.conditions)||null==(u=u.utm)||!u.utm_term||(null==(c=e.conditions)||null==(c=c.utm)?void 0:c.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;t>s;s++)i[s-1]=arguments[s];qi.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?Qo._logInfo(Yo):"control"!==t?i.forEach((i=>{if(i.selector){var s;Qo._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)}))}})):Qo._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ve&&this._instance?tn(ve,this._config.custom_blocked_useragents):void 0}}var Zo,ea,ta=zi("[Conversations]"),ia="Conversations not available yet.",sa={featureFlags:class{constructor(e){this._override_warning=!1,this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this._hasLoggedDeprecationWarning=!1,this._staleCacheRefreshTriggered=!1,this._instance=e,this.featureFlagEventHandlers=[]}get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}_prop(e){return this._instance.get_property(e)}_isCacheStale(){var e,t;return null!==(e=null==(t=this._persistence)?void 0:t._isFeatureFlagCacheStale(this._config.feature_flag_cache_ttl_ms))&&void 0!==e&&e}_checkAndTriggerStaleRefresh(){return!!this._isCacheStale()&&(this._staleCacheRefreshTriggered||this._requestInFlight||(this._staleCacheRefreshTriggered=!0,Uo.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_getValidEvaluationEnvironments(){var e,t=null!==(e=this._config.evaluation_contexts)&&void 0!==e?e:this._config.evaluation_environments;return!this._config.evaluation_environments||this._config.evaluation_contexts||this._hasLoggedDeprecationWarning||(Uo.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this._hasLoggedDeprecationWarning=!0),null!=t&&t.length?t.filter((e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||Uo.error("Invalid evaluation context found:",e,"Expected non-empty string"),t})):[]}_shouldIncludeEvaluationEnvironments(){return this._getValidEvaluationEnvironments().length>0}initialize(){var e,t,{config:i}=this._instance,s=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(s).length){var r,n,o=null!==(r=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==r?r:{},a=Object.keys(s).filter((e=>!!s[e])).reduce(((e,t)=>(e[t]=s[t]||!1,e)),{}),l=Object.keys(o).filter((e=>a[e])).reduce(((e,t)=>(o[t]&&(e[t]=o[t]),e)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(e,t,s){var r=null!=s&&s.merge?this.getFlagVariants():{},n=null!=s&&s.merge?this.getFlagPayloads():{},o=i({},r,e),a=i({},n,t),l={};for(var[u,c]of Object.entries(o)){var d="string"==typeof c;l[u]={key:u,enabled:!!d||Boolean(c),variant:d?c:void 0,reason:void 0,metadata:ze(null==a?void 0:a[u])?void 0:{id:0,version:void 0,description:void 0,payload:a[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._prop(F),t=this._prop(L),s=this._prop(M);if(!s&&!t)return e||{};var r=ji({},e||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=r[o],c=null==t?void 0:t[o],d=ze(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=ze(c)?u.variant:"string"==typeof c?c:void 0,h=null==s?void 0:s[o],p=i({},u,{enabled:d,variant:d?null!=_?_:null==u?void 0:u.variant:void 0});d!==(null==u?void 0:u.enabled)&&(p.original_enabled=null==u?void 0:u.enabled),_!==(null==u?void 0:u.variant)&&(p.original_variant=null==u?void 0:u.variant),h&&(p.metadata=i({},null==u?void 0:u.metadata,{payload:h,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),r[o]=p}return this._override_warning||(Uo.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:s,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._prop(C),t=this._prop(L);if(!t)return e||{};for(var i=ji({},e),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(Uo.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(T),t=this._prop(M);if(!t)return e||{};for(var i=ji({},e||{}),s=Object.keys(t),r=0;s.length>r;r++)i[s[r]]=t[s[r]];return this._override_warning||(Uo.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this._config.advanced_disable_feature_flags||this._reloadDebouncer||(this._instance._internalEventEmitter.emit("featureFlagsReloading",!0),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._config.token,r=this._prop(a),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._persistence)?void 0:t.get_initial_props())||{},this._prop(O)||{}),group_properties:this._prop(A),timezone:Bs()};je(r)||ze(r)||(n.$device_id=r),(null!=e&&e.disableFlags||this._config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this._shouldIncludeEvaluationEnvironments()&&(n.evaluation_contexts=this._getValidEvaluationEnvironments());var o=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this._config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this._requestInFlight=!0,this._instance._send_request({method:"POST",url:o,data:n,compression:this._config.disable_compression?void 0:sr,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,s,r=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),r=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!r;var o=[];e.error?e.error instanceof Error?o.push("AbortError"===e.error.name?"timeout":"connection_error"):o.push("unknown_error"):200!==e.statusCode&&o.push("api_error_"+e.statusCode),null!=(t=e.json)&&t.errorsWhileComputingFlags&&o.push("errors_while_computing_flags");var a,l=!(null==(i=e.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(l&&o.push("quota_limited"),null==(s=this._persistence)||s.register({[j]:o}),l)Uo.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 n.disable_flags||this.receivedFeatureFlags(null!==(a=e.json)&&void 0!==a?a:{},r,{partialResponse:!!this._config.advanced_only_evaluate_survey_feature_flags}),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callFlagsEndpoint())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var s=this.getFeatureFlagResult(e,t);return null!==(i=null==s?void 0:s.variant)&&void 0!==i?i:null==s?void 0:s.enabled}}else Uo.warn('getFeatureFlag for key "'+e+Vo)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),!t.fresh||this._flagsLoadedFromRemote)if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){if(!this._checkAndTriggerStaleRefresh()){var i=this.getFlagVariants(),s=e in i,r=i[e],n=this.getFlagPayloads()[e],o=String(r),a=this._prop(R)||void 0,l=this._prop(B)||void 0,u=this._prop(H)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(N);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[H]:u,[N]:d}))}if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,v,f,m,y,b,w,x;Oe(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[H]:u});var E=this.getFeatureFlagDetails(e),S=[...null!==(p=this._prop(j))&&void 0!==p?p:[]];ze(r)&&S.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(g=this._config.bootstrap)||null==(g=g.featureFlags)?void 0:g[e])||null,$feature_flag_bootstrapped_payload:(null==(v=this._config.bootstrap)||null==(v=v.featureFlagPayloads)?void 0:v[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};ze(null==E||null==(f=E.metadata)?void 0:f.version)||(k.$feature_flag_version=E.metadata.version);var C,P=null!==(m=null==E||null==(y=E.reason)?void 0:y.description)&&void 0!==m?m:null==E||null==(b=E.reason)?void 0:b.code;P&&(k.$feature_flag_reason=P),null!=E&&null!=(w=E.metadata)&&w.id&&(k.$feature_flag_id=E.metadata.id),ze(null==E?void 0:E.original_variant)&&ze(null==E?void 0:E.original_enabled)||(k.$feature_flag_original_response=ze(E.original_variant)?E.original_enabled:E.original_variant),null!=E&&null!=(x=E.metadata)&&x.original_payload&&(k.$feature_flag_original_payload=null==E||null==(C=E.metadata)?void 0:C.original_payload),S.length&&(k.$feature_flag_error=S.join(",")),this._instance.capture("$feature_flag_called",k)}if(s){var I=n;if(!ze(n))try{I=JSON.parse(n)}catch(e){}return{key:e,enabled:!!r,variant:"string"==typeof r?r:void 0,payload:I}}}}else Uo.warn('getFeatureFlagResult for key "'+e+Vo)}getRemoteConfigPayload(e,t){var i=this._config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(s.evaluation_contexts=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this._config.disable_compression?void 0:sr,timeout:this._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={}),!t.fresh||this._flagsLoadedFromRemote){if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return ze(i)?void 0:!!i}Uo.warn('isFeatureEnabled for key "'+e+Vo)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,s){if(this._persistence){this._hasLoadedFlags=!0;var r=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,s,r,n,o){void 0===s&&(s={}),void 0===r&&(r={}),void 0===n&&(n={});var a=(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]})))):Uo.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),l=a.flags,u=a.featureFlags,c=a.featureFlagPayloads;if(u){var d=e.requestId,_=e.evaluatedAt;if(Oe(u)){Uo.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(u)for(var p=0;u.length>p;p++)h[u[p]]=!0;t&&t.register({[P]:u,[C]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},s,g),v=i({},r,v),f=i({},n,f);else if(e.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((e=>{var t;return!(null!=(t=l[e])&&t.failed)})));g=i({},s,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},r,Object.fromEntries(Object.entries(v||{}).filter((e=>{var[t]=e;return m.has(t)})))),f=i({},n,Object.fromEntries(Object.entries(f||{}).filter((e=>{var[t]=e;return m.has(t)}))))}else g=i({},s,g),v=i({},r,v),f=i({},n,f);t&&t.register(i({[P]:Object.keys(Ko(g)),[C]:g||{},[T]:v||{},[F]:f||{}},d?{[R]:d}:{},_?{[B]:_}:{}))}}}(e,this._persistence,r,n,o,s),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),Uo.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return Uo.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(L),this._persistence.unregister(M),this._fireFeatureFlagsCallbacks(),Wo.info("All overrides cleared");if(Oe(e)){var t=Go(e);return this._persistence.register({[L]:t}),this._fireFeatureFlagsCallbacks(),Wo.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,s=e;if(this._override_warning=Boolean(null!==(i=s.suppressWarning)&&void 0!==i&&i),"flags"in s)if(!1===s.flags)this._persistence.unregister(L),Wo.info("Flag overrides cleared");else if(s.flags){if(Oe(s.flags)){var r=Go(s.flags);this._persistence.register({[L]:r})}else this._persistence.register({[L]:s.flags});Wo.info("Flag overrides set",{flags:s.flags})}return"payloads"in s&&(!1===s.payloads?(this._persistence.unregister(M),Wo.info("Payload overrides cleared")):s.payloads&&(this._persistence.register({[M]:s.payloads}),Wo.info("Payload overrides set",{payloads:s.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[L]:e}),this._fireFeatureFlagsCallbacks(),Wo.info("Flag overrides set",{flags:e});Uo.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:e})}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._prop(I)||[]).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._persistence)||r.register({[P]:Object.keys(Ko(l)),[C]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var s=this._prop(I),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._config.token+r),method:"GET",callback:t=>{var i,s;if(t.json){var r=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(I),null==(s=this._persistence)||s.register({[I]: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._prop(O)||{},r=(null==e?void 0:e.$set)||(null!=e&&e.$set_once?{}:e),n=null==e?void 0:e.$set_once,o={};if(n)for(var a in n)({}).hasOwnProperty.call(n,a)&&(a in s||(o[a]=n[a]));this._instance.register({[O]:i({},s,o,r)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(O)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var s=this._prop(A)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((t=>{s[t]=i({},s[t],e[t]),delete e[t]})),this._instance.register({[A]:i({},s,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._prop(A)||{};this._instance.register({[A]:i({},t,{[e]:{}})})}else this._instance.unregister(A)}reset(){this._hasLoadedFlags=!1,this._requestInFlight=!1,this._reloadingDisabled=!1,this._additionalReloadRequested=!1,this._flagsLoadedFromRemote=!1,this.$anon_distinct_id=void 0,this._clearDebouncer(),this._override_warning=!1}}},ra={sessionRecording:class{get _config(){return this._instance.config}get _persistence(){return this._instance.persistence}get started(){var e;return!(null==(e=this._lazyLoadedSessionRecording)||!e.isStarted)}get status(){var e,t;return this._recordingStatus===ko||this._recordingStatus===Co?this._recordingStatus:null!==(e=null==(t=this._lazyLoadedSessionRecording)?void 0:t.status)&&void 0!==e?e:this._recordingStatus}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this._recordingStatus=Eo,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Io.error("started without valid sessionManager"),new Error(Po+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===re)throw new Error(Po+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get _isRecordingEnabled(){var e,t=!(null==(e=this._instance.get_property(y))||!e.enabled),i=!this._config.disable_session_recording,s=this._config.disable_session_recording||this._instance.consent.isOptedOut();return pe&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!ze(Object.assign)&&!ze(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Io.info("starting")):(this._recordingStatus=Eo,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,s;this._isRecordingEnabled&&(this._recordingStatus!==ko&&this._recordingStatus!==Co&&(this._recordingStatus=So),null!=Se&&null!=(t=Se.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=Se.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(s=Se.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Io.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()}_discardRecording(){var e,t;null==(e=this._persistFlagsOnSessionListener)||e.call(this),this._persistFlagsOnSessionListener=void 0,null==(t=this._lazyLoadedSessionRecording)||t.discard()}_resetSampling(){var e;null==(e=this._persistence)||e.unregister(k)}_validateSampleRate(e,t){if(Be(e))return null;var i,s=Ue(e)?e:parseFloat(e);return"number"!=typeof(i=s)||!Number.isFinite(i)||0>i||i>1?(Io.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):s}_persistRemoteConfig(e){if(this._persistence){var t,s,r=this._persistence,n=()=>{var t,s=!1===e.sessionRecording?void 0:e.sessionRecording,n=this._validateSampleRate(null==(t=this._config.session_recording)?void 0:t.sampleRate,"session_recording.sampleRate"),o=this._validateSampleRate(null==s?void 0:s.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Be(a)&&this._resetSampling();var l=null==s?void 0:s.minimumDurationMilliseconds;r.register({[y]:i({cache_timestamp:Date.now(),enabled:!!s},s,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==s?void 0:s.networkPayloadCapture),canvasRecording:{enabled:null==s?void 0:s.recordCanvas,fps:null==s?void 0:s.canvasFps,quality:null==s?void 0:s.canvasQuality},sampleRate:a,minimumDurationMilliseconds:ze(l)?null:l,endpoint:null==s?void 0:s.endpoint,triggerMatchType:null==s?void 0:s.triggerMatchType,masking:null==s?void 0:s.masking,urlTriggers:null==s?void 0:s.urlTriggers,version:null==s?void 0:s.version,triggerGroups:null==s?void 0:s.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(s=this._instance.sessionManager)?void 0:s.onSessionId(n)}}onRemoteConfig(e){return"sessionRecording"in e?!1===e.sessionRecording?(this._persistRemoteConfig(e),void this._discardRecording()):(this._persistRemoteConfig(e),void this.startIfEnabledOrStop()):(this._recordingStatus===ko&&(this._recordingStatus=Co,Io.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this._lazyLoadedSessionRecording)&&i.log?this._lazyLoadedSessionRecording.log(e,t):Io.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(y);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}_isRemoteConfigFresh(){var e,t=this._instance.get_property(y);if(!t)return!1;var i=null!==(e=("object"==typeof t?t:JSON.parse(t)).cache_timestamp)&&void 0!==e?e:Date.now();return 36e5>=Date.now()-i}_onScriptLoaded(e){var t,i;if(null==(t=Se.__PosthogExtensions__)||!t.initSessionRecording)return Io.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[te]:!0});if(this._lazyLoadedSessionRecording||(this._lazyLoadedSessionRecording=null==(i=Se.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Co||this._recordingStatus===ko)return;return this._recordingStatus=ko,Io.info("persisted remote config is stale, requesting fresh config before starting"),void new tr(this._instance).load()}this._recordingStatus=So,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._persistence)||t.register({[w]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this._lazyLoadedSessionRecording||null==(t=this._persistence)||t.register({[b]:!0}),null==(e=this._lazyLoadedSessionRecording)||e.overrideSampling()}overrideTrigger(e){var t,i;this._lazyLoadedSessionRecording||null==(i=this._persistence)||i.register({["url"===e?x:E]:!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))}}},na={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new _o(e.config.rageclick),this._elementSelectors=null}initialize(){this.startIfEnabled()}get _config(){var e,t,i=De(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(pe&&fe){var e=e=>{e=e||(null==pe?void 0:pe.event);try{this._captureEvent(e)}catch(e){po.error("Failed to capture event",e)}};if(Ji(fe,"submit",e,{capture:!0}),Ji(fe,"change",e,{capture:!0}),Ji(fe,"click",e,{capture:!0}),this._config.capture_copied_text){var t=e=>{this._captureEvent(e=e||(null==pe?void 0:pe.event),ho)};Ji(fe,"copy",t,{capture:!0}),Ji(fe,"cut",t,{capture:!0})}}}else po.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({[c]:!!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==fe?void 0:fe.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[c];if(je(this._isDisabledServerSide)&&!Ve(i)&&!this.instance._shouldDisableFlags())return!1;var s=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,s=Un(e);Dn(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())&&function(e,t){if(!pe||Yn(e))return!1;var i,s,r;if(Ve(t)?(i=!!t&&Jn,s=void 0):(i=null!==(r=null==t?void 0:t.css_selector_ignorelist)&&void 0!==r?r:Jn,s=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Xn(e,!1);return!function(e,t){if(!1===e||ze(e))return!1;var i;if(!0===e)i=Kn;else{if(!Oe(e))return!1;if(e.length>10)return qi.error("[PostHog] content_ignorelist array cannot exceed 10 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,n.map((e=>{var t;return{safeText:Bn(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!Vn(n,i)}(s,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var r=t===ho;if(s&&function(e,t,i,s,r){var n,o,a,l;if(void 0===i&&(i=void 0),!pe||Yn(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!Hn(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&Hn(i.url_ignorelist))return!1;if(null!=(a=i)&&a.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((e=>t.type===e)))return!1}var{parentIsUsefulElement:c,targetElementList:d}=Xn(e,s);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(ze(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}(d,i))return!1;if(!Vn(d,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var _=pe.getComputedStyle(e);if(_&&"pointer"===_.getPropertyValue("cursor")&&"click"===t.type)return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return c?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(Wn.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this._config,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=fo(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(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),t===ho){var l,u=jn(null==pe||null==(l=pe.getSelection())?void 0:l.toString()),c=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return Ae(null==fe?void 0:fe.querySelectorAll)}},historyAutocapture:class{constructor(e){var t;this._instance=e,this._lastPathname=(null==pe||null==(t=pe.location)?void 0:t.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(qi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,qi.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(pe&&pe.history){var i=this;null!=(e=pe.history.pushState)&&e.__posthog_wrapped__||yo(pe.history,"pushState",(e=>function(t,s,r){e.call(this,t,s,r),i._capturePageview("pushState")})),null!=(t=pe.history.replaceState)&&t.__posthog_wrapped__||yo(pe.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==pe||null==(t=pe.location)?void 0:t.pathname;if(!i)return;i!==this._lastPathname&&this.isEnabled&&this._instance.capture(ce,{navigation_type:e}),this._lastPathname=i}catch(t){qi.error("Error capturing "+e+" pageview",t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};Ji(pe,"popstate",e),this._popstateListener=()=>{pe&&pe.removeEventListener("popstate",e)}}}},heatmaps:class{get _config(){return this.instance.config}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[d]),this.rageclicks=new _o(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return De(this._config.capture_heatmaps)&&this._config.capture_heatmaps.flush_interval_milliseconds&&(e=this._config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return Be(this._config.capture_heatmaps)?Be(this._config.enable_heatmaps)?this._enabledServerSide:this._config.enable_heatmaps:!1!==this._config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Fo.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){if("heatmaps"in e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[d]: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)}(fe)?setInterval(this._flush.bind(this),this.flushIntervalMilliseconds):null}_setupListeners(){pe&&fe&&(this._flushHandler=this._flush.bind(this),Ji(pe,ue,this._flushHandler),this._onClickHandler=e=>this._onClick(e||(null==pe?void 0:pe.event)),Ji(fe,"click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler=e=>this._onMouseMove(e||(null==pe?void 0:pe.event)),Ji(fe,"mousemove",this._onMouseMoveHandler,{capture:!0}),this._deadClicksCapture=new ms(this.instance,vs,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabledOrStop(),this._onVisibilityChange_handler=this._onVisibilityChange.bind(this),Ji(fe,le,this._onVisibilityChange_handler),this._initialized=!0)}_removeListeners(){var e;pe&&fe&&(this._flushHandler&&pe.removeEventListener(ue,this._flushHandler),this._onClickHandler&&fe.removeEventListener("click",this._onClickHandler,{capture:!0}),this._onMouseMoveHandler&&fe.removeEventListener("mousemove",this._onMouseMoveHandler,{capture:!0}),this._onVisibilityChange_handler&&fe.removeEventListener(le,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(),r=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var s=e;s&&On(s)&&!An(s,"body");){if(s===i)return!1;if(Fe(t,null==pe?void 0:pe.getComputedStyle(s).position))return!0;s=Gn(s)}return!1}(Un(e),["fixed","sticky"],r);return{x:e.clientX+(n?0:s),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var s;if(void 0===t&&(t="click"),!Mn(e.target)&&To(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){!Mn(e.target)&&To(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(pe){var t=pe.location.href,i=this._config.custom_personal_data_properties,s=this._config.mask_personal_data_properties?[...Rs,...i||[]]:[],r=Is(t,s,$s);this._buffer=this._buffer||{},this._buffer[r]||(this._buffer[r]=[]),this._buffer[r].push(e)}}_flush(){this._buffer&&!qe(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ms,webVitalsAutocapture:class{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(ze(s))wo.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();ze(r)||(Be(null==e?void 0:e.name)||Be(null==e?void 0:e.value)?wo.error("Invalid metric received",e):!this._maxAllowedValue||this._maxAllowedValue>e.value?(this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),ze(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=ze(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()):wo.error("Ignoring metric with value >= "+this._maxAllowedValue,e))}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,s,r=Se.__PosthogExtensions__;ze(r)||ze(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):wo.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this._enabledServerSide=!(null==(t=this._instance.persistence)||!t.props[g]),this.startIfEnabled()}get _perfConfig(){return this._instance.config.capture_performance}get allowedMetrics(){var e,t,i=De(this._perfConfig)?null==(e=this._perfConfig)?void 0:e.web_vitals_allowed_metrics:void 0;return Be(i)?(null==(t=this._instance.persistence)?void 0:t.props[m])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(De(this._perfConfig)?this._perfConfig.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=De(this._perfConfig)?this._perfConfig.web_vitals_attribution:void 0;return null!=e&&e}get _maxAllowedValue(){var e=De(this._perfConfig)&&Ue(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:xo;return e>0&&6e4>=e?xo:e}get isEnabled(){var e=null==me?void 0:me.protocol;if("http:"!==e&&"https:"!==e)return wo.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=De(this._perfConfig)?this._perfConfig.web_vitals:Ve(this._perfConfig)?this._perfConfig:void 0;return Ve(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(wo.info("enabled, starting..."),this._loadScript(this._startCapturing))}onRemoteConfig(e){if("capturePerformance"in e){var t=De(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=De(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[g]:t}),this._instance.persistence.register({[m]:i})),this._enabledServerSide=t,this.startIfEnabled()}}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?wo.error("failed to load script",t):e()}))}_currentURL(){var e=pe?pe.location.href:void 0;if(e){var t=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Rs,...t||[]]:[];return Is(e,i,$s)}wo.error("Could not determine current URL")}}},oa={exceptionObserver:class{constructor(e){var t,i,s;this._startCapturing=()=>{var e;if(pe&&this.isEnabled&&null!=(e=Se.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=Se.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=Se.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=Se.__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){mo.error("failed to start",e),this._stopCapturing()}}},this._instance=e,this._remoteEnabled=!(null==(t=this._instance.persistence)||!t.props[_]),this._rateLimiter=new it({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:mo}),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 De(e)?t=i({},t,e):(ze(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?(mo.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return mo.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){"autocaptureExceptions"in e&&(this._remoteEnabled=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[_]:this._remoteEnabled}),this._config=this._requiredConfig(),this.startIfEnabledOrStop())}onConfigChange(){this._config=this._requiredConfig()}captureException(e){var t,i,s,r=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(r)?mo.info("Skipping exception capture because of client rate limiting.",{exception:r}):null==(s=this._instance.exceptions)||s.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,s;this._suppressionRules=[],this._errorPropertiesBuilder=new ai([new yi,new Fi,new wi,new bi,new Pi,new Ci,new Ei,new Ii],function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),r=1;t>r;r++)s[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var n=[],o=t.split("\n"),a=r;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=mi.test(l)?l.replace(mi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of s){var d=c(u,e);if(d){n.push(d);break}}if(n.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map((e=>{return i({},e,{filename:e.filename||(s=t,s[s.length-1]||{}).filename,function:e.function||li});var s}))}(n)}}("web:javascript",pi,fi)),this._instance=e,this._suppressionRules=null!==(t=null==(s=this._instance.persistence)?void 0:s.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Oi(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,s;if("errorTracking"in e){var 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({[h]:this._suppressionRules,[p]:n})}}get _captureExtensionExceptions(){var e,t=!!this._instance.get_property(p),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}})}addExceptionStep(e,t){if(this._exceptionStepsConfig.enabled)try{if(!He(e)||0===e.trim().length)return void Jo.warn("Ignoring exception step because message must be a non-empty string");var s=this._coerceExceptionStepProperties(t),{sanitizedProperties:r,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,s)=>Li.has(s)?(t.push(s),i):(i[s]=e[s],i)),{}),droppedKeys:t}}(s);n.length>0&&Jo.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[Ti]:e,[Ri]:(new Date).toISOString()},r))}catch(e){Jo.error("Failed to add exception step. Ignoring breadcrumb.",e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this._isExceptionList(t)){if(this._matchesSuppressionRule(t))return this._addDroppedExceptionStep("Exception dropped: matched a suppression rule"),void Jo.info("Skipping exception capture because a suppression rule matched");if(!this._captureExtensionExceptions&&this._isExtensionException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by a browser extension"),void Jo.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this._isPostHogException(t))return this._addDroppedExceptionStep("Exception dropped: thrown by the PostHog SDK"),void Jo.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this._exceptionStepsConfig.enabled&&Be(e.$exception_steps)?this._addBufferedExceptionSteps(e):e;try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return s&&this._exceptionStepsBuffer.clear(),s}catch(e){return Jo.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void Jo.error("Failed to process exception event. Ignoring this exception.",e)}}_addBufferedExceptionSteps(e){try{var t=this._exceptionStepsBuffer.getAttachable();return 0===t.length?e:i({},e,{$exception_steps:t})}catch(t){return Jo.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Ti]:e,[Ri]:(new Date).toISOString()})}_coerceExceptionStepProperties(e){return De(e)?i({},e):{}}_getExceptionStepsConfig(){var e,t;return null!==(e=null==(t=this._instance.config.error_tracking)?void 0:t.exception_steps)&&void 0!==e?e:{}}_matchesSuppressionRule(e){if(0===e.length)return!1;var t=e.reduce(((e,t)=>{var{type:i,value:s}=t;return He(i)&&i.length>0&&e.$exception_types.push(i),He(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=nn[e.operator],r=Oe(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!Be(e)&&Oe(e)}}},aa=i({productTours:class{get _persistence(){return this._instance.persistence}constructor(e){this._productTourManager=null,this._cachedTours=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){"productTours"in e&&(this._persistence&&this._persistence.register({[f]:!!e.productTours}),this.loadIfEnabled())}loadIfEnabled(){var e,t;this._productTourManager||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(f)||this._loadScript((()=>this._startProductTours()))}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Ro.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=Se.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=Se.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Oe(this._cachedTours)||t){var i=this._persistence;if(i){var s=i.props[z];if(Oe(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 Ro.error(r),void e([],{isLoaded:!1,error:r})}var n=Oe(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[z]:n}),e(n,{isLoaded:!0})}})}else e(this._cachedTours,{isLoaded:!0})}getActiveProductTours(e){Be(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._persistence)||e.unregister(z)}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)}}},sa),la={siteApps:class{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=Se._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.siteApps}initialize(){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,u;if(!e)throw new Error("Event payload is required");var c={},d=this._instance.get_property("$groups")||[],_=this._instance.get_property("$stored_group_properties")||{};for(var[h,p]of Object.entries(_))c[h]={id:d[h],type:h,properties:p};var{$set_once:g,$set:v}=e;return{event:i({},s(e,Lo),{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==(u=e.properties)?void 0:u.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this._bufferedInvocations.length&&($o.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,$o.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){$o.error(Mo+e.id,t),r(!1)}if(s&&t.loaded)try{i()}catch(i){$o.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){$o.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 $o.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;Se["__$$ph_site_app_"+e]=r._instance,null==(t=Se.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(r._instance,a,(t=>{if(t)return $o.error(Mo+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else $o.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},ua={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t,i=this._getConfiguredHostnames()||[];ze(this._restoreXHRPatch)&&(null==(e=Se.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),ze(this._restoreFetchPatch)&&(null==(t=Se.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(i,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}initialize(){this.startIfEnabledOrStop()}_loadScript(e){var t,i;null!=(t=Se.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=Se.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return bo.error("failed to load script",t);e()}))}_getConfiguredHostnames(){var e;return null!==(e=this._instance.config.addTracingHeaders)&&void 0!==e?e:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var e,t;this._getConfiguredHostnames()?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)}}},ca=i({surveys:class{get _config(){return this._instance.config}constructor(e){this._isSurveysEnabled=void 0,this._surveyManager=null,this._isInitializingSurveys=!1,this._surveyCallbacks=[],this._getSurveysInFlightPromise=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._config.disable_surveys){var t=e.surveys;if(Be(t))return _n.warn("Flags not loaded yet. Not loading surveys.");var i=Oe(t);this._isSurveysEnabled=i?t.length>0:t,_n.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)_n.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)_n.info(Ho);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())_n.info("Not loading surveys in cookieless mode without consent.");else{var e=null==Se?void 0:Se.__PosthogExtensions__;if(e){if(!ze(this._isSurveysEnabled)||this._config.advanced_enable_surveys){var t=this._isSurveysEnabled||this._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(ie);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 _n.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new qo(this._instance),_n.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){_n.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._config.disable_surveys)return _n.info(Ho),e([]);var i,s=this._instance.get_property(D);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._config.token),method:"GET",timeout:this._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;_n.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],u=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))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(s=this._instance.persistence)||s.register({[D]:l});var c={isLoaded:!0};e(l,c),null==i||i({surveys:l,context:c})}}))}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){_n.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Be(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);_n.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(Be(this._surveyManager))return{eligible:!1,reason:zo};var t="string"==typeof e?this._getSurveyById(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Be(this._surveyManager))return _n.warn("init was not called"),{visible:!1,disabledReason:zo};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Be(this._surveyManager)?(_n.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:zo})):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,i){var s;if(Be(this._surveyManager))_n.warn("init was not called");else{var r="string"==typeof e?this._getSurveyById(e):e;if(null!=r&&r.id)if(pn.includes(r.type)){var n=null==fe?void 0:fe.querySelector(t);if(n)return null!=(s=r.appearance)&&s.surveyPopupDelaySeconds?(_n.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;_n.info("Rendering survey "+r.id+" with delay of "+(null==(e=r.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(r,n,i),_n.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,i);_n.warn("Survey element not found")}else _n.warn("Surveys of type "+r.type+" cannot be rendered in the app");else _n.warn("Survey not found")}}displaySurvey(e,t){var s;if(Be(this._surveyManager))_n.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})})),t.displayType!==Xs&&t.initialResponses&&_n.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(r);if(!o.visible)return void _n.warn("Survey is not eligible to be displayed: ",o.disabledReason)}"inline"!==t.displayType?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else _n.warn("Survey not found")}}cancelPendingSurvey(e){Be(this._surveyManager)?_n.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},sa),da={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){Se.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=Se.ph_toolbar_state)&&void 0!==e?e:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),Yi(this.instance.config))return!1;if(!pe||!fe)return!1;e=null!=e?e:pe.location,i=null!=i?i:pe.history;try{if(!t){try{pe.localStorage.setItem("test","test"),pe.localStorage.removeItem("test")}catch(e){return!1}t=null==pe?void 0:pe.localStorage}var s,r=No||Fs(e.hash,"__posthog")||Fs(e.hash,"state"),n=r?Ui((()=>JSON.parse(atob(decodeURIComponent(r)))))||Ui((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&"ph_authorize"===n.action?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(jo)||"{}")).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=Se.ph_load_toolbar||Se.ph_load_editor;!Be(t)&&Ae(t)?t(e,this.instance):Bo.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==fe||!fe.getElementById(X));if(!pe||t)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(pe.localStorage.setItem(jo,JSON.stringify(i({},r,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(r);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=Se.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return Bo.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(r)})),Ji(pe,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(r)}))}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)}}},_a=i({experiments:Qo},sa),ha={conversations:class{constructor(e){this._isConversationsEnabled=void 0,this._conversationsManager=null,this._isInitializing=!1,this._remoteConfig=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;Be(t)||(Ve(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||Yi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==Se?void 0:Se.__PosthogExtensions__;if(e&&!ze(this._isConversationsEnabled)&&this._isConversationsEnabled)if(this._remoteConfig&&this._remoteConfig.token){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(ie);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 ta.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),ta.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else ta.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){ta.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():ta.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!je(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,s){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,i,s):(ta.warn(ia),null)}))()}getMessages(e,i){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.getMessages(e,i):(ta.warn(ia),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(ta.warn(ia),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(ta.warn(ia),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(ta.warn(ia),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(ta.warn(ia),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(ta.warn(ia),null)}))()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}_onIdentityChanged(){var e;null==(e=this._conversationsManager)||e.setIdentity()}_onIdentityCleared(){var e;null==(e=this._conversationsManager)||e.clearIdentity()}}},pa={logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=zi("[logs]"),this._logBuffer=[],this._intervalLogCount=0,this._intervalWindowStart=0,this._droppedWarned=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this._isLogsEnabled=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!Be(i)&&i&&(this._isLogsEnabled=!0,this.loadIfEnabled())}reset(){this._logBuffer=[],this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0),this._intervalLogCount=0,this._intervalWindowStart=0,this._droppedWarned=!1}loadIfEnabled(){if(this._isLogsEnabled&&!this._isLoaded){var e=null==Se?void 0:Se.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(t=>{var i;t||null==(i=e.logs)||!i.initializeLogs?this._logger.error("Could not load logs script",t):(e.logs.initializeLogs(this._instance),this._isLoaded=!0)})):this._logger.error(ie)}else this._logger.error("PostHog Extensions not found.")}}captureLog(e){var t,s,r,n,o,a;if(this._instance.is_capturing())if(e&&e.body){var l=null!==(t=null==(s=this._instance.config.logs)?void 0:s.flushIntervalMs)&&void 0!==t?t:3e3,u=null!==(r=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==r?r:1e3,c=Date.now();if(l>c-this._intervalWindowStart||(this._intervalWindowStart=c,this._intervalLogCount=0,this._droppedWarned=!1),u>this._intervalLogCount){this._intervalLogCount++;var d=function(e,t){var s=e.level||"info",{text:r,number:n}=ii[s]||si,o=String(Date.now())+"000000",a={};t.distinctId&&(a.posthogDistinctId=t.distinctId),t.sessionId&&(a.sessionId=t.sessionId),t.currentUrl&&(a["url.full"]=t.currentUrl),t.screenName&&(a["screen.name"]=t.screenName),t.appState&&(a["app.state"]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(a.feature_flags=t.activeFeatureFlags);var l=i({},a,e.attributes||{}),u={timeUnixNano:o,observedTimeUnixNano:o,severityNumber:n,severityText:r,body:{stringValue:e.body},attributes:ni(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),ze(e.trace_flags)||(u.flags=e.trace_flags),u}(e,this._getSdkContext());this._logBuffer.push({record:d}),(null!==(o=null==(a=this._instance.config.logs)?void 0:a.maxBufferSize)&&void 0!==o?o:100)>this._logBuffer.length?this._scheduleFlush():this.flushLogs()}else this._droppedWarned||(this._logger.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this._droppedWarned=!0)}else this._logger.warn("captureLog requires a body")}get logger(){return this._logger_instance||(this._logger_instance={trace:(e,t)=>this.captureLog({body:e,level:"trace",attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:"debug",attributes:t}),info:(e,t)=>this.captureLog({body:e,level:"info",attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:"warn",attributes:t}),error:(e,t)=>this.captureLog({body:e,level:"error",attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:"fatal",attributes:t})}),this._logger_instance}flushLogs(e){if(this._flushTimeout&&(clearTimeout(this._flushTimeout),this._flushTimeout=void 0),0!==this._logBuffer.length){var t=this._logBuffer;this._logBuffer=[];var s=this._instance.config.logs,r=i({"service.name":(null==s?void 0:s.serviceName)||"unknown_service"},(null==s?void 0:s.environment)&&{"deployment.environment":s.environment},(null==s?void 0:s.serviceVersion)&&{"service.version":s.serviceVersion},null==s?void 0:s.resourceAttributes),o=function(e,t,i,s){return{resourceLogs:[{resource:{attributes:ni(t)},scopeLogs:[{scope:{name:i,version:s},logRecords:e}]}]}}(t.map((e=>e.record)),r,n.LIB_NAME,n.LIB_VERSION),a=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance._send_retriable_request({method:"POST",url:a,data:o,compression:"best-available",batchKey:"logs",transport:e})}}_scheduleFlush(){var e,t;this._flushTimeout||(this._flushTimeout=setTimeout((()=>{this._flushTimeout=void 0,this.flushLogs()}),null!==(e=null==(t=this._instance.config.logs)?void 0:t.flushIntervalMs)&&void 0!==e?e:3e3))}_getSdkContext(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);t.sessionId=i}if(null!=Se&&null!=(e=Se.location)&&e.href&&(t.currentUrl=Se.location.href),this._instance.featureFlags){var s=this._instance.featureFlags.getFlags();s&&s.length>0&&(t.activeFeatureFlags=s)}return t}}},ga=i({},sa,ra,na,oa,aa,la,ca,ua,da,_a,ha,pa);$n.__defaultExtensionClasses=i({},ga),Zo=bn[Pn]=new $n,(ea=Se.posthog)&&Ni(ea._i,(function(e){if(e&&Oe(e)){var t=Zo.init(e[0],e[1],e[2]),i=ea[e[2]]||ea;t&&(t._execute_array.call(t.people,i.people),t._execute_array(i))}})),Se.posthog=Zo,function(){function e(){e.done||(e.done=!0,In=!1,Ni(bn,(function(e){e._dom_loaded()})))}null!=fe&&fe.addEventListener?"complete"===fe.readyState?e():Ji(fe,"DOMContentLoaded",e,{capture:!1}):pe&&qi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}()}();
2
2
  //# sourceMappingURL=array.no-external.js.map