posthog-js 1.372.6 → 1.372.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- function e(e,t,i,r,s,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(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,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 r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="1.372.6",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},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",E="$replay_override_url_trigger",S="$replay_override_event_trigger",x="$sesid",k="$session_is_sampled",I="$enabled_feature_flags",C="$active_feature_flags",P="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",F="$feature_flag_request_id",L="$override_feature_flags",O="$override_feature_flag_payloads",M="$stored_person_properties",A="$stored_group_properties",D="$surveys",N="$surveys_activated",U="ph_product_tours",q="$flag_call_reported",H="$flag_call_reported_session_id",z="$feature_flag_errors",B="$feature_flag_evaluated_at",j="$user_state",V="$client_session_props",W="$capture_rate_limit",G="$initial_campaign_params",Y="$initial_referrer_info",K="$initial_person_info",J="$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.",re="on_reject",se="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,Ee=null==ge?void 0:ge.CompressionStream,Se=null==ve?void 0:ve.userAgent,xe=null!=pe?pe:{};function ke(){return ke=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=new CompressionStream("gzip"),n=s.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(s.readable).blob(),[l]=yield Promise.all([a,o]);return l}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ke.apply(this,arguments)}var Ie=["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"],Ce=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ie.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},Pe=["$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 Te(e,t){return-1!==e.indexOf(t)}var Re=function(e){return e.trim()},Fe=function(e){return e.replace(/^\$/,"")},Le=Object.prototype,$e=Le.hasOwnProperty,Oe=Le.toString,Me=Array.isArray||function(e){return"[object Array]"===Oe.call(e)},Ae=e=>"function"==typeof e,De=e=>e===Object(e)&&!Me(e),Ne=e=>{if(De(e)){for(var t in e)if($e.call(e,t))return!1;return!0}return!1},Ue=e=>void 0===e,qe=e=>"[object String]"==Oe.call(e),He=e=>qe(e)&&0===e.trim().length,ze=e=>null===e,Be=e=>Ue(e)||ze(e),je=e=>"[object Number]"==Oe.call(e)&&e==e,Ve=e=>je(e)&&e>0,We=e=>"[object Boolean]"===Oe.call(e),Ge=e=>e instanceof FormData,Ye=e=>Te(Pe,e);function Ke(e){return null===e||"object"!=typeof e}function Je(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=>Te(Qe,e),et=[!1,"false",0,"0","no"];function tt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),je(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),tt(s||i,t,i,r))}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(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var rt,st,nt,ot=(e,t,i)=>{function r(r){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;s>o;o++)n[o-1]=arguments[o];t((()=>{(0,i[r])(e,...n)}))}return{debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("error",...t)},critical(){for(var t=arguments.length,r=new Array(t),s=0;t>s;s++)r[s]=arguments[s];i.error(e,...r)},createLogger:r=>ot(e+" "+r,t,i)}},at="Mobile",lt="iOS",ut="Android",ct="Tablet",dt=ut+" "+ct,_t="iPad",ht="Apple",pt=ht+" Watch",gt="Safari",vt="BlackBerry",ft="Samsung",mt=ft+"Browser",yt=ft+" Internet",bt="Chrome",wt=bt+" OS",Et=bt+" "+lt,St="Internet Explorer",xt=St+" "+at,kt="Opera",It=kt+" Mini",Ct="Edge",Pt="Microsoft "+Ct,Tt="Firefox",Rt=Tt+" "+lt,Ft="Nintendo",Lt="PlayStation",$t="Xbox",Ot=ut+" "+at,Mt=at+" "+gt,At="Windows",Dt=At+" Phone",Nt="Nokia",Ut="Ouya",qt="Generic",Ht=qt+" "+at.toLowerCase(),zt=qt+" "+ct.toLowerCase(),Bt="Konqueror",jt="(\\d+(\\.\\d+)?)",Vt=new RegExp("Version/"+jt),Wt=new RegExp($t,"i"),Gt=new RegExp(Lt+" \\w+","i"),Yt=new RegExp(Ft+" \\w+","i"),Kt=new RegExp(vt+"|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"},Xt=function(e,t){return t=t||"",Te(e," OPR/")&&Te(e,"Mini")?It:Te(e," OPR/")?kt:Kt.test(e)?vt:Te(e,"IE"+at)||Te(e,"WPDesktop")?xt:Te(e,mt)?yt:Te(e,Ct)||Te(e,"Edg/")?Pt:Te(e,"FBIOS")?"Facebook "+at:Te(e,"UCWEB")||Te(e,"UCBrowser")?"UC Browser":Te(e,"CriOS")?Et:Te(e,"CrMo")||Te(e,bt)?bt:Te(e,ut)&&Te(e,gt)?Ot:Te(e,"FxiOS")?Rt:Te(e.toLowerCase(),Bt.toLowerCase())?Bt:((e,t)=>t&&Te(t,ht)||function(e){return Te(e,gt)&&!Te(e,bt)&&!Te(e,ut)}(e))(e,t)?Te(e,at)?Mt:gt:Te(e,Tt)?Tt:Te(e,"MSIE")||Te(e,"Trident/")?St:Te(e,"Gecko")?Tt:""},Qt={[xt]:[new RegExp("rv:"+jt)],[Pt]:[new RegExp(Ct+"?\\/"+jt)],[bt]:[new RegExp("("+bt+"|CrMo)\\/"+jt)],[Et]:[new RegExp("CriOS\\/"+jt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+jt)],[gt]:[Vt],[Mt]:[Vt],[kt]:[new RegExp("(Opera|OPR)\\/"+jt)],[Tt]:[new RegExp(Tt+"\\/"+jt)],[Rt]:[new RegExp("FxiOS\\/"+jt)],[Bt]:[new RegExp("Konqueror[:/]?"+jt,"i")],[vt]:[new RegExp(vt+" "+jt),Vt],[Ot]:[new RegExp("android\\s"+jt,"i")],[yt]:[new RegExp(mt+"\\/"+jt)],[St]:[new RegExp("(rv:|MSIE )"+jt)],Mozilla:[new RegExp("rv:"+jt)]},Zt=function(e,t){var i=Xt(e,t),r=Qt[i];if(Ue(r))return null;for(var s=0;r.length>s;s++){var n=e.match(r[s]);if(n)return parseFloat(n[n.length-2])}return null},ei=[[new RegExp($t+"; "+$t+" (.*?)[);]","i"),e=>[$t,e&&e[1]||""]],[new RegExp(Ft,"i"),[Ft,""]],[new RegExp(Lt,"i"),[Lt,""]],[Kt,[vt,""]],[new RegExp(At,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Dt,""];if(new RegExp(at).test(t)&&!/IEMobile\b/.test(t))return[At+" "+at,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=Jt[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[At,r]}return[At,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[lt,[e[3],e[4],e[5]||"0"].join(".")]:[lt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ue(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ut+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ut+")","i"),e=>e&&e[2]?[ut,[e[2],e[3],e[4]||"0"].join(".")]:[ut,""]],[/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/,[wt,""]],[/Linux|debian/i,["Linux",""]]],ti=function(e){return Yt.test(e)?Ft:Gt.test(e)?Lt:Wt.test(e)?$t:new RegExp(Ut,"i").test(e)?Ut:new RegExp("("+Dt+"|WPDesktop)","i").test(e)?Dt:/iPad/.test(e)?_t:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?pt:Kt.test(e)?vt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Nt,"i").test(e)?Nt:/(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(at).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)?ut:dt:new RegExp("(pda|"+at+")","i").test(e)?Ht:new RegExp(ct,"i").test(e)&&!new RegExp(ct+" pc","i").test(e)?zt:""},ii=e=>e instanceof Error,ri={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=ri.info;function ni(e){if(We(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(Me(e))return{arrayValue:{values:e.map((e=>ni(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function oi(e){var t=[];for(var i in e){var r=e[i];ze(r)||Ue(r)||t.push({key:i,value:ni(r)})}return t}function ai(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return nt&&i.length===st||(st=i.length,nt=i.reduce(((i,r)=>{rt||(rt={});var s=rt[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,rt[r]=[l,u];break}}return i}),{})),nt}}class li{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"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);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&&Me(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 r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}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 r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,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:ai(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var ui="?";function ci(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?ui:i,in_app:!0};return Ue(r)||(n.lineno=r),Ue(s)||(n.colno=s),n}var di=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:ui,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},_i=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pi=/\((\S*)(?::(\d+))(?::(\d+))\)/,gi=(e,t)=>{var i=_i.exec(e);if(i){var[,r,s,n]=i;return ci(t,r,ui,+s,+n)}var o=hi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=pi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=di(o[1]||ui,o[2]);return ci(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},vi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,fi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,mi=(e,t)=>{var i=vi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=fi.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||ui;return[n,s]=di(n,s),ci(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},yi=/\(error: (.*)\)/;class bi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=qe(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 Je(e,"DOMException")}isDOMError(e){return Je(e,"DOMError")}}class wi{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 Ei{constructor(){}match(e){return Je(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 Si=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class xi{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Si);return r&&(t=r[1],i=r[2]),[t,i]}}var ki=["fatal","error","warning","log","info","debug"];function Ii(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class Ci{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{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: "+Ii(e)}isSeverityLevel(e){return qe(e)&&!He(e)&&ki.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ii(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,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ii(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ti{match(e){return Ke(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 Ri{match(e){return Je(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,r=this.getUnhandledRejectionReason(e);return Ke(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}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 Fi="$message",Li="$timestamp",$i=new Set([Fi,Li]),Oi={enabled:!0,max_bytes:32768};function Mi(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Oi.enabled,max_bytes:Di(e.max_bytes,Oi.max_bytes)}:i({},Oi)}class Ai{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 r=i,s=r[Fi],n=r[Li];if(!qe(s)||0===s.trim().length)return;if(!qe(n)&&!je(n))return;return{step:r,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,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=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 Di(e,t){if(!je(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Ni=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(pe&&(n.DEBUG||xe.POSTHOG_DEBUG||i)&&!Ue(pe.console)&&pe.console){for(var r=("__rrweb_original__"in pe.console[t]?pe.console[t].__rrweb_original__:pe.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Ni(e+" "+t,i)};return r},Ui=Ni("[PostHog.js]"),qi=Ui.createLogger;function Hi(e,t){Me(e)&&e.forEach(t)}function zi(e,t){if(!Be(e))if(Me(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 Bi=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function ji(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Vi=function(e){try{return e()}catch(e){return}},Wi=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){Ui.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ui.critical(e)}}},Gi=function(e){var t={};return zi(e,(function(e,i){(qe(e)&&e.length>0||je(e))&&(t[i]=e)})),t};var Yi=["herokuapp.com","vercel.app","netlify.app"];function Ki(e){var t=null==e?void 0:e.hostname;if(!qe(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Yi)if(i===r)return!1;return!0}function Ji(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Xi(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 je(e)&&isFinite(e)&&Math.floor(e)===e});class Qi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new Qi(s)}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 Qi(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 Zi{constructor(){this._timestamp=0,this._counter=0,this._random=new ir}generate(){var e=this.generateOrAbort();if(Ue(e)){this._timestamp=0;var t=this.generateOrAbort();if(Ue(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 Qi.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 er,tr=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&&!Ue(pe.crypto)&&crypto.getRandomValues&&(tr=e=>crypto.getRandomValues(e));class ir{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(tr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var rr=()=>sr().toString(),sr=()=>(er||(er=new Zi)).generate(),nr="",or=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var ar={_is_supported:()=>!!fe,_error(e){Ui.error("cookieStore error: "+e)},_get(e){if(fe){try{for(var t=e+"=",i=fe.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse(e){var t;try{t=JSON.parse(ar._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(fe)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=fe),nr)return nr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+rr();!nr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",nr=n)}return nr}(e);if(!i){var r=(e=>{var t=e.match(or);return t?t[0]:""})(e);r!==i&&Ui.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(fe.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&Ui.warn("cookieStore warning: large cookie, len="+u.length),fe.cookie=u,u}catch(e){return}},_remove(e,t){if(null!=fe&&fe.cookie)try{ar._set(e,"",-1,t)}catch(e){return}}},lr=null,ur={_is_supported(){if(!ze(lr))return lr;var e=!0;if(Ue(pe))e=!1;else try{var t="__mplssupport__";ur._set(t,"xyz"),'"xyz"'!==ur._get(t)&&(e=!1),ur._remove(t)}catch(t){e=!1}return e||Ui.error("localStorage unsupported; falling back to cookie store"),lr=e,e},_error(e){Ui.error("localStorage error: "+e)},_get(e){try{return null==pe?void 0:pe.localStorage.getItem(e)}catch(e){ur._error(e)}return null},_parse(e){try{return JSON.parse(ur._get(e))||{}}catch(e){}return null},_set(e,t){try{null==pe||pe.localStorage.setItem(e,JSON.stringify(t))}catch(e){ur._error(e)}},_remove(e){try{null==pe||pe.localStorage.removeItem(e)}catch(e){ur._error(e)}}},cr=[a,"distinct_id",x,k,J,K,j],dr={},_r={_is_supported:()=>!0,_error(e){Ui.error("memoryStorage error: "+e)},_get:e=>dr[e]||null,_parse:e=>dr[e]||null,_set(e,t){dr[e]=t},_remove(e){delete dr[e]}},hr=null,pr={_is_supported(){if(!ze(hr))return hr;if(hr=!0,Ue(pe))hr=!1;else try{var e="__support__";pr._set(e,"xyz"),'"xyz"'!==pr._get(e)&&(hr=!1),pr._remove(e)}catch(e){hr=!1}return hr},_error(e){Ui.error("sessionStorage error: ",e)},_get(e){try{return null==pe?void 0:pe.sessionStorage.getItem(e)}catch(e){pr._error(e)}return null},_parse(e){try{return JSON.parse(pr._get(e))||null}catch(e){}return null},_set(e,t){try{null==pe||pe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){pr._error(e)}},_remove(e){try{null==pe||pe.sessionStorage.removeItem(e)}catch(e){pr._error(e)}}};class gr{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===se||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===re}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:Te(et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ur:ar;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?ar:ur;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,xe.doNotTrack].some((e=>Ze(e)))}}var vr=qi("[Dead Clicks]"),fr=()=>!0,mr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return We(r)?r:!!De(r)||i};class yr{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=xe.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?vr.error("failed to load script",t):e()}))}_start(){var e;if(fe){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=xe.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=De(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=xe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(fe),vr.info("starting...")}}else vr.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,vr.info("stopping..."))}}var br=qi("[SegmentIntegration]");var wr="posthog-js";function Er(e,t){var{organization:r,projectId:s,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 r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class Sr{constructor(e,t,i,r,s,n){this.name=wr,this.setupOnce=function(o){o(Er(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class xr{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(Ui.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,r=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(),r}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 r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(Ue(n)||Ue(o)||Ue(a)||Ue(l)||Ue(u)||Ue(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,Ui):1,_=n>1?tt(a/n,0,1,Ui):1,h=l>1?tt(u/l,0,1,Ui):1,p=l>1?tt(c/l,0,1,Ui):1;r=Bi(r,{$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&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var kr={[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"},[x]:{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"},[I]:{exposure:"derived",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!De(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event"},[P]:{exposure:"hidden"},[T]:{exposure:"hidden"},[R]:{exposure:"event"},[F]:{exposure:"event"},[L]:{exposure:"event"},[O]:{exposure:"hidden"},[M]:{exposure:"hidden"},[A]:{exposure:"hidden"},[D]:{exposure:"hidden"},[N]:{exposure:"event"},[U]:{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"},[q]:{exposure:"hidden"},[H]:{exposure:"hidden"},[z]:{exposure:"hidden"},[B]:{exposure:"hidden"},[j]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden"},[G]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"event"},[E]:{exposure:"event"},[S]:{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"}},Ir=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Cr=e=>{var t=null==fe?void 0:fe.createElement("a");return Ue(t)?null:(t.href=e,t)},Pr=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!Me(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ui.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Tr=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Me(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Rr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Fr="https?://(.*)",Lr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],$r=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Lr],Or="<masked>",Mr=["li_fat_id"];function Ar(e,t,i){if(!fe)return{};var r,s=t?[...Lr,...i||[]]:[],n=Dr(Tr(fe.URL,s,Or),e),o=(r={},zi(Mr,(function(e){var t=ar._get(e);r[e]=t||null})),r);return Bi(o,n)}function Dr(e,t){var i=$r.concat(t||[]),r={};return zi(i,(function(t){var i=Pr(e,t);r[t]=i||null})),r}function Nr(e){var t=function(e){return e?0===e.search(Fr+"google.([^/?]*)")?"google":0===e.search(Fr+"bing.com")?"bing":0===e.search(Fr+"yahoo.com")?"yahoo":0===e.search(Fr+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!ze(t)){r.$search_engine=t;var s=fe?Pr(fe.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function Ur(){return navigator.language||navigator.userLanguage}var qr="$direct";function Hr(){return(null==fe?void 0:fe.referrer)||qr}function zr(e,t){var i=e?[...Lr,...t||[]]:[],r=null==me?void 0:me.href.substring(0,1e3);return{r:Hr().substring(0,1e3),u:r?Tr(r,i,Or):void 0}}function Br(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:i==qr?qr:null==(t=Cr(i))?void 0:t.host};if(r){s.$current_url=r;var n=Cr(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=Dr(r);Bi(s,o)}if(i){var a=Nr(i);Bi(s,a)}return s}function jr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Vr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Wr=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Gr{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&&Ui.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Wr.indexOf(e.persistence.toLowerCase())&&(Ui.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=[...cr,...e];return i({},ur,{_parse(e){try{var t={};try{t=ar._parse(e)||{}}catch(e){}var i=Bi(t,JSON.parse(ur._get(e)||"{}"));return ur._set(e,i),i}catch(e){}return null},_set(e,i,r,s,n,o){try{ur._set(e,i,void 0,void 0,o);var a={};t.forEach((e=>{i[e]&&(a[e]=i[e])})),Object.keys(a).length&&ar._set(e,a,r,s,n,o)}catch(e){ur._error(e)}},_remove(e,t){try{null==pe||pe.localStorage.removeItem(e),ar._remove(e,t)}catch(e){ur._error(e)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return"localstorage"===r&&ur._is_supported()?ur:"localstorage+cookie"===r&&t._is_supported()?t:"sessionstorage"===r&&pr._is_supported()?pr:"memory"===r?_r:"cookie"===r?ar:t._is_supported()?t:ar}_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 zi(this.props,((t,i)=>{var r=(e=>{var t=kr[e];if(t)return t;for(var[i,r]of Ir)if(0===e.indexOf(i))return r})(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===I?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&Bi(e,r.transformToEventProperties(t))}else r&&"event"!==r.exposure||(e[i]=t)})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Bi({},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)){Ue(t)&&(t="None"),this._expire_days=Ue(i)?this._default_expiry:i;var r=!1;if(zi(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(De(e)){this._expire_days=Ue(t)?this._default_expiry:t;var i=!1;if(zi(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,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=Ar(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);Ne(Gi(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==fe?void 0:fe.referrer)?Nr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Hr(),$referring_domain:null!=fe&&fe.referrer&&(null==(e=Cr(fe.referrer))?void 0:e.host)||qr},void 0)}set_initial_person_info(){this.props[G]||this.props[Y]||this.register_once({[K]:zr(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};zi([Y,G],(t=>{var i=this.props[t];i&&zi(i,(function(t,i){e["$initial_"+Fe(i)]=t}))}));var t,i,r=this.props[K];if(r){var s=(t=Br(r),i={},zi(t,(function(e,t){i["$initial_"+Fe(t)]=e})),i);Bi(e,s)}return e}safe_merge(e){return zi(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(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this._buildStorage(e),s=this.props;this.clear(),this._storage=r,this.props=s,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 Ue(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 Yr={Activation:"events",Cancellation:"cancelEvents"},Kr={Button:"button",Tab:"tab",Selector:"selector"},Jr={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},Xr={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Qr={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Zr={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},es={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ts={Once:"once",Recurring:"recurring",Always:"always"},is={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},rs={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},ss={Popover:"popover",Inline:"inline"},ns={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},os={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},as={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},ls=qi("[RateLimiter]");class us{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=>{ls.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void ls.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,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(W))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);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 "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(W,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var cs=qi("[RemoteConfig]");class ds{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=xe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=xe.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=xe.__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 cs.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void cs.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return cs.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){cs.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||cs.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 _s=["fatal","error","warning","log","info","debug"],hs={GZipJS:"gzip-js",Base64:"base64"},ps=Uint8Array,gs=Uint16Array,vs=Uint32Array,fs=new ps([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]),ms=new ps([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]),ys=new ps([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bs=function(e,t){for(var i=new gs(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new vs(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},ws=bs(fs,2),Es=ws[1];ws[0][28]=258,Es[258]=28;for(var Ss=bs(ms,0)[1],xs=new gs(32768),ks=0;32768>ks;++ks){var Is=(43690&ks)>>>1|(21845&ks)<<1;xs[ks]=((65280&(Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4))>>>8|(255&Is)<<8)>>>1}var Cs=function(e,t,i){for(var r=e.length,s=0,n=new gs(t);r>s;++s)++n[e[s]-1];var o,a=new gs(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new gs(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[xs[d]>>>l]=u}else for(o=new gs(r),s=0;r>s;++s)o[s]=xs[a[e[s]-1]++]>>>15-e[s];return o},Ps=new ps(288);for(ks=0;144>ks;++ks)Ps[ks]=8;for(ks=144;256>ks;++ks)Ps[ks]=9;for(ks=256;280>ks;++ks)Ps[ks]=7;for(ks=280;288>ks;++ks)Ps[ks]=8;var Ts=new ps(32);for(ks=0;32>ks;++ks)Ts[ks]=5;var Rs=Cs(Ps,9,0),Fs=Cs(Ts,5,0),Ls=function(e){return(e/8>>0)+(7&e&&1)},$s=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof gs?gs:e instanceof vs?vs:ps)(i-t);return r.set(e.subarray(t,i)),r},Os=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Ms=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},As=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new ps(0),0];if(1==s){var o=new ps(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!=s-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(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new gs(_+1),p=Ds(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new ps(h),p]},Ds=function(e,t,i){return-1==e.s?Math.max(Ds(e.l,t,i+1),Ds(e.r,t,i+1)):t[e.s]=i},Ns=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new gs(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Us=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},qs=function(e,t,i){var r=i.length,s=Ls(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Hs=function(e,t,i,r,s,n,o,a,l,u,c){Os(t,c++,i),++s[256];for(var d=As(s,15),_=d[0],h=d[1],p=As(n,15),g=p[0],v=p[1],f=Ns(_),m=f[0],y=f[1],b=Ns(g),w=b[0],E=b[1],S=new gs(19),x=0;m.length>x;++x)S[31&m[x]]++;for(x=0;w.length>x;++x)S[31&w[x]]++;for(var k=As(S,7),I=k[0],C=k[1],P=19;P>4&&!I[ys[P-1]];--P);var T,R,F,L,O=u+5<<3,M=Us(s,Ps)+Us(n,Ts)+o,A=Us(s,_)+Us(n,g)+o+14+3*P+Us(S,I)+(2*S[16]+3*S[17]+7*S[18]);if(M>=O&&A>=O)return qs(t,c,e.subarray(l,l+u));if(Os(t,c,1+(M>A)),c+=2,M>A){T=Cs(_,h,0),R=_,F=Cs(g,v,0),L=g;var D=Cs(I,C,0);for(Os(t,c,y-257),Os(t,c+5,E-1),Os(t,c+10,P-4),c+=14,x=0;P>x;++x)Os(t,c+3*x,I[ys[x]]);c+=3*P;for(var N=[m,w],U=0;2>U;++U){var q=N[U];for(x=0;q.length>x;++x)Os(t,c,D[H=31&q[x]]),c+=I[H],H>15&&(Os(t,c,q[x]>>>5&127),c+=q[x]>>>12)}}else T=Rs,R=Ps,F=Fs,L=Ts;for(x=0;a>x;++x)if(r[x]>255){var H;Ms(t,c,T[257+(H=r[x]>>>18&31)]),c+=R[H+257],H>7&&(Os(t,c,r[x]>>>23&31),c+=fs[H]);var z=31&r[x];Ms(t,c,F[z]),c+=L[z],z>3&&(Ms(t,c,r[x]>>>5&8191),c+=ms[z])}else Ms(t,c,T[r[x]]),c+=R[r[x]];return Ms(t,c,T[256]),c+R[256]},zs=new vs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bs=function(){for(var e=new vs(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),js=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Vs(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=Bs[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new ps(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=qs(l,u,e.subarray(c,d)):(l[c]=!0,u=qs(l,u,e.subarray(c,o)))}else{for(var _=zs[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new gs(32768),f=new gs(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 vs(25e3),E=new gs(288),S=new gs(32),x=0,k=0,I=(c=0,0),C=0,P=0;o>c;++c){var T=b(c),R=32767&c,F=f[T];if(v[R]=F,f[T]=R,c>=C){var L=o-c;if((x>7e3||I>24576)&&L>423){u=Hs(e,l,0,w,E,S,k,I,P,c-P,u),I=x=k=0,P=c;for(var O=0;286>O;++O)E[O]=0;for(O=0;30>O;++O)S[O]=0}var M=2,A=0,D=p,N=R-F&32767;if(L>2&&T==b(c-N))for(var U=Math.min(h,L)-1,q=Math.min(32767,c),H=Math.min(258,L);q>=N&&--D&&R!=F;){if(e[c+M]==e[c+M-N]){for(var z=0;H>z&&e[c+z]==e[c+z-N];++z);if(z>M){if(M=z,A=N,z>U)break;var B=Math.min(N,z-2),j=0;for(O=0;B>O;++O){var V=c-N+O+32768&32767,W=V-v[V]+32768&32767;W>j&&(j=W,F=V)}}}N+=(R=F)-(F=v[R])+32768&32767}if(A){w[I++]=268435456|Es[M]<<18|Ss[A];var G=31&Es[M],Y=31&Ss[A];k+=fs[G]+ms[Y],++E[257+G],++S[Y],C=c+M,++x}else w[I++]=e[c],++E[e[c]]}}u=Hs(e,l,!0,w,E,S,k,I,P,c-P,u)}return $s(a,0,r+Ls(u)+s)}(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&&js(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),js(u,c-8,i.d()),js(u,c-4,r),u}var Ws=!!be||!!ye,Gs="text/plain",Ys=!1,Ks=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return zi(e,(function(e,t){Ue(e)||Ue(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(a);return u&&l.push(u),n+"?"+l.join("&")},Js=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Xs=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===hs.GZipJS){var r=Vs(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new ps(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new ps(s+8+(i-o<<1));a.set(r),r=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 $s(r,0,s)}(Js(t)),{mtime:0});return{contentType:Gs,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===hs.Base64){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(Js(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:Js(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Js(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Qs=function(){var e=t((function*(e){var t=Js(e.data),r=yield function(e,t,i){return ke.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:Gs,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Zs=(e,t)=>Ks(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),en=[];ye&&en.push({transport:"fetch",method(e){var t,r,{contentType:s,body:n,estimatedSize:o}=null!==(t=Xs(e))&&void 0!==t?t:{},a=new Headers;zi(e.headers,(function(e,t){a.append(t,e)})),s&&a.append("Content-Type",s);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==(r=u)?void 0:r.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){Ui.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{Ui.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),be&&en.push({transport:"XHR",method(e){var t,i=new be;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Xs(e))&&void 0!==t?t:{};zi(e.headers,(function(e,t){i.setRequestHeader(t,e)})),r&&i.setRequestHeader("Content-Type",r),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(s)}}),null!=ve&&ve.sendBeacon&&en.push({transport:"sendBeacon",method(e){var t=Ks(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Xs(e))&&void 0!==i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});ve.sendBeacon(t,n)}catch(e){}}});var tn=3e3;class rn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=tt((null==t?void 0:t.flush_interval_ms)||tn,250,5e3,Ui.createLogger("flush interval"),tn),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[r],s=(new Date).getTime();i.data&&Me(i.data)&&zi(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return zi(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;Ue(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var sn=["retriesPerformedSoFar"];class nn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!Ue(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,s=r(e,sn);Ve(t)&&(s.url=Ks(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{200===e.statusCode||e.statusCode>=400&&500>e.statusCode||(null!=t?t:0)>=10?null==s.callback||s.callback(e):this._enqueue(i({retriesPerformedSoFar:t},s))}}))}_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,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Ui.warn(s),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:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,Ue(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){Ui.error(e)}this._queue=[]}}class on{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.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!==(r=this._context.maxContentHeight)&&void 0!==r?r: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=Me(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 an=e=>zr(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class ln{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[V]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||an,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[V]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?Br(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 zi(Gi(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Fe(i)]=t})),e}}class un{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 r of this._events["*"]||[])r(e,t)}}var cn=qi("[SessionId]");class dn{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new un,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Ve(e)||!Ve(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===se)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||rr,this._windowIdGenerator=i||rr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*tt(this._config.session_idle_timeout_seconds||1800,60,36e3,cn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=pr._parse(this._window_id_storage_key),o=pr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:pr._remove(this._window_id_storage_key),pr._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.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){cn.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Ue(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&&pr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&pr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?pr._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({[x]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[x];return Me(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()&&pr._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===se)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this._getSessionId(),o=this._getWindowId(),a=Ve(n)&&Math.abs(i-n)>864e5,l=!1,u=!s,c=!u&&!e&&this._sessionHasBeenIdleTooLong(i,r);u||c||a?(s=this._sessionIdGenerator(),o=this._windowIdGenerator(),cn.info("new session ID generated",{sessionId:s,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=Ve(r)&&e&&!a?r:i,_=Ve(n)?n:(new Date).getTime();return this._setWindowId(o),this._setSessionId(s,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(s,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:s,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}_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 _n=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ce(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ce(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},hn=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 pn(e,t,i){return Js({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var gn={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=>hn(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!hn(t,e))))),icontains:(e,t)=>t.map(vn).some((t=>e.map(vn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(vn).every((t=>e.map(vn).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)))}))},vn=e=>e.toLowerCase();function fn(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(Ue(s)||ze(s))return!1;var n=[String(s)],o=gn[r.operator];return!!o&&o(r.values,n)}))}var mn,yn,bn="custom",wn="i.posthog.com",En=/^\/static\//;class Sn{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("."+wn,".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":bn),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if("string"==typeof t&&En.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===bn)return this.apiHost+t;var r=wn+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}void 0===mn&&(mn=e=>e()),ot("[SurveyTranslations]",mn,(void 0===yn&&(yn=console),{log:yn.log.bind(yn),warn:yn.warn.bind(yn),error:yn.error.bind(yn),debug:yn.debug.bind(yn)}));var xn=qi("[Surveys]"),kn="seenSurvey_",In=[Qr.Popover,Qr.Widget,Qr.API],Cn={ignoreConditions:!1,ignoreDelay:!1,displayType:ss.Popover},Pn=qi("[PostHog ExternalIntegrations]"),Tn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Rn{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Pn.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=xe.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Tn[t],(()=>{var i;null==(i=xe.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=xe.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=xe.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var Fn,Ln={},$n=0,On=()=>{},Mn='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',An="Surveys module not available",Dn="sanitize_properties is deprecated. Use before_send instead",Nn="Invalid value for property_denylist config: ",Un="posthog",qn=!Ws&&-1===(null==Se?void 0:Se.indexOf("MSIE"))&&-1===(null==Se?void 0:Se.indexOf("Mozilla")),Hn=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:On,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&&qe(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){Ui.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:tn},error_tracking:{},_onCapture:On,__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))},zn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Bn=e=>{var t={};for(var[i,r]of zn)Ue(e[i])||(t[r]=e[i]);var s=Bi({},t,e);return Me(e.property_blacklist)&&(Ue(e.property_denylist)?s.property_denylist=e.property_blacklist:Me(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ui.error(Nn+e.property_denylist)),s};class jn{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ui.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Vn{_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===se||this.config.cookieless_mode===re&&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 jn,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new un,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Hn(),this.SentryIntegration=Sr,this.sentryIntegration=e=>function(e,t){var i=Er(e,t);return{name:wr,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 on(this),this.pageViewManager=new xr(this),this.rateLimiter=new us(this),this.requestRouter=new Sn(this),this.consent=new gr(this),this.externalIntegrations=new Rn(this);var t=null!==(e=Vn.__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 r=qe(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=qe(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>Ui.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Un){var r,s=null!==(r=Ln[i])&&void 0!==r?r:new Vn;return s._init(e,t,i),Ln[i]=s,Ln[Un][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;if(void 0===t&&(t={}),Ue(e)||He(e))return Ui.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(Bi({},Hn(t.defaults),Bn(t),{name:r,token:e})),this.config.on_xhr_error&&Ui.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:hs.GZipJS;var a=this._is_persistence_disabled();this.persistence=new Gr(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Gr(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 rn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new nn(this),this.__request_queue=[];var c=this._inCookielessMode();if(c||(this.sessionManager=new dn(this),this.sessionPropsManager=new ln(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Ui.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(Ui.info("Initializing extensions synchronously"),this._initExtensions(c)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&Ui.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.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(j);if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===ne)this.identify(d);else if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===oe)Ui.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(rr()),g=t.bootstrap.isIdentifiedID?p:d;this.persistence.set_property(j,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(rr());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(j,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 r=i=>{var r=()=>i.anonymousId()||rr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(j,oe)),t()},s=i.user();"then"in s&&Ae(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||br.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()||(br.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(br.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,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!==On&&(Ui.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Ui.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,r,s,n,o,a,l,u=performance.now(),c=i({},Vn.__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!==(r=this.exceptions)&&void 0!==r?r: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!==(s=this.surveys)&&void 0!==s?s: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,mr)),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){Ui.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Z]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ee]:r}),this.config.__preview_deferred_init_extensions&&Ui.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!fe||!fe.body)return Ui.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=Te(e.supportedCompression,hs.GZipJS)?hs.GZipJS:Te(e.supportedCompression,hs.Base64)?hs.Base64: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){Ui.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 ds(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,r;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==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(de,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(qn?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ks(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,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=Zs(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=en.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===hs.GZipJS&&Ee&&!Ys?Qs(n).then((e=>{l(e)})).catch((t=>{if((e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""))(t))return Ys=!0,void l(i({},n,{compression:void 0,url:Zs(e.url,void 0)}));l(n)})):l(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){$n++;try{var t,i=[],r=[],s=[];Hi(e,(e=>{e&&(Me(t=e[0])?s.push(e):Ae(e)?e.call(this):Me(e)&&"alias"===t?i.push(e):Me(e)&&-1!==t.indexOf("capture")&&Ae(this[t])?s.push(e):r.push(e))}));var n=function(e,t){Hi(e,(function(e){if(Me(e[0])){var i=t;zi(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(r,this),n(s,this)}finally{$n--}}push(e){if($n>0&&Me(e)&&qe(e[0])){var t=Vn.prototype[e[0]];Ae(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!Ue(e)&&qe(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!qe(null==t?void 0:t.$current_url)&&(Ui.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!=r&&r._originatedFromCaptureException||Ui.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==r?void 0:r.timestamp)||d,h=rr(),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==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g,v,f,m=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==he,e===_e);if(m&&(p.$set_once=m),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>qe(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),Me(t)?(r=[],Hi(t,(t=>{r.push(e(t))}))):(r={},zi(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,Ue(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===is.DISMISSED||e===is.SENT){var y=null==t?void 0:t[rs.SURVEY_ID],b=null==t?void 0:t[rs.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var i=""+kn+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+kn+t.id+"_"+t.current_iteration),i})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){xn.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===is.SENT?"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===is.SHOWN&&(p.$set=i({},p.$set,{[rs.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===os.SHOWN){var w=null==t?void 0:t[as.TOUR_TYPE];w&&(p.$set=i({},p.$set,{[as.TOUR_LAST_SEEN_DATE+"/"+w]:(new Date).toISOString()}))}var E=i({},p.properties.$set,p.$set);if(Ne(E)||this.setPersonPropertiesForFlags(E),!Be(this.config.before_send)){var S=this._runBeforeSend(p);if(!S)return;p=S}this._internalEventEmitter.emit("eventCaptured",p);var x={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:null==r?void 0:r._batchKey};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(x):this._requestQueue.enqueue(x),p}Ui.critical("This capture call is ignored due to client rate limiting.")}}else Ui.error("No event name provided to posthog.capture")}else Ui.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,o){if(r=r||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,(!qe(l.distinct_id)&&!je(l.distinct_id)||He(l.distinct_id))&&Ui.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t){var i,r,s,o;if(!Se)return{};var a,l,u,c,d,_,h,p,g=e?[...Lr,...t||[]]:[],[v,f]=function(e){for(var t=0;ei.length>t;t++){var[i,r]=ei[t],s=i.exec(e),n=s&&(Ae(r)?r(s,e):r);if(n)return n}return["",""]}(Se);return Bi(Gi({$os:v,$os_version:f,$browser:Xt(Se,navigator.vendor),$device:ti(Se),$device_type:(l=Se,u={userAgentDataPlatform:null==(i=navigator)||null==(i=i.userAgentData)?void 0:i.platform,maxTouchPoints:null==(r=navigator)?void 0:r.maxTouchPoints,screenWidth:null==pe||null==(s=pe.screen)?void 0:s.width,screenHeight:null==pe||null==(o=pe.screen)?void 0:o.height,devicePixelRatio:null==pe?void 0:pe.devicePixelRatio},p=ti(l),p===_t||p===dt||"Kobo"===p||"Kindle Fire"===p||p===zt?ct:p===Ft||p===$t||p===Lt||p===Ut?"Console":p===pt?"Wearable":p?at:"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)?at:ct:"Desktop"),$timezone:jr(),$timezone_offset:Vr()}),{$current_url:Tr(null==me?void 0:me.href,g,Or),$host:null==me?void 0:me.host,$pathname:null==me?void 0:me.pathname,$raw_user_agent:Se.length>1e3?Se.substring(0,997)+"...":Se,$browser_version:Zt(Se,navigator.vendor),$browser_language:Ur(),$browser_language_prefix:(a=Ur(),"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,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&Bi(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Bi(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===bn&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ce||o?e!==de||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=Bi(l,c),e===ce&&fe&&(l.title=fe.title),!Ue(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Se&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=Bi({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Me(this.config.property_denylist)?zi(this.config.property_denylist,(function(e){delete l[e]})):Ui.error(Nn+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(Ui.error(Dn),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 r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=Bi({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(Ui.error(Dn),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Ne(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.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 r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.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:An}),()=>{})}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:An})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:An})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Cn),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:An}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:An})}_validateIdentifyId(e){return!e||He(e)?(Ui.critical("Unique user id has not been set in posthog.identify"),!1):e===Q?(Ui.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())||(Ui.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 Ui.uninitializedWarning("posthog.identify");if(je(e)&&(e=e.toString(),Ui.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 r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(j)||ne)===ne;e!==r&&n?(this.persistence.set_property(j,oe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(_e,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=pn(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(q))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=pn(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):Ui.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(he,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else Ui.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,r,s,n,o,l,u;if(Ui.info("reset"),!this.__loaded)return Ui.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==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.persistence)||l.set_property(j,ne),null==(u=this.sessionManager)||u.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===se)this.register_once({distinct_id:Q,$device_id:null},"");else{var d=this.config.get_device_id(rr());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),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(o)?(Ui.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Ue(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ui.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 r,s,o,a,l,u,c,d,_,h;Bi(this.config,Bn(e));var p=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Gr(i({},this.config,{persistence:"sessionStorage"}),p);var g=this._checkLocalStorageForDebug(this.config.debug);We(g)&&(this.config.debug=g),We(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,ur._is_supported()&&ur._set("ph_debug",!0),Ui.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,ur._is_supported()&&ur._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.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,r,s,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==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.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 r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,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:Vn._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:Un;return t!==Un&&(t=Un+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(j))===oe||(null==(t=this.sessionPersistence)?void 0:t.get_property(j))===oe}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ae&&!this._isIdentified()&&Ne(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[J]))}_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?(Ui.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(J,!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!==re)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==se){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new dn(this),this.pageViewManager=new xr(this),this.persistence&&(this.sessionPropsManager=new ln(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=Vn.__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==re&&(null==(u=this.surveys)||u.loadIfEnabled()),(Ue(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 Ui.warn(Mn)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==se?(this.config.cookieless_mode===re&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===re&&(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())):Ui.warn(Mn)}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===se||(this.config.cookieless_mode===re?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?_n(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,r,s,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?(Ui.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,r=Ui,s=(t="advanced_disable_flags")in(e=o)&&!Be(e[t]),n=i in e&&!Be(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){if(Be(this.config.before_send))return e;var t=Me(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),Be(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return Ye(e.event)?Ui.warn(s+". This can cause unexpected behavior."):Ui.info(s),null}i.properties&&!Ne(i.properties)||Ui.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=We(e)&&!e,i=ur._is_supported()&&"true"===ur._get("ph_debug");return!t&&(!!i||e)}}Vn.__defaultExtensionClasses={},Vn._noopLogger={trace:Fn=()=>{},debug:Fn,info:Fn,warn:Fn,error:Fn,fatal:Fn},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Wi(e.prototype[t[i]])}(Vn,["identify"]);var Wn=1,Gn=3,Yn=11;function Kn(e){return e instanceof Element&&(e.id===X||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Jn(e){return!!e&&e.nodeType===Wn}function Xn(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Qn(e){return!!e&&e.nodeType===Gn}function Zn(e){return!!e&&e.nodeType===Yn&&Jn(e.host)}function eo(e){return e?Re(e).split(/\s+/):[]}function to(e){var t=null==pe?void 0:pe.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function io(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 eo(t)}function ro(e){return Be(e)?null:Re(e).split(/(\s+)/).filter((e=>Eo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function so(e){var t="";return po(e)&&!go(e)&&e.childNodes&&e.childNodes.length&&zi(e.childNodes,(function(e){var i;Qn(e)&&e.textContent&&(t+=null!==(i=ro(e.textContent))&&void 0!==i?i:"")})),Re(t)}function no(e){return Ue(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var oo=["a","button","form","input","select","textarea","label"];function ao(e,t){if(Ue(t))return!0;var i,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function lo(e){var t=e.parentNode;return!(!t||!Jn(t))&&t}var uo=["next","previous","prev",">","<"],co=[".ph-no-rageclick",".ph-no-capture"];var _o=e=>!e||Xn(e,"html")||!Jn(e),ho=(e,t)=>{if(!pe||_o(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Xn(s,"body");)if(Zn(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=lo(s);if(!n)break;if(t||oo.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=pe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function po(e){for(var t=e;t.parentNode&&!Xn(t,"body");t=t.parentNode){var i=io(t);if(Te(i,"ph-sensitive")||Te(i,"ph-no-capture"))return!1}if(Te(io(e),"ph-include"))return!0;var r=e.type||"";if(qe(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!qe(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function go(e){return!!(Xn(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Xn(e,"select")||Xn(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var vo="(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})",fo=new RegExp("^(?:"+vo+")$"),mo=new RegExp(vo),yo="\\d{3}-?\\d{2}-?\\d{4}",bo=new RegExp("^("+yo+")$"),wo=new RegExp("("+yo+")");function Eo(e,t){if(void 0===t&&(t=!0),Be(e))return!1;if(qe(e)){if(e=Re(e),(t?fo:mo).test((e||"").replace(/[- ]/g,"")))return!1;if((t?bo:wo).test(e))return!1}return!0}function So(e){var t=so(e);return Eo(t=(t+" "+xo(e)).trim())?t:""}function xo(e){var t="";return e&&e.childNodes&&e.childNodes.length&&zi(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=so(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+xo(e)).trim())}catch(e){Ui.error("[AutoCapture]",e)}})),t}function ko(e){return e.replace(/"|\\"/g,'\\"')}function Io(e){var t=e.attr__class;return t?Me(t)?t:eo(t):void 0}class Co{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 r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.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 Po="$copy_autocapture",To=qi("[AutoCapture]");function Ro(e,t){return t.length>e?t.slice(0,e)+"...":t}function Fo(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Jn(t));return t}function Lo(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t;if(!Jn(e))return{props:{}};for(var c=[e],d=e;d.parentNode&&!Xn(d,"body");)if(Zn(d.parentNode))c.push(d.parentNode.host),d=d.parentNode.host;else{if(!Jn(d.parentNode))break;c.push(d.parentNode),d=d.parentNode}var _,h,p=[],g={},v=!1,f=!1;if(zi(c,(e=>{var t=po(e);if(Xn(e,"a")){var i=e.getAttribute("href");v=t&&!!i&&Eo(i)&&i}Te(io(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};oo.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Ro(1024,So(e)):Ro(1024,so(e)));var o=io(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),zi(e.attributes,(function(i){var s;if((!go(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Eo(i.value)&&(!qe(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=eo(o).join(" ")),n["attr__"+i.name]=Ro(1024,o)}}));for(var a=1,l=1,u=e;u=Fo(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var r=function(e){if(!po(e))return{};var t={};return zi(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Eo(r)&&(t[i]=r)}})),t}(e);Bi(g,r)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text=Xn(e,"a")||Xn(e,"button")?So(e):so(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Cr(v))?void 0:m.host,w=null==pe||null==(y=pe.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:Bi({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+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!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return ji(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[ko(t.toString())]=ko(i.toString())})),(s+=":")+ji(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={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:Io(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return ji(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(h)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var $o=qi("[ExceptionAutocapture]");function Oo(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Ae(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}var Mo=qi("[TracingHeaders]"),Ao=qi("[Web Vitals]"),Do=9e5,No="disabled",Uo="lazy_loading",qo="awaiting_config",Ho="missing_config";qi("[SessionRecording]"),qi("[SessionRecording]");var zo="[SessionRecording]",Bo=qi(zo),jo=qi("[Heatmaps]");function Vo(e){return De(e)&&"clientX"in e&&"clientY"in e&&je(e.clientX)&&je(e.clientY)}var Wo=qi("[Product Tours]"),Go=["$set_once","$set"],Yo=qi("[SiteApps]"),Ko="Error while initializing PostHog app with config id ";function Jo(e,t,i){if(Be(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Xo{constructor(e){this._debugEventEmitter=new un,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;Ue(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(!Ue(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 r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}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,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Jo(r,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 r=this._getElementsList(e);if(r.length>0)return r.some((e=>Jo(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Jo((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Jo(e.text,t.text,t.text_matching||"exact")||Jo(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!Be(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>Jo(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$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||fn(t.properties.reduce(((e,t)=>{var i=Me(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 Qo{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&fn(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===Yr.Activation?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;Ue(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 Xo(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.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})),r=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===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Yr.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,Yr.Cancellation))}onEvent(e,t){var i,r=this._getLogger(),s=this._getActivatedKey(),n=this._getShownEventName(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===e&&t&&o.length>0){var a,l;r.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,Yr.Cancellation);d.length>0&&(r.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)){r.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var _=this._getMatchingItems(e,t,Yr.Activation);this._updateActivatedItems(o.concat(_.map((e=>e.id))||[]))}}}onAction(e){var t,i=this._getActivatedKey(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this._actionToItems.has(e)&&this._updateActivatedItems(r.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 Zo extends Qo{constructor(e){super(e)}_getActivatedKey(){return N}_getShownEventName(){return is.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return xn}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[N]:e})}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var ea="SDK is not enabled or survey functionality is not yet loaded",ta="Disabled. Not loading surveys.",ia=null!=pe&&pe.location?Rr(pe.location.hash,"__posthog")||Rr(location.hash,"state"):null,ra="_postHogToolbarParams",sa=qi("[Toolbar]"),na=qi("[FeatureFlags]"),oa=qi("[FeatureFlags]",{debugEnabled:!0}),aa="\" failed. Feature flags didn't load in time.",la=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},ua=e=>{var t={};for(var[i,r]of ji(e||{}))r&&(t[i]=r);return t},ca=qi("[Error tracking]"),da="Refusing to render web experiment since the viewer is a likely bot",_a={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&&hn(t.href,e),not_regex:(e,t)=>!!pe&&!hn(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class ha{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{ha._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(ha._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);qe(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];ha._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())ha._logInfo(da);else if(!this._config.disable_web_experiments){if(Be(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ha._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=ha.getWindowLocation();if(null!=e&&e.search){var t=Pr(null==e?void 0:e.search,"__experiment_id"),i=Pr(null==e?void 0:e.search,"__experiment_variant");t&&i&&(ha._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 r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(ha._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!Be(e.conditions)&&ha._matchUrlConditions(e)&&ha._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=ha.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||_a[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"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=Ar();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.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),r=1;t>r;r++)i[r-1]=arguments[r];Ui.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?ha._logInfo(da):"control"!==t?i.forEach((i=>{if(i.selector){var r;ha._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):ha._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ve&&this._instance?_n(ve,this._config.custom_blocked_useragents):void 0}}var pa=qi("[Conversations]"),ga="Conversations not available yet.",va={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,na.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||(na.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||na.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,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[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,r){var s=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},o=i({},s,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:Ue(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(T),t=this._prop(L),r=this._prop(O);if(!r&&!t)return e||{};var s=Bi({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=Ue(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=Ue(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[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})),s[o]=p}return this._override_warning||(na.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._prop(I),t=this._prop(L);if(!t)return e||{};for(var i=Bi({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(na.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(O);if(!t)return e||{};for(var i=Bi({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(na.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 r=this._config.token,s=this._prop(a),n={token:r,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(M)||{}),group_properties:this._prop(A),timezone:jr()};ze(s)||Ue(s)||(n.$device_id=s),(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:hs.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;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==(r=this._persistence)||r.register({[z]:o}),l)na.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:{},s,{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 r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else na.warn('getFeatureFlag for key "'+e+aa)}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(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(F)||void 0,l=this._prop(B)||void 0,u=this._prop(q)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(H);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[q]:u,[H]: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,E;Me(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[q]:u});var S=this.getFeatureFlagDetails(e),x=[...null!==(p=this._prop(z))&&void 0!==p?p:[]];Ue(s)&&x.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:s,$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};Ue(null==S||null==(f=S.metadata)?void 0:f.version)||(k.$feature_flag_version=S.metadata.version);var I,C=null!==(m=null==S||null==(y=S.reason)?void 0:y.description)&&void 0!==m?m:null==S||null==(b=S.reason)?void 0:b.code;C&&(k.$feature_flag_reason=C),null!=S&&null!=(w=S.metadata)&&w.id&&(k.$feature_flag_id=S.metadata.id),Ue(null==S?void 0:S.original_variant)&&Ue(null==S?void 0:S.original_enabled)||(k.$feature_flag_original_response=Ue(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(E=S.metadata)&&E.original_payload&&(k.$feature_flag_original_payload=null==S||null==(I=S.metadata)?void 0:I.original_payload),x.length&&(k.$feature_flag_error=x.join(",")),this._instance.capture("$feature_flag_called",k)}if(r){var P=n;if(!Ue(n))try{P=JSON.parse(n)}catch(e){}return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:P}}}}else na.warn('getFeatureFlagResult for key "'+e+aa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:hs.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[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 Ue(i)?void 0:!!i}na.warn('isFeatureEnabled for key "'+e+aa)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),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]})))):na.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(Me(u)){na.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({[C]:u,[I]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,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({},r,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},s,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({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[C]:Object.keys(ua(g)),[I]:g||{},[R]:v||{},[T]:f||{}},d?{[F]:d}:{},_?{[B]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),na.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return na.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(L),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),oa.info("All overrides cleared");if(Me(e)){var t=la(e);return this._persistence.register({[L]:t}),this._fireFeatureFlagsCallbacks(),oa.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(L),oa.info("Flag overrides cleared");else if(r.flags){if(Me(r.flags)){var s=la(r.flags);this._persistence.register({[L]:s})}else this._persistence.register({[L]:r.flags});oa.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),oa.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),oa.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[L]:e}),this._fireFeatureFlagsCallbacks(),oa.info("Flag overrides set",{flags:e});na.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,r){var s,n=(this._prop(P)||[]).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),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(ua(l)),[I]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(P),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(P),null==(r=this._persistence)||r.register({[P]:s}),e(s)}}})}_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((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(M)||{},s=(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 r||(o[a]=n[a]));this._instance.register({[M]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(M)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(A)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[A]:i({},r,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}}},fa={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===qo||this._recordingStatus===Ho?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=No,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Bo.error("started without valid sessionManager"),new Error(zo+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===se)throw new Error(zo+' 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,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return pe&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!Ue(Object.assign)&&!Ue(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Bo.info("starting")):(this._recordingStatus=No,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==qo&&this._recordingStatus!==Ho&&(this._recordingStatus=Uo),null!=xe&&null!=(t=xe.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=xe.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=xe.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Bo.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,r=je(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Bo.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!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==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Be(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:Ue(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.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===qo&&(this._recordingStatus=Ho,Bo.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):Bo.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=xe.__PosthogExtensions__)||!t.initSessionRecording)return Bo.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=xe.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Ho||this._recordingStatus===qo)return;return this._recordingStatus=qo,Bo.info("persisted remote config is stale, requesting fresh config before starting"),void new ds(this._instance).load()}this._recordingStatus=Uo,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?E:S]:!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))}}},ma={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new Co(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){To.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=>{e=e||(null==pe?void 0:pe.event);try{this._captureEvent(e,Po)}catch(e){To.error("Failed to capture copy/cut event",e)}};Ji(fe,"copy",t,{capture:!0}),Ji(fe,"cut",t,{capture:!0})}}}else To.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 r=null==fe?void 0:fe.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c];if(ze(this._isDisabledServerSide)&&!We(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=no(e);Qn(r)&&(r=r.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||_o(e))return!1;var i,r,s;if(We(t)?(i=!!t&&co,r=void 0):(i=null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:co,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=ho(e,!1);return!function(e,t){if(!1===e||Ue(e))return!1;var i;if(!0===e)i=uo;else{if(!Me(e))return!1;if(e.length>10)return Ui.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:r}=e;return i.some((e=>t.includes(e)||r.includes(e)))}))}(r,n.map((e=>{var t;return{safeText:so(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!ao(n,i)}(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===Po;if(r&&function(e,t,i,r,s){var n,o,a,l;if(void 0===i&&(i=void 0),!pe||_o(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!to(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&to(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}=ho(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(Ue(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(d,i))return!1;if(!ao(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(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return c?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(oo.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=Lo(r,{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(r);if(a&&a.length>0&&(n.$element_selectors=a),t===Po){var l,u=ro(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&&(Ui.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Ui.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(pe&&pe.history){var i=this;null!=(e=pe.history.pushState)&&e.__posthog_wrapped__||Oo(pe.history,"pushState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("pushState")})),null!=(t=pe.history.replaceState)&&t.__posthog_wrapped__||Oo(pe.history,"replaceState",(e=>function(t,r,s){e.call(this,t,r,s),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){Ui.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 Co(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;jo.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="visible"===(null==fe?void 0:fe.visibilityState)?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 yr(this.instance,fr,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(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&Jn(r)&&!Xn(r,"body");){if(r===i)return!1;if(Te(t,null==pe?void 0:pe.getComputedStyle(r).position))return!0;r=lo(r)}return!1}(no(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!Kn(e.target)&&Vo(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Kn(e.target)&&Vo(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,r=this._config.mask_personal_data_properties?[...Lr,...i||[]]:[],s=Tr(t,r,Or);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!Ne(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:yr,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,r=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(Ue(r))Ao.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this._currentURL();Ue(s)||(Be(null==e?void 0:e.name)||Be(null==e?void 0:e.value)?Ao.error("Invalid metric received",e):!this._maxAllowedValue||this._maxAllowedValue>e.value?(this._buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Ue(this._buffer.url)&&(this._buffer.url=s),this._buffer.firstMetricTimestamp=Ue(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:s,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()):Ao.error("Ignoring metric with value >= "+this._maxAllowedValue,e))}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=xe.__PosthogExtensions__;Ue(s)||Ue(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(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&&r(this._addToBuffer.bind(this)),this._initialized=!0):Ao.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)&&je(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Do;return e>0&&6e4>=e?Do:e}get isEnabled(){var e=null==me?void 0:me.protocol;if("http:"!==e&&"https:"!==e)return Ao.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=De(this._perfConfig)?this._perfConfig.web_vitals:We(this._perfConfig)?this._perfConfig:void 0;return We(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ao.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=xe.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?Ao.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?[...Lr,...t||[]]:[];return Tr(e,i,Or)}Ao.error("Could not determine current URL")}}},ya={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(pe&&this.isEnabled&&null!=(e=xe.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=xe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=xe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=xe.__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=r(this.captureException.bind(this)))}catch(e){$o.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!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:$o}),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):(Ue(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?($o.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=xe.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return $o.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,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?$o.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new li([new bi,new Ri,new Ei,new wi,new Pi,new Ci,new xi,new Ti],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=yi.test(l)?l.replace(yi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){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||(r=t,r[r.length-1]||{}).filename,function:e.function||ui});var r}))}(n)}}("web:javascript",gi,mi)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ai(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,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(!qe(e)||0===e.trim().length)return void ca.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>$i.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&ca.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[Fi]:e,[Li]:(new Date).toISOString()},s))}catch(e){ca.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 ca.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 ca.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 ca.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 r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return ca.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void ca.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 ca.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Fi]:e,[Li]:(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:r}=t;return qe(i)&&i.length>0&&e.$exception_types.push(i),qe(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,r=gn[e.operator],s=Me(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,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,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}_isExceptionList(e){return!Be(e)&&Me(e)}}},ba=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=xe.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Wo.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=xe.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=xe.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Me(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[U];if(Me(r)&&!t)return this._cachedTours=r,void e(r,{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 r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return Wo.error(s),void e([],{isLoaded:!1,error:s})}var n=Me(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[U]: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(U)}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)}}},va),wa={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=xe._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,s,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({},r(e,Go),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$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&&(Yo.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))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,Yo.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback(e){s(e)}});n&&(t.processEvent=n),r=!0}catch(t){Yo.error(Ko+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Yo.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){Yo.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void Yo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;xe["__$$ph_site_app_"+e]=s._instance,null==(t=xe.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return Yo.error(Ko+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Yo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Ea={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t,i=this._getConfiguredHostnames()||[];Ue(this._restoreXHRPatch)&&(null==(e=xe.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),Ue(this._restoreFetchPatch)&&(null==(t=xe.__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=xe.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Mo.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)}}},Sa=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 xn.warn("Flags not loaded yet. Not loading surveys.");var i=Me(t);this._isSurveysEnabled=i?t.length>0:t,xn.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(kn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)xn.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)xn.info(ta);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())xn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==xe?void 0:xe.__PosthogExtensions__;if(e){if(!Ue(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 r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(ie);r(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 xn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Zo(this._instance),xn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){xn.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 xn.info(ta),e([]);var i,r=this._instance.get_property(D);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("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 r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;xn.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==(r=this._instance.persistence)||r.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){xn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Be(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);xn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(Be(this._surveyManager))return{eligible:!1,reason:ea};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 xn.warn("init was not called"),{visible:!1,disabledReason:ea};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Be(this._surveyManager)?(xn.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ea})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(Be(this._surveyManager))xn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(In.includes(s.type)){var n=null==fe?void 0:fe.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(xn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;xn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),xn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);xn.warn("Survey element not found")}else xn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else xn.warn("Survey not found")}}displaySurvey(e,t){var r;if(Be(this._surveyManager))xn.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ss.Popover&&t.initialResponses&&xn.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void xn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==ss.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else xn.warn("Survey not found")}}cancelPendingSurvey(e){Be(this._surveyManager)?xn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},va),xa={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){xe.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=xe.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),Xi(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 r,s=ia||Rr(e.hash,"__posthog")||Rr(e.hash,"state"),n=s?Vi((()=>JSON.parse(atob(decodeURIComponent(s)))))||Vi((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(ra)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=xe.ph_load_toolbar||xe.ph_load_editor;!Be(t)&&Ae(t)?t(e,this.instance):sa.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==fe||!fe.getElementById(X));if(!pe||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(pe.localStorage.setItem(ra,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=xe.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return sa.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Ji(pe,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}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)}}},ka=i({experiments:ha},va),Ia={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)||(We(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||Xi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==xe?void 0:xe.__PosthogExtensions__;if(e&&!Ue(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 pa.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),pa.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else pa.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){pa.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():pa.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!ze(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(pa.warn(ga),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(pa.warn(ga),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(pa.warn(ga),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(pa.warn(ga),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(pa.warn(ga),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(pa.warn(ga),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(pa.warn(ga),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()}}},Ca={logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=qi("[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==xe?void 0:xe.__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,r,s,n,o,a;if(this._instance.is_capturing())if(e&&e.body){var l=null!==(t=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==t?t:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s: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 r=e.level||"info",{text:s,number:n}=ri[r]||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:s,body:{stringValue:e.body},attributes:oi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),Ue(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 r=this._instance.config.logs,s=i({"service.name":(null==r?void 0:r.serviceName)||"unknown_service"},(null==r?void 0:r.environment)&&{"deployment.environment":r.environment},(null==r?void 0:r.serviceVersion)&&{"service.version":r.serviceVersion},null==r?void 0:r.resourceAttributes),o=function(e,t,i,r){return{resourceLogs:[{resource:{attributes:oi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),s,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!=xe&&null!=(e=xe.location)&&e.href&&(t.currentUrl=xe.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}},Pa=i({},va,fa,ma,ya,ba,wa,Sa,Ea,xa,ka,Ia,Ca);Vn.__defaultExtensionClasses=i({},Pa);var Ta,Ra=(Ta=Ln[Un]=new Vn,function(){function e(){e.done||(e.done=!0,qn=!1,zi(Ln,(function(e){e._dom_loaded()})))}null!=fe&&fe.addEventListener?"complete"===fe.readyState?e():Ji(fe,"DOMContentLoaded",e,{capture:!1}):pe&&Ui.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Ta);export{hs as Compression,ns as DEFAULT_PRODUCT_TOUR_APPEARANCE,ss as DisplaySurveyType,Vn as PostHog,os as ProductTourEventName,as as ProductTourEventProperties,is as SurveyEventName,rs as SurveyEventProperties,Yr as SurveyEventType,Jr as SurveyPosition,es as SurveyQuestionBranchingType,Zr as SurveyQuestionType,ts as SurveySchedule,Xr as SurveyTabPosition,Qr as SurveyType,Kr as SurveyWidgetType,Ra as default,Ra as posthog,_s as severityLevels};
1
+ function e(e,t,i,r,s,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(r,s)}function t(t){return function(){var i=this,r=arguments;return new Promise((function(s,n){var o=t.apply(i,r);function a(t){e(o,s,n,a,l,"next",t)}function l(t){e(o,s,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 r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},i.apply(null,arguments)}function r(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var s="1.372.7",n={DEBUG:!1,LIB_VERSION:s,LIB_NAME:"web",JS_SDK_VERSION:s},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",E="$replay_override_url_trigger",S="$replay_override_event_trigger",x="$sesid",k="$session_is_sampled",I="$enabled_feature_flags",C="$active_feature_flags",P="$early_access_features",T="$feature_flag_details",R="$feature_flag_payloads",F="$feature_flag_request_id",L="$override_feature_flags",O="$override_feature_flag_payloads",M="$stored_person_properties",A="$stored_group_properties",D="$surveys",N="$surveys_activated",U="ph_product_tours",q="$flag_call_reported",H="$flag_call_reported_session_id",z="$feature_flag_errors",B="$feature_flag_evaluated_at",j="$user_state",V="$client_session_props",W="$capture_rate_limit",G="$initial_campaign_params",Y="$initial_referrer_info",K="$initial_person_info",J="$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.",re="on_reject",se="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,Ee=null==ge?void 0:ge.CompressionStream,Se=null==ve?void 0:ve.userAgent,xe=null!=pe?pe:{};function ke(){return ke=t((function*(e,i,r){void 0===i&&(i=!0);try{var s=new CompressionStream("gzip"),n=s.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(s.readable).blob(),[l]=yield Promise.all([a,o]);return l}catch(e){if(null!=r&&r.rethrow)throw e;return i&&console.error("Failed to gzip compress data",e),null}})),ke.apply(this,arguments)}var Ie=["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"],Ce=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return Ie.concat(t).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},Pe=["$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 Te(e,t){return-1!==e.indexOf(t)}var Re=function(e){return e.trim()},Fe=function(e){return e.replace(/^\$/,"")},Le=Object.prototype,$e=Le.hasOwnProperty,Oe=Le.toString,Me=Array.isArray||function(e){return"[object Array]"===Oe.call(e)},Ae=e=>"function"==typeof e,De=e=>e===Object(e)&&!Me(e),Ne=e=>{if(De(e)){for(var t in e)if($e.call(e,t))return!1;return!0}return!1},Ue=e=>void 0===e,qe=e=>"[object String]"==Oe.call(e),He=e=>qe(e)&&0===e.trim().length,ze=e=>null===e,Be=e=>Ue(e)||ze(e),je=e=>"[object Number]"==Oe.call(e)&&e==e,Ve=e=>je(e)&&e>0,We=e=>"[object Boolean]"===Oe.call(e),Ge=e=>e instanceof FormData,Ye=e=>Te(Pe,e);function Ke(e){return null===e||"object"!=typeof e}function Je(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=>Te(Qe,e),et=[!1,"false",0,"0","no"];function tt(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),je(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):t>e?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),tt(s||i,t,i,r))}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(),r=String(e),s=this._buckets[r];return s?this._applyRefill(s,i):this._buckets[r]=s={tokens:this._bucketSize,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this._onBucketRateLimited)||t.call(this,e)),0===s.tokens)}stop(){this._buckets={}}}var rt,st,nt,ot=(e,t,i)=>{function r(r){for(var s=arguments.length,n=new Array(s>1?s-1:0),o=1;s>o;o++)n[o-1]=arguments[o];t((()=>{(0,i[r])(e,...n)}))}return{debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r("error",...t)},critical(){for(var t=arguments.length,r=new Array(t),s=0;t>s;s++)r[s]=arguments[s];i.error(e,...r)},createLogger:r=>ot(e+" "+r,t,i)}},at="Mobile",lt="iOS",ut="Android",ct="Tablet",dt=ut+" "+ct,_t="iPad",ht="Apple",pt=ht+" Watch",gt="Safari",vt="BlackBerry",ft="Samsung",mt=ft+"Browser",yt=ft+" Internet",bt="Chrome",wt=bt+" OS",Et=bt+" "+lt,St="Internet Explorer",xt=St+" "+at,kt="Opera",It=kt+" Mini",Ct="Edge",Pt="Microsoft "+Ct,Tt="Firefox",Rt=Tt+" "+lt,Ft="Nintendo",Lt="PlayStation",$t="Xbox",Ot=ut+" "+at,Mt=at+" "+gt,At="Windows",Dt=At+" Phone",Nt="Nokia",Ut="Ouya",qt="Generic",Ht=qt+" "+at.toLowerCase(),zt=qt+" "+ct.toLowerCase(),Bt="Konqueror",jt="(\\d+(\\.\\d+)?)",Vt=new RegExp("Version/"+jt),Wt=new RegExp($t,"i"),Gt=new RegExp(Lt+" \\w+","i"),Yt=new RegExp(Ft+" \\w+","i"),Kt=new RegExp(vt+"|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"},Xt=function(e,t){return t=t||"",Te(e," OPR/")&&Te(e,"Mini")?It:Te(e," OPR/")?kt:Kt.test(e)?vt:Te(e,"IE"+at)||Te(e,"WPDesktop")?xt:Te(e,mt)?yt:Te(e,Ct)||Te(e,"Edg/")?Pt:Te(e,"FBIOS")?"Facebook "+at:Te(e,"UCWEB")||Te(e,"UCBrowser")?"UC Browser":Te(e,"CriOS")?Et:Te(e,"CrMo")||Te(e,bt)?bt:Te(e,ut)&&Te(e,gt)?Ot:Te(e,"FxiOS")?Rt:Te(e.toLowerCase(),Bt.toLowerCase())?Bt:((e,t)=>t&&Te(t,ht)||function(e){return Te(e,gt)&&!Te(e,bt)&&!Te(e,ut)}(e))(e,t)?Te(e,at)?Mt:gt:Te(e,Tt)?Tt:Te(e,"MSIE")||Te(e,"Trident/")?St:Te(e,"Gecko")?Tt:""},Qt={[xt]:[new RegExp("rv:"+jt)],[Pt]:[new RegExp(Ct+"?\\/"+jt)],[bt]:[new RegExp("("+bt+"|CrMo)\\/"+jt)],[Et]:[new RegExp("CriOS\\/"+jt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+jt)],[gt]:[Vt],[Mt]:[Vt],[kt]:[new RegExp("(Opera|OPR)\\/"+jt)],[Tt]:[new RegExp(Tt+"\\/"+jt)],[Rt]:[new RegExp("FxiOS\\/"+jt)],[Bt]:[new RegExp("Konqueror[:/]?"+jt,"i")],[vt]:[new RegExp(vt+" "+jt),Vt],[Ot]:[new RegExp("android\\s"+jt,"i")],[yt]:[new RegExp(mt+"\\/"+jt)],[St]:[new RegExp("(rv:|MSIE )"+jt)],Mozilla:[new RegExp("rv:"+jt)]},Zt=function(e,t){var i=Xt(e,t),r=Qt[i];if(Ue(r))return null;for(var s=0;r.length>s;s++){var n=e.match(r[s]);if(n)return parseFloat(n[n.length-2])}return null},ei=[[new RegExp($t+"; "+$t+" (.*?)[);]","i"),e=>[$t,e&&e[1]||""]],[new RegExp(Ft,"i"),[Ft,""]],[new RegExp(Lt,"i"),[Lt,""]],[Kt,[vt,""]],[new RegExp(At,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Dt,""];if(new RegExp(at).test(t)&&!/IEMobile\b/.test(t))return[At+" "+at,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=Jt[i[1]]||"";return/arm/i.test(t)&&(r="RT"),[At,r]}return[At,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[lt,[e[3],e[4],e[5]||"0"].join(".")]:[lt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=Ue(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+ut+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+ut+")","i"),e=>e&&e[2]?[ut,[e[2],e[3],e[4]||"0"].join(".")]:[ut,""]],[/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/,[wt,""]],[/Linux|debian/i,["Linux",""]]],ti=function(e){return Yt.test(e)?Ft:Gt.test(e)?Lt:Wt.test(e)?$t:new RegExp(Ut,"i").test(e)?Ut:new RegExp("("+Dt+"|WPDesktop)","i").test(e)?Dt:/iPad/.test(e)?_t:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?pt:Kt.test(e)?vt:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Nt,"i").test(e)?Nt:/(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(at).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)?ut:dt:new RegExp("(pda|"+at+")","i").test(e)?Ht:new RegExp(ct,"i").test(e)&&!new RegExp(ct+" pc","i").test(e)?zt:""},ii=e=>e instanceof Error,ri={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=ri.info;function ni(e){if(We(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(Me(e))return{arrayValue:{values:e.map((e=>ni(e)))}};try{return{stringValue:JSON.stringify(e)}}catch(t){return{stringValue:String(e)}}}function oi(e){var t=[];for(var i in e){var r=e[i];ze(r)||Ue(r)||t.push({key:i,value:ni(r)})}return t}function ai(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return nt&&i.length===st||(st=i.length,nt=i.reduce(((i,r)=>{rt||(rt={});var s=rt[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,rt[r]=[l,u];break}}return i}),{})),nt}}class li{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"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);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&&Me(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 r,s;return null!=e.cause&&(r=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),i({},e,{cause:r,stack:s})}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 r of i.modifiers)t=yield r(t);return t}))()}convertToExceptionList(e,t){var r,s,n,o={type:e.type,value:e.value,mechanism:{type:null!==(r=t.type)&&void 0!==r?r:"generic",handled:null===(s=t.handled)||void 0===s||s,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:ai(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return i({},t,{syntheticException:0==r?t.syntheticException:void 0,mechanism:e,apply:e=>s(e,r),next:e=>s(e,r+1)})}}var ui="?";function ci(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?ui:i,in_app:!0};return Ue(r)||(n.lineno=r),Ue(s)||(n.colno=s),n}var di=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:ui,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},_i=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,hi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pi=/\((\S*)(?::(\d+))(?::(\d+))\)/,gi=(e,t)=>{var i=_i.exec(e);if(i){var[,r,s,n]=i;return ci(t,r,ui,+s,+n)}var o=hi.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=pi.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=di(o[1]||ui,o[2]);return ci(t,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},vi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,fi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,mi=(e,t)=>{var i=vi.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=fi.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||ui;return[n,s]=di(n,s),ci(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},yi=/\(error: (.*)\)/;class bi{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=qe(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 Je(e,"DOMException")}isDOMError(e){return Je(e,"DOMError")}}class wi{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 Ei{constructor(){}match(e){return Je(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 Si=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class xi{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Si);return r&&(t=r[1],i=r[2]),[t,i]}}var ki=["fatal","error","warning","log","info","debug"];function Ii(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(t>=s.length)return r===i.length?s:s.length>t?s.slice(0,t)+"...":s}return""}class Ci{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{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: "+Ii(e)}isSeverityLevel(e){return qe(e)&&!He(e)&&ki.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(ii(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,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Ii(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Ti{match(e){return Ke(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 Ri{match(e){return Je(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,r=this.getUnhandledRejectionReason(e);return Ke(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}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 Fi="$message",Li="$timestamp",$i=new Set([Fi,Li]),Oi={enabled:!0,max_bytes:32768};function Mi(e){var t;return e?{enabled:null!==(t=e.enabled)&&void 0!==t?t:Oi.enabled,max_bytes:Di(e.max_bytes,Oi.max_bytes)}:i({},Oi)}class Ai{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 r=i,s=r[Fi],n=r[Li];if(!qe(s)||0===s.trim().length)return;if(!qe(n)&&!je(n))return;return{step:r,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,r=0;t.length>r;r++)"%"===t[r]?(i+=1,r+=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 Di(e,t){if(!je(e)||e===1/0||e===-1/0)return t;var i=Math.floor(e);return 0>i?t:i}var Ni=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={_log(t){if(pe&&(n.DEBUG||xe.POSTHOG_DEBUG||i)&&!Ue(pe.console)&&pe.console){for(var r=("__rrweb_original__"in pe.console[t]?pe.console[t].__rrweb_original__:pe.console[t]),s=arguments.length,o=new Array(s>1?s-1:0),a=1;s>a;a++)o[a-1]=arguments[a];r(e,...o)}},debug(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("debug",...t)},info(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("log",...t)},warn(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("warn",...t)},error(){for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];r._log("error",...t)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(e){r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>Ni(e+" "+t,i)};return r},Ui=Ni("[PostHog.js]"),qi=Ui.createLogger;function Hi(e,t){Me(e)&&e.forEach(t)}function zi(e,t){if(!Be(e))if(Me(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 Bi=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(e[n]=s[n]);return e};function ji(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Vi=function(e){try{return e()}catch(e){return}},Wi=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];return e.apply(this,i)}catch(e){Ui.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),Ui.critical(e)}}},Gi=function(e){var t={};return zi(e,(function(e,i){(qe(e)&&e.length>0||je(e))&&(t[i]=e)})),t};var Yi=["herokuapp.com","vercel.app","netlify.app"];function Ki(e){var t=null==e?void 0:e.hostname;if(!qe(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Yi)if(i===r)return!1;return!0}function Ji(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}function Xi(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 je(e)&&isFinite(e)&&Math.floor(e)===e});class Qi{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new Qi(s)}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 Qi(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 Zi{constructor(){this._timestamp=0,this._counter=0,this._random=new ir}generate(){var e=this.generateOrAbort();if(Ue(e)){this._timestamp=0;var t=this.generateOrAbort();if(Ue(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 Qi.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 er,tr=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&&!Ue(pe.crypto)&&crypto.getRandomValues&&(tr=e=>crypto.getRandomValues(e));class ir{constructor(){this._buffer=new Uint32Array(8),this._cursor=1/0}nextUint32(){return this._buffer.length>this._cursor||(tr(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var rr=()=>sr().toString(),sr=()=>(er||(er=new Zi)).generate(),nr="",or=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var ar={_is_supported:()=>!!fe,_error(e){Ui.error("cookieStore error: "+e)},_get(e){if(fe){try{for(var t=e+"=",i=fe.cookie.split(";").filter((e=>e.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(e){}return null}},_parse(e){var t;try{t=JSON.parse(ar._get(e))||{}}catch(e){}return t},_set(e,t,i,r,s){if(fe)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=fe),nr)return nr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+rr();!nr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",nr=n)}return nr}(e);if(!i){var r=(e=>{var t=e.match(or);return t?t[0]:""})(e);r!==i&&Ui.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}(fe.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(o="; secure");var u=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&Ui.warn("cookieStore warning: large cookie, len="+u.length),fe.cookie=u,u}catch(e){return}},_remove(e,t){if(null!=fe&&fe.cookie)try{ar._set(e,"",-1,t)}catch(e){return}}},lr=null,ur={_is_supported(){if(!ze(lr))return lr;var e=!0;if(Ue(pe))e=!1;else try{var t="__mplssupport__";ur._set(t,"xyz"),'"xyz"'!==ur._get(t)&&(e=!1),ur._remove(t)}catch(t){e=!1}return e||Ui.error("localStorage unsupported; falling back to cookie store"),lr=e,e},_error(e){Ui.error("localStorage error: "+e)},_get(e){try{return null==pe?void 0:pe.localStorage.getItem(e)}catch(e){ur._error(e)}return null},_parse(e){try{return JSON.parse(ur._get(e))||{}}catch(e){}return null},_set(e,t){try{null==pe||pe.localStorage.setItem(e,JSON.stringify(t))}catch(e){ur._error(e)}},_remove(e){try{null==pe||pe.localStorage.removeItem(e)}catch(e){ur._error(e)}}},cr=[a,"distinct_id",x,k,J,K,j],dr={},_r={_is_supported:()=>!0,_error(e){Ui.error("memoryStorage error: "+e)},_get:e=>dr[e]||null,_parse:e=>dr[e]||null,_set(e,t){dr[e]=t},_remove(e){delete dr[e]}},hr=null,pr={_is_supported(){if(!ze(hr))return hr;if(hr=!0,Ue(pe))hr=!1;else try{var e="__support__";pr._set(e,"xyz"),'"xyz"'!==pr._get(e)&&(hr=!1),pr._remove(e)}catch(e){hr=!1}return hr},_error(e){Ui.error("sessionStorage error: ",e)},_get(e){try{return null==pe?void 0:pe.sessionStorage.getItem(e)}catch(e){pr._error(e)}return null},_parse(e){try{return JSON.parse(pr._get(e))||null}catch(e){}return null},_set(e,t){try{null==pe||pe.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){pr._error(e)}},_remove(e){try{null==pe||pe.sessionStorage.removeItem(e)}catch(e){pr._error(e)}}};class gr{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===se||this.isRejected()||-1===this.consent&&this._config.cookieless_mode===re}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:Te(et,e)?0:-1}get _storage(){var e=this._config.opt_out_capturing_persistence_type,t="localStorage"===e?ur:ar;if(!this._persistentStore||this._persistentStore!==t){this._persistentStore=t;var i="localStorage"===e?ar:ur;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,xe.doNotTrack].some((e=>Ze(e)))}}var vr=qi("[Dead Clicks]"),fr=()=>!0,mr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(v)),r=e.instance.config.capture_dead_clicks;return We(r)?r:!!De(r)||i};class yr{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=xe.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(t=>{t?vr.error("failed to load script",t):e()}))}_start(){var e;if(fe){if(!this._lazyLoadedDeadClicksAutocapture&&null!=(e=xe.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=De(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=xe.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(fe),vr.info("starting...")}}else vr.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,vr.info("stopping..."))}}var br=qi("[SegmentIntegration]");var wr="posthog-js";function Er(e,t){var{organization:r,projectId:s,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 r&&s&&(f.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+t.event_id),a&&(null==(p=e.exceptions)||p.sendExceptionEvent(f)),t}}class Sr{constructor(e,t,i,r,s,n){this.name=wr,this.setupOnce=function(o){o(Er(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class xr{constructor(e){this._onSessionIdChange=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(Ui.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,r=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(),r}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 r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=s;if(!(Ue(n)||Ue(o)||Ue(a)||Ue(l)||Ue(u)||Ue(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,Ui):1,_=n>1?tt(a/n,0,1,Ui):1,h=l>1?tt(u/l,0,1,Ui):1,p=l>1?tt(c/l,0,1,Ui):1;r=Bi(r,{$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&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var kr={[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"},[x]:{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"},[I]:{exposure:"derived",shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!De(e))return{};for(var t={},i=Object.keys(e),r=0;i.length>r;r++)t["$feature/"+i[r]]=e[i[r]];return t}},[C]:{exposure:"event"},[P]:{exposure:"hidden"},[T]:{exposure:"hidden"},[R]:{exposure:"event"},[F]:{exposure:"event"},[L]:{exposure:"event"},[O]:{exposure:"hidden"},[M]:{exposure:"hidden"},[A]:{exposure:"hidden"},[D]:{exposure:"hidden"},[N]:{exposure:"event"},[U]:{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"},[q]:{exposure:"hidden"},[H]:{exposure:"hidden"},[z]:{exposure:"hidden"},[B]:{exposure:"hidden"},[j]:{exposure:"hidden"},[V]:{exposure:"hidden"},[W]:{exposure:"hidden"},[G]:{exposure:"hidden"},[Y]:{exposure:"hidden"},[K]:{exposure:"hidden"},[J]:{exposure:"hidden"},[b]:{exposure:"event"},[w]:{exposure:"event"},[E]:{exposure:"event"},[S]:{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"}},Ir=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Cr=e=>{var t=null==fe?void 0:fe.createElement("a");return Ue(t)?null:(t.href=e,t)},Pr=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!Me(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){Ui.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Tr=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var d=l[c].split("=");Me(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(l[c]))}var _=a;return null!=o&&(_+="?"+u.join("&")),null!=s&&(_+="#"+s),_},Rr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},Fr="https?://(.*)",Lr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],$r=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Lr],Or="<masked>",Mr=["li_fat_id"];function Ar(e,t,i){if(!fe)return{};var r,s=t?[...Lr,...i||[]]:[],n=Dr(Tr(fe.URL,s,Or),e),o=(r={},zi(Mr,(function(e){var t=ar._get(e);r[e]=t||null})),r);return Bi(o,n)}function Dr(e,t){var i=$r.concat(t||[]),r={};return zi(i,(function(t){var i=Pr(e,t);r[t]=i||null})),r}function Nr(e){var t=function(e){return e?0===e.search(Fr+"google.([^/?]*)")?"google":0===e.search(Fr+"bing.com")?"bing":0===e.search(Fr+"yahoo.com")?"yahoo":0===e.search(Fr+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!ze(t)){r.$search_engine=t;var s=fe?Pr(fe.referrer,i):"";s.length&&(r.ph_keyword=s)}return r}function Ur(){return navigator.language||navigator.userLanguage}var qr="$direct";function Hr(){return(null==fe?void 0:fe.referrer)||qr}function zr(e,t){var i=e?[...Lr,...t||[]]:[],r=null==me?void 0:me.href.substring(0,1e3);return{r:Hr().substring(0,1e3),u:r?Tr(r,i,Or):void 0}}function Br(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:i==qr?qr:null==(t=Cr(i))?void 0:t.host};if(r){s.$current_url=r;var n=Cr(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=Dr(r);Bi(s,o)}if(i){var a=Nr(i);Bi(s,a)}return s}function jr(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function Vr(){try{return(new Date).getTimezoneOffset()}catch(e){return}}var Wr=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Gr{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&&Ui.info("Persistence loaded",e.persistence,i({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this._disabled}_buildStorage(e){-1===Wr.indexOf(e.persistence.toLowerCase())&&(Ui.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=[...cr,...e];return i({},ur,{_parse(e){try{var t={};try{t=ar._parse(e)||{}}catch(e){}var i=Bi(t,JSON.parse(ur._get(e)||"{}"));return ur._set(e,i),i}catch(e){}return null},_set(e,i,r,s,n,o){try{ur._set(e,i,void 0,void 0,o);var a={};t.forEach((e=>{i[e]&&(a[e]=i[e])})),Object.keys(a).length&&ar._set(e,a,r,s,n,o)}catch(e){ur._error(e)}},_remove(e,t){try{null==pe||pe.localStorage.removeItem(e),ar._remove(e,t)}catch(e){ur._error(e)}}})}(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return"localstorage"===r&&ur._is_supported()?ur:"localstorage+cookie"===r&&t._is_supported()?t:"sessionstorage"===r&&pr._is_supported()?pr:"memory"===r?_r:"cookie"===r?ar:t._is_supported()?t:ar}_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 zi(this.props,((t,i)=>{var r=(e=>{var t=kr[e];if(t)return t;for(var[i,r]of Ir)if(0===e.indexOf(i))return r})(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(t,i===I?()=>this._isFeatureFlagCacheStale():()=>!1))return;r.transformToEventProperties&&Bi(e,r.transformToEventProperties(t))}else r&&"event"!==r.exposure||(e[i]=t)})),e}load(){if(!this._disabled){var e=this._storage._parse(this._name);e&&(this.props=Bi({},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)){Ue(t)&&(t="None"),this._expire_days=Ue(i)?this._default_expiry:i;var r=!1;if(zi(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this._setProp(i,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(De(e)){this._expire_days=Ue(t)?this._default_expiry:t;var i=!1;if(zi(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this._setProp(r,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=Ar(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);Ne(Gi(e))||this.register(e),this._campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==fe?void 0:fe.referrer)?Nr(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Hr(),$referring_domain:null!=fe&&fe.referrer&&(null==(e=Cr(fe.referrer))?void 0:e.host)||qr},void 0)}set_initial_person_info(){this.props[G]||this.props[Y]||this.register_once({[K]:zr(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};zi([Y,G],(t=>{var i=this.props[t];i&&zi(i,(function(t,i){e["$initial_"+Fe(i)]=t}))}));var t,i,r=this.props[K];if(r){var s=(t=Br(r),i={},zi(t,(function(e,t){i["$initial_"+Fe(t)]=e})),i);Bi(e,s)}return e}safe_merge(e){return zi(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(),r=[...t].sort();return i.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this._buildStorage(e),s=this.props;this.clear(),this._storage=r,this.props=s,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 Ue(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 Yr={Activation:"events",Cancellation:"cancelEvents"},Kr={Button:"button",Tab:"tab",Selector:"selector"},Jr={TopLeft:"top_left",TopRight:"top_right",TopCenter:"top_center",MiddleLeft:"middle_left",MiddleRight:"middle_right",MiddleCenter:"middle_center",Left:"left",Center:"center",Right:"right",NextToTrigger:"next_to_trigger"},Xr={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Qr={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Zr={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},es={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},ts={Once:"once",Recurring:"recurring",Always:"always"},is={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},rs={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date",SURVEY_LANGUAGE:"$survey_language"},ss={Popover:"popover",Inline:"inline"},ns={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},os={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},as={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},ls=qi("[RateLimiter]");class us{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=>{ls.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void ls.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,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(W))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);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 "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(W,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var cs=qi("[RemoteConfig]");class ds{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=xe._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}_loadRemoteConfigJs(e){var t,i;null!=(t=xe.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=xe.__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 cs.info("Using preloaded remote config",this.remoteConfig),this._onRemoteConfig(this.remoteConfig),void this._startRefreshInterval();if(this._instance._shouldDisableFlags())return void cs.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return cs.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){cs.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||cs.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 _s=["fatal","error","warning","log","info","debug"],hs={GZipJS:"gzip-js",Base64:"base64"},ps=Uint8Array,gs=Uint16Array,vs=Uint32Array,fs=new ps([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]),ms=new ps([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]),ys=new ps([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bs=function(e,t){for(var i=new gs(31),r=0;31>r;++r)i[r]=t+=1<<e[r-1];var s=new vs(i[30]);for(r=1;30>r;++r)for(var n=i[r];i[r+1]>n;++n)s[n]=n-i[r]<<5|r;return[i,s]},ws=bs(fs,2),Es=ws[1];ws[0][28]=258,Es[258]=28;for(var Ss=bs(ms,0)[1],xs=new gs(32768),ks=0;32768>ks;++ks){var Is=(43690&ks)>>>1|(21845&ks)<<1;xs[ks]=((65280&(Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4))>>>8|(255&Is)<<8)>>>1}var Cs=function(e,t,i){for(var r=e.length,s=0,n=new gs(t);r>s;++s)++n[e[s]-1];var o,a=new gs(t);for(s=0;t>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new gs(1<<t);var l=15-t;for(s=0;r>s;++s)if(e[s])for(var u=s<<4|e[s],c=t-e[s],d=a[e[s]-1]++<<c,_=d|(1<<c)-1;_>=d;++d)o[xs[d]>>>l]=u}else for(o=new gs(r),s=0;r>s;++s)o[s]=xs[a[e[s]-1]++]>>>15-e[s];return o},Ps=new ps(288);for(ks=0;144>ks;++ks)Ps[ks]=8;for(ks=144;256>ks;++ks)Ps[ks]=9;for(ks=256;280>ks;++ks)Ps[ks]=7;for(ks=280;288>ks;++ks)Ps[ks]=8;var Ts=new ps(32);for(ks=0;32>ks;++ks)Ts[ks]=5;var Rs=Cs(Ps,9,0),Fs=Cs(Ts,5,0),Ls=function(e){return(e/8>>0)+(7&e&&1)},$s=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof gs?gs:e instanceof vs?vs:ps)(i-t);return r.set(e.subarray(t,i)),r},Os=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8},Ms=function(e,t,i){var r=t/8>>0;e[r]|=i<<=7&t,e[r+1]|=i>>>8,e[r+2]|=i>>>16},As=function(e,t){for(var i=[],r=0;e.length>r;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new ps(0),0];if(1==s){var o=new ps(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!=s-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(r=1;s>r;++r)n[r].s>_&&(_=n[r].s);var h=new gs(_+1),p=Ds(i[c-1],h,0);if(p>t){r=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return h[t.s]-h[e.s]||e.f-t.f}));s>r;++r){var m=n[r].s;if(t>=h[m])break;g+=f-(1<<p-h[m]),h[m]=t}for(g>>>=v;g>0;){var y=n[r].s;t>h[y]?g-=1<<t-h[y]++-1:++r}for(;r>=0&&g;--r){var b=n[r].s;h[b]==t&&(--h[b],++g)}p=t}return[new ps(h),p]},Ds=function(e,t,i){return-1==e.s?Math.max(Ds(e.l,t,i+1),Ds(e.r,t,i+1)):t[e.s]=i},Ns=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new gs(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;t>=a;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Us=function(e,t){for(var i=0,r=0;t.length>r;++r)i+=e[r]*t[r];return i},qs=function(e,t,i){var r=i.length,s=Ls(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;r>n;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Hs=function(e,t,i,r,s,n,o,a,l,u,c){Os(t,c++,i),++s[256];for(var d=As(s,15),_=d[0],h=d[1],p=As(n,15),g=p[0],v=p[1],f=Ns(_),m=f[0],y=f[1],b=Ns(g),w=b[0],E=b[1],S=new gs(19),x=0;m.length>x;++x)S[31&m[x]]++;for(x=0;w.length>x;++x)S[31&w[x]]++;for(var k=As(S,7),I=k[0],C=k[1],P=19;P>4&&!I[ys[P-1]];--P);var T,R,F,L,O=u+5<<3,M=Us(s,Ps)+Us(n,Ts)+o,A=Us(s,_)+Us(n,g)+o+14+3*P+Us(S,I)+(2*S[16]+3*S[17]+7*S[18]);if(M>=O&&A>=O)return qs(t,c,e.subarray(l,l+u));if(Os(t,c,1+(M>A)),c+=2,M>A){T=Cs(_,h,0),R=_,F=Cs(g,v,0),L=g;var D=Cs(I,C,0);for(Os(t,c,y-257),Os(t,c+5,E-1),Os(t,c+10,P-4),c+=14,x=0;P>x;++x)Os(t,c+3*x,I[ys[x]]);c+=3*P;for(var N=[m,w],U=0;2>U;++U){var q=N[U];for(x=0;q.length>x;++x)Os(t,c,D[H=31&q[x]]),c+=I[H],H>15&&(Os(t,c,q[x]>>>5&127),c+=q[x]>>>12)}}else T=Rs,R=Ps,F=Fs,L=Ts;for(x=0;a>x;++x)if(r[x]>255){var H;Ms(t,c,T[257+(H=r[x]>>>18&31)]),c+=R[H+257],H>7&&(Os(t,c,r[x]>>>23&31),c+=fs[H]);var z=31&r[x];Ms(t,c,F[z]),c+=L[z],z>3&&(Ms(t,c,r[x]>>>5&8191),c+=ms[z])}else Ms(t,c,T[r[x]]),c+=R[r[x]];return Ms(t,c,T[256]),c+R[256]},zs=new vs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Bs=function(){for(var e=new vs(256),t=0;256>t;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),js=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};function Vs(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p(t){for(var i=e,r=0;t.length>r;++r)i=Bs[255&i^t[r]]^i>>>8;e=i},d(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n,o,a,l,u=(a=10+((s=t).filename&&s.filename.length+1||0),l=8,function(e,t,i,r,s,n){var o=e.length,a=new ps(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!t||8>o)for(var c=0;o>=c;c+=65535){var d=c+65535;o>d?u=qs(l,u,e.subarray(c,d)):(l[c]=!0,u=qs(l,u,e.subarray(c,o)))}else{for(var _=zs[t-1],h=_>>>13,p=8191&_,g=(1<<i)-1,v=new gs(32768),f=new gs(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 vs(25e3),E=new gs(288),S=new gs(32),x=0,k=0,I=(c=0,0),C=0,P=0;o>c;++c){var T=b(c),R=32767&c,F=f[T];if(v[R]=F,f[T]=R,c>=C){var L=o-c;if((x>7e3||I>24576)&&L>423){u=Hs(e,l,0,w,E,S,k,I,P,c-P,u),I=x=k=0,P=c;for(var O=0;286>O;++O)E[O]=0;for(O=0;30>O;++O)S[O]=0}var M=2,A=0,D=p,N=R-F&32767;if(L>2&&T==b(c-N))for(var U=Math.min(h,L)-1,q=Math.min(32767,c),H=Math.min(258,L);q>=N&&--D&&R!=F;){if(e[c+M]==e[c+M-N]){for(var z=0;H>z&&e[c+z]==e[c+z-N];++z);if(z>M){if(M=z,A=N,z>U)break;var B=Math.min(N,z-2),j=0;for(O=0;B>O;++O){var V=c-N+O+32768&32767,W=V-v[V]+32768&32767;W>j&&(j=W,F=V)}}}N+=(R=F)-(F=v[R])+32768&32767}if(A){w[I++]=268435456|Es[M]<<18|Ss[A];var G=31&Es[M],Y=31&Ss[A];k+=fs[G]+ms[Y],++E[257+G],++S[Y],C=c+M,++x}else w[I++]=e[c],++E[e[c]]}}u=Hs(e,l,!0,w,E,S,k,I,P,c-P,u)}return $s(a,0,r+Ls(u)+s)}(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&&js(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;i.length>=r;++r)e[r+10]=i.charCodeAt(r)}}(u,t),js(u,c-8,i.d()),js(u,c-4,r),u}var Ws=!!be||!!ye,Gs="text/plain",Ys=!1,Ks=function(e,t,r){var s;void 0===r&&(r=!0);var[n,o]=e.split("?"),a=i({},t),l=null!==(s=null==o?void 0:o.split("&").map((e=>{var t,[i,s]=e.split("="),n=r&&null!==(t=a[i])&&void 0!==t?t:s;return delete a[i],i+"="+n})))&&void 0!==s?s:[],u=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return zi(e,(function(e,t){Ue(e)||Ue(t)||"undefined"===t||(i=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)})),s.join(t)}(a);return u&&l.push(u),n+"?"+l.join("&")},Js=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Xs=e=>{if(e._encodedBody)return e._encodedBody;var{data:t,compression:i}=e;if(t){if(i===hs.GZipJS){var r=Vs(function(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new ps(e.length+(e.length>>>1)),s=0,n=function(e){r[s++]=e},o=0;i>o;++o){if(s+5>r.length){var a=new ps(s+8+(i-o<<1));a.set(r),r=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 $s(r,0,s)}(Js(t)),{mtime:0});return{contentType:Gs,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===hs.Base64){var s=function(e){return e?btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>String.fromCharCode(parseInt(t,16))))):e}(Js(t)),n=(e=>"data="+encodeURIComponent("string"==typeof e?e:Js(e)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Js(t);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Qs=function(){var e=t((function*(e){var t=Js(e.data),r=yield function(e,t,i){return ke.apply(this,arguments)}(t,n.DEBUG,{rethrow:!0});if(!r)return e;var s=yield r.arrayBuffer();return i({},e,{_encodedBody:{contentType:Gs,body:s,estimatedSize:s.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Zs=(e,t)=>Ks(e,{_:(new Date).getTime().toString(),ver:n.JS_SDK_VERSION,compression:t}),en=[];ye&&en.push({transport:"fetch",method(e){var t,r,{contentType:s,body:n,estimatedSize:o}=null!==(t=Xs(e))&&void 0!==t?t:{},a=new Headers;zi(e.headers,(function(e,t){a.append(t,e)})),s&&a.append("Content-Type",s);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==(r=u)?void 0:r.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){Ui.error(e)}null==e.callback||e.callback(r)})))).catch((t=>{Ui.error(t),null==e.callback||e.callback({statusCode:0,error:t})})).finally((()=>u?clearTimeout(u.timeout):null))}}),be&&en.push({transport:"XHR",method(e){var t,i=new be;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Xs(e))&&void 0!==t?t:{};zi(e.headers,(function(e,t){i.setRequestHeader(t,e)})),r&&i.setRequestHeader("Content-Type",r),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(s)}}),null!=ve&&ve.sendBeacon&&en.push({transport:"sendBeacon",method(e){var t=Ks(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Xs(e))&&void 0!==i?i:{};if(!s)return;var n=s instanceof Blob?s:new Blob([s],{type:r});ve.sendBeacon(t,n)}catch(e){}}});var tn=3e3;class rn{constructor(e,t){this._isPaused=!0,this._queue=[],this._flushTimeoutMs=tt((null==t?void 0:t.flush_interval_ms)||tn,250,5e3,Ui.createLogger("flush interval"),tn),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[r],s=(new Date).getTime();i.data&&Me(i.data)&&zi(i.data,(e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp})),e._sendRequest(i)};for(var r in t)i()}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return zi(this._queue,(t=>{var r,s=t,n=(s?s.batchKey:null)||s.url;Ue(e[n])&&(e[n]=i({},s,{data:[]})),null==(r=e[n].data)||r.push(s.data)})),this._queue=[],e}}var sn=["retriesPerformedSoFar"];class nn{constructor(e){this._isPolling=!1,this._pollIntervalMs=3e3,this._queue=[],this._instance=e,this._queue=[],this._areWeOnline=!0,!Ue(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,s=r(e,sn);Ve(t)&&(s.url=Ks(s.url,{retry_count:t})),this._instance._send_request(i({},s,{callback:e=>{200===e.statusCode||e.statusCode>=400&&500>e.statusCode||(null!=t?t:0)>=10?null==s.callback||s.callback(e):this._enqueue(i({retriesPerformedSoFar:t},s))}}))}_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,r=Math.min(18e5,t),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),Ui.warn(s),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:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._isPolling=!1,Ue(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){Ui.error(e)}this._queue=[]}}class on{constructor(e){this._updateScrollData=()=>{var e,t,i,r;this._context||(this._context={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.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!==(r=this._context.maxContentHeight)&&void 0!==r?r: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=Me(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 an=e=>zr(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class ln{constructor(e,t,i,r){this._onSessionIdCallback=e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[V]:i})}},this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||an,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[V]}getSetOnceProps(){var e,t=null==(e=this._getStored())?void 0:e.props;return t?"r"in t?Br(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 zi(Gi(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+Fe(i)]=t})),e}}class un{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 r of this._events["*"]||[])r(e,t)}}var cn=qi("[SessionId]");class dn{on(e,t){return this._eventEmitter.on(e,t)}constructor(e,t,i){var r;if(this._sessionIdChangedHandlers=[],this._beforeUnloadListener=void 0,this._eventEmitter=new un,this._sessionHasBeenIdleTooLong=(e,t)=>!(!Ve(e)||!Ve(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===se)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||rr,this._windowIdGenerator=i||rr;var s=this._config.persistence_name||this._config.token;if(this._sessionTimeoutMs=1e3*tt(this._config.session_idle_timeout_seconds||1800,60,36e3,cn.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this._resetIdleTimer(),this._window_id_storage_key="ph_"+s+"_window_id",this._primary_window_exists_storage_key="ph_"+s+"_primary_window_exists",this._canUseSessionStorage()){var n=pr._parse(this._window_id_storage_key),o=pr._parse(this._primary_window_exists_storage_key);n&&!o?this._windowId=n:pr._remove(this._window_id_storage_key),pr._set(this._primary_window_exists_storage_key,!0)}if(null!=(r=this._config.bootstrap)&&r.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){cn.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return Ue(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&&pr._is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&pr._set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?pr._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({[x]:[t,e,i]}))}_getSessionId(){var e=this._persistence.props[x];return Me(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()&&pr._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===se)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this._getSessionId(),o=this._getWindowId(),a=Ve(n)&&Math.abs(i-n)>864e5,l=!1,u=!s,c=!u&&!e&&this._sessionHasBeenIdleTooLong(i,r);u||c||a?(s=this._sessionIdGenerator(),o=this._windowIdGenerator(),cn.info("new session ID generated",{sessionId:s,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=Ve(r)&&e&&!a?r:i,_=Ve(n)?n:(new Date).getTime();return this._setWindowId(o),this._setSessionId(s,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(s,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:s,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}_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 _n=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Ce(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>Ce(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver},hn=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 pn(e,t,i){return Js({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var gn={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=>hn(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!hn(t,e))))),icontains:(e,t)=>t.map(vn).some((t=>e.map(vn).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(vn).every((t=>e.map(vn).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)))}))},vn=e=>e.toLowerCase();function fn(e,t){return!e||Object.entries(e).every((e=>{var[i,r]=e,s=null==t?void 0:t[i];if(Ue(s)||ze(s))return!1;var n=[String(s)],o=gn[r.operator];return!!o&&o(r.values,n)}))}var mn,yn,bn="custom",wn="i.posthog.com",En=/^\/static\//;class Sn{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("."+wn,".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":bn),this._regionCache[this.apiHost]}_staticAssetHostOverride(e){var t=this.instance.config.__preview_external_dependency_versioned_paths;if("string"==typeof t&&En.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===bn)return this.apiHost+t;var r=wn+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}void 0===mn&&(mn=e=>e()),ot("[SurveyTranslations]",mn,(void 0===yn&&(yn=console),{log:yn.log.bind(yn),warn:yn.warn.bind(yn),error:yn.error.bind(yn),debug:yn.debug.bind(yn)}));var xn=qi("[Surveys]"),kn="seenSurvey_",In=[Qr.Popover,Qr.Widget,Qr.API],Cn={ignoreConditions:!1,ignoreDelay:!1,displayType:ss.Popover},Pn=qi("[PostHog ExternalIntegrations]"),Tn={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Rn{constructor(e){this._instance=e}_loadScript(e,t){var i;null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,(e=>{if(e)return Pn.error("failed to load script",e);t()}))}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=xe.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e._loadScript(Tn[t],(()=>{var i;null==(i=xe.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)})),!r&&null!=(s=xe.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=xe.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var Fn,Ln={},$n=0,On=()=>{},Mn='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',An="Surveys module not available",Dn="sanitize_properties is deprecated. Use before_send instead",Nn="Invalid value for property_denylist config: ",Un="posthog",qn=!Ws&&-1===(null==Se?void 0:Se.indexOf("MSIE"))&&-1===(null==Se?void 0:Se.indexOf("Mozilla")),Hn=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:On,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&&qe(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){Ui.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:tn},error_tracking:{},_onCapture:On,__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))},zn=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Bn=e=>{var t={};for(var[i,r]of zn)Ue(e[i])||(t[r]=e[i]);var s=Bi({},t,e);return Me(e.property_blacklist)&&(Ue(e.property_denylist)?s.property_denylist=e.property_blacklist:Me(e.property_denylist)?s.property_denylist=[...e.property_blacklist,...e.property_denylist]:Ui.error(Nn+e.property_denylist)),s};class jn{constructor(){this.__forceAllowLocalhost=!1}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){Ui.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Vn{_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===se||this.config.cookieless_mode===re&&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 jn,this._personProcessingSetOncePropertiesSent=!1,this.version=n.LIB_VERSION,this._internalEventEmitter=new un,this._extensions=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Hn(),this.SentryIntegration=Sr,this.sentryIntegration=e=>function(e,t){var i=Er(e,t);return{name:wr,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 on(this),this.pageViewManager=new xr(this),this.rateLimiter=new us(this),this.requestRouter=new Sn(this),this.consent=new gr(this),this.externalIntegrations=new Rn(this);var t=null!==(e=Vn.__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 r=qe(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=qe(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>Ui.info('send "'+(null==e?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==Un){var r,s=null!==(r=Ln[i])&&void 0!==r?r:new Vn;return s._init(e,t,i),Ln[i]=s,Ln[Un][i]=s,s}return this._init(e,t,i)}_init(e,t,r){var s,o;if(void 0===t&&(t={}),Ue(e)||He(e))return Ui.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(Bi({},Hn(t.defaults),Bn(t),{name:r,token:e})),this.config.on_xhr_error&&Ui.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:hs.GZipJS;var a=this._is_persistence_disabled();this.persistence=new Gr(this.config,a),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Gr(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 rn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new nn(this),this.__request_queue=[];var c=this._inCookielessMode();if(c||(this.sessionManager=new dn(this),this.sessionPropsManager=new ln(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(Ui.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this._initExtensions(c)}),0)):(Ui.info("Initializing extensions synchronously"),this._initExtensions(c)),n.DEBUG=n.DEBUG||this.config.debug,n.DEBUG&&Ui.info("Starting in debug mode",{this:this,config:t,thisC:i({},this.config),p:l,s:u}),!this.config.identity_distinct_id||null!=(s=t.bootstrap)&&s.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(j);if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===ne)this.identify(d);else if(t.bootstrap.isIdentifiedID&&null!=_&&_!==d&&h===oe)Ui.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(rr()),g=t.bootstrap.isIdentifiedID?p:d;this.persistence.set_property(j,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(rr());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(j,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 r=i=>{var r=()=>i.anonymousId()||rr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(j,oe)),t()},s=i.user();"then"in s&&Ae(s.then)?s.then(r):r(s)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||br.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()||(br.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(br.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,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!==On&&(Ui.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this.config.ip&&Ui.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,r,s,n,o,a,l,u=performance.now(),c=i({},Vn.__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!==(r=this.exceptions)&&void 0!==r?r: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!==(s=this.surveys)&&void 0!==s?s: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,mr)),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){Ui.error("Error initializing extension:",e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Z]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[ee]:r}),this.config.__preview_deferred_init_extensions&&Ui.info("PostHog extensions initialized ("+r+"ms)")}_onRemoteConfig(e){var t;if(!fe||!fe.body)return Ui.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=Te(e.supportedCompression,hs.GZipJS)?hs.GZipJS:Te(e.supportedCompression,hs.Base64)?hs.Base64: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){Ui.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 ds(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,r;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==(r=this._retryQueue)||r.unload()):this._shouldCapturePageleave()&&this.capture(de,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(qn?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ks(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,r,s,n=i({},e);n.timeout=n.timeout||6e4,n.url=Zs(n.url,n.compression);var o=null!==(t=n.transport)&&void 0!==t?t:"fetch",a=en.filter((e=>!n.disableTransport||!e.transport||!n.disableTransport.includes(e.transport))),l=null!==(r=null==(s=function(e,t){for(var i=0;e.length>i;i++)if(e[i].transport===o)return e[i]}(a))?void 0:s.method)&&void 0!==r?r:a[0].method;if(!l)throw new Error("No available transport method");"sendBeacon"!==o&&n.data&&n.compression===hs.GZipJS&&Ee&&!Ys?Qs(n).then((e=>{l(e)})).catch((t=>{if((e=>!(!e||"object"!=typeof e)&&"NotReadableError"===("name"in e?String(e.name):""))(t))return Ys=!0,void l(i({},n,{compression:void 0,url:Zs(e.url,void 0)}));l(n)})):l(n)})(i({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,t),null==e.callback||e.callback(t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){$n++;try{var t,i=[],r=[],s=[];Hi(e,(e=>{e&&(Me(t=e[0])?s.push(e):Ae(e)?e.call(this):Me(e)&&"alias"===t?i.push(e):Me(e)&&-1!==t.indexOf("capture")&&Ae(this[t])?s.push(e):r.push(e))}));var n=function(e,t){Hi(e,(function(e){if(Me(e[0])){var i=t;zi(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(r,this),n(s,this)}finally{$n--}}push(e){if($n>0&&Me(e)&&qe(e[0])){var t=Vn.prototype[e[0]];Ae(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,r){var s,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(this.is_capturing())if(!Ue(e)&&qe(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=null!=r&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==c||!c.isRateLimited){null!=t&&t.$current_url&&!qe(null==t?void 0:t.$current_url)&&(Ui.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!=r&&r._originatedFromCaptureException||Ui.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==r?void 0:r.timestamp)||d,h=rr(),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==r?void 0:r.$set)&&(p.$set=null==r?void 0:r.$set);var g,v,f,m=this._calculate_set_once_properties(null==r?void 0:r.$set_once,e!==he,e===_e);if(m&&(p.$set_once=m),null!=r&&r._noTruncate||(n=this.config.properties_string_max_length,o=p,a=e=>qe(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),Me(t)?(r=[],Hi(t,(t=>{r.push(e(t))}))):(r={},zi(t,((t,i)=>{l.has(t)||(r[i]=e(t,i))}))),r);var r}(o)),p.timestamp=_,Ue(null==r?void 0:r.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=d),e===is.DISMISSED||e===is.SENT){var y=null==t?void 0:t[rs.SURVEY_ID],b=null==t?void 0:t[rs.SURVEY_ITERATION];(e=>{try{var t=(e=>((e,t)=>{var i=""+kn+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+kn+t.id+"_"+t.current_iteration),i})(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,"true")}catch(e){xn.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===is.SENT?"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===is.SHOWN&&(p.$set=i({},p.$set,{[rs.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(e===os.SHOWN){var w=null==t?void 0:t[as.TOUR_TYPE];w&&(p.$set=i({},p.$set,{[as.TOUR_LAST_SEEN_DATE+"/"+w]:(new Date).toISOString()}))}var E=i({},p.properties.$set,p.$set);if(Ne(E)||this.setPersonPropertiesForFlags(E),!Be(this.config.before_send)){var S=this._runBeforeSend(p);if(!S)return;p=S}this._internalEventEmitter.emit("eventCaptured",p);var x={method:"POST",url:null!==(s=null==r?void 0:r._url)&&void 0!==s?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:null==r?void 0:r._batchKey};return!this.config.request_batching||r&&(null==r||!r._batchKey)||null!=r&&r.send_instantly?this._send_retriable_request(x):this._requestQueue.enqueue(x),p}Ui.critical("This capture call is ignored due to client rate limiting.")}}else Ui.error("No event name provided to posthog.capture")}else Ui.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,s,o){if(r=r||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,(!qe(l.distinct_id)&&!je(l.distinct_id)||He(l.distinct_id))&&Ui.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),l}var c,d=function(e,t){var i,r,s,o;if(!Se)return{};var a,l,u,c,d,_,h,p,g=e?[...Lr,...t||[]]:[],[v,f]=function(e){for(var t=0;ei.length>t;t++){var[i,r]=ei[t],s=i.exec(e),n=s&&(Ae(r)?r(s,e):r);if(n)return n}return["",""]}(Se);return Bi(Gi({$os:v,$os_version:f,$browser:Xt(Se,navigator.vendor),$device:ti(Se),$device_type:(l=Se,u={userAgentDataPlatform:null==(i=navigator)||null==(i=i.userAgentData)?void 0:i.platform,maxTouchPoints:null==(r=navigator)?void 0:r.maxTouchPoints,screenWidth:null==pe||null==(s=pe.screen)?void 0:s.width,screenHeight:null==pe||null==(o=pe.screen)?void 0:o.height,devicePixelRatio:null==pe?void 0:pe.devicePixelRatio},p=ti(l),p===_t||p===dt||"Kobo"===p||"Kindle Fire"===p||p===zt?ct:p===Ft||p===$t||p===Lt||p===Ut?"Console":p===pt?"Wearable":p?at:"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)?at:ct:"Desktop"),$timezone:jr(),$timezone_offset:Vr()}),{$current_url:Tr(null==me?void 0:me.href,g,Or),$host:null==me?void 0:me.host,$pathname:null==me?void 0:me.pathname,$raw_user_agent:Se.length>1e3?Se.substring(0,997)+"...":Se,$browser_version:Zt(Se,navigator.vendor),$browser_language:Ur(),$browser_language_prefix:(a=Ur(),"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,r.getTime());l.$session_id=_,l.$window_id=h}this.sessionPropsManager&&Bi(l,this.sessionPropsManager.getSessionProps());try{var p;this.sessionRecording&&Bi(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===bn&&(l.$lib_custom_api_host=this.config.api_host),c=e!==ce||o?e!==de||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,s),l=Bi(l,c),e===ce&&fe&&(l.title=fe.title),!Ue(a)){var g=r.getTime()-a;l.$duration=parseFloat((g/1e3).toFixed(3))}Se&&this.config.opt_out_useragent_filter&&(l.$browser_type=this._is_bot()?"bot":"browser"),(l=Bi({},d,this.persistence.properties(),this.sessionPersistence.properties(),l)).$is_identified=this._isIdentified(),Me(this.config.property_denylist)?zi(this.config.property_denylist,(function(e){delete l[e]})):Ui.error(Nn+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(Ui.error(Dn),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 r;if(void 0===t&&(t=!0),void 0===i&&(i=!1),!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent&&!i)return e;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=Bi({},s,n||{},e||{}),a=this.config.sanitize_properties;return a&&(Ui.error(Dn),o=a(o,"$set_once")),t&&(this._personProcessingSetOncePropertiesSent=!0),Ne(o)?void 0:o}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.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 r;null==(r=this.featureFlags)||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return void 0===t&&(t=!1),null==(r=this.featureFlags)?void 0:r.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:An}),()=>{})}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:An})}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:An})}renderSurvey(e,t){var i;null==(i=this.surveys)||i.renderSurvey(e,t)}displaySurvey(e,t){var i;void 0===t&&(t=Cn),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:An}}canRenderSurveyAsync(e,t){var i,r;return void 0===t&&(t=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(e,t))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:An})}_validateIdentifyId(e){return!e||He(e)?(Ui.critical("Unique user id has not been set in posthog.identify"),!1):e===Q?(Ui.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())||(Ui.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 Ui.uninitializedWarning("posthog.identify");if(je(e)&&(e=e.toString(),Ui.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 r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(a)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(l)&&(this.unregister(l),this.register({distinct_id:e}));var s,n=(this.persistence.get_property(j)||ne)===ne;e!==r&&n?(this.persistence.set_property(j,oe),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(_e,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=pn(e,t,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(q))}}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=pn(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):Ui.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var s=this.getGroups(),n=s[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:i({},s,{[e]:t})}),n||r){var o={$group_type:e,$group_key:t};r&&(o.$group_set=r),this.capture(he,o)}r&&this.setGroupPropertiesForFlags({[e]:r}),n&&!r&&this.reloadFeatureFlags()}else Ui.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,r,s,n,o,l,u;if(Ui.info("reset"),!this.__loaded)return Ui.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==(r=this.surveys)||r.reset(),null==(s=this._remoteConfigLoader)||s.stop(),null==(n=this.featureFlags)||n.reset(),null==(o=this.conversations)||o.reset(),null==(l=this.persistence)||l.set_property(j,ne),null==(u=this.sessionManager)||u.resetSessionId(),this._cachedPersonProperties=null,this.config.cookieless_mode===se)this.register_once({distinct_id:Q,$device_id:null},"");else{var d=this.config.get_device_id(rr());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),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(o)?(Ui.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(Ue(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(l,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(Ui.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 r,s,o,a,l,u,c,d,_,h;Bi(this.config,Bn(e));var p=this._is_persistence_disabled();null==(r=this.persistence)||r.update_config(this.config,t,p),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Gr(i({},this.config,{persistence:"sessionStorage"}),p);var g=this._checkLocalStorageForDebug(this.config.debug);We(g)&&(this.config.debug=g),We(this.config.debug)&&(this.config.debug?(n.DEBUG=!0,ur._is_supported()&&ur._set("ph_debug",!0),Ui.info("set_config",{config:e,oldConfig:t,newConfig:i({},this.config)})):(n.DEBUG=!1,ur._is_supported()&&ur._remove("ph_debug"))),null==(s=this.exceptionObserver)||s.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,r,s,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==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.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 r=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(i({},s,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:Vn._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:Un;return t!==Un&&(t=Un+"."+t),t}_isIdentified(){var e,t;return(null==(e=this.persistence)?void 0:e.get_property(j))===oe||(null==(t=this.sessionPersistence)?void 0:t.get_property(j))===oe}_hasPersonProcessing(){var e,t;return!("never"===this.config.person_profiles||this.config.person_profiles===ae&&!this._isIdentified()&&Ne(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[l])&&(null==(t=this.persistence)||null==(t=t.props)||!t[J]))}_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?(Ui.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(J,!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!==re)}_sync_opt_out_with_persistence(){var e,t,i,r,s=this._is_persistence_disabled();return(null==(e=this.persistence)?void 0:e._disabled)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t._disabled)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==se){if(this._inCookielessMode()){var i,r,s,n,o;this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new dn(this),this.pageViewManager=new xr(this),this.persistence&&(this.sessionPropsManager=new ln(this,this.sessionManager,this.persistence));var a,l=null!==(s=null==(n=this.config.__extensionClasses)?void 0:n.sessionRecording)&&void 0!==s?s:null==(o=Vn.__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==re&&(null==(u=this.surveys)||u.loadIfEnabled()),(Ue(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 Ui.warn(Mn)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==se?(this.config.cookieless_mode===re&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._sync_opt_out_with_persistence(),this.config.cookieless_mode===re&&(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())):Ui.warn(Mn)}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===se||(this.config.cookieless_mode===re?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?_n(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,r,s,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?(Ui.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,r=Ui,s=(t="advanced_disable_flags")in(e=o)&&!Be(e[t]),n=i in e&&!Be(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}_runBeforeSend(e){if(Be(this.config.before_send))return e;var t=Me(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),Be(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return Ye(e.event)?Ui.warn(s+". This can cause unexpected behavior."):Ui.info(s),null}i.properties&&!Ne(i.properties)||Ui.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=We(e)&&!e,i=ur._is_supported()&&"true"===ur._get("ph_debug");return!t&&(!!i||e)}}Vn.__defaultExtensionClasses={},Vn._noopLogger={trace:Fn=()=>{},debug:Fn,info:Fn,warn:Fn,error:Fn,fatal:Fn},function(e,t){for(var i=0;t.length>i;i++)e.prototype[t[i]]=Wi(e.prototype[t[i]])}(Vn,["identify"]);var Wn=1,Gn=3,Yn=11;function Kn(e){return e instanceof Element&&(e.id===X||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function Jn(e){return!!e&&e.nodeType===Wn}function Xn(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Qn(e){return!!e&&e.nodeType===Gn}function Zn(e){return!!e&&e.nodeType===Yn&&Jn(e.host)}function eo(e){return e?Re(e).split(/\s+/):[]}function to(e){var t=null==pe?void 0:pe.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function io(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 eo(t)}function ro(e){return Be(e)?null:Re(e).split(/(\s+)/).filter((e=>Eo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function so(e){var t="";return po(e)&&!go(e)&&e.childNodes&&e.childNodes.length&&zi(e.childNodes,(function(e){var i;Qn(e)&&e.textContent&&(t+=null!==(i=ro(e.textContent))&&void 0!==i?i:"")})),Re(t)}function no(e){return Ue(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var oo=["a","button","form","input","select","textarea","label"];function ao(e,t){if(Ue(t))return!0;var i,r=function(e){if(t.some((t=>e.matches(t))))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function lo(e){var t=e.parentNode;return!(!t||!Jn(t))&&t}var uo=["next","previous","prev",">","<"],co=[".ph-no-rageclick",".ph-no-capture"];var _o=e=>!e||Xn(e,"html")||!Jn(e),ho=(e,t)=>{if(!pe||_o(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Xn(s,"body");)if(Zn(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=lo(s);if(!n)break;if(t||oo.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=pe.getComputedStyle(n);o&&"pointer"===o.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function po(e){for(var t=e;t.parentNode&&!Xn(t,"body");t=t.parentNode){var i=io(t);if(Te(i,"ph-sensitive")||Te(i,"ph-no-capture"))return!1}if(Te(io(e),"ph-include"))return!0;var r=e.type||"";if(qe(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!qe(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function go(e){return!!(Xn(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Xn(e,"select")||Xn(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var vo="(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})",fo=new RegExp("^(?:"+vo+")$"),mo=new RegExp(vo),yo="\\d{3}-?\\d{2}-?\\d{4}",bo=new RegExp("^("+yo+")$"),wo=new RegExp("("+yo+")");function Eo(e,t){if(void 0===t&&(t=!0),Be(e))return!1;if(qe(e)){if(e=Re(e),(t?fo:mo).test((e||"").replace(/[- ]/g,"")))return!1;if((t?bo:wo).test(e))return!1}return!0}function So(e){var t=so(e);return Eo(t=(t+" "+xo(e)).trim())?t:""}function xo(e){var t="";return e&&e.childNodes&&e.childNodes.length&&zi(e.childNodes,(function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=so(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+xo(e)).trim())}catch(e){Ui.error("[AutoCapture]",e)}})),t}function ko(e){return e.replace(/"|\\"/g,'\\"')}function Io(e){var t=e.attr__class;return t?Me(t)?t:eo(t):void 0}class Co{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 r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.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 Po="$copy_autocapture",To=qi("[AutoCapture]");function Ro(e,t){return t.length>e?t.slice(0,e)+"...":t}function Fo(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Jn(t));return t}function Lo(e,t){var r,s,{e:n,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=t;if(!Jn(e))return{props:{}};for(var c=[e],d=e;d.parentNode&&!Xn(d,"body");)if(Zn(d.parentNode))c.push(d.parentNode.host),d=d.parentNode.host;else{if(!Jn(d.parentNode))break;c.push(d.parentNode),d=d.parentNode}var _,h,p=[],g={},v=!1,f=!1;if(zi(c,(e=>{var t=po(e);if(Xn(e,"a")){var i=e.getAttribute("href");v=t&&!!i&&Eo(i)&&i}Te(io(e),"ph-no-capture")&&(f=!0),p.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};oo.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Ro(1024,So(e)):Ro(1024,so(e)));var o=io(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),zi(e.attributes,(function(i){var s;if((!go(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Eo(i.value)&&(!qe(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=eo(o).join(" ")),n["attr__"+i.name]=Ro(1024,o)}}));for(var a=1,l=1,u=e;u=Fo(u);)a++,u.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,o,a,l));var r=function(e){if(!po(e))return{};var t={};return zi(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Eo(r)&&(t[i]=r)}})),t}(e);Bi(g,r)})),f)return{props:{},explicitNoCapture:f};if(a||(p[0].$el_text=Xn(e,"a")||Xn(e,"button")?So(e):so(e)),v){var m,y;p[0].attr__href=v;var b=null==(m=Cr(v))?void 0:m.host,w=null==pe||null==(y=pe.location)?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:Bi({$event_type:n.type,$ce_version:1},u?{}:{$elements:p},{$elements_chain:(h=p,function(e){return e.map((e=>{var t,r,s="";if(e.tag_name&&(s+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))s+="."+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!==(r=e.nth_of_type)&&void 0!==r?r:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),a={};return ji(o).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return a[ko(t.toString())]=ko(i.toString())})),(s+=":")+ji(a).map((e=>{var[t,i]=e;return t+'="'+i+'"'})).join("")})).join(";")}(function(e){return e.map((e=>{var t,i,r={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:Io(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return ji(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(h)))},null!=(r=p[0])&&r.$el_text?{$el_text:null==(s=p[0])?void 0:s.$el_text}:{},_&&"click"===n.type?{$external_click_url:_}:{},g)}}var $o=qi("[ExceptionAutocapture]");function Oo(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return Ae(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(e){return()=>{}}}var Mo=qi("[TracingHeaders]"),Ao=qi("[Web Vitals]"),Do=9e5,No="disabled",Uo="lazy_loading",qo="awaiting_config",Ho="missing_config";qi("[SessionRecording]"),qi("[SessionRecording]");var zo="[SessionRecording]",Bo=qi(zo),jo=qi("[Heatmaps]");function Vo(e){return De(e)&&"clientX"in e&&"clientY"in e&&je(e.clientX)&&je(e.clientY)}var Wo=qi("[Product Tours]"),Go=["$set_once","$set"],Yo=qi("[SiteApps]"),Ko="Error while initializing PostHog app with config id ";function Jo(e,t,i){if(Be(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(e){return!1}default:return!1}}class Xo{constructor(e){this._debugEventEmitter=new un,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;Ue(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(!Ue(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 r,s=new Set;e.forEach((e=>{var t;null==(t=e.steps)||t.forEach((e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}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,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Jo(r,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 r=this._getElementsList(e);if(r.length>0)return r.some((e=>Jo(e.href,t.href,t.href_matching||"exact")));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Jo((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}_checkStepText(e,t){var i;if(null==t||!t.text)return!0;var r=this._getElementsList(e);if(r.length>0)return r.some((e=>Jo(e.text,t.text,t.text_matching||"exact")||Jo(e.$el_text,t.text,t.text_matching||"exact")));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!Be(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some((e=>Jo(e,n,o))))}_checkStepSelector(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$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||fn(t.properties.reduce(((e,t)=>{var i=Me(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 Qo{constructor(e){this._instance=e,this._eventToItems=new Map,this._cancelEventToItems=new Map,this._actionToItems=new Map}_doesEventMatchFilter(e,t){return!!e&&fn(e.propertyFilters,null==t?void 0:t.properties)}_buildEventToItemMap(e,t){var i=new Map;return e.forEach((e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach((t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}}))})),i}_getMatchingItems(e,t,i){var r=(i===Yr.Activation?this._eventToItems:this._cancelEventToItems).get(e),s=[];return this._getItems((e=>{s=e.filter((e=>null==r?void 0:r.includes(e.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((t=>t.name===e));return this._doesEventMatchFilter(n,t)}))}register(e){var t;Ue(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 Xo(this._instance),this._actionMatcher.init(),this._actionMatcher._addActionHook((e=>{this.onAction(e)}))),t.forEach((e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this._actionMatcher)||s.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})),r=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===r.length||(null==(t=this._instance)||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this._eventToItems=this._buildEventToItemMap(e,Yr.Activation),this._cancelEventToItems=this._buildEventToItemMap(e,Yr.Cancellation))}onEvent(e,t){var i,r=this._getLogger(),s=this._getActivatedKey(),n=this._getShownEventName(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===e&&t&&o.length>0){var a,l;r.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,Yr.Cancellation);d.length>0&&(r.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)){r.info("event name matched",{event:e,eventPayload:t,items:this._eventToItems.get(e)});var _=this._getMatchingItems(e,t,Yr.Activation);this._updateActivatedItems(o.concat(_.map((e=>e.id))||[]))}}}onAction(e){var t,i=this._getActivatedKey(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this._actionToItems.has(e)&&this._updateActivatedItems(r.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 Zo extends Qo{constructor(e){super(e)}_getActivatedKey(){return N}_getShownEventName(){return is.SHOWN}_getItems(e){var t;null==(t=this._instance)||t.getSurveys(e)}_cancelPendingItem(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}_getLogger(){return xn}_setActivatedItems(e){var t;null==(t=this._instance)||null==(t=t.persistence)||t.register({[N]:e})}_isItemPermanentlyIneligible(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var ea="SDK is not enabled or survey functionality is not yet loaded",ta="Disabled. Not loading surveys.",ia=null!=pe&&pe.location?Rr(pe.location.hash,"__posthog")||Rr(location.hash,"state"):null,ra="_postHogToolbarParams",sa=qi("[Toolbar]"),na=qi("[FeatureFlags]"),oa=qi("[FeatureFlags]",{debugEnabled:!0}),aa="\" failed. Feature flags didn't load in time.",la=e=>{for(var t={},i=0;e.length>i;i++)t[e[i]]=!0;return t},ua=e=>{var t={};for(var[i,r]of ji(e||{}))r&&(t[i]=r);return t},ca=qi("[Error tracking]"),da="Refusing to render web experiment since the viewer is a likely bot",_a={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&&hn(t.href,e),not_regex:(e,t)=>!!pe&&!hn(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class ha{get _config(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments((e=>{ha._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;t._flagToExperiments&&(ha._logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t._flagToExperiments)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);qe(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];ha._matchesTestVariant(n)&&t._applyTransforms(e.name,s,n.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())ha._logInfo(da);else if(!this._config.disable_web_experiments){if(Be(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ha._logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!=(t=this._flagToExperiments)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this._flagToExperiments)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this._applyTransforms(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var e=ha.getWindowLocation();if(null!=e&&e.search){var t=Pr(null==e?void 0:e.search,"__experiment_id"),i=Pr(null==e?void 0:e.search,"__experiment_variant");t&&i&&(ha._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 r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._config.token),method:"GET",callback:t=>e(200===t.statusCode&&t.json&&t.json.experiments||[])})}_showPreviewWebExperiment(e,t,i){var r=i.filter((t=>t.id===e));r&&r.length>0&&(ha._logInfo("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!Be(e.conditions)&&ha._matchUrlConditions(e)&&ha._matchUTMConditions(e)}static _matchUrlConditions(e){var t;if(Be(e.conditions)||Be(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=ha.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||_a[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"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=Ar();if(i.utm_source){var r,s,n,o,a,l,u,c,d=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.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),r=1;t>r;r++)i[r-1]=arguments[r];Ui.info("[WebExperiments] "+e,i)}_applyTransforms(e,t,i){this._is_bot()?ha._logInfo(da):"control"!==t?i.forEach((i=>{if(i.selector){var r;ha._logInfo("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):ha._logInfo("Control variants leave the page unmodified.")}_is_bot(){return ve&&this._instance?_n(ve,this._config.custom_blocked_useragents):void 0}}var pa=qi("[Conversations]"),ga="Conversations not available yet.",va={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,na.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||(na.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||na.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,r=null!==(e=null==(t=i.bootstrap)?void 0:t.featureFlags)&&void 0!==e?e:{};if(Object.keys(r).length){var s,n,o=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},a=Object.keys(r).filter((e=>!!r[e])).reduce(((e,t)=>(e[t]=r[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,r){var s=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},o=i({},s,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:Ue(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(T),t=this._prop(L),r=this._prop(O);if(!r&&!t)return e||{};var s=Bi({},e||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of n){var a,l,u=s[o],c=null==t?void 0:t[o],d=Ue(c)?null!==(a=null==u?void 0:u.enabled)&&void 0!==a&&a:!!c,_=Ue(c)?u.variant:"string"==typeof c?c:void 0,h=null==r?void 0:r[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})),s[o]=p}return this._override_warning||(na.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:s}),this._override_warning=!0),s}getFlagVariants(){var e=this._prop(I),t=this._prop(L);if(!t)return e||{};for(var i=Bi({},e),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(na.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this._prop(R),t=this._prop(O);if(!t)return e||{};for(var i=Bi({},e||{}),r=Object.keys(t),s=0;r.length>s;s++)i[r[s]]=t[r[s]];return this._override_warning||(na.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 r=this._config.token,s=this._prop(a),n={token:r,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(M)||{}),group_properties:this._prop(A),timezone:jr()};ze(s)||Ue(s)||(n.$device_id=s),(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:hs.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,s=!0;if(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,!n.disable_flags||this._additionalReloadRequested){this._flagsLoadedFromRemote=!s;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==(r=this._persistence)||r.register({[z]:o}),l)na.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:{},s,{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 r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else na.warn('getFeatureFlag for key "'+e+aa)}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(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._prop(F)||void 0,l=this._prop(B)||void 0,u=this._prop(q)||{};if(this._config.advanced_feature_flags_dedup_per_session){var c,d=this._instance.get_session_id(),_=this._prop(H);d&&d!==_&&(u={},null==(c=this._persistence)||c.register({[q]:u,[H]: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,E;Me(u[e])?u[e].push(o):u[e]=[o],null==(h=this._persistence)||h.register({[q]:u});var S=this.getFeatureFlagDetails(e),x=[...null!==(p=this._prop(z))&&void 0!==p?p:[]];Ue(s)&&x.push("flag_missing");var k={$feature_flag:e,$feature_flag_response:s,$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};Ue(null==S||null==(f=S.metadata)?void 0:f.version)||(k.$feature_flag_version=S.metadata.version);var I,C=null!==(m=null==S||null==(y=S.reason)?void 0:y.description)&&void 0!==m?m:null==S||null==(b=S.reason)?void 0:b.code;C&&(k.$feature_flag_reason=C),null!=S&&null!=(w=S.metadata)&&w.id&&(k.$feature_flag_id=S.metadata.id),Ue(null==S?void 0:S.original_variant)&&Ue(null==S?void 0:S.original_enabled)||(k.$feature_flag_original_response=Ue(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(E=S.metadata)&&E.original_payload&&(k.$feature_flag_original_payload=null==S||null==(I=S.metadata)?void 0:I.original_payload),x.length&&(k.$feature_flag_error=x.join(",")),this._instance.capture("$feature_flag_called",k)}if(r){var P=n;if(!Ue(n))try{P=JSON.parse(n)}catch(e){}return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:P}}}}else na.warn('getFeatureFlagResult for key "'+e+aa)}getRemoteConfigPayload(e,t){var i=this._config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this._shouldIncludeEvaluationEnvironments()&&(r.evaluation_contexts=this._getValidEvaluationEnvironments()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this._config.disable_compression?void 0:hs.Base64,timeout:this._config.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[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 Ue(i)?void 0:!!i}na.warn('isFeatureEnabled for key "'+e+aa)}}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,r){if(this._persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),o=this.getFlagsWithDetails();!function(e,t,r,s,n,o){void 0===r&&(r={}),void 0===s&&(s={}),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]})))):na.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(Me(u)){na.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({[C]:u,[I]:h})}else{var g=u,v=c,f=l;if(null!=o&&o.partialResponse)g=i({},r,g),v=i({},s,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({},r,Object.fromEntries(Object.entries(g).filter((e=>{var[t]=e;return m.has(t)})))),v=i({},s,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({},r,g),v=i({},s,v),f=i({},n,f);t&&t.register(i({[C]:Object.keys(ua(g)),[I]:g||{},[R]:v||{},[T]:f||{}},d?{[F]:d}:{},_?{[B]:_}:{}))}}}(e,this._persistence,s,n,o,r),t||(this._staleCacheRefreshTriggered=!1),this._fireFeatureFlagsCallbacks(t)}}override(e,t){void 0===t&&(t=!1),na.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._persistence)return na.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._persistence.unregister(L),this._persistence.unregister(O),this._fireFeatureFlagsCallbacks(),oa.info("All overrides cleared");if(Me(e)){var t=la(e);return this._persistence.register({[L]:t}),this._fireFeatureFlagsCallbacks(),oa.info("Flag overrides set",{flags:e})}if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var i,r=e;if(this._override_warning=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this._persistence.unregister(L),oa.info("Flag overrides cleared");else if(r.flags){if(Me(r.flags)){var s=la(r.flags);this._persistence.register({[L]:s})}else this._persistence.register({[L]:r.flags});oa.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this._persistence.unregister(O),oa.info("Payload overrides cleared")):r.payloads&&(this._persistence.register({[O]:r.payloads}),oa.info("Payload overrides set",{payloads:r.payloads}))),void this._fireFeatureFlagsCallbacks()}if(e&&"object"==typeof e)return this._persistence.register({[L]:e}),this._fireFeatureFlagsCallbacks(),oa.info("Flag overrides set",{flags:e});na.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,r){var s,n=(this._prop(P)||[]).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),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=i({},this.getFlagVariants(),{[e]:t});null==(s=this._persistence)||s.register({[C]:Object.keys(ua(l)),[I]:l}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._prop(P),s=i?"&"+i.map((e=>"stage="+e)).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._persistence)||i.unregister(P),null==(r=this._persistence)||r.register({[P]:s}),e(s)}}})}_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((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(M)||{},s=(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 r||(o[a]=n[a]));this._instance.register({[M]:i({},r,o,s)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(M)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var r=this._prop(A)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((t=>{r[t]=i({},r[t],e[t]),delete e[t]})),this._instance.register({[A]:i({},r,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}}},fa={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===qo||this._recordingStatus===Ho?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=No,this._persistFlagsOnSessionListener=void 0,this._instance=e,!this._instance.sessionManager)throw Bo.error("started without valid sessionManager"),new Error(zo+" started without valid sessionManager. This is a bug.");if(this._config.cookieless_mode===se)throw new Error(zo+' 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,r=this._config.disable_session_recording||this._instance.consent.isOptedOut();return pe&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this._isRecordingEnabled||null==(t=this._lazyLoadedSessionRecording)||!t.isStarted){var i=!Ue(Object.assign)&&!Ue(Array.from);this._isRecordingEnabled&&i?(this._lazyLoadAndStart(e),Bo.info("starting")):(this._recordingStatus=No,this.stopRecording())}}_lazyLoadAndStart(e){var t,i,r;this._isRecordingEnabled&&(this._recordingStatus!==qo&&this._recordingStatus!==Ho&&(this._recordingStatus=Uo),null!=xe&&null!=(t=xe.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=xe.__PosthogExtensions__)&&i.initSessionRecording?this._onScriptLoaded(e):null==(r=xe.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this._scriptName,(t=>{if(t)return Bo.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,r=je(e)?e:parseFloat(e);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Bo.warn(t+" must be between 0 and 1. Ignoring invalid value:",e),null):r}_persistRemoteConfig(e){if(this._persistence){var t,r,s=this._persistence,n=()=>{var t,r=!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==r?void 0:r.sampleRate,"remote config sampleRate"),a=null!=n?n:o;Be(a)&&this._resetSampling();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[y]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:e.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:a,minimumDurationMilliseconds:Ue(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(t=this._persistFlagsOnSessionListener)||t.call(this),this._persistFlagsOnSessionListener=null==(r=this._instance.sessionManager)?void 0:r.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===qo&&(this._recordingStatus=Ho,Bo.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):Bo.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=xe.__PosthogExtensions__)||!t.initSessionRecording)return Bo.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=xe.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this._lazyLoadedSessionRecording._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this._isRemoteConfigFresh()){if(this._recordingStatus===Ho||this._recordingStatus===qo)return;return this._recordingStatus=qo,Bo.info("persisted remote config is stale, requesting fresh config before starting"),void new ds(this._instance).load()}this._recordingStatus=Uo,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?E:S]:!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))}}},ma={autocapture:class{constructor(e){this._initialized=!1,this._isDisabledServerSide=null,this._elementsChainAsString=!1,this.instance=e,this.rageclicks=new Co(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){To.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=>{e=e||(null==pe?void 0:pe.event);try{this._captureEvent(e,Po)}catch(e){To.error("Failed to capture copy/cut event",e)}};Ji(fe,"copy",t,{capture:!0}),Ji(fe,"cut",t,{capture:!0})}}}else To.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 r=null==fe?void 0:fe.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[c];if(ze(this._isDisabledServerSide)&&!We(i)&&!this.instance._shouldDisableFlags())return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=no(e);Qn(r)&&(r=r.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||_o(e))return!1;var i,r,s;if(We(t)?(i=!!t&&co,r=void 0):(i=null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:co,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=ho(e,!1);return!function(e,t){if(!1===e||Ue(e))return!1;var i;if(!0===e)i=uo;else{if(!Me(e))return!1;if(e.length>10)return Ui.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:r}=e;return i.some((e=>t.includes(e)||r.includes(e)))}))}(r,n.map((e=>{var t;return{safeText:so(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}})))&&!ao(n,i)}(r,this.instance.config.rageclick)&&this._captureEvent(e,"$rageclick");var s=t===Po;if(r&&function(e,t,i,r,s){var n,o,a,l;if(void 0===i&&(i=void 0),!pe||_o(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!to(i.url_allowlist))return!1;if(null!=(o=i)&&o.url_ignorelist&&to(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}=ho(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(Ue(i))return!0;var r,s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(d,i))return!1;if(!ao(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(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return c?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&(oo.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this._config,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=Lo(r,{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(r);if(a&&a.length>0&&(n.$element_selectors=a),t===Po){var l,u=ro(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&&(Ui.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,Ui.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(pe&&pe.history){var i=this;null!=(e=pe.history.pushState)&&e.__posthog_wrapped__||Oo(pe.history,"pushState",(e=>function(t,r,s){e.call(this,t,r,s),i._capturePageview("pushState")})),null!=(t=pe.history.replaceState)&&t.__posthog_wrapped__||Oo(pe.history,"replaceState",(e=>function(t,r,s){e.call(this,t,r,s),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){Ui.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 Co(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;jo.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="visible"===(null==fe?void 0:fe.visibilityState)?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 yr(this.instance,fr,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(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&Jn(r)&&!Xn(r,"body");){if(r===i)return!1;if(Te(t,null==pe?void 0:pe.getComputedStyle(r).position))return!0;r=lo(r)}return!1}(no(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}_onClick(e,t){var r;if(void 0===t&&(t="click"),!Kn(e.target)&&Vo(e)){var s=this._getProperties(e,t);null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(i({},s,{type:"rageclick"})),this._capture(s)}}_onMouseMove(e){!Kn(e.target)&&Vo(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,r=this._config.mask_personal_data_properties?[...Lr,...i||[]]:[],s=Tr(t,r,Or);this._buffer=this._buffer||{},this._buffer[s]||(this._buffer[s]=[]),this._buffer[s].push(e)}}_flush(){this._buffer&&!Ne(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:yr,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,r=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(Ue(r))Ao.error("Could not read session ID. Dropping metrics!");else{this._buffer=this._buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this._currentURL();Ue(s)||(Be(null==e?void 0:e.name)||Be(null==e?void 0:e.value)?Ao.error("Invalid metric received",e):!this._maxAllowedValue||this._maxAllowedValue>e.value?(this._buffer.url!==s&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),Ue(this._buffer.url)&&(this._buffer.url=s),this._buffer.firstMetricTimestamp=Ue(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:s,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()):Ao.error("Ignoring metric with value >= "+this._maxAllowedValue,e))}},this._startCapturing=()=>{if(!this._initialized){var e,t,i,r,s=xe.__PosthogExtensions__;Ue(s)||Ue(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(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&&r(this._addToBuffer.bind(this)),this._initialized=!0):Ao.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)&&je(this._perfConfig.__web_vitals_max_value)?this._perfConfig.__web_vitals_max_value:Do;return e>0&&6e4>=e?Do:e}get isEnabled(){var e=null==me?void 0:me.protocol;if("http:"!==e&&"https:"!==e)return Ao.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=De(this._perfConfig)?this._perfConfig.web_vitals:We(this._perfConfig)?this._perfConfig:void 0;return We(t)?t:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ao.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=xe.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks?e():null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(t=>{t?Ao.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?[...Lr,...t||[]]:[];return Tr(e,i,Or)}Ao.error("Could not determine current URL")}}},ya={exceptionObserver:class{constructor(e){var t,i,r;this._startCapturing=()=>{var e;if(pe&&this.isEnabled&&null!=(e=xe.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=xe.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=xe.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=xe.__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=r(this.captureException.bind(this)))}catch(e){$o.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!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,_logger:$o}),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):(Ue(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?($o.info("enabled"),this._stopCapturing(),this._loadScript(this._startCapturing)):this._stopCapturing()}_loadScript(e){var t,i;null!=(t=xe.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(t=>{if(t)return $o.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,r,s=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this._rateLimiter.consumeRateLimit(s)?$o.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(e)}},exceptions:class{constructor(e){var t,r;this._suppressionRules=[],this._errorPropertiesBuilder=new li([new bi,new Ri,new Ei,new wi,new Pi,new Ci,new xi,new Ti],function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;t>s;s++)r[s-1]=arguments[s];return function(t,s){void 0===s&&(s=0);for(var n=[],o=t.split("\n"),a=s;o.length>a;a++){var l=o[a];if(1024>=l.length){var u=yi.test(l)?l.replace(yi,"$1"):l;if(!u.match(/\S*Error: /)){for(var c of r){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||(r=t,r[r.length-1]||{}).filename,function:e.function||ui});var r}))}(n)}}("web:javascript",gi,mi)),this._instance=e,this._suppressionRules=null!==(t=null==(r=this._instance.persistence)?void 0:r.get_property(h))&&void 0!==t?t:[],this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer=new Ai(this._exceptionStepsConfig)}onConfigChange(){this._exceptionStepsConfig=Mi(this._getExceptionStepsConfig()),this._exceptionStepsBuffer.setConfig(this._exceptionStepsConfig)}onRemoteConfig(e){var t,i,r;if("errorTracking"in e){var s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this._suppressionRules=s,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(!qe(e)||0===e.trim().length)return void ca.warn("Ignoring exception step because message must be a non-empty string");var r=this._coerceExceptionStepProperties(t),{sanitizedProperties:s,droppedKeys:n}=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((i,r)=>$i.has(r)?(t.push(r),i):(i[r]=e[r],i)),{}),droppedKeys:t}}(r);n.length>0&&ca.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._exceptionStepsBuffer.add(i({[Fi]:e,[Li]:(new Date).toISOString()},s))}catch(e){ca.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 ca.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 ca.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 ca.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 r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",_originatedFromCaptureException:!0});return r&&this._exceptionStepsBuffer.clear(),r}catch(e){return ca.error("Failed to capture exception event. Dropping this exception.",e),void this._exceptionStepsBuffer.clear()}}catch(e){return void ca.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 ca.error("Failed to read buffered exception steps. Capturing exception without steps.",t),e}}_addDroppedExceptionStep(e){this._exceptionStepsConfig.enabled&&this._exceptionStepsBuffer.add({[Fi]:e,[Li]:(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:r}=t;return qe(i)&&i.length>0&&e.$exception_types.push(i),qe(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this._suppressionRules.some((e=>{var i=e.values.map((e=>{var i,r=gn[e.operator],s=Me(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,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,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}_isExceptionList(e){return!Be(e)&&Me(e)}}},ba=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=xe.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(t=>{t?Wo.error("Could not load product tours script",t):e()}))}_startProductTours(){var e;!this._productTourManager&&null!=(e=xe.__PosthogExtensions__)&&e.generateProductTours&&(this._productTourManager=xe.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!Me(this._cachedTours)||t){var i=this._persistence;if(i){var r=i.props[U];if(Me(r)&&!t)return this._cachedTours=r,void e(r,{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 r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return Wo.error(s),void e([],{isLoaded:!1,error:s})}var n=Me(t.json.product_tours)?t.json.product_tours:[];this._cachedTours=n,i&&i.register({[U]: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(U)}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)}}},va),wa={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=xe._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,s,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({},r(e,Go),{properties:i({},e.properties,v?{$set:i({},null!==(t=null==(s=e.properties)?void 0:s.$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&&(Yo.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))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,Yo.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback(e){s(e)}});n&&(t.processEvent=n),r=!0}catch(t){Yo.error(Ko+e.id,t),s(!1)}if(r&&t.loaded)try{i()}catch(i){Yo.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){Yo.error("Error while processing event "+e.event+" for site app "+i.id,t)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this._setupSiteApps(),void this._instance.on("eventCaptured",(e=>this._onCapturedEvent(e)))):void Yo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this._stopBuffering)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;xe["__$$ph_site_app_"+e]=s._instance,null==(t=xe.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,(t=>{if(t)return Yo.error(Ko+e,t)}))};for(var{id:o,url:a}of e.siteApps)n(o)}else Yo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},Ea={tracingHeaders:class{constructor(e){this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0,this._startCapturing=()=>{var e,t,i=this._getConfiguredHostnames()||[];Ue(this._restoreXHRPatch)&&(null==(e=xe.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),Ue(this._restoreFetchPatch)&&(null==(t=xe.__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=xe.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=xe.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(t=>{if(t)return Mo.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)}}},Sa=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 xn.warn("Flags not loaded yet. Not loading surveys.");var i=Me(t);this._isSurveysEnabled=i?t.length>0:t,xn.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(kn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)xn.info("Already initializing surveys, skipping...");else if(this._config.disable_surveys)xn.info(ta);else if(this._config.cookieless_mode&&this._instance.consent.isOptedOut())xn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==xe?void 0:xe.__PosthogExtensions__;if(e){if(!Ue(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 r=e.loadExternalDependency;if(!r)return void this._handleSurveyLoadError(ie);r(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 xn.error("PostHog Extensions not found.")}}_completeSurveyInitialization(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Zo(this._instance),xn.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){xn.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 xn.info(ta),e([]);var i,r=this._instance.get_property(D);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this._getSurveysInFlightPromise?this._getSurveysInFlightPromise.then((t=>{var{surveys:i,context:r}=t;return e(i,r)})):("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 r;this._getSurveysInFlightPromise=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;xn.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==(r=this._instance.persistence)||r.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){xn.error("Error in survey callback",e)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!Be(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);xn.warn("init was not called")}_getSurveyById(e){var t=null;return this.getSurveys((i=>{var r;t=null!==(r=i.find((t=>t.id===e)))&&void 0!==r?r:null})),t}_checkSurveyEligibility(e){if(Be(this._surveyManager))return{eligible:!1,reason:ea};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 xn.warn("init was not called"),{visible:!1,disabledReason:ea};var t=this._checkSurveyEligibility(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return Be(this._surveyManager)?(xn.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ea})):new Promise((i=>{this.getSurveys((t=>{var r,s=null!==(r=t.find((t=>t.id===e)))&&void 0!==r?r:null;if(s){var n=this._checkSurveyEligibility(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var r;if(Be(this._surveyManager))xn.warn("init was not called");else{var s="string"==typeof e?this._getSurveyById(e):e;if(null!=s&&s.id)if(In.includes(s.type)){var n=null==fe?void 0:fe.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(xn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var e,t;xn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),xn.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);xn.warn("Survey element not found")}else xn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else xn.warn("Survey not found")}}displaySurvey(e,t){var r;if(Be(this._surveyManager))xn.warn("init was not called");else{var s=this._getSurveyById(e);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ss.Popover&&t.initialResponses&&xn.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var o=this.canRenderSurvey(s);if(!o.visible)return void xn.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==ss.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else xn.warn("Survey not found")}}cancelPendingSurvey(e){Be(this._surveyManager)?xn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}},va),xa={toolbar:class{constructor(e){this.instance=e}_setToolbarState(e){xe.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=xe.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),Xi(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 r,s=ia||Rr(e.hash,"__posthog")||Rr(e.hash,"state"),n=s?Vi((()=>JSON.parse(atob(decodeURIComponent(s)))))||Vi((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(ra)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(e){return!1}}_callLoadToolbar(e){var t=xe.ph_load_toolbar||xe.ph_load_editor;!Be(t)&&Ae(t)?t(e,this.instance):sa.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==fe||!fe.getElementById(X));if(!pe||t)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(pe.localStorage.setItem(ra,JSON.stringify(i({},s,{source:void 0}))),2===this._getToolbarState())this._callLoadToolbar(s);else if(0===this._getToolbarState()){var n;this._setToolbarState(1),null==(n=xe.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(e=>{if(e)return sa.error("[Toolbar] Failed to load",e),void this._setToolbarState(0);this._setToolbarState(2),this._callLoadToolbar(s)})),Ji(pe,"turbolinks:load",(()=>{this._setToolbarState(0),this.loadToolbar(s)}))}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)}}},ka=i({experiments:ha},va),Ia={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)||(We(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||Xi(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=null==xe?void 0:xe.__PosthogExtensions__;if(e&&!Ue(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 pa.error("Conversations enabled but missing token in remote config.")}}_completeInitialization(e){if(this._remoteConfig)try{this._conversationsManager=e(this._remoteConfig,this._instance),pa.info("Conversations loaded successfully")}catch(e){this._handleLoadError("Error completing conversations initialization",e)}else pa.error("Cannot complete initialization: remote config is null")}_handleLoadError(e,t){pa.error(e,t),this._conversationsManager=null,this._isInitializing=!1}show(){this._conversationsManager?this._conversationsManager.show():pa.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this._isConversationsEnabled&&!ze(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,i,r){var s=this;return t((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,i,r):(pa.warn(ga),null)}))()}getMessages(e,i){var r=this;return t((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,i):(pa.warn(ga),null)}))()}markAsRead(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(e):(pa.warn(ga),null)}))()}getTickets(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.getTickets(e):(pa.warn(ga),null)}))()}requestRestoreLink(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(e):(pa.warn(ga),null)}))()}restoreFromToken(e){var i=this;return t((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(e):(pa.warn(ga),null)}))()}restoreFromUrlToken(){var e=this;return t((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(pa.warn(ga),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()}}},Ca={logs:class{constructor(e){var t;this._isLogsEnabled=!1,this._isLoaded=!1,this._logger=qi("[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==xe?void 0:xe.__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,r,s,n,o,a;if(this._instance.is_capturing())if(e&&e.body){var l=null!==(t=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==t?t:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s: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 r=e.level||"info",{text:s,number:n}=ri[r]||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:s,body:{stringValue:e.body},attributes:oi(l)};return e.trace_id&&(u.traceId=e.trace_id),e.span_id&&(u.spanId=e.span_id),Ue(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 r=this._instance.config.logs,s=i({"service.name":(null==r?void 0:r.serviceName)||"unknown_service"},(null==r?void 0:r.environment)&&{"deployment.environment":r.environment},(null==r?void 0:r.serviceVersion)&&{"service.version":r.serviceVersion},null==r?void 0:r.resourceAttributes),o=function(e,t,i,r){return{resourceLogs:[{resource:{attributes:oi(t)},scopeLogs:[{scope:{name:i,version:r},logRecords:e}]}]}}(t.map((e=>e.record)),s,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!=xe&&null!=(e=xe.location)&&e.href&&(t.currentUrl=xe.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(t.activeFeatureFlags=r)}return t}}},Pa=i({},va,fa,ma,ya,ba,wa,Sa,Ea,xa,ka,Ia,Ca);Vn.__defaultExtensionClasses=i({},Pa);var Ta,Ra=(Ta=Ln[Un]=new Vn,function(){function e(){e.done||(e.done=!0,qn=!1,zi(Ln,(function(e){e._dom_loaded()})))}null!=fe&&fe.addEventListener?"complete"===fe.readyState?e():Ji(fe,"DOMContentLoaded",e,{capture:!1}):pe&&Ui.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Ta);export{hs as Compression,ns as DEFAULT_PRODUCT_TOUR_APPEARANCE,ss as DisplaySurveyType,Vn as PostHog,os as ProductTourEventName,as as ProductTourEventProperties,is as SurveyEventName,rs as SurveyEventProperties,Yr as SurveyEventType,Jr as SurveyPosition,es as SurveyQuestionBranchingType,Zr as SurveyQuestionType,ts as SurveySchedule,Xr as SurveyTabPosition,Qr as SurveyType,Kr as SurveyWidgetType,Ra as default,Ra as posthog,_s as severityLevels};
2
2
  //# sourceMappingURL=module.no-external.js.map