posthog-js 1.412.0 → 1.412.1

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.
package/dist/module.js CHANGED
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:t,i=null==e?void 0:e.navigator,r=null==e?void 0:e.document,s=null==e?void 0:e.location,n=null==e?void 0:e.fetch,o=null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest?e.XMLHttpRequest:void 0,a=null==e?void 0:e.AbortController,l=null==e?void 0:e.CompressionStream,u=null==i?void 0:i.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"};function f(t,e,i,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var e=this,i=arguments;return new Promise((function(r,s){var n=t.apply(e,i);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_.apply(null,arguments)}function g(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function b(t){return"string"==typeof t||t}function y(t){return"string"==typeof t?t:void 0}var w,x=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],E=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),S=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),k=["$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"],T=["token"],R="NativeGzipValidationError",P=t=>t.length>=2&&31===t[0]&&139===t[1],O=(t,e)=>t===S.GZipJS||e===S.GZipJS||"gzip"===e,I=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),C=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=R,e},A=function(){var t=p((function*(t,e){18>t.size&&C("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());P(i)&&8===i[2]||C("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var e=(()=>{if(w)return w;w=[];for(var t=0;256>t;t++){for(var e=t,i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;w[t]=e>>>0}return w})(),i=4294967295,r=0;t.length>r;r++)i=e[255&(i^t[r])]^i>>>8;return(4294967295^i)>>>0})(e)&&C("invalid-crc");var s=e.length>>>0;r.getUint32(4,!0)!==s&&C("invalid-size")}));return function(e,i){return t.apply(this,arguments)}}();function M(){return M=p((function*(t,e,i){void 0===e&&(e=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(e){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield A(l,r),l}catch(t){if(null!=i&&i.rethrow)throw t;return e&&console.error("Failed to gzip compress data",t),null}})),M.apply(this,arguments)}var F=["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"],D=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return F.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function N(t,e){return-1!==t.indexOf(e)}var U=function(t){return t.trim()},L=function(t){return t.replace(/^\$/,"")};function j(t){var e,i=[];return null!==(e=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(e))return"[Circular]";i.push(e)}return e}})))&&void 0!==e?e:"null"}var B=Object.prototype,z=B.hasOwnProperty,H=B.toString,q=Array.isArray||function(t){return"[object Array]"===H.call(t)},V=t=>"function"==typeof t,W=t=>t===Object(t)&&!q(t),G=t=>{if(W(t)){for(var e in t)if(z.call(t,e))return!1;return!0}return!1},K=t=>void 0===t,J=t=>"[object String]"==H.call(t),Y=t=>J(t)&&0===t.trim().length,Q=t=>null===t,X=t=>K(t)||Q(t),Z=t=>"[object Number]"==H.call(t)&&t==t,tt=t=>Z(t)&&t>0,et=t=>"[object Boolean]"===H.call(t),it=t=>t instanceof FormData,rt=t=>N(k,t),st=t=>N(T,t);function nt(t){return null===t||"object"!=typeof t}function ot(t,e){return{}.toString.call(t)==="[object "+e+"]"}function at(t){return"undefined"!=typeof Event&&lt(t,Event)}function lt(t,e){try{return t instanceof e}catch(t){return!1}}var ut=[!0,"true",1,"1","yes"],ht=t=>N(ut,t),dt=[!1,"false",0,"0","no"];function vt(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),Z(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),vt(s||i,e,i,r))}class ct{constructor(t){this.tt={},this.et=t.et,this.it=vt(t.bucketSize,0,100,t.rt),this.nt=vt(t.refillRate,0,this.it,t.rt),this.st=vt(t.refillInterval,0,864e5,t.rt)}ot(t,e){var i=Math.floor((e-t.lastAccess)/this.st);i>0&&(t.tokens=Math.min(t.tokens+i*this.nt,this.it),t.lastAccess=t.lastAccess+i*this.st)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.tt[r];return s?this.ot(s,i):this.tt[r]=s={tokens:this.it,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.et)||e.call(this,t)),0===s.tokens)}stop(){this.tt={}}}var ft="Mobile",pt="iOS",_t="Android",gt="Tablet",mt=_t+" "+gt,bt="iPad",yt="Apple",wt=yt+" Watch",xt="Safari",Et="BlackBerry",St="Samsung",$t=St+"Browser",kt=St+" Internet",Tt="Chrome",Rt=Tt+" OS",Pt=Tt+" "+pt,Ot="Internet Explorer",It=Ot+" "+ft,Ct="Opera",At=Ct+" Mini",Mt="Edge",Ft="Microsoft "+Mt,Dt="Firefox",Nt=Dt+" "+pt,Ut="Nintendo",Lt="PlayStation",jt="Xbox",Bt=_t+" "+ft,zt=ft+" "+xt,Ht="Windows",qt=Ht+" Phone",Vt="Nokia",Wt="Ouya",Gt="Generic",Kt=Gt+" "+ft.toLowerCase(),Jt=Gt+" "+gt.toLowerCase(),Yt="Konqueror",Qt="Oculus Browser",Xt="Vivaldi",Zt="Yandex",te="Whale",ee="DuckDuckGo",ie="Pale Moon",re="Waterfox",se="Brave",ne="Google Search App",oe="(\\d+(\\.\\d+)?)",ae=new RegExp("Version/"+oe),le=new RegExp(jt,"i"),ue=new RegExp(Lt+" \\w+","i"),he=new RegExp(Ut+" \\w+","i"),de=new RegExp(Et+"|PlayBook|BB10","i"),ve={"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"},ce=function(t,e,i,r){e=e||"";var s=function(t){return null!=t&&t.brave?se:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&N(t,"GSA/")?ne:N(t," OPR/")&&N(t,"Mini")?At:N(t," OPR/")?Ct:de.test(t)?Et:N(t,"IE"+ft)||N(t,"WPDesktop")?It:N(t,"OculusBrowser")?Qt:N(t,$t)?kt:N(t,Mt)||N(t,"Edg/")?Ft:N(t,Xt+"/")?Xt:N(t,"YaBrowser/")?Zt:N(t,te+"/")?te:N(t,ee+"/")||N(t,"Ddg/")?ee:N(t,"FBIOS")?"Facebook "+ft:N(t,"UCWEB")||N(t,"UCBrowser")?"UC Browser":N(t,"CriOS")?Pt:N(t,"CrMo")||N(t,Tt)?Tt:N(t,_t)&&N(t,xt)?Bt:N(t,"FxiOS")?Nt:N(t.toLowerCase(),Yt.toLowerCase())?Yt:N(t,se+"/")?se:((t,e)=>e&&N(e,yt)||function(t){return N(t,xt)&&!N(t,Tt)&&!N(t,_t)}(t))(t,e)?N(t,ft)?zt:xt:N(t,"PaleMoon/")?ie:N(t,re+"/")?re:N(t,Dt)?Dt:N(t,"MSIE")||N(t,"Trident/")?Ot:N(t,"Gecko")?Dt:"")},fe={[It]:[new RegExp("rv:"+oe)],[Ft]:[new RegExp(Mt+"?\\/"+oe)],[Tt]:[new RegExp("("+Tt+"|CrMo)\\/"+oe)],[Pt]:[new RegExp("CriOS\\/"+oe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+oe)],[xt]:[ae],[zt]:[ae],[Ct]:[new RegExp("(Opera|OPR)\\/"+oe)],[Dt]:[new RegExp(Dt+"\\/"+oe)],[Nt]:[new RegExp("FxiOS\\/"+oe)],[Yt]:[new RegExp("Konqueror[:/]?"+oe,"i")],[Et]:[new RegExp(Et+" "+oe),ae],[Bt]:[new RegExp("android\\s"+oe,"i")],[kt]:[new RegExp($t+"\\/"+oe)],[Qt]:[new RegExp("OculusBrowser\\/"+oe)],[Xt]:[new RegExp(Xt+"\\/"+oe)],[Zt]:[new RegExp("YaBrowser\\/"+oe)],[te]:[new RegExp(te+"\\/"+oe)],[se]:[new RegExp(se+"\\/"+oe)],[ee]:[new RegExp("(DuckDuckGo|Ddg)\\/"+oe)],[ie]:[new RegExp("PaleMoon\\/"+oe)],[re]:[new RegExp(re+"\\/"+oe)],[ne]:[new RegExp("GSA\\/"+oe)],[Ot]:[new RegExp("(rv:|MSIE )"+oe)],Mozilla:[new RegExp("rv:"+oe)]},pe=function(t,e,i,r){var s=ce(t,e,i,r),n=fe[s];if(K(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},_e=[[new RegExp(jt+"; "+jt+" (.*?)[);]","i"),t=>[jt,t&&t[1]||""]],[new RegExp(Ut,"i"),[Ut,""]],[new RegExp(Lt,"i"),[Lt,""]],[de,[Et,""]],[new RegExp(Ht,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[qt,""];if(new RegExp(ft).test(e)&&!/IEMobile\b/.test(e))return[Ht+" "+ft,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=ve[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[Ht,r]}return[Ht,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[pt,[t[3],t[4],t[5]||"0"].join(".")]:[pt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=K(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+_t+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+_t+")","i"),t=>t&&t[2]?[_t,[t[2],t[3],t[4]||"0"].join(".")]:[_t,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Rt,""]],[/Linux|debian/i,["Linux",""]]],ge=function(t){return he.test(t)?Ut:ue.test(t)?Lt:le.test(t)?jt:new RegExp(Wt,"i").test(t)?Wt:new RegExp("("+qt+"|WPDesktop)","i").test(t)?qt:/iPad/.test(t)?bt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?wt:de.test(t)?Et:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Vt,"i").test(t)?Vt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(ft).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?_t:mt:new RegExp("(pda|"+ft+")","i").test(t)?Kt:new RegExp(gt,"i").test(t)&&!new RegExp(gt+" pc","i").test(t)?Jt:""},me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function be(t,e){return"string"==typeof(i=t)&&me.test(i)?t:e();var i}function ye(t){return t?t.split("#")[0]:t}function we(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function xe(t,e,i){return Ee.apply(this,arguments)}function Ee(){return(Ee=p((function*(t,e,i){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=we((()=>{try{null==i||i(),t()}catch(t){s(t)}}),e)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Se=t=>t instanceof Error,$e={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}},ke=$e.info;function Te(t){if(et(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(q(t))return{arrayValue:{values:t.map((t=>Te(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function Re(t){var e=[];for(var i in t){var r=t[i];Q(r)||K(r)||e.push({key:i,value:Te(r)})}return e}function Pe(t,e){var i=$e[t.level||"info"]||ke,r=i.text,s=i.number,n=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),X(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),X(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var a=_({},o,t.attributes||{}),l={timeUnixNano:n,observedTimeUnixNano:n,severityNumber:s,severityText:r,body:{stringValue:t.body},attributes:Re(a)};return t.trace_id&&(l.traceId=t.trace_id),t.span_id&&(l.spanId=t.span_id),K(t.trace_flags)||(l.flags=t.trace_flags),l}function Oe(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}function Ie(t,e,i,r){return{resourceLogs:[{resource:{attributes:Re(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let Ce=class{constructor(t,e,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Pe=e,this.rt=i,this.ut=r,this.ht=s,this.dt=n,this.vt=o,this.ct=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=e.maxBufferSize,this.kt=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.St=e.flushIntervalMs,this.Ct=e.maxBatchRecordsPerPost,this.Mt=e.rateCapWindowMs,this.Tt=e.maxLogsPerInterval}reset(){this.Et(),this.ct=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Pe.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.It()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.Pt(t);if(null!==e)if(e.body){if(this.Rt()){var i={record:Pe(e,this.ut())};this.ht((()=>this.Lt(i)))}}else this.rt.info("Log was rejected in beforeSend function")}}Pt(t){var e=this.Pe.beforeSend;if(!e)return t;var i=q(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.rt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for log:",t),null}return r}Rt(){if(void 0===this.Tt)return!0;var t=Date.now(),e=t-this.bt;return this.Mt>e&&e>=0||(this.bt=t,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||(this.rt.warn("captureLog dropping logs: exceeded "+this.Tt+" logs per "+this.Mt+"ms"),this.wt=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.ct||(t.ct=t.Ot().finally((()=>{t.ct=null}))),t.ct}))()}Ot(){var t=this;return p((function*(){var e;t.Et();var i=null!==(e=t._instance.getPersistedProperty(E.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;t.ft=0;var a=Math.min(i.length,t.Ct),l=i.slice(0,a),u=Ie(l.map((t=>t.record)),t.Ft(),null!==(n=t.vt)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.At(u);if("too-large"===h.kind&&l.length>1)t.Ct=Math.max(1,Math.floor(l.length/2)),t.rt.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+t.Ct);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.rt.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Pe.maxBatchRecordsPerPost>t.Ct&&(t.Ct=Math.min(t.Pe.maxBatchRecordsPerPost,t.Ct+1)),yield t.Dt(l.length),i=null!==(o=t._instance.getPersistedProperty(E.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===h.kind)throw h.error}}}))()}Dt(t){var e=this;return p((function*(){var i,r=Math.max(0,t-e.ft),s=null!==(i=e._instance.getPersistedProperty(E.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(E.LogsQueue,s.slice(r)),yield e.dt()}))()}Ft(){return Oe(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Lt(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(E.LogsQueue))&&void 0!==e?e:[];this.kt>i.length||(i.shift(),this.ft++,this.rt.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(E.LogsQueue,i),this.xt>i.length?this.$t():this.It()}}$t(t){void 0===t&&(t=this.St),this.Nt||(this.Nt=we((()=>{this.Nt=void 0,this.It()}),t))}qt(){var t=Math.min(Math.max(0,this.yt-1),6);return this.St*Math.pow(2,t)}jt(){var t=this._instance.getPersistedProperty(E.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return p((function*(){e.Et();var i=e.flush().catch((()=>{}));void 0!==t?yield xe(i,t):yield i}))()}flushWithTimeout(t){var e=this;return p((function*(){var i=e.flush();yield xe(i,t,(()=>{i.catch((()=>{}))}))}))()}It(){this.flush().then((()=>{this.yt=0}),(t=>{this.yt++,this.rt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.$t(this.qt())}))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}};var Ae=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Me(t){return String(t)+"000000"}function Fe(t,e,i,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+s}let De=class{constructor(t,e,i){this._instance=t,this.Pe=e,this.rt=i,this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Wt=0}count(t,e,i){void 0===e&&(e=1),this.Vt({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.Vt({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.Vt({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.ct,i=function(){var i=p((function*(){e&&(yield e.catch((()=>{}))),yield t.Zt()}));return function(){return i.apply(this,arguments)}}(),r=i().finally((()=>{this.ct===r&&(this.ct=null)}));return this.ct=r,r}drainWindow(){if(0===this.Bt.size)return null;var t=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(t)}reset(){this.Wt++,this.Et(),this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Vt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.Pt(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.rt.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=e.attributes?_({},e.attributes):void 0,r=Fe(e.type,e.name,e.unit,i)}catch(t){return void this.rt.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var s=this.Bt.get(r);if(!s){if(!this.Qt())return;s={name:e.name,type:e.type,unit:e.unit,attributes:i,windowStartMs:Date.now()},this.Bt.set(r,s)}var n=this.Ut.get(e.name);void 0===n?this.Ut.set(e.name,e.type):n===e.type||this.zt.has(e.name)||(this.zt.add(e.name),this.rt.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Jt(s,e.value),this.$t()}else this.rt.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.rt.warn("Dropping metric with empty name")}}Qt(){return this.Pe.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.rt.warn("Metric series cap reached ("+this.Pe.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jt(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Ae.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,Ae)]+=1}}Pt(t){var e=this.Pe.beforeSend;if(!e)return t;var i=q(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.rt.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for metric:",t),null}return r}$t(){this.Nt||(this.Nt=we((()=>{this.Nt=void 0,this.flush().catch((t=>{this.rt.error("Metrics flush failed:",t)}))}),this.Pe.flushIntervalMs))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}Zt(){var t=this;return p((function*(){if(0!==t.Bt.size){var e=t.Bt;t.Bt=new Map,t.Ht=!1,t.Ut=new Map,t.zt=new Set;var i=t.Wt,r=yield t._instance.Kt(t.Gt(e));if(i===t.Wt)switch(r.kind){case"ok":return;case"retry-later":return t.Yt(e),void t.$t();case"too-large":return void t.rt.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.rt.error("Failed to send metrics batch:",r.error)}}}))()}Gt(t){return e=this.Xt(t),i=function(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Re(i)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,i,r,s}Xt(t){var e=Me(Date.now()),i=new Map;for(var r of t.values()){var s,n=Fe(r.type,r.name,r.unit,void 0),o=i.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},i.set(n,o));var a=Re(null!==(s=r.attributes)&&void 0!==s?s:{}),l=Me(r.windowStartMs);if("count"===r.type){var u,h={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:null!==(u=r.total)&&void 0!==u?u:0};o.sum.dataPoints.push(h)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:e,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:Ae})}return Array.from(i.values())}Yt(t){var e,i;for(var r of t){var s=r[0],n=r[1],o=this.Bt.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Qt()&&this.Bt.set(s,n)}}};var Ne,Ue,Le;function je(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Le&&i.length===Ue||(Ue=i.length,Le=i.reduce(((i,r)=>{Ne||(Ne={});var s=Ne[r];if(s)i[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=e[r];if(l&&u){i[l]=u,Ne[r]=[l,u];break}}return i}),{})),Le}}class Be{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var e=this;return p((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&q(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var i,r;return null!=t.cause&&(i=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),_({},t,{cause:i,stack:r})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return p((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,e){var i,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(i=e.type)&&void 0!==i?i:"generic",handled:null===(r=e.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:je(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,i){void 0===i&&(i=0);var r=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return _({},e,{syntheticException:0==i?e.syntheticException:void 0,mechanism:t,apply:t=>r(t,i),next:t=>r(t,i+1)})}}var ze="?";function He(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?ze:i,in_app:!0};return K(r)||(n.lineno=r),K(s)||(n.colno=s),n}var qe=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:ze,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Ve=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,We=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ge=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ke=(t,e)=>{var i=Ve.exec(t);if(i)return He(e,i[1],ze,+i[2],+i[3]);var r=We.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=Ge.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=qe(r[1]||ze,r[2]);return He(e,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Je=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Qe=(t,e)=>{var i=Je.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Ye.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]||ze,o=qe(n,s);return He(e,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Xe=/\(error: (.*)\)/;class Ze{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=J(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return ot(t,"DOMException")}isDOMError(t){return ot(t,"DOMError")}}class ti{match(t){return function(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return lt(t,Error)}}(t)}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class ei{constructor(){}match(t){return!!ot(t,"ErrorEvent")&&(null!=t.error||this.fe(t))}coerce(t,e){var i;if(null!=t.error)return e.apply(t.error);var r=e.apply(t.message);return _({},r,{stack:null!==(i=this.pe(t))&&void 0!==i?i:r.stack,synthetic:!0})}fe(t){return J(t.message)&&t.message.length>0}pe(t){var e=t;if(J(e.filename)&&e.filename.length>0){var i,r,s=null!==(i=e.lineno)&&void 0!==i?i:0,n=null!==(r=e.colno)&&void 0!==r?r:0;return"Error\n at "+e.filename+":"+s+":"+n}}}var ii=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ri{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(ii);return r&&(e=r[1],i=r[2]),[e,i]}}var si=["fatal","error","warning","log","info","debug"];function ni(t,e){void 0===e&&(e=40);var i=Object.keys(t);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(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class oi{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,s=this.getErrorPropertyFromObject(t);return s?e.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return at(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ni(t)}isSeverityLevel(t){return J(t)&&!Y(t)&&si.indexOf(t)>=0}getStack(t){try{return J(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:J(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(Se(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class ai{match(t){return at(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ni(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class li{match(t){return nt(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ui{match(t){return ot(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!at(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return nt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var hi="$message",di="$timestamp",vi=new Set([hi,di]),ci={enabled:!0,max_bytes:32768};function fi(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:ci.enabled,max_bytes:_i(t.max_bytes,ci.max_bytes)}:_({},ci)}class pi{constructor(t){this.Je=[],this.Ke=0,this.Pe=fi(t)}setConfig(t){this.Pe=fi(t),this.Xe()}add(t){var e=function(t){var e;try{e=j(t)}catch(t){return}try{var i=JSON.parse(e);if(!W(i))return;var r=i,s=r[hi],n=r[di];if(!J(s)||0===s.trim().length)return;if(!J(n)&&!Z(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Pe.max_bytes||(this.Je.push({step:e.step,bytes:i}),this.Ke+=i,this.Xe())}}getAttachable(){return this.Je.map((t=>t.step))}clear(){this.Je=[],this.Ke=0}size(){return this.Je.length}Xe(){for(;this.Ke>this.Pe.max_bytes&&this.Je.length>0;){var t=this.Je.shift();t&&(this.Ke-=t.bytes)}}}function _i(t,e){if(!Z(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var gi=function(e,i){var r=(void 0===i?{}:i).debugEnabled,s={k(i){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!K(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[i]?t.console[i].__rrweb_original__:t.console[i]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(e,...o)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("error",...e)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,i)=>gi(e+" "+t,i)};return s},mi=gi("[PostHog.js]"),bi=mi.createLogger,yi=bi("[ExternalScriptsLoader]"),wi=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return yi.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=null==r?void 0:r.querySelectorAll("script");if(s)for(var n,o=function(){if(s[a].src===e){var t=s[a];return t.__posthog_loading_callback_fired?{v:i()}:(t.addEventListener("load",(e=>{t.__posthog_loading_callback_fired=!0,i(void 0,e)})),t.onerror=t=>i(t),{v:void 0})}},a=0;s.length>a;a++)if(n=o())return n.v;var l=()=>{if(!r)return i("document not found");var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=e,s.onload=t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)},s.onerror=t=>i(t),t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return i("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?l():null==r||r.addEventListener("DOMContentLoaded",l)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if("remote-config"!==e){var r;if(t.config.strict_script_versioning)r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var s="/static/"+e+".js?v="+t.version;if("toolbar"===e){var n=3e5;s=s+"&t="+Math.floor(Date.now()/n)*n}r=t.requestRouter.endpointFor("assets",s)}wi(t,r,i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");wi(t,o,i)}},v.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var r=t.requestRouter.endpointFor("api",e);wi(t,r,i)};c.DEBUG=!1,c.LIB_VERSION="1.412.0",c.LIB_NAME="web";var xi="$people_distinct_id",Ei="$device_id",Si="$device_model",$i="__alias",ki="__timers",Ti="$autocapture_disabled_server_side",Ri="$heatmaps_enabled_server_side",Pi="$exception_capture_enabled_server_side",Oi="$error_tracking_suppression_rules",Ii="$error_tracking_capture_extension_exceptions",Ci="$web_vitals_enabled_server_side",Ai="$dead_clicks_enabled_server_side",Mi="$product_tours_enabled_server_side",Fi="$web_vitals_allowed_metrics",Di="$session_recording_remote_config",Ni="$replay_sample_rate",Ui="$replay_override_sampling",Li="$replay_override_linked_flag",ji="$replay_override_url_trigger",Bi="$replay_override_event_trigger",zi="$sesid",Hi="$session_is_sampled",qi="$enabled_feature_flags",Vi="$active_feature_flags",Wi="$early_access_features",Gi="$feature_flag_details",Ki="$feature_flag_payloads",Ji="$feature_flag_request_id",Yi="$minimal_flag_called_events",Qi="$override_feature_flags",Xi="$override_feature_flag_payloads",Zi="$stored_person_properties",tr="$stored_group_properties",er="$surveys",ir="$surveys_loaded_at",rr="$surveys_activated",sr="$surveys_activated_session",nr="$surveys_activated_timestamps",or="ph_product_tours",ar="$flag_call_reported",lr="$flag_call_reported_session_id",ur="$feature_flag_errors",hr="$feature_flag_evaluated_at",dr="$user_state",vr="$client_session_props",cr="$capture_rate_limit",fr="$initial_campaign_params",pr="$initial_referrer_info",_r="$initial_person_info",gr="$epp",mr="$posthog_cookieless",br="$cookieless_mode",yr="$sdk_debug_extensions_init_method",wr="$sdk_debug_extensions_init_time_ms",xr="$sdk_debug_recording_script_not_loaded",Er="PostHog loadExternalDependency extension not found.",Sr="on_reject",$r="always",kr="anonymous",Tr="identified",Rr="identified_only",Pr="visibilitychange",Or="beforeunload",Ir="$pageview",Cr="$pageleave",Ar="$identify",Mr="$groupidentify";function Fr(t,e){q(t)&&t.forEach(e)}function Dr(t,e){if(!X(t))if(q(t))t.forEach(e);else if(it(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)z.call(t,i)&&e(t[i],i)}var Nr=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ur(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Lr=function(t){try{return t()}catch(t){return}},jr=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,i)}catch(t){mi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),mi.critical(t)}}},Br=function(t){var e={};return Dr(t,(function(t,i){(J(t)&&t.length>0||Z(t))&&(e[i]=t)})),e};var zr=["herokuapp.com","vercel.app","netlify.app"];function Hr(t){var e=null==t?void 0:t.hostname;if(!J(e))return!1;var i=e.split(".").slice(-2).join(".");for(var r of zr)if(i===r)return!1;return!0}function qr(t,e,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(e,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function Vr(t){return"ph_toolbar_internal"===t.name}var Wr=t=>{if(r){try{for(var e=t+"=",i=r.cookie.split(";").filter((t=>t.length)),s=0;i.length>s;s++){for(var n=i[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Z(t)&&isFinite(t)&&Math.floor(t)===t});class Gr{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|e>>>8,s[7]=e,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 Gr(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Gr(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class Kr{generate(){var t=this.generateOrAbort();if(!K(t))return t;this.S=0;var e=this.generateOrAbort();if(K(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.C();else{if(this.S>=t+1e4)return;this.I++,this.I>4398046511103&&(this.S++,this.C())}return Gr.fromFieldsV7(this.S,Math.trunc(this.I/Math.pow(2,30)),this.I&Math.pow(2,30)-1,this.R.nextUint32())}C(){this.I=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}constructor(){this.S=0,this.I=0,this.R=new Qr}}var Jr,Yr=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!K(t.crypto)&&crypto.getRandomValues&&(Yr=t=>crypto.getRandomValues(t));class Qr{nextUint32(){return this.O.length>this.N||(Yr(this.O),this.N=0),this.O[this.N++]}constructor(){this.O=new Uint32Array(8),this.N=1/0}}var Xr=()=>Zr().toString(),Zr=()=>(Jr||(Jr=new Kr)).generate(),ts="",es=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var is={P:()=>!!r,j(t){mi.error("cookieStore error: "+t)},q:Wr,H(t){var e;try{e=JSON.parse(is.q(t))||{}}catch(t){}return e},A(t,e,i,s,n){if(!r)return!1;try{var o="",a="",l=function(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=r),ts)return ts;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),s=Math.min(i.length,8),n="dmn_chk_"+Xr();!ts&&s--;){var o=i.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(n)&&(e.cookie=a+";max-age=0",ts=o)}return ts}(t);if(!i){var s=(t=>{var e=t.match(es);return e?e[0]:""})(t);s!==i&&mi.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(r.location.hostname,s);if(i){var u=new Date;u.setTime(u.getTime()+864e5*i),o="; expires="+u.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+l+a;return h.length>3686.4&&mi.warn("cookieStore warning: large cookie, len="+h.length),r.cookie=h,!0}catch(t){return!1}},F(t,e){if(null!=r&&r.cookie)try{is.A(t,"",-1,e)}catch(t){return}}},rs=null,ss={P(){if(!Q(rs))return rs;var e=!0;if(K(t))e=!1;else try{var i="__mplssupport__";ss.A(i,"xyz"),'"xyz"'!==ss.q(i)&&(e=!1),ss.F(i)}catch(t){e=!1}return e||mi.error("localStorage unsupported; falling back to cookie store"),rs=e,e},j(t){mi.error("localStorage error: "+t)},q(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(t){ss.j(t)}return null},H(t){try{return JSON.parse(ss.q(t))||{}}catch(t){}return null},A(e,i){try{return null==t||t.localStorage.setItem(e,JSON.stringify(i)),!0}catch(t){ss.j(t)}return!1},F(e){try{null==t||t.localStorage.removeItem(e)}catch(t){ss.j(t)}}},ns=[Ei,"distinct_id",zi,Hi,gr,_r,dr],os={},as={P:()=>!0,j(t){mi.error("memoryStorage error: "+t)},q:t=>os[t]||null,H:t=>os[t]||null,A:(t,e)=>(os[t]=e,!0),F(t){delete os[t]}},ls=null,us={P(){if(!Q(ls))return ls;if(ls=!0,K(t))ls=!1;else try{var e="__support__";us.A(e,"xyz"),'"xyz"'!==us.q(e)&&(ls=!1),us.F(e)}catch(t){ls=!1}return ls},j(t){mi.error("sessionStorage error: ",t)},q(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(t){us.j(t)}return null},H(t){try{return JSON.parse(us.q(t))||null}catch(t){}return null},A(e,i){try{return null==t||t.sessionStorage.setItem(e,JSON.stringify(i)),!0}catch(t){us.j(t)}return!1},F(e){try{null==t||t.sessionStorage.removeItem(e)}catch(t){us.j(t)}}};class hs{constructor(t){this._instance=t}get Pe(){return this._instance.config}get consent(){return this.ti()?0:this.ei}isOptedOut(){return this.Pe.cookieless_mode===$r||this.isRejected()||-1===this.consent&&this.Pe.cookieless_mode===Sr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Pe.opt_out_capturing_by_default}optInOut(t){this.ii.A(this.ri,t?1:0,this.Pe.cookie_expiration,this.Pe.cross_subdomain_cookie,this.Pe.secure_cookie)}reset(){this.ii.F(this.ri,this.Pe.cross_subdomain_cookie)}get ri(){var t=this._instance.config,e=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+e:"__ph_opt_in_out_"+e)}get ei(){var t=this.ii.q(this.ri);return ht(t)?1:N(dt,t)?0:-1}get ii(){var t=this.Pe.opt_out_capturing_persistence_type,e="localStorage"===t?ss:is;if(!this.ni||this.ni!==e){this.ni=e;var i="localStorage"===t?is:ss;i.q(this.ri)&&(this.ni.q(this.ri)||this.optInOut(ht(i.q(this.ri))),i.F(this.ri,this.Pe.cross_subdomain_cookie))}return this.ni}ti(){return!!this.Pe.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,v.doNotTrack].some((t=>ht(t)))}}function ds(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!V(r))return e;try{var s=r(e);return J(s)&&s?s:e}catch(t){return mi.error("Error in get_current_url, falling back to window.location.href",t),e}}var vs="__POSTHOG_TOOLBAR__",cs=1,fs=3,ps=11;function _s(t){return t instanceof Element&&(t.id===vs||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function gs(t){return!!t&&t.nodeType===cs}function ms(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function bs(t){return!!t&&t.nodeType===fs}function ys(t){return!!t&&t.nodeType===ps&&gs(t.host)}var ws=1e3;function xs(t){return t?U(t).split(/\s+/):[]}function Es(e,i){var r=function(e){var i,r=null==t||null==(i=t.location)?void 0:i.href;return K(r)?void 0:ds(e,r)}(i);return!!(r&&e&&e.some((t=>r.match(t))))}function Ss(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return xs(e)}function $s(t){return X(t)?null:U(t).split(/(\s+)/).filter((t=>Js(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ks(t){var e="";return js(t)&&!Bs(t)&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,(function(t){var i;bs(t)&&t.textContent&&(e+=null!==(i=$s(t.textContent))&&void 0!==i?i:"")})),U(e)}function Ts(t){var e;return K(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Rs=["a","button","form","input","select","textarea","label"];function Ps(t,e){if(K(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Os(t){var e=t.parentNode;return!(!e||!gs(e))&&e}var Is=[".ph-no-autocapture","[data-ph-no-autocapture]"],Cs=["next","previous","prev",">","<"],As=[...Cs,"+","-","−","–"],Ms=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Fs=[".ph-no-rageclick",".ph-no-capture"],Ds=["","text","search","email","password","url","tel","number"];function Ns(e,i){if(!t||Us(e))return!1;var r,s,n,o,a;if(et(i)?(r=!!i&&Fs,s=void 0,n=!1):(r=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Fs,s=null==i?void 0:i.content_ignorelist,n=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!gs(t))&&(!!ms(t,"textarea")||(ms(t,"input")?N(Ds,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(e))return!1;var l=Ls(e,!1).targetElementList;return!function(t,e){if(!1===t||K(t))return!1;var i;if(!0===t)i=Cs;else{if(!q(t))return!1;if(t.length>10)return mi.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var e=t.safeText,r=t.ariaLabel;return i.some((t=>Ms(e,t)||Ms(r,t)))}))}(s,l.map((t=>{var e;return{safeText:ks(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Ps(l,r)}var Us=t=>!t||ms(t,"html")||!gs(t),Ls=(e,i)=>{if(!t||Us(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[e],n=e;n.parentNode&&!ms(n,"body");)if(ys(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Os(n);if(!o)break;if(i||Rs.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function js(t){for(var e=new Set,i=0,r=t;r.parentNode&&!ms(r,"body");r=r.parentNode){if(i++>=ws||e.has(r))return!1;e.add(r);var s=Ss(r);if(N(s,"ph-sensitive")||N(s,"ph-no-capture"))return!1}if(N(Ss(t),"ph-include"))return!0;var n=t.type||"";if(J(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!J(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Bs(t){return!!(ms(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ms(t,"select")||ms(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var zs=new RegExp("^(?:(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}))$"),Hs=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,qs=[16,15,14,13],Vs=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ws=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Gs=/[0-9A-Za-z_]/;function Ks(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),e+=s,i=!i}return e%10==0}function Js(t,e){if(void 0===e&&(e=!0),X(t))return!1;if(J(t)){t=U(t);var i=e?zs.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(Hs.lastIndex=0;e=Hs.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of qs){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(zs.test(a)&&Ks(a))return!0}}}return!1}(t);if(i)return!1;var r=e?Vs.test(t):function(t){var e;for(Ws.lastIndex=0;e=Ws.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&Gs.test(i)&&Gs.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Ys(t){var e=ks(t);return Js(e=(e+" "+Qs(t)).trim())?e:""}function Qs(t){var e="";return t&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=ks(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Qs(t)).trim())}catch(t){mi.error("[AutoCapture]",t)}})),e}function Xs(t){return t.replace(/"|\\"/g,'\\"')}function Zs(t){var e=t.attr__class;if(e)return q(e)?e:xs(e)}var tn=bi("[Dead Clicks]"),en=()=>!0,rn=t=>{var e,i=!(null==(e=t.instance.persistence)||!e.get_property(Ai)),r=t.instance.config.capture_dead_clicks;return et(r)?r:!!W(r)||i};class sn{get lazyLoadedDeadClicksAutocapture(){return this.si}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Ai]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.ai((()=>{this.oi()})):this.stop()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?tn.error("failed to load script",e):t()}))}oi(){var t;if(r){if(!this.si&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=W(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.si=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.si.start(r),tn.info("starting...")}}else tn.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,tn.info("stopping..."))}}var nn=bi("[SegmentIntegration]");var on="posthog-js";function an(t,e){var i=void 0===e?{}:e,r=i.organization,s=i.projectId,n=i.prefix,o=i.severityAllowList,a=void 0===o?["error"]:o,l=i.sendExceptionsToPostHog,u=void 0===l||l;return e=>{var i,o,l,h,d;if("*"!==a&&!a.includes(e.level)||!t.__loaded)return e;e.tags||(e.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());e.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(e.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(i=e.exception)?void 0:i.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||e.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:e.level,$exception_list:p,$sentry_event_id:e.event_id,$sentry_exception:e.exception,$sentry_exception_message:(null==(h=f[0])?void 0:h.value)||e.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:e.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+e.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),e}}class ln{constructor(t,e,i,r,s,n){this.name=on,this.setupOnce=function(o){o(an(t,{organization:e,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class un{constructor(t){this.li=(t,e,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(mi.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.ui=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.hi()}hi(){var t;this.di=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.li)}destroy(){var t;null==(t=this.di)||t.call(this),this.di=void 0}doPageView(e,i){var r,s=this.vi(e,i);return this.ui={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var e;return this.vi(t,null==(e=this.ui)?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.ui)?void 0:t.pageViewId}}vi(t,e){var i=this.ui;if(!i)return{$pageview_id:e};var r={$pageview_id:e,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,u=s.lastContentY,h=s.maxContentY;if(!(K(n)||K(o)||K(a)||K(l)||K(u)||K(h))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),h=Math.ceil(h);var d=n>1?vt(o/n,0,1,mi):1,v=n>1?vt(a/n,0,1,mi):1,c=l>1?vt(u/l,0,1,mi):1,f=l>1?vt(h/l,0,1,mi):1;r=Nr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:f})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),r}}var hn=["flags","surveys"],dn={[xi]:{exposure:"hidden"},[$i]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ki]:{exposure:"hidden"},[Ti]:{exposure:"event"},[Ri]:{exposure:"hidden"},[Pi]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ii]:{exposure:"event"},[Ci]:{exposure:"event"},[Ai]:{exposure:"event"},[Mi]:{exposure:"hidden"},[Fi]:{exposure:"event"},[Di]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[zi]:{exposure:"hidden"},[Hi]:{exposure:"event"},[Ni]:{exposure:"event",shouldSkipFromEventProperties:t=>Q(t)},$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"},$sess_rec_flush_size:{exposure:"hidden"},[qi]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!W(t))return{};for(var e={},i=Object.keys(t),r=0;i.length>r;r++)e["$feature/"+i[r]]=t[i[r]];return e}},[Vi]:{exposure:"event",storageGroup:"flags"},[Wi]:{exposure:"hidden"},[Gi]:{exposure:"hidden",storageGroup:"flags"},[Ki]:{exposure:"event",storageGroup:"flags"},[Ji]:{exposure:"event",storageGroup:"flags",volatile:!0},[Yi]:{exposure:"hidden",storageGroup:"flags"},[Qi]:{exposure:"event"},[Xi]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[er]:{exposure:"hidden",storageGroup:"surveys"},[ir]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[rr]:{exposure:"event"},[sr]:{exposure:"hidden"},[nr]:{exposure:"hidden"},[or]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[ar]:{exposure:"hidden"},[lr]:{exposure:"hidden"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[dr]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[cr]:{exposure:"hidden"},[fr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[Ui]:{exposure:"event"},[Li]:{exposure:"event"},[ji]:{exposure:"event"},[Bi]:{exposure:"event"},[yr]:{exposure:"event"},[wr]:{exposure:"event"},[xr]:{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"}},vn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],cn=t=>{var e=dn[t];if(e)return e;for(var i of vn){var r=i[1];if(0===t.indexOf(i[0]))return r}},fn=(t,e)=>{try{return JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString():e),e)}catch(e){return j(t)}},pn=t=>{var e=null==r?void 0:r.createElement("a");return K(e)?null:(e.href=t,e)},_n=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!q(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(t){mi.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],h=0;l.length>h;h++){var d=l[h].split("=");q(d)&&(e.includes(d[0])?u.push(d[0]+"="+i):u.push(l[h]))}var v=a;return null!=o&&(v+="?"+u.join("&")),null!=s&&(v+="#"+s),v},mn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},bn=(t,e)=>t>=e&&h(),yn=(t,e,i,r)=>{if(0===t){if(h()){var s=e+1;return s===i&&r(),s}return e}return 0},wn="https?://(.*)",xn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],En=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xn],Sn="<masked>",$n=["li_fat_id"];function kn(t,e,i){if(!r)return{};var s,n=e?[...xn,...i||[]]:[],o=Tn(gn(r.URL,n,Sn),t),a=(s={},Dr($n,(function(t){var e=Wr(t);s[t]=e||null})),s);return Nr(a,o)}function Tn(t,e){var i=En.concat(e||[]),r={};return Dr(i,(function(e){var i=_n(t,e);r[e]=i||null})),r}function Rn(t){var e=function(t){return t?0===t.search(wn+"google.([^/?]*)")?"google":0===t.search(wn+"bing.com")?"bing":0===t.search(wn+"yahoo.com")?"yahoo":0===t.search(wn+"duckduckgo.com")?"duckduckgo":null:null}(t),i="yahoo"!=e?"q":"p",s={};if(!Q(e)){s.$search_engine=e;var n=r?_n(r.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function Pn(){return navigator.language||navigator.userLanguage}var On="$direct";function In(){return(null==r?void 0:r.referrer)||On}function Cn(t,e,i){void 0===i&&(i=!1);var r=t?[...xn,...e||[]]:[],n=i?ye(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:In().substring(0,1e3),u:o?gn(o,r,Sn):void 0}}function An(t,e){var i;void 0===e&&(e=!1);var r=t.r,s=t.u,n=e?ye(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==On?On:null==(i=pn(r))?void 0:i.host};if(n){o.$current_url=n;var a=pn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=Tn(n);Nr(o,l)}if(r){var u=Rn(r);Nr(o,u)}return o}function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function Fn(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var Dn={flags:hr,surveys:ir},Nn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Un="main";class Ln{constructor(e,i,r){if(void 0===r&&(r=!0),this.ci={},this.fi=!1,this.pi=!1,this.Pe=e,this.gi=r,this.props={},this.mi=void 0,this.yi=(t=>{var e="";return t.token&&(e=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+e+"_posthog"})(e),this.ii=this.bi(e),this.pi=this.wi(e),this.load(),e.debug&&mi.info("Persistence loaded",e.persistence,_({},this.props)),this.update_config(e,e,i),this.save(),t){var s=()=>this.flush();qr(t,"beforeunload",s,{capture:!1}),qr(t,"pagehide",s,{capture:!1})}}xi(){var t,e=null==(t=this.Pe)?void 0:t.persistence_save_debounce_ms;return Z(e)&&e>0?e:0}isDisabled(){return!!this.ki}bi(e){-1===Nn.indexOf(e.persistence.toLowerCase())&&(mi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i,r=function(e,i){void 0===e&&(e=[]),void 0===i&&(i=!1);var r=[...ns,...e];return _({},ss,{H(t){try{var e={};try{e=is.H(t)||{}}catch(t){}var r,s=JSON.parse(ss.q(t)||"{}");if(i){var n={};for(var o in e){var a=e[o];Q(a)||""===a||(n[o]=a)}r=Nr(s,n)}else r=Nr(e,s);return ss.A(t,r),r}catch(t){}return null},A(t,e,i,s,n,o){var a=ss.A(t,e,void 0,void 0,o);try{var l={};r.forEach((t=>{e[t]&&(l[t]=e[t])})),Object.keys(l).length&&is.A(t,l,i,s,n,o)}catch(t){ss.j(t)}return a},F(e,i){try{null==t||t.localStorage.removeItem(e),is.F(e,i)}catch(t){ss.j(t)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&ss.P()?(i=ss,s=!0):"localstorage+cookie"===n&&r.P()?(i=r,s=!0):"sessionstorage"===n&&us.P()?i=us:"memory"===n?i=as:"cookie"===n?i=is:r.P()?(i=r,s=!0):i=is,this.fi=s,i}Si(t){return this.yi+"__"+t}wi(t){return this.fi&&!!t.split_storage}Ci(t){var e=null!=t?t:this.Pe.feature_flag_cache_ttl_ms;if(!e||0>=e)return!1;var i=this.props[hr];return!i||"number"!=typeof i||Date.now()-i>e}properties(){var t={};return Dr(this.props,((e,i)=>{var r=cn(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e,i===qi?()=>this.Ci():()=>!1))return;r.transformToEventProperties&&Nr(t,r.transformToEventProperties(e))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e,(()=>!1)))return;t[i]=e}})),t}load(){if(!this.ki){var t=this.ii.H(this.yi);t&&(this.props=Nr({},t)),this.pi&&this.Mi()}}Mi(){for(var t of hn){var e=ss.H(this.Si(t));if(e&&!G(e)){var i=this.Ti(t);i.persisted=!0,this.Ei(t)||(i.fingerprint=this.Ii(e,t)),this.Pi(t,e)||Nr(this.props,e)}}}Ei(t){return Object.keys(this.props).some((e=>{var i;return(null==(i=cn(e))?void 0:i.storageGroup)===t}))}Pi(t,e){var i=Dn[t];if(!i)return!1;var r=e[i],s=this.props[i];return Z(r)&&Z(s)&&s>r}refreshKey(t){var e;if(!this.ki){var i=this.pi?null==(e=cn(t))?void 0:e.storageGroup:void 0,r=i?ss.H(this.Si(i)):this.ii.H(this.yi);if(r&&t in r)this.Ri(t,r[t]);else{if(i){var s=this.ii.H(this.yi);if(s&&t in s)return void this.Ri(t,s[t])}this.Li(t)}}}save(){if(!this.ki){var t=this.xi();t>0?K(this.Oi)&&(this.Oi=setTimeout((()=>{this.Oi=void 0,this.Fi()}),t)):this.Fi()}}flush(){K(this.Oi)||(clearTimeout(this.Oi),this.Oi=void 0,this.Fi())}Fi(){this.ki||(this.pi?this.Ai():this.Di(this.ii,this.yi,this.props,Un))}Ai(){var t=this.$i(),e=t.main,i=t.groups;for(var r of(this.Di(this.ii,this.yi,e,Un),hn)){var s,n=i[r];(!G(n)||null!=(s=this.ci[r])&&s.persisted)&&this.Di(ss,this.Si(r),n,r)}}$i(){var t={},e={flags:{},surveys:{}};return Dr(this.props,((i,r)=>{var s,n=null==(s=cn(r))?void 0:s.storageGroup;n?e[n][r]=i:t[r]=i})),{main:t,groups:e}}Ii(t,e){if(e===Un)return JSON.stringify(t)+"|"+this.Ni+"|"+this.qi+"|"+this.ji;var i={};return Dr(t,((t,e)=>{var r;i[e]=null!=(r=cn(e))&&r.volatile?"__volatile__":t})),JSON.stringify(i)}Di(t,e,i,r){var s=this.Ti(r);if(r===Un||s.dirty||K(s.fingerprint)){var n;try{if((n=this.Ii(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(t){n=void 0}t.A(e,i,this.Ni,this.qi,this.ji,this.Pe.debug)?(s.dirty=!1,r!==Un&&(s.persisted=!0),K(n)||(s.fingerprint=n)):this.Pe.debug&&mi.warn('failed to persist storage entry "'+e+'"; will retry on next save')}}remove(t){var e=(void 0===t?{}:t).keepGroupEntries,i=void 0!==e&&e;if(K(this.Oi)||(clearTimeout(this.Oi),this.Oi=void 0),this.ii.F(this.yi,!1),this.ii.F(this.yi,!0),!i&&this.gi)for(var r of hn)ss.F(this.Si(r));i?delete this.ci[Un]:this.ci={}}clear(){this.remove(),this.props={}}register_once(t,e,i){if(W(t)){K(e)&&(e="None"),this.Ni=K(i)?this.Bi:i;var r=!1;if(Dr(t,((t,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==e||(this.Ri(i,t),r=!0)})),r)return this.save(),!0}return!1}register(t,e){if(W(t)){this.Ni=K(e)?this.Bi:e;var i=!1;if(Dr(t,((e,r)=>{t.hasOwnProperty(r)&&this.props[r]!==e&&(this.Ri(r,e),i=!0)})),i)return this.save(),!0}return!1}unregister(t){t in this.props&&(this.Li(t),this.save())}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.mi){var e=kn(this.Pe.custom_campaign_params,this.Pe.mask_personal_data_properties,this.Pe.custom_personal_data_properties);G(Br(e))||this.register(e),this.mi=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?Rn(t):{})}update_referrer_info(){var t;this.register_once({$referrer:In(),$referring_domain:null!=r&&r.referrer&&(null==(t=pn(r.referrer))?void 0:t.host)||On},void 0)}set_initial_person_info(){this.props[fr]||this.props[pr]||this.register_once({[_r]:Cn(this.Pe.mask_personal_data_properties,this.Pe.custom_personal_data_properties,this.Pe.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Dr([pr,fr],(e=>{var i=this.props[e];i&&Dr(i,(function(e,i){t["$initial_"+L(i)]=e}))}));var e=this.props[_r];if(e){var i=function(t,e){void 0===e&&(e=!1);var i=An(t,e),r={};return Dr(i,(function(t,e){r["$initial_"+L(e)]=t})),r}(e,this.Pe.disable_capture_url_hashes);Nr(t,i)}return t}safe_merge(t){return Dr(this.props,(function(e,i){i in t||(t[i]=e)})),t}update_config(t,e,i){this.Bi=this.Ni=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!i),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie);var r=t.persistence!==e.persistence||!((t,e)=>{if(t.length!==e.length)return!1;var i=[...t].sort(),r=[...e].sort();return i.every(((t,e)=>t===r[e]))})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),s=r?this.bi(t):this.ii,n=this.wi(t);if(r||n!==this.pi){var o=this.props;this.clear(),this.ii=s,this.pi=n,this.props=o,this.save()}}set_disabled(t){this.ki=t,this.ki?this.remove():this.save()}set_cross_subdomain(t){t!==this.qi&&(this.qi=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.ji&&(this.ji=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var i=this.props[ki]||{};i[t]=e,this.Ri(ki,i),this.save()}remove_event_timer(t){var e=this.props[ki]||{},i=e[t];return K(i)||(delete e[t],this.Ri(ki,e),this.save()),i}get_property(t){return this.props[t]}set_property(t,e){this.Ri(t,e),this.save()}Ri(t,e){var i;this.props[t]=e,null!=(i=cn(t))&&i.volatile||this.Hi(t)}Li(t){delete this.props[t],this.Hi(t)}Hi(t){var e,i=null==(e=cn(t))?void 0:e.storageGroup;i&&(this.Ti(i).dirty=!0)}Ti(t){return this.ci[t]||(this.ci[t]={})}}function jn(t){var e=!0;return{dispose(){if(e){e=!1;var i=t();i&&V(i.then)&&i.then(void 0,(()=>{}))}}}}var Bn={GZipJS:"gzip-js",Base64:"base64"},zn={Activation:"events",Cancellation:"cancelEvents"},Hn={Button:"button",Tab:"tab",Selector:"selector"},qn={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"},Vn={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Wn={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Gn={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Kn={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Jn={Once:"once",Recurring:"recurring",Always:"always"},Yn={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Qn={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"},Xn={Popover:"popover",Inline:"inline"},Zn={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},to={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"},eo={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"},io=bi("[RateLimiter]");class ro{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var e=t.text;if(e&&e.length)try{(JSON.parse(e).quota_limited||[]).forEach((t=>{io.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void io.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:e})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,i,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(e=null==(i=this.instance.persistence)?void 0:i.get_property(cr))&&void 0!==e?e:{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;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(Z(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ui(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(cr,a),{isRateLimited:l,remainingTokens:a.tokens}}zi(t){var e=this.instance.config.property_denylist;return!q(e)||!e.includes(t)}Wi(){var t;if(this.zi("$current_url")&&this.zi("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}Ui(t){var e,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.Wi(),o=this.zi("$session_id")?null==(e=(i=this.instance).get_session_id)?void 0:e.call(i):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return!1!==e&&(new Date).getTime()<e}}var so=bi("[RemoteConfig]");class no{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Vi(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return so.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance.Ji())return void so.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return so.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((t=>{this.Gi(t.json,t),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){so.error("Error loading remote config",t),this.Gi()}}stop(){this.Ki&&(clearInterval(this.Ki),this.Ki=void 0)}refresh(){!this._instance.Ji()&&r&&"hidden"!==r.visibilityState&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ki){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Ki=setInterval((()=>{this.refresh()}),e))}}Gi(t,e){!t&&e&&(0===e.statusCode?e.error||so.warn("Failed to fetch remote config from PostHog."):so.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(t){so.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){so.error("Error loading feature flags",t)}}}var oo=["fatal","error","warning","log","info","debug"],ao=Uint8Array,lo=Uint16Array,uo=Uint32Array,ho=new ao([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]),vo=new ao([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]),co=new ao([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fo=function(t,e){for(var i=new lo(31),r=0;31>r;++r)i[r]=e+=1<<t[r-1];var s=new uo(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]},po=fo(ho,2),_o=po[1];po[0][28]=258,_o[258]=28;for(var go=fo(vo,0)[1],mo=new lo(32768),bo=0;32768>bo;++bo){var yo=(43690&bo)>>>1|(21845&bo)<<1;mo[bo]=((65280&(yo=(61680&(yo=(52428&yo)>>>2|(13107&yo)<<2))>>>4|(3855&yo)<<4))>>>8|(255&yo)<<8)>>>1}var wo=function(t,e,i){for(var r=t.length,s=0,n=new lo(e);r>s;++s)++n[t[s]-1];var o,a=new lo(e);for(s=0;e>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new lo(1<<e);var l=15-e;for(s=0;r>s;++s)if(t[s])for(var u=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,v=d|(1<<h)-1;v>=d;++d)o[mo[d]>>>l]=u}else for(o=new lo(r),s=0;r>s;++s)o[s]=mo[a[t[s]-1]++]>>>15-t[s];return o},xo=new ao(288);for(bo=0;144>bo;++bo)xo[bo]=8;for(bo=144;256>bo;++bo)xo[bo]=9;for(bo=256;280>bo;++bo)xo[bo]=7;for(bo=280;288>bo;++bo)xo[bo]=8;var Eo=new ao(32);for(bo=0;32>bo;++bo)Eo[bo]=5;var So=wo(xo,9,0),$o=wo(Eo,5,0),ko=function(t){return(t/8>>0)+(7&t&&1)},To=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var r=new(t instanceof lo?lo:t instanceof uo?uo:ao)(i-e);return r.set(t.subarray(e,i)),r},Ro=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8},Po=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8,t[r+2]|=i>>>16},Oo=function(t,e){for(var i=[],r=0;t.length>r;++r)t[r]&&i.push({s:r,f:t[r]});var s=i.length,n=i.slice();if(!s)return[new ao(0),0];if(1==s){var o=new ao(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(t,e){return t.f-e.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,h=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=h&&i[d].f>i[u].f?u++:d++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new lo(v+1),f=Io(i[h-1],c,0);if(f>e){r=0;var p=0,_=f-e,g=1<<_;for(n.sort((function(t,e){return c[e.s]-c[t.s]||t.f-e.f}));s>r;++r){var m=n[r].s;if(e>=c[m])break;p+=g-(1<<f-c[m]),c[m]=e}for(p>>>=_;p>0;){var b=n[r].s;e>c[b]?p-=1<<e-c[b]++-1:++r}for(;r>=0&&p;--r){var y=n[r].s;c[y]==e&&(--c[y],++p)}f=e}return[new ao(c),f]},Io=function(t,e,i){return-1==t.s?Math.max(Io(t.l,e,i+1),Io(t.r,e,i+1)):e[t.s]=i},Co=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new lo(++e),r=0,s=t[0],n=1,o=function(t){i[r++]=t},a=1;e>=a;++a)if(t[a]==s&&a!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[i.subarray(0,r),e]},Ao=function(t,e){for(var i=0,r=0;e.length>r;++r)i+=t[r]*e[r];return i},Mo=function(t,e,i){var r=i.length,s=ko(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=i[n];return 8*(s+4+r)},Fo=function(t,e,i,r,s,n,o,a,l,u,h){Ro(e,h++,i),++s[256];for(var d=Oo(s,15),v=d[0],c=d[1],f=Oo(n,15),p=f[0],_=f[1],g=Co(v),m=g[0],b=g[1],y=Co(p),w=y[0],x=y[1],E=new lo(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=Oo(E,7),T=k[0],R=k[1],P=19;P>4&&!T[co[P-1]];--P);var O,I,C,A,M=u+5<<3,F=Ao(s,xo)+Ao(n,Eo)+o,D=Ao(s,v)+Ao(n,p)+o+14+3*P+Ao(E,T)+(2*E[16]+3*E[17]+7*E[18]);if(F>=M&&D>=M)return Mo(e,h,t.subarray(l,l+u));if(Ro(e,h,1+(F>D)),h+=2,F>D){O=wo(v,c,0),I=v,C=wo(p,_,0),A=p;var N=wo(T,R,0);for(Ro(e,h,b-257),Ro(e,h+5,x-1),Ro(e,h+10,P-4),h+=14,S=0;P>S;++S)Ro(e,h+3*S,T[co[S]]);h+=3*P;for(var U=[m,w],L=0;2>L;++L){var j=U[L];for(S=0;j.length>S;++S)Ro(e,h,N[B=31&j[S]]),h+=T[B],B>15&&(Ro(e,h,j[S]>>>5&127),h+=j[S]>>>12)}}else O=So,I=xo,C=$o,A=Eo;for(S=0;a>S;++S)if(r[S]>255){var B;Po(e,h,O[257+(B=r[S]>>>18&31)]),h+=I[B+257],B>7&&(Ro(e,h,r[S]>>>23&31),h+=ho[B]);var z=31&r[S];Po(e,h,C[z]),h+=A[z],z>3&&(Po(e,h,r[S]>>>5&8191),h+=vo[z])}else Po(e,h,O[r[S]]),h+=I[r[S]];return Po(e,h,O[256]),h+I[256]},Do=new uo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),No=function(){for(var t=new uo(256),e=0;256>e;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),Uo=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function Lo(t,e){void 0===e&&(e={});var i=function(){var t=4294967295;return{p(e){for(var i=t,r=0;e.length>r;++r)i=No[255&i^e[r]]^i>>>8;t=i},d(){return 4294967295^t}}}(),r=t.length;i.p(t);var s,n,o,a,l,u=(a=10+((s=e).filename&&s.filename.length+1||0),l=8,function(t,e,i,r,s,n){var o=t.length,a=new ao(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!e||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=Mo(l,u,t.subarray(h,d)):(l[h]=!0,u=Mo(l,u,t.subarray(h,o)))}else{for(var v=Do[e-1],c=v>>>13,f=8191&v,p=(1<<i)-1,_=new lo(32768),g=new lo(p+1),m=Math.ceil(i/3),b=2*m,y=function(e){return(t[e]^t[e+1]<<m^t[e+2]<<b)&p},w=new uo(25e3),x=new lo(288),E=new lo(32),S=0,k=0,T=(h=0,0),R=0,P=0;o>h;++h){var O=y(h),I=32767&h,C=g[O];if(_[I]=C,g[O]=I,h>=R){var A=o-h;if((S>7e3||T>24576)&&A>423){u=Fo(t,l,0,w,x,E,k,T,P,h-P,u),T=S=k=0,P=h;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)E[M]=0}var F=2,D=0,N=f,U=I-C&32767;if(A>2&&O==y(h-U))for(var L=Math.min(c,A)-1,j=Math.min(32767,h),B=Math.min(258,A);j>=U&&--N&&I!=C;){if(t[h+F]==t[h+F-U]){for(var z=0;B>z&&t[h+z]==t[h+z-U];++z);if(z>F){if(F=z,D=U,z>L)break;var H=Math.min(U,z-2),q=0;for(M=0;H>M;++M){var V=h-U+M+32768&32767,W=V-_[V]+32768&32767;W>q&&(q=W,C=V)}}}U+=(I=C)-(C=_[I])+32768&32767}if(D){w[T++]=268435456|_o[F]<<18|go[D];var G=31&_o[F],K=31&go[D];k+=ho[G]+vo[K],++x[257+G],++E[K],R=h+F,++S}else w[T++]=t[h],++x[t[h]]}}u=Fo(t,l,!0,w,x,E,k,T,P,h-P,u)}return To(a,0,r+ko(u)+s)}(n=t,null==(o=e).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)),h=u.length;return function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>e.level?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&Uo(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;i.length>=r;++r)t[r+10]=i.charCodeAt(r)}}(u,e),Uo(u,h-8,i.d()),Uo(u,h-4,r),u}var jo=!!o||!!n,Bo="text/plain",zo=!1,Ho=(t,e)=>{var i=t.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==e)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},qo=function(t,e,i){var r;void 0===i&&(i=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},e),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var e,r=t.split("="),s=r[0],n=i&&null!==(e=a[s])&&void 0!==e?e:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],u=function(t,e){var i,r;void 0===e&&(e="&");var s=[];return Dr(t,(function(t,e){K(t)||K(e)||"undefined"===e||(i=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(e),s[s.length]=r+"="+i)})),s.join(e)}(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},Vo=t=>{if(t.Yi)return t.Yi;var e=t.data,i=t.compression;if(e){if(i===Bn.GZipJS){var r=Lo(function(t,e){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new ao(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;i>o;++o){if(s+5>r.length){var a=new ao(s+8+(i-o<<1));a.set(r),r=a}var l=t.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&t.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 To(r,0,s)}(fn(e)),{mtime:0});return{contentType:Bo,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Bn.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(parseInt(e,16))))):t}(fn(e)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:fn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=fn(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Wo=t=>{var e,i,r=()=>"sendBeacon"===t.transport?{url:qo(t.url,{compression:Bn.Base64}),encodedBody:Vo(_({},t,{compression:Bn.Base64,Yi:void 0}))}:{url:Ho(t.url,"compression"),encodedBody:Vo(_({},t,{compression:void 0,Yi:void 0}))};try{e=Vo(t)}catch(e){if(O(t.compression,_n(t.url,"compression")))return mi.error("Failed to gzip request body, sending uncompressed payload",e),r();throw e}return e&&O(t.compression,_n(t.url,"compression"))&&!((i=e.body)instanceof ArrayBuffer?P(new Uint8Array(i)):ArrayBuffer.isView(i)&&P(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(zo=!0,r()):{url:t.url,encodedBody:e}},Go=t=>{try{return Wo(t)}catch(e){return mi.error(e),void(null==t.callback||t.callback({statusCode:0,error:e}))}},Ko=function(){var t=p((function*(t){var e=fn(t.data),i=yield function(t,e,i){return M.apply(this,arguments)}(e,c.DEBUG,{rethrow:!0});if(!i)return t;var r=yield i.arrayBuffer();return _({},t,{Yi:{contentType:Bo,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}}(),Jo=/Failed to fetch|NetworkError|Load failed/i,Yo=t=>{var e=Go(t);if(e){var i=e.url,r=e.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,u=s.estimatedSize,h=new Headers;Dr(t.headers,(function(t,e){h.append(e,t)})),o&&h.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var e,i;v=!0,c.abort((e=t.timeout,(i=new Error("PostHog request timed out"+(e?" after "+e+"ms":""))).name="AbortError",i))}),t.timeout)}}var f=e=>{v&&"AbortError"===(null==e?void 0:e.name)||(t=>"TypeError"===(null==t?void 0:t.name)&&Jo.test((null==t?void 0:t.message)||""))(e)?mi.warn(e):mi.error(e),null==t.callback||t.callback({statusCode:0,error:e})};try{var p;n(i,_({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.Xi&&52428.8>(u||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((e=>e.text().then((i=>{var r={statusCode:e.status,text:i};if(200===e.status)try{r.json=JSON.parse(i)}catch(t){mi.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Qo=t=>{try{var e,r=Wo(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(i.sendBeacon(s,u))return;var h=q(t.data)?t.data:null==(e=t.data)?void 0:e.batch;if(q(h)&&h.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(h.length/2),v=e=>q(t.data)?e:_({},t.data,{batch:e});return Qo(_({},t,{data:v(h.slice(0,d))})),void Qo(_({},t,{data:v(h.slice(d))}))}mi.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Yo(_({},t,{Xi:!0}))}catch(t){mi.warn("Beacon send failed",t)}},Xo=(t,e,i,r)=>{var s="query"===r?"POST"===e?"sent_at":"_":void 0;return qo(i===Bn.GZipJS?Ho(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},i===Bn.GZipJS?{}:{compression:i}))},Zo=[];n&&Zo.push({transport:"fetch",method:Yo}),o&&Zo.push({transport:"XHR",method(t){var e=Go(t);if(e){var i=new o,r=e.encodedBody;i.open(t.method||"GET",e.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;Dr(t.headers,(function(t,e){i.setRequestHeader(e,t)})),n&&i.setRequestHeader("Content-Type",n),t.timeout&&(i.timeout=t.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var e={statusCode:i.status,text:i.responseText};if(200===i.status)try{e.json=JSON.parse(i.responseText)}catch(t){}null==t.callback||t.callback(e)}},i.send(a)}}}),null!=i&&i.sendBeacon&&Zo.push({transport:"sendBeacon",method:Qo});var ta=3e3;class ea{constructor(t,e){this.tr=!0,this.er=[],this.ir=vt((null==e?void 0:e.flush_interval_ms)||ta,250,5e3,mi.createLogger("flush interval"),ta),this.rr=t}enqueue(t){this.er.push(t),this.nr||this.sr()}unload(){this.ar();var t=this.er.length>0?this.lr():{},e=Object.values(t);[...e.filter((t=>0===t.url.indexOf("/e"))),...e.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.ur(_({},t,{transport:"sendBeacon"}))}))}enable(){this.tr=!1,this.sr()}sr(){var t=this;this.tr||(this.nr=setTimeout((()=>{if(this.ar(),this.er.length>0){var e=this.lr(),i=function(){var i=e[r],s=(new Date).getTime();i.data&&q(i.data)&&Dr(i.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.ur(i)};for(var r in e)i()}}),this.ir))}ur(t){try{this.rr(t)}catch(t){mi.error(t)}}ar(){clearTimeout(this.nr),this.nr=void 0}lr(){var t={};return Dr(this.er,(e=>{var i,r=e,s=(r?r.batchKey:null)||r.url;K(t[s])&&(t[s]=_({},r,{data:[]})),null==(i=t[s].data)||i.push(r.data)})),this.er=[],t}}var ia=["retriesPerformedSoFar"];class ra{constructor(e){this.hr=!1,this.dr=3e3,this.er=[],this._instance=e,this.er=[],this.vr=!0,!K(t)&&"onLine"in t.navigator&&(this.vr=t.navigator.onLine,this.cr=()=>{this.vr=!0,this.pr()},this.gr=()=>{this.vr=!1},qr(t,"online",this.cr),qr(t,"offline",this.gr))}get length(){return this.er.length}retriableRequest(t){var e=t.retriesPerformedSoFar,i=g(t,ia);tt(e)&&(i.url=qo(i.url,{retry_count:e})),this._instance._send_request(_({},i,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Lt(_({retriesPerformedSoFar:e},i));0===t.statusCode&&mi.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=e?e:0)+" retries.")}null==i.callback||i.callback(t)}}))}Lt(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var i=function(t){var e=3e3*Math.pow(2,t),i=e/2,r=Math.min(18e5,e),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(e),r=Date.now()+i;this.er.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),mi.warn(s),this.hr||(this.hr=!0,this.mr())}mr(){if(this.yr&&clearTimeout(this.yr),0===this.er.length)return this.hr=!1,void(this.yr=void 0);this.yr=setTimeout((()=>{this.vr&&this.er.length>0&&this.pr(),this.mr()}),this.dr)}pr(){var t=Date.now(),e=[],i=this.er.filter((i=>t>i.retryAt||(e.push(i),!1)));if(this.er=e,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.yr&&(clearTimeout(this.yr),this.yr=void 0),this.hr=!1,K(t)||(this.cr&&(t.removeEventListener("online",this.cr),this.cr=void 0),this.gr&&(t.removeEventListener("offline",this.gr),this.gr=void 0)),this.er)){var i=e.requestOptions;try{this._instance._send_request(_({},i,{transport:"sendBeacon"}))}catch(t){mi.error(t)}}this.er=[]}}class sa{constructor(t){this.br=()=>{var t,e,i,r;this._r||(this._r={});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._r.lastScrollY=Math.ceil(n),this._r.maxScrollY=Math.max(n,null!==(t=this._r.maxScrollY)&&void 0!==t?t:0),this._r.maxScrollHeight=Math.max(o,null!==(e=this._r.maxScrollHeight)&&void 0!==e?e:0),this._r.lastContentY=a,this._r.maxContentY=Math.max(a,null!==(i=this._r.maxContentY)&&void 0!==i?i:0),this._r.maxContentHeight=Math.max(l,null!==(r=this._r.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get wr(){return this._instance.config.scroll_root_selector}getContext(){return this._r}resetContext(){var t=this._r;return setTimeout(this.br,0),t}startMeasuringScrollPosition(){qr(t,"scroll",this.br,{capture:!0}),qr(t,"scrollend",this.br,{capture:!0}),qr(t,"resize",this.br)}scrollElement(){if(!this.wr)return null==t?void 0:t.document.documentElement;var e=q(this.wr)?this.wr:[this.wr];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}kr(e){var i="y"===e?"scrollTop":"scrollLeft";if(this.wr){var r=this.scrollElement();return r&&r[i]||0}return t?"y"===e?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.kr("y")}scrollX(){return this.kr("x")}}var na=t=>Cn(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class oa{constructor(t,e,i,r){this.Sr=t=>{var e=this.Cr();if(!e||e.sessionId!==t){var i={sessionId:t,props:this.Mr(this._instance)};this.Tr.register({[vr]:i})}},this._instance=t,this.Er=e,this.Tr=i,this.Mr=r||na,this.Er.onSessionId(this.Sr)}Cr(){return this.Tr.props[vr]}getSetOnceProps(){var t,e=null==(t=this.Cr())?void 0:t.props;return e?"r"in e?An(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return Dr(Br(this.getSetOnceProps()),((e,i)=>{"$current_url"===i&&(i="url"),t["$session_entry_"+L(i)]=e})),t}}class aa{on(t,e){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(e),()=>{this.Ir[t]=this.Ir[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ir[t]||[])i(e);for(var r of this.Ir["*"]||[])r(t,e)}constructor(){this.Ir={}}}var la=bi("[SessionId]");class ua{on(t,e){return this.Pr.on(t,e)}constructor(t,e,i){var r;if(this.Rr=null,this.Lr=[],this.Or=void 0,this.Fr=!1,this.Pr=new aa,this.Ar=(t,e)=>!(!tt(t)||!tt(e))&&Math.abs(t-e)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===$r)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Pe=t.config,this.Tr=t.persistence,this.Dr=void 0,this.$r=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Nr=e||Xr,this.qr=i||Xr;var s=this.Pe.persistence_name||this.Pe.token;if(this._sessionTimeoutMs=1e3*vt(this.Pe.session_idle_timeout_seconds||1800,60,36e3,la.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jr(),this.Br="ph_"+s+"_window_id",this.Hr="ph_"+s+"_primary_window_exists",this.Ur()){var n=us.H(this.Br),o=us.H(this.Hr);n&&!o?this.Dr=n:us.F(this.Br),us.A(this.Hr,!0)}if(null!=(r=this.Pe.bootstrap)&&r.sessionID)try{var a=(t=>{var e=this.Pe.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.zr(this.Pe.bootstrap.sessionID,(new Date).getTime(),a)}catch(t){la.error("Invalid sessionID in bootstrap",t)}this.Wr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return K(this.Lr)&&(this.Lr=[]),this.Lr.push(t),this.$r&&t(this.$r,this.Dr),()=>{this.Lr=this.Lr.filter((e=>e!==t))}}Ur(){return"memory"!==this.Pe.persistence&&!this.Tr.ki&&us.P()}Vr(t){t!==this.Dr&&(this.Dr=t,this.Ur()&&us.A(this.Br,t))}Zr(){return this.Dr?this.Dr:this.Ur()?us.H(this.Br):null}Gr(t){var e=this.Rr;return!Q(e)&&!Q(t)&&5e3>Math.abs(t-e)}zr(t,e,i){var r=e!==this._sessionActivityTimestamp,s=!(t!==this.$r||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=e,this.$r=t,s&&!r||s&&this.Gr(e)||(this.Rr=e,this.Tr.register({[zi]:[e,t,i]}))}Qr(){var t,e=null==(t=this.Pe)?void 0:t.persistence_save_debounce_ms;return tt(e)&&e>0}Jr(){this.Qr()?this.Tr.refreshKey(zi):(this.Tr.flush(),this.Tr.load())}Kr(){var t;if(!Q(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Rr){this.Jr();var e=this.Yr();e[1]===this.$r&&e[2]===this._sessionStartTimestamp&&(this.Rr=this._sessionActivityTimestamp,this.Tr.register({[zi]:[this._sessionActivityTimestamp,null!==(t=this.$r)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Tr.flush())}}Xr(){var t=this.Yr()[0],e=tt(t)?t:0,i=tt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,i)}tn(t){return this.Jr(),this.Ar(t,this.Xr())}Yr(){var t=this.Tr.props[zi];return q(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rr=null,clearTimeout(this.en),this.en=void 0,this.zr(null,null,null)}destroy(){this.Fr=!0,this.Kr(),clearTimeout(this.en),this.en=void 0,this.Or&&t&&(t.removeEventListener(Or,this.Or,{capture:!1}),this.Or=void 0),this.Lr=[]}Wr(){this.Or=()=>{this.Kr(),this.Ur()&&us.F(this.Hr)},qr(t,Or,this.Or,{capture:!1})}checkAndGetSessionAndWindowId(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=null),this.Pe.cookieless_mode===$r)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=e||(new Date).getTime(),r=this.Yr(),s=r[1],n=r[2],o=this.Xr(),a=this.Zr(),l=tt(n)&&Math.abs(i-n)>864e5,u=!1,h=!1,d=!s,v=s,c=!d&&!t&&this.Ar(i,o);if(c){(c=this.tn(i))||la.info("cross-tab refresh kept the session alive",{sessionId:s});var f=this.Yr();s=f[1],n=f[2]}d||c||l?(s=this.Nr(),a=this.qr(),la.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:d,activityTimeout:c,sessionPastMaximumLength:l}}),n=i,u=!0):(a||(a=this.qr(),u=!0),(h=s!==v)&&(la.info("adopted cross-tab session id",{sessionId:s,windowId:a}),u=!0));var p=tt(o)&&t&&!l?o:i,_=tt(n)?n:(new Date).getTime();this.Vr(a),this.zr(s,p,_),t||this.jr();var g={noSessionId:d,activityTimeout:c,sessionPastMaximumLength:l,crossTabAdoption:h};return u&&this.Lr.forEach((t=>t(s,a,g))),{sessionId:s,windowId:a,sessionStartTimestamp:_,changeReason:u?g:void 0,lastActivityTimestamp:o}}jr(){this.Fr||(clearTimeout(this.en),this.en=setTimeout((()=>{if(!this.Fr)if(this.tn((new Date).getTime())){var t=this.$r;this.resetSessionId(),this.Pr.emit("forcedIdleReset",{idleSessionId:t})}else this.jr()}),1.1*this.sessionTimeoutMs))}}var ha=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&D(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>D(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver};function da(){return(da=p((function*(){var t=null==i?void 0:i.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),r=null==e?void 0:e.model;return J(r)&&r.length>0?r:void 0}catch(t){return void mi.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}var va=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}};function ca(t,e,i){return fn({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}var fa={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>va(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!va(e,t))))),icontains:(t,e)=>e.map(pa).some((e=>t.map(pa).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(pa).every((e=>t.map(pa).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},pa=t=>t.toLowerCase();function _a(t,e){return!t||Object.entries(t).every((t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(K(r)||Q(r))return!1;var s=[String(r)],n=fa[i.operator];return!!n&&n(i.values,s)}))}var ga="custom",ma="i.posthog.com",ba=/^\/static\//;class ya{constructor(t){this.rn={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+ma,".posthog.com")),"https://app.posthog.com"===e?"https://us.posthog.com":e}get region(){return this.rn[this.apiHost]||(this.rn[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":ga),this.rn[this.apiHost]}nn(t){if(ba.test(t)){var e=this.instance.config.asset_host;if("string"==typeof e)return e.trim().replace(/\/$/,"")||void 0}}endpointFor(t,e){if(void 0===e&&(e=""),e&&(e="/"===e[0]?e:"/"+e),"ui"===t)return this.uiHost+e;if("flags"===t)return this.flagsApiHost+e;if("assets"===t){var i=this.nn(e);if(i)return""+i+e}if(this.region===ga)return this.apiHost+e;var r=ma+e;switch(t){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}function wa(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var xa=bi("[Surveys]"),Ea="seenSurvey_",Sa=t=>{try{var e=(t=>((t,e)=>""+Ea+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){xa.error("Failed to persist survey seen state",t)}},$a=[Wn.Popover,Wn.Widget,Wn.API],ka={ignoreConditions:!1,ignoreDelay:!1,displayType:Xn.Popover},Ta=bi("[PostHog ExternalIntegrations]"),Ra={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Pa{constructor(t){this._instance=t}ai(t,e){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,t,(t=>{if(t)return Ta.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var t=this,e=function(){var e,r,s,n=i[0],o=i[1];!o||null!=(e=v.__PosthogExtensions__)&&null!=(e=e.integrations)&&e[n]||t.ai(Ra[n],(()=>{var e;null==(e=v.__PosthogExtensions__)||null==(e=e.integrations)||null==(e=e[n])||e.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var i of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;e()}}}class Oa{constructor(t,e){this.rt=t,this.sn=e,this.an=new Map,this.ln=!1}add(t){var e=this;return p((function*(){if(e.ln)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.an.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.an.set(t.name,t);try{var i=t.setup(e.sn);i&&(yield i)}catch(i){var r=e.an.get(t.name)===t;r&&e.an.delete(t.name),e.rt.error('Failed to set up browser extension "'+t.name+'"',i),r&&e.un(t)}}))()}dispose(){if(!this.ln){this.ln=!0;var t=Array.from(this.an.values()).reverse();for(var e of(this.an.clear(),t))this.un(e)}}un(t){try{var e=null==t.dispose?void 0:t.dispose();e&&V(e.then)&&e.then(void 0,(e=>{this.rt.error('Failed to dispose browser extension "'+t.name+'"',e)}))}catch(e){this.rt.error('Failed to dispose browser extension "'+t.name+'"',e)}}}class Ia{constructor(t){this._instance=t}get(t){var e;return null==(e=this._instance.persistence)?void 0:e.get_property(t)}set(t,e){var i;null==(i=this._instance.persistence)||i.set_property(t,e)}remove(t){var e;null==(e=this._instance.persistence)||e.unregister(t)}}var Ca="extensionsRemoteConfig";class Aa{constructor(t){this.ln=!1,this.instance=t,this.rt=mi.createLogger("[BrowserExtensions]"),this.hn=t.dn,this.kv=new Ia(t),this.onEvent=t=>jn(this.instance.on("eventCaptured",(e=>{try{t({event:e.event,properties:e.properties})}catch(t){this.rt.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.ln)return jn((()=>{}));var e=e=>{try{t(e)}catch(t){this.rt.error("Browser extension remote config listener failed",t)}},i=this.instance.vn.on(Ca,e);return this.hn&&e(this.hn),jn(i)},this.cn=new Oa(this.rt,this)}get logger(){return this.rt}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(Ei))&&void 0!==t?t:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var t,e,i,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(e=null==s?void 0:s.sessionId)&&void 0!==e?e:"",windowId:null!==(i=null==s?void 0:s.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.cn.add(t)}capture(t,e,i){var r=this;return p((function*(){i?r.instance.capture(t,e,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):r.instance.capture(t,e)}))()}registerDynamicEventProperties(t){return jn(this.instance.fn(t))}handleRemoteConfig(t){this.ln||(this.hn=t,this.instance.vn.emit(Ca,t))}sendRequest(t,e){var i=this;return p((function*(){var r;void 0===e&&(e={});var s=i.instance.requestRouter.endpointFor(null!==(r=e.target)&&void 0!==r?r:"api",t),n={method:e.method,url:e.query?qo(s,e.query):s,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport};return"sendBeacon"===e.transport?(i.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,i.instance._send_request(n)}))}))()}dispose(){this.ln||(this.ln=!0,this.cn.dispose())}}var Ma={},Fa=0,Da=()=>{},Na='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ua="Surveys module not available",La="sanitize_properties is deprecated. Use before_send instead",ja="Invalid value for property_denylist config: ",Ba=["token","distinct_id",br],za="posthog",Ha=!jo&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla")),qa=e=>{var i;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Hr(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Da,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,__preview_cookie_wins_on_conflict:!1,debug:s&&J(null==s?void 0:s.search)&&-1!==s.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null==(i=t.location)?void 0:i.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(t){mi.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Rr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:ta},error_tracking:{},_onCapture:Da},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:As,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:t&&t>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t)}))(e))},Va=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],Wa=t=>{var e={};for(var i of Va){var r=i[0],s=i[1];K(t[r])||(e[s]=t[r])}var n=Nr({},e,t),o=t.__preview_external_dependency_versioned_paths;return K(o)||(K(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),J(o)&&K(t.asset_host)&&(n.asset_host=o)),q(t.property_blacklist)&&(K(t.property_denylist)?n.property_denylist=t.property_blacklist:q(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:mi.error(ja+t.property_denylist)),n};class Ga{constructor(){this.__forceAllowLocalhost=!1}get pn(){return this.__forceAllowLocalhost}set pn(t){mi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Ka{gn(t,e){if(t){var i=this.an.indexOf(t);-1!==i&&this.an.splice(i,1)}return this.an.push(e),null==e.initialize||e.initialize(),e}mn(){return this.config.cookieless_mode===$r||this.config.cookieless_mode===Sr&&this.consent.isRejected()}get decideEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new Ga,this.yn=!1,this.version=c.LIB_VERSION,this.vn=new aa,this.an=[],this.bn=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=qa(),this.SentryIntegration=ln,this.sentryIntegration=t=>function(t,e){var i=an(t,e);return{name:on,processEvent:t=>i(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._n=!1,this.wn=null,this.xn=null,this.kn=null,this.scrollManager=new sa(this),this.pageViewManager=new un(this),this.rateLimiter=new ro(this),this.requestRouter=new ya(this),this.consent=new hs(this),this.externalIntegrations=new Pa(this);var e=null!==(t=Ka.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,e,i)=>{var r=J(t)?{[t]:e}:t;this.setPersonProperties(r),null==i||i({})},set_once:(t,e,i)=>{var r=J(t)?{[t]:e}:t;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(t=>mi.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,e,i){if(i&&i!==za){var r,s=null!==(r=Ma[i])&&void 0!==r?r:new Ka;return s._init(t,e,i),Ma[i]=s,Ma[za][i]=s,s}return this._init(t,e,i)}_init(e,i,r){var s,n;void 0===i&&(i={});var o,a=J(e)?e.trim():"";if(!a)return mi.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 a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=qa(i.defaults),i.debug=this.Sn(i.debug),this.Cn=i,this.Mn=[],i.person_profiles?this.xn=i.person_profiles:i.process_person&&(this.xn=i.process_person);var l=qa(i.defaults),u=Wa(i),h=Nr({},l,u,{name:r,token:a});W(l.rageclick)&&W(u.rageclick)&&(h.rageclick=Nr({},l.rageclick,u.rageclick)),W(l.session_recording)&&W(u.session_recording)&&(h.session_recording=Nr({},l.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&mi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Bn.GZipJS;var d=this.Tn();this.persistence=new Ln(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ln(_({},this.config,{persistence:"sessionStorage"}),d,!1);var v=_({},this.persistence.props),f=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.En=new ea((t=>this.In(t)),this.config.request_queue_config),this.Pn=new ra(this),this.__request_queue=[];var p=this.mn();if(p||(this.sessionManager=new ua(this),this.sessionPropsManager=new oa(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(mi.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Rn(p)}),0)):(mi.info("Initializing extensions synchronously"),this.Rn(p)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&mi.info("Starting in debug mode",{this:this,config:i,thisC:_({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=_({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=i.bootstrap)?void 0:n.distinctID)){var g=i.bootstrap.distinctID,m=this.get_distinct_id(),b=this.persistence.get_property(dr);if(i.bootstrap.isIdentifiedID&&null!=m&&m!==g&&b===kr)this.identify(g);else if(i.bootstrap.isIdentifiedID&&null!=m&&m!==g&&b===Tr)mi.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 y=this.config.get_device_id(Xr()),w=i.bootstrap.isIdentifiedID?y:g;this.persistence.set_property(dr,i.bootstrap.isIdentifiedID?Tr:kr),this.register({distinct_id:g,$device_id:w})}}if(p)this.register_once({distinct_id:mr,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(Xr());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(dr,kr)}return qr(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?function(t,e){var i=t.config.segment;if(!i)return e();!function(t,e){var i=t.config.segment;if(!i)return e();var r=i=>{var r=()=>i.anonymousId()||Xr();t.config.get_device_id=r,i.id()&&(t.register({distinct_id:i.id(),$device_id:r()}),t.persistence.set_property(dr,Tr)),e()},s=i.user();"then"in s&&V(s.then)?s.then(r):r(s)}(t,(()=>{i.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||nn.warn("This browser does not have Promise support, and can not use the segment integration");var e=(e,i)=>{if(!i)return e;e.event.userId||e.event.anonymousId===t.get_distinct_id()||(nn.info("No userId set, resetting PostHog"),t.reset()),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(nn.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var r=t.calculateEventProperties(i,e.event.properties);return e.event.properties=Object.assign({},r,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>e(t,t.event.event),page:t=>e(t,Ir),identify:t=>e(t,Ar),screen:t=>e(t,"$screen")}})(t)).then((()=>{e()}))}))}(this,(()=>this.Ln())):this.Ln(),V(this.config._onCapture)&&this.config._onCapture!==Da&&(mi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&mi.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.config.disableDeviceModel||function(){return da.apply(this,arguments)}().then((t=>{t&&this.register({[Si]:t})})).catch(Da),this}Rn(t){var e,i,r,s,n,o,a,l,u=performance.now(),h=_({},Ka.__defaultExtensionClasses,this.config.__extensionClasses),d=[];h.featureFlags&&this.an.push(this.featureFlags=null!==(e=this.featureFlags)&&void 0!==e?e:new h.featureFlags(this)),h.exceptions&&this.an.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new h.exceptions(this)),h.historyAutocapture&&this.an.push(this.historyAutocapture=new h.historyAutocapture(this)),h.tracingHeaders&&this.an.push(this.tracingHeaders=new h.tracingHeaders(this)),h.siteApps&&this.an.push(this.siteApps=new h.siteApps(this)),h.sessionRecording&&!t&&this.an.push(this.sessionRecording=new h.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),h.autocapture&&this.an.push(this.autocapture=new h.autocapture(this)),h.surveys&&this.an.push(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new h.surveys(this)),h.logs&&this.an.push(this.logs=null!==(s=this.logs)&&void 0!==s?s:new h.logs(this)),h.metrics&&this.an.push(this.metrics=null!==(n=this.metrics)&&void 0!==n?n:new h.metrics(this)),h.conversations&&this.an.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new h.conversations(this)),h.productTours&&this.an.push(this.productTours=new h.productTours(this)),h.heatmaps&&this.an.push(this.heatmaps=new h.heatmaps(this)),h.webVitalsAutocapture&&this.an.push(this.webVitalsAutocapture=new h.webVitalsAutocapture(this)),h.exceptionObserver&&this.an.push(this.exceptionObserver=new h.exceptionObserver(this)),h.deadClicksAutocapture&&this.an.push(this.deadClicksAutocapture=new h.deadClicksAutocapture(this,rn)),h.toolbar&&this.an.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new h.toolbar(this)),h.experiments&&this.an.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new h.experiments(this)),this.an.forEach((t=>{t.initialize&&d.push((()=>{null==t.initialize||t.initialize()}))})),d.push((()=>{if(this.On){var t=this.On;this.On=void 0,this.an.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}})),this.Fn(d,u)}Fn(t,e){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-e>=30&&t.length>0)return void setTimeout((()=>{this.Fn(t,e)}),0);var i=t.shift();if(i)try{i()}catch(t){mi.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-e);this.register_for_session({[yr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[wr]:r}),this.config.__preview_deferred_init_extensions&&mi.info("PostHog extensions initialized ("+r+"ms)")}Gi(t){var e;if(!r||!r.body)return mi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Gi(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.On=t),this.dn=t,this.compression=void 0,t.ok){var i,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=N(s.supportedCompression,Bn.GZipJS)?Bn.GZipJS:N(s.supportedCompression,Bn.Base64)?Bn.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.xn?this.xn:Rr}),null==(e=this.An)||e.handleRemoteConfig(t),this.an.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}Ln(){try{this.config.loaded(this)}catch(t){mi.critical("`loaded` function failed",t)}if(this.Dn(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,e=this.config.internal_or_test_user_hostname;("string"==typeof e?t===e:e.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.mn())&&this.$n()}),1),this.Nn=new no(this),this.Nn.load()}Dn(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.En)||t.enable())}_dom_loaded(){this.is_capturing()&&Fr(this.__request_queue,(t=>this.In(t))),this.__request_queue=[],this.Dn()}_handle_unload(){var t,e,i,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(e=this.metrics)||e.flush("sendBeacon"),this.config.request_batching?(this.qn()&&this.capture(Cr),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this.En)||r.unload(),null==(s=this.Pn)||s.unload()):this.qn()&&this.capture(Cr,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?Ha?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?this.compression:t.compression,(K(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var e,i,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,u,h,d=null!==(e=s.transport)&&void 0!==e?e:"fetch";"sendBeacon"===d&&K(s.compression)&&s.data&&(s.compression=Bn.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(h=(u=q(n=s.data)?n:[n])[0])||null==(a=h.properties)?void 0:a.token)&&void 0!==o?o:null==h?void 0:h.token,batch:u,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,e){return void 0===e&&(e=(new Date).toISOString()),q(t)?t.map((t=>_({},t,{sent_at:e}))):_({},t,{sent_at:e})}(s.data))),s.url=Xo(s.url,s.method,s.compression,s.timestampMode);var v=Zo.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(i=null==(r=function(t,e){for(var i=0;t.length>i;i++)if(t[i].transport===d)return t[i]}(v))?void 0:r.method)&&void 0!==i?i:v[0].method;if(!c)throw new Error("No available transport method");"sendBeacon"!==d&&s.data&&s.compression===Bn.GZipJS&&l&&"undefined"!=typeof Promise&&!zo?Ko(s).then((t=>{c(t)})).catch((e=>{if(I(e))return zo=!0,void c(_({},s,{compression:void 0,url:Xo(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var e="name"in t?String(t.name):"";return I(t)||e===R})(e)&&(zo=!0),c(s)})):c(s)})(_({},t,{callback:e=>{var i,r;this.rateLimiter.checkForLimiting(e),400>e.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,e),null==t.callback||t.callback(e)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}In(t){this.Pn?this.Pn.retriableRequest(t):this._send_request(t)}_execute_array(t){Fa++;try{var e,i=[],r=[],s=[];Fr(t,(t=>{if(t)if(q(e=t[0]))s.push(t);else if(V(t))try{t.call(this)}catch(e){mi.error("Error executing queued PostHog call",t,e)}else q(t)&&"alias"===e?i.push(t):q(t)&&-1!==e.indexOf("capture")&&V(this[e])?s.push(t):r.push(t)}));var n=function(t,e){Fr(t,(function(t){try{if(q(t[0])){var i=e;Dr(t,(function(t){i=i[t[0]].apply(i,t.slice(1))}))}else e[t[0]].apply(e,t.slice(1))}catch(e){mi.error("Error executing queued PostHog call",t,e)}}))};n(i,this),n(r,this),n(s,this)}finally{Fa--}}push(t){if(Fa>0&&q(t)&&J(t[0])){var e=Ka.prototype[t[0]];V(e)&&e.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,e,i){var r,s,n,o,a,l,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.En){if(this.is_capturing())if(!K(t)&&J(t)){var h=!this.config.opt_out_useragent_filter&&this._is_bot();if(!h||this.config.__preview_capture_bot_pageviews){var d=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==d||!d.isRateLimited){if(this.bn.length>0){var v={};for(var c of this.bn.slice())try{Nr(v,c())}catch(t){mi.error("Failed to produce browser extension event properties",t)}e=_({},v,null!=e?e:{})}var f;null!=(r=e)&&r.$current_url&&!J(null==(s=e)?void 0:s.$current_url)&&(mi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==(f=e)||delete f.$current_url),"$exception"!==t||null!=i&&i.jn||mi.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 p=new Date,g=(null==i?void 0:i.timestamp)||p,m=be(null==i?void 0:i.uuid,Xr),b={uuid:m,event:t,properties:this.calculateEventProperties(t,e||{},g,m)};t===Ir&&this.config.__preview_capture_bot_pageviews&&h&&(b.event="$bot_pageview",b.properties.$browser_type="bot"),d&&(b.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens);var y="$feature_flag_called"===t&&!1===b.properties.$feature_flag_has_experiment&&!0===this.get_property(Yi);(null==i?void 0:i.$set)&&!y&&(b.$set=null==i?void 0:i.$set);var w=null==i?void 0:i.$unset;w&&(b.$unset=w);var E,S,k,T=y?void 0:this.Bn(null==i?void 0:i.$set_once,t!==Mr,t===Ar);if(T&&(b.$set_once=T),null!=i&&i._noTruncate||(o=this.config.properties_string_max_length,a=b,l=t=>J(t)?t.slice(0,o):t,u=new Set,b=function t(e,i){if(e!==Object(e))return l?l(e):e;if(!u.has(e)){var r;if(u.add(e),q(e))r=[],Fr(e,(e=>{r.push(t(e))}));else{var s={};Dr(e,((e,i)=>{u.has(e)||(s[i]=t(e,i))})),r=s}return r}}(a)),b.timestamp=g,K(null==i?void 0:i.timestamp)||(b.properties.$event_time_override_provided=!0,b.properties.$event_time_override_system_time=p),y&&(b.properties=function(t,e){void 0===e&&(e=[]);var i={},r=e=>{void 0!==t[e]&&(i[e]=t[e])};return x.forEach(r),e.forEach(r),i}(b.properties,Ba)),t===Yn.DISMISSED||t===Yn.SENT){var R,P,O=null==(R=e)?void 0:R[Qn.SURVEY_ID],I=null==(P=e)?void 0:P[Qn.SURVEY_ITERATION];Sa({id:O,current_iteration:I}),b.$set=_({},b.$set,{[(E={id:O,current_iteration:I},S=t===Yn.SENT?"responded":"dismissed",k="$survey_"+S+"/"+E.id,E.current_iteration&&E.current_iteration>0&&(k="$survey_"+S+"/"+E.id+"/"+E.current_iteration),k)]:!0})}else t===Yn.SHOWN&&(b.$set=_({},b.$set,{[Qn.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===to.SHOWN){var C,A=null==(C=e)?void 0:C[eo.TOUR_TYPE];A&&(b.$set=_({},b.$set,{[eo.TOUR_LAST_SEEN_DATE+"/"+A]:(new Date).toISOString()}))}var M=_({},b.properties.$set,b.$set);if(G(M)||this.setPersonPropertiesForFlags(M),!X(this.config.before_send)){var F=this.Pt(b);if(!F)return;(b=F).uuid=be(b.uuid,Xr)}this.vn.emit("eventCaptured",b);var D=null!==(n=null==i?void 0:i._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),N={method:"POST",url:D,data:b,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(D)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey,transport:null==i?void 0:i.transport};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.In(N):this.En.enqueue(N),b}mi.critical("This capture call is ignored due to client rate limiting.")}}else mi.error("No event name provided to posthog.capture")}else mi.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(e=>t(e.event,e)))}Hn(){var t;return null!==(t=this.An)&&void 0!==t?t:this.An=new Aa(this)}fn(t){this.bn.push(t);var e=!0;return()=>{if(e){e=!1;var i=this.bn.indexOf(t);-1!==i&&this.bn.splice(i,1)}}}calculateEventProperties(e,i,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return i;var l=a?void 0:this.persistence.remove_event_timer(e),h=_({},i);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.mn()&&(h[br]=!0),"$snapshot"===e){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return h.distinct_id=d.distinct_id,(!J(h.distinct_id)&&!Z(h.distinct_id)||Y(h.distinct_id))&&mi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}var v,f=function(e,i,r,n){var o,a,l,h;if(void 0===n&&(n=!1),!u)return{};var d,v=e?[...xn,...i||[]]:[],f=function(t){for(var e=0;_e.length>e;e++){var i=_e[e],r=i[1],s=i[0].exec(t),n=s&&(V(r)?r(s,t):r);if(n)return n}return["",""]}(u),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};K(r)||(m.detectGoogleSearchApp=r);var b={},y=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,E=null==t||null==(h=t.screen)?void 0:h.height,S=null==t?void 0:t.devicePixelRatio;K(y)||(b.userAgentDataPlatform=y),K(w)||(b.maxTouchPoints=w),K(x)||(b.screenWidth=x),K(E)||(b.screenHeight=E),K(S)||(b.devicePixelRatio=S);var k,T,R,P,O,I,C,A,M=Nr(Br({$os:p,$os_version:_,$browser:ce(u,navigator.vendor,g,m),$device:ge(u),$device_type:(T=u,R=b,A=ge(T),A===bt||A===mt||"Kobo"===A||"Kindle Fire"===A||A===Jt?gt:A===Ut||A===jt||A===Lt||A===Wt?"Console":A===wt?"Wearable":A?ft:"Android"===(null==R?void 0:R.userAgentDataPlatform)&&(null!==(P=null==R?void 0:R.maxTouchPoints)&&void 0!==P?P:0)>0?600>Math.min(null!==(O=null==R?void 0:R.screenWidth)&&void 0!==O?O:0,null!==(I=null==R?void 0:R.screenHeight)&&void 0!==I?I:0)/(null!==(C=null==R?void 0:R.devicePixelRatio)&&void 0!==C?C:1)?ft:gt:"Desktop"),$timezone:Mn(),$timezone_offset:Fn()}),{$current_url:gn(n?ye(null==s?void 0:s.href):null==s?void 0:s.href,v,Sn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:pe(u,navigator.vendor,g,m),$browser_language:Pn(),$browser_language_prefix:(k=Pn(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(M.$sdk_dist_channel=c.SDK_DIST_CHANNEL),M}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime()),g=p.windowId;h.$session_id=p.sessionId,h.$window_id=g}this.sessionPropsManager&&Nr(h,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&Nr(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null==(m=this.Pn)?void 0:m.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===ga&&(h.$lib_custom_api_host=this.config.api_host),v=e!==Ir||a?e!==Cr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),h=Nr(h,v),e===Ir&&r&&(h.title=r.title),!K(l)){var b=n.getTime()-l;h.$duration=parseFloat((b/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");var y=this.persistence.properties(),w=this.sessionPersistence.properties();Dr(["$referrer","$referring_domain"],(t=>{t in y&&delete w[t]})),(h=Nr({},f,y,w,h)).$is_identified=this._isIdentified(),q(this.config.property_denylist)?Dr(this.config.property_denylist,(function(t){delete h[t]})):mi.error(ja+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(mi.error(La),h=x(h,e));var E=this.Un();return h.$process_person_profile=E,E&&!a&&this.zn("_calculate_event_properties"),h}Bn(t,e,i){var r;if(void 0===e&&(e=!0),void 0===i&&(i=!1),!this.persistence||!this.Un())return t;if(this.yn&&!i)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=Nr({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(mi.error(La),o=a(o,"$set_once")),e&&(this.yn=!0),G(o)?void 0:o}register(t,e){var i;null==(i=this.persistence)||i.register(t,e)}register_once(t,e,i){var r;null==(r=this.persistence)||r.register_once(t,e,i)}register_for_session(t){var e;null==(e=this.sessionPersistence)||e.register(t)}unregister(t){var e;null==(e=this.persistence)||e.unregister(t)}unregister_for_session(t){var e;null==(e=this.sessionPersistence)||e.unregister(t)}Wn(t,e){this.register({[t]:e})}getFeatureFlag(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(t,e)}getFeatureFlagPayload(t){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagPayload(t)}getFeatureFlagResult(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(t,e)}getAllFeatureFlags(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,e){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,e))&&void 0!==i?i:null==e?void 0:e.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,e,i){var r;null==(r=this.featureFlags)||r.updateFlags(t,e,i)}updateEarlyAccessFeatureEnrollment(t,e,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,e,i)}getEarlyAccessFeatures(t,e,i){var r;return void 0===e&&(e=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,e,i)}on(t,e){return this.vn.on(t,e)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Ua}),()=>{})}onSessionId(t){var e,i;return null!==(e=null==(i=this.sessionManager)?void 0:i.onSessionId(t))&&void 0!==e?e:()=>{}}getSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getSurveys(t,e):t([],{isLoaded:!1,error:Ua})}getActiveMatchingSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,e):t([],{isLoaded:!1,error:Ua})}renderSurvey(t,e){var i;null==(i=this.surveys)||i.renderSurvey(t,e)}displaySurvey(t,e){var i;void 0===e&&(e=ka),null==(i=this.surveys)||i.displaySurvey(t,e)}cancelPendingSurvey(t){var e;null==(e=this.surveys)||e.cancelPendingSurvey(t)}canRenderSurvey(t){var e,i;return null!==(e=null==(i=this.surveys)?void 0:i.canRenderSurvey(t))&&void 0!==e?e:{visible:!1,disabledReason:Ua}}canRenderSurveyAsync(t,e){var i,r;return void 0===e&&(e=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,e))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ua})}Vn(t){return!t||Y(t)?(mi.critical("Unique user id has not been set in posthog.identify"),!1):t===mr?(mi.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(mi.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,e,i){if(!this.__loaded||!this.persistence)return mi.uninitializedWarning("posthog.identify");if(Z(t)&&(t=t.toString(),mi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Vn(t)&&this.zn("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Ei)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),t!==r&&t!==this.get_property($i)&&(this.unregister($i),this.register({distinct_id:t}));var s,n=(this.persistence.get_property(dr)||kr)===kr,o=t!==r,a=!o&&n;if(o&&n)this.persistence.set_property(dr,Tr),this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!1),this.capture(Ar,{distinct_id:t,$anon_distinct_id:r},{$set:e||{},$set_once:i||{}}),this.kn=ca(t,e,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r);else if(a){this.persistence.set_property(dr,Tr);var l=e||{},u=i||{};this.setPersonPropertiesForFlags({$set:l,$set_once:u},!1),this.capture("$set",{$set:l,$set_once:u}),this.kn=ca(t,e,i)}else(e||i)&&this.setPersonProperties(e,i);o?(this.reloadFeatureFlags(),this.unregister(ar)):a&&(e||i)&&this.reloadFeatureFlags()}}setPersonProperties(t,e){if((t||e)&&this.zn("posthog.setPersonProperties")){var i=ca(this.get_distinct_id(),t,e);this.kn!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:e||{}},!0),this.capture("$set",{$set:t||{},$set_once:e||{}}),this.kn=i):mi.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var e,i=(q(t)?t:[t]).filter((t=>J(t)&&t.length>0));0!==i.length&&this.zn("posthog.unsetPersonProperties")&&(null==(e=this.featureFlags)||e.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.kn=null)}group(t,e,i){if(t&&e){var r=this.getGroups(),s=r[t]!==e;if(s&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},r,{[t]:e})}),s||i){var n={$group_type:t,$group_key:e};i&&(n.$group_set=i),this.capture(Mr,n)}i&&this.setGroupPropertiesForFlags({[t]:i}),s&&!i&&this.reloadFeatureFlags()}else mi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(t,e)}resetPersonPropertiesForFlags(t){var e;void 0===t&&(t=!0),null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),this.zn("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(t,e))}resetGroupPropertiesForFlags(t){var e;null==(e=this.featureFlags)||e.resetGroupPropertiesForFlags(t)}reset(t){this.Zn(t)}Zn(t,e){var i,r,s,n,o,a,l,u,h,d;if(void 0===e&&(e=!1),mi.info("reset"),!this.__loaded)return mi.uninitializedWarning("posthog.reset");var v,c=this.get_property(Ei),f=this.get_property(Si),p=this.get_property(Di),_=this.is_capturing();if(this.consent.reset(),e||!_||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after."),null==(i=this.persistence)||i.clear(),null==(r=this.sessionPersistence)||r.clear(),K(p)||null==(v=this.persistence)||v.register({[Di]:p}),null==(s=this.surveys)||s.reset(),null==(n=this.Nn)||n.stop(),null==(o=this.featureFlags)||o.reset(),null==(a=this.conversations)||a.reset(),null==(l=this.logs)||l.reset(),null==(u=this.metrics)||u.reset(),null==(h=this.persistence)||h.set_property(dr,kr),null==(d=this.sessionManager)||d.resetSessionId(),this.kn=null,this.config.cookieless_mode===$r)this.register_once({distinct_id:mr,$device_id:null},"");else{var g=this.config.get_device_id(Xr());this.register_once({distinct_id:g,$device_id:t?g:c},""),t||K(f)||this.register({[Si]:f})}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(t){var e=this;return p((function*(){var t,i,r,s,n,o,a;e.__loaded?(null==(t=e.Nn)||t.stop(),null==(i=e.An)||i.dispose(),null==(r=e.logs)||r.flushLogs("sendBeacon"),null==(s=e.metrics)||s.flush("sendBeacon"),null==(n=e.En)||n.unload(),null==(o=e.Pn)||o.unload(),null==(a=e.featureFlags)||a.destroy()):mi.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,e){var i;this.config.identity_distinct_id=t,this.config.identity_hash=e,this.alias(t),null==(i=this.conversations)||i.Gn()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.Qn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,e;return null!==(t=null==(e=this.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var e=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=e.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+e.sessionId);if(null!=t&&t.withTimestamp&&i){var s,n=null!==(s=t.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(t,e){return t===this.get_property(xi)?(mi.critical("Attempting to create alias for existing People user - aborting."),-2):this.zn("posthog.alias")?(K(e)&&(e=this.get_distinct_id()),t!==e?(this.Wn($i,t),this.capture("$create_alias",{alias:t,distinct_id:e})):(mi.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var e=_({},this.config);if(W(t)){var i,r,s,n,o,a,l,u,h,d,v;Nr(this.config,Wa(t));var f=this.Tn();null==(i=this.persistence)||i.update_config(this.config,e,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ln(_({},this.config,{persistence:"sessionStorage"}),f,!1);var p=this.Sn(this.config.debug);et(p)&&(this.config.debug=p),et(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,ss.P()&&ss.A("ph_debug",!0),mi.info("set_config",{config:t,oldConfig:e,newConfig:_({},this.config)})):(c.DEBUG=!1,ss.P()&&ss.F("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(s=this.exceptions)||s.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(o=this.tracingHeaders)||o.startIfEnabledOrStop(),null==(a=this.autocapture)||a.startIfEnabled(),null==(l=this.heatmaps)||l.startIfEnabled(),null==(u=this.exceptionObserver)||u.startIfEnabledOrStop(),null==(h=this.deadClicksAutocapture)||h.startIfEnabledOrStop(),null==(d=this.surveys)||d.loadIfEnabled(),this.Jn(),null==(v=this.externalIntegrations)||v.startIfEnabledOrStop()}}_overrideSDKInfo(t,e){c.LIB_NAME=t,c.LIB_VERSION=e}startSessionRecording(t){var e,i,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(e=this.sessionManager)||e.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 t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,e){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(_({},r,e))}}addExceptionStep(t,e){var i;null==(i=this.exceptions)||i.addExceptionStep(t,e)}captureLog(t){var e;null==(e=this.logs)||e.captureLog(t)}get logger(){var t,e;return null!==(t=null==(e=this.logs)?void 0:e.logger)&&void 0!==t?t:Ka.Kn}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var e,i;return null!==(e=null==(i=this.toolbar)?void 0:i.loadToolbar(t))&&void 0!==e&&e}get_property(t){var e;return null==(e=this.persistence)?void 0:e.props[t]}getSessionProperty(t){var e;return null==(e=this.sessionPersistence)?void 0:e.props[t]}toString(){var t,e=null!==(t=this.config.name)&&void 0!==t?t:za;return e!==za&&(e=za+"."+e),e}_isIdentified(){var t,e;return(null==(t=this.persistence)?void 0:t.get_property(dr))===Tr||(null==(e=this.sessionPersistence)?void 0:e.get_property(dr))===Tr}Un(){var t,e;return!("never"===this.config.person_profiles||this.config.person_profiles===Rr&&!this._isIdentified()&&G(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[$i])&&(null==(e=this.persistence)||null==(e=e.props)||!e[gr]))}qn(){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.Un()||this.zn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.zn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}zn(t){return"never"===this.config.person_profiles?(mi.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Wn(gr,!0),!0)}Tn(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Sr)}Jn(){var t,e,i,r,s=this.Tn();return(null==(t=this.persistence)?void 0:t.ki)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(e=this.sessionPersistence)?void 0:e.ki)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(t){var e;if(this.config.cookieless_mode!==$r){if(this.mn()){var i,r,s,n,o;this.Zn(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ua(this),this.pageViewManager=new un(this),this.persistence&&(this.sessionPropsManager=new oa(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=Ka.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.gn(this.sessionRecording,new l(this)),this.dn&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.dn)))}var u,h;this.consent.optInOut(!0),this.Jn(),this.Dn(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),this.config.cookieless_mode==Sr&&(null==(u=this.surveys)||u.loadIfEnabled()),(K(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(h=null==t?void 0:t.captureEventName)&&void 0!==h?h:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$n()}else mi.warn(Na)}opt_out_capturing(){var t,e,i;this.config.cookieless_mode!==$r?(this.config.cookieless_mode===Sr&&this.consent.isOptedIn()&&this.Zn(!0,!0),this.consent.optInOut(!1),this.Jn(),this.config.cookieless_mode===Sr&&(this.register({distinct_id:mr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.$n(),this.Dn())):mi.warn(Na)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===$r||(this.config.cookieless_mode===Sr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Jn()}_is_bot(){return i?ha(i,this.config.custom_blocked_useragents):void 0}$n(){r&&("visible"===r.visibilityState?this._n||(this._n=!0,this.capture(Ir,{title:r.title},{send_instantly:!0}),this.wn&&(r.removeEventListener(Pr,this.wn),this.wn=null)):this.wn||(this.wn=this.$n.bind(this),qr(r,Pr,this.wn)))}debug(e){!1===e?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Ji(){var t=this.Cn||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(mi.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):function(t,e,i,r,s){var n=e in t&&!X(t[e]),o=i in t&&!X(t[i]);return n?t[e]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+e+"' instead. The old field will be removed in a future major version."),t[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,mi)}Pt(t){var e;if(X(this.config.before_send))return t;var i=Object.keys(null!==(e=t.properties)&&void 0!==e?e:{}).filter(st),r=q(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r){if(s=n(s),X(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return rt(t.event)?mi.warn(o+". This can cause unexpected behavior."):mi.info(o),null}s.properties&&!G(s.properties)||mi.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&X(s.properties[a]))return mi.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.ui)?void 0:t.pageViewId}captureTraceFeedback(t,e){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:e})}captureTraceMetric(t,e,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:e,$ai_metric_value:String(i)})}Sn(t){var e=et(t)&&!t,i=ss.P()&&"true"===ss.q("ph_debug");return!e&&(!!i||t)}}Ka.__defaultExtensionClasses={},Ka.Kn=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=jr(t.prototype[e[i]])}(Ka,["identify"]);class Ja{constructor(t){this.disabled=!1===t;var e=W(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Ya="$copy_autocapture",Qa=bi("[AutoCapture]");function Xa(t,e){return e.length>t?e.slice(0,t)+"...":e}function Za(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!gs(e));return e}function tl(e,i){var r,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!gs(e))return{props:{}};for(var d=[e],v=new Set([e]),c=e;c.parentNode&&!ms(c,"body")&&ws>d.length;)if(ys(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!gs(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],b={},y=!1,w=!1;if(Dr(d,(t=>{var e=js(t);if(ms(t,"a")){var i=t.getAttribute("href");y=!!(e&&i&&Js(i))&&(h?ye(i):i)}N(Ss(t),"ph-no-capture")&&(w=!0),m.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};Rs.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xa(1024,Ys(t)):Xa(1024,ks(t)));var a=Ss(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),Dr(t.attributes,(function(i){var n;if((!Bs(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Js(i.value)&&(!J(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=xs(a).join(" ")),o["attr__"+i.name]=Xa(1024,"href"===i.name&&s?ye(a):a)}}));for(var l=1,u=1,h=t;h=Za(h);)l++,h.tagName===t.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(t,o,a,l,h));var r=function(t){if(!js(t))return{};var e={};return Dr(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Js(r)&&(e[i]=r)}})),e}(t);Nr(b,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=ms(e,"a")||ms(e,"button")?Ys(e):ks(e)),y){var x,E;m[0].attr__href=y;var S=null==(x=pn(y))?void 0:x.host,k=null==t||null==(E=t.location)?void 0:E.host;S&&k&&S!==k&&(p=y)}return{props:Nr({$event_type:n.type,$ce_version:1},u?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var e,i,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(i=t.nth_of_type)&&void 0!==i?i:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ur(n).sort(((t,e)=>t[0].localeCompare(e[0]))).forEach((t=>{var e=t[1];return o[Xs(t[0].toString())]=Xs(e.toString())})),(r+=":")+Ur(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Zs(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ur(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},b)}}var el=bi("[ExceptionAutocapture]"),il=()=>{},rl=bi("[TracingHeaders]"),sl=bi("[Web Vitals]"),nl=9e5,ol="disabled",al="lazy_loading",ll="awaiting_config",ul="missing_config";bi("[SessionRecording]"),bi("[SessionRecording]");var hl="[SessionRecording]",dl=bi(hl),vl=bi("[Heatmaps]");function cl(t){return W(t)&&"clientX"in t&&"clientY"in t&&Z(t.clientX)&&Z(t.clientY)}var fl=bi("[Product Tours]"),pl=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Mi))},_l=["$set_once","$set"],gl=bi("[SiteApps]"),ml="Error while initializing PostHog app with config id ";function bl(t,e,i){if(X(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class yl{constructor(t){this.Yn=new aa,this.Xn=(t,e)=>this.ts(t,e)&&this.es(t,e)&&this.rs(t,e)&&this.ns(t,e),this.ts=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.ss=new Set,this.os=new Set}init(){var t,e;K(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!K(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.os)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.ss)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.ss.has(t)||this.ss.has(e.event))&&this.os&&(null==(i=this.os)?void 0:i.size)>0&&this.os.forEach((t=>{this.ls(e,t)&&this.Yn.emit("actionCaptured",t.name)}))}us(t){this.onAction("actionCaptured",(e=>t(e)))}ls(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Xn(t,i))return!0;return!1}onAction(t,e){return this.Yn.on(t,e)}es(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!bl(r,e.url,e.url_matching||"contains"))return!1}return!0}rs(t,e){return!!this.hs(t,e)&&!!this.ds(t,e)&&!!this.vs(t,e)}hs(t,e){var i;if(null==e||!e.href)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>bl(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&bl((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}ds(t,e){var i;if(null==e||!e.text)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>bl(t.text,e.text,e.text_matching||"exact")||bl(t.$el_text,e.text,e.text_matching||"exact")));var s,n,o,a=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!X(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(a),n=e.text,o=e.text_matching||"exact",s.some((t=>bl(t,n,o))))}vs(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}cs(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}ns(t,e){return null==e||!e.properties||0===e.properties.length||_a(e.properties.reduce(((t,e)=>{var i=q(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class wl{constructor(t){var e;this.fs=[],this._instance=t,this.ps=new Map,this.gs=new Map,this.ys=new Map,null==(e=this._instance)||null==e.onSessionId||e.onSessionId((t=>this.bs(t)))}_s(t){return!1}ws(){return null}xs(t){}ks(){}Ss(t,e){return!!t&&_a(t.propertyFilters,null==e?void 0:e.properties)}Cs(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Ms(t,e,i){var r=(i===zn.Activation?this.ps:this.gs).get(t),s=[];return this.Ts((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Ss(n,e)}))}register(t){var e;K(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Es(t),this.Is(t))}Is(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Ps&&(this.Ps=new yl(this._instance),this.Ps.init(),this.Ps.us((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Ps)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.ys.get(e.name);i&&i.push(t.id),this.ys.set(e.name,i||[t.id])}})))})))}Es(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.ps=this.Cs(t,zn.Activation),this.gs=this.Cs(t,zn.Cancellation))}onEvent(t,e){var i,r,s=this.Rs(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Ls(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Os([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Fs(n),void this.As([n])}if(this.gs.has(t)){var a=this.Ms(t,e,zn.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.Os(a.map((t=>t.id))),a.forEach((t=>this.Ds(t.id))))}if(this.ps.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.ps.get(t)});var l=this.Ms(t,e,zn.Activation);this.$s(l.map((t=>t.id)))}}onAction(t){this.ys.has(t)&&this.$s(this.ys.get(t)||[])}$s(t){var e;if(0!==t.length){var i=!(null==(e=this._instance)||null==e.get_session_id||!e.get_session_id()),r=[];for(var s of t)i&&this._s(s)?this.Fs(s)&&this.Ns(s):r.push(s);r.length>0&&(this.fs=[...new Set([...this.fs,...r])]),this.Rs().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Fs(t){this.fs=this.fs.filter((e=>e!==t));var e=this.qs();return!e.includes(t)&&(this.js([...e,t]),this.Bs(),!0)}Os(t){var e=new Set(t);this.fs=this.fs.filter((t=>!e.has(t)));var i=this.Hs(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&(this.js(r),0===r.length&&this.Us()),this.As(t)}zs(){var t,e=this.ws();if(!e)return{};var i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e];return i&&"object"==typeof i?i:{}}Ns(t){if(this.ws()){var e=this.zs();this.xs(_({},e,{[t]:Date.now()}))}}As(t){if(this.ws()){var e=this.zs(),i={},r=!1;for(var s of Object.entries(e)){var n=s[0],o=s[1];t.includes(n)?r=!0:i[n]=o}r&&(G(i)?this.ks():this.xs(i))}}Ws(){this.ws()&&this.ks()}getActivationTimestamp(t){if(this.qs().includes(t)){var e=this.zs()[t];return Z(e)?e:void 0}}Hs(){var t,e=this.Vs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}qs(){var t,e,i=this.Hs();if(0===i.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zs()],s=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();return s&&r===s?i:[]}Bs(){var t,e=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();e&&this.Gs(e)}Us(){this.Qs()}bs(t){var e,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this.Zs()];if(i&&i!==t){var r=this.Hs(),s=this.zs();r.length>0&&(this.js([]),r.filter((t=>Z(s[t]))).forEach((t=>this.Ds(t)))),this.Us(),this.Ws()}}getActivatedIds(){return[...new Set([...this.qs(),...this.fs])].filter((t=>!this.Js(t)))}reset(){this.fs=[],this.Hs().length>0&&this.js([]),this.Us(),this.Ws()}getEventToItemsMap(){return this.ps}Ks(){return this.Ps}}class xl extends wl{constructor(t){super(t)}Vs(){return rr}Zs(){return sr}ws(){return nr}xs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[nr]:t})}ks(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(nr)}_s(t){var e,i;this.Ts((e=>{i=e.find((e=>e.id===t))}));var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return Z(r)&&r>0}Ys(){return Yn.SHOWN}Ts(t){var e;null==(e=this._instance)||e.getSurveys(t)}Ds(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rs(){return xa}js(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[rr]:t})}Gs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[sr]:t})}Qs(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(sr)}Js(){return!1}Ls(t,e){var i;this.Ts((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e;return wa(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(i);return r?t===Yn.SHOWN?"consume":"ignore":t===Yn.SHOWN?"persist":t===Yn.DISMISSED||t===Yn.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var El="SDK is not enabled or survey functionality is not yet loaded",Sl="Disabled. Not loading surveys.",$l=null!=t&&t.location?mn(t.location.hash,"__posthog")||mn(location.hash,"state"):null,kl="_postHogToolbarParams",Tl=bi("[Toolbar]"),Rl=bi("[FeatureFlags]"),Pl=bi("[FeatureFlags]",{debugEnabled:!0}),Ol="\" failed. Feature flags didn't load in time.",Il=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Cl=t=>{var e={};for(var i of Ur(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Al=bi("[Error tracking]"),Ml="Refusing to render web experiment since the viewer is a likely bot",Fl={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>va(e,t),not_regex:(t,e)=>!va(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class Dl{get Pe(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{Dl.Xs("retrieved web experiments from the server"),e.ta=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.ta&&(Dl.Xs("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.ta)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);J(r)&&t.variants[r]&&e.ea(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Dl.ia(n,e._instance)&&e.ea(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Dl.Xs(Ml);else if(!this.Pe.disable_web_experiments){if(X(this.ta))return this.ta=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Dl.Xs("applying feature flags",t),t.forEach((t=>{var e;if(this.ta&&null!=(e=this.ta)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.ta)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.ea(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Dl.getWindowLocation();if(null!=t&&t.search){var e=_n(null==t?void 0:t.search,"__experiment_id"),i=_n(null==t?void 0:t.search,"__experiment_variant");e&&i&&(Dl.Xs("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ra(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Pe.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Pe.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Pe.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ra(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(Dl.Xs("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.ea(r[0].name,e,r[0].variants[e].transforms))}static ia(t,e){return!X(t.conditions)&&Dl.na(t,e)&&Dl.sa(t)}static na(t,e){var i;if(X(t.conditions)||X(null==(i=t.conditions)?void 0:i.url))return!0;var r=Dl.getWindowLocation();if(r){var s,n,o,a=ds(e,r.href);return null==(s=t.conditions)||!s.url||Fl[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static sa(t){var e;if(X(t.conditions)||X(null==(e=t.conditions)?void 0:e.utm))return!0;var i=kn();if(i.utm_source){var r,s,n,o,a,l,u,h,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return d&&c&&f&&v}return!1}static Xs(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mi.info("[WebExperiments] "+t,i)}ea(t,e,i){this._is_bot()?Dl.Xs(Ml):"control"!==e?i.forEach((i=>{if(i.selector){var r;Dl.Xs("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):Dl.Xs("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?ha(i,this.Pe.custom_blocked_useragents):void 0}}var Nl=bi("[Conversations]"),Ul="Conversations not available yet.",Ll="console",jl="__posthogHandledLogsRequestError",Bl=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[jl]=!0,i},zl=t=>!!t&&"object"==typeof t&&!0===t[jl],Hl={featureFlags:class{constructor(e){this.aa=!1,this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=0,this.pa=()=>{var t=this.ga();this.fa=0,t&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],t&&qr(t,"online",this.pa)}destroy(){null==t||t.removeEventListener("online",this.pa)}get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}ma(t){return this._instance.get_property(t)}ya(){var t,e;return null!==(t=null==(e=this.Tr)?void 0:e.Ci(this.Pe.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ba(){return!!this.ya()&&(this.ca||this.la||(this.ca=!0,Rl.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_a(){var t,e=null!==(t=this.Pe.evaluation_contexts)&&void 0!==t?t:this.Pe.evaluation_environments;return!this.Pe.evaluation_environments||this.Pe.evaluation_contexts||this.va||(Rl.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.va=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Rl.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}wa(){return this._a().length>0}xa(){var t=this.Pe.flag_keys;if(!K(t)){if(q(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Rl.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Rl.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,i=this._instance.config,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};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((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,e)=>(o[e]&&(t[e]=o[e]),t)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var r,s,n=null!=i&&i.merge&&null!==(r=this.ma(qi))&&void 0!==r?r:{},o=null!=i&&i.merge&&null!==(s=this.ma(Ki))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,e),u={};for(var h of Object.entries(a)){var d=h[0],v=h[1];u[d]={key:d,enabled:b(v),variant:y(v),reason:void 0,metadata:K(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.receivedFeatureFlags({flags:u})}get hasLoadedFlags(){return this.oa}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ma(Gi),e=this.ma(Qi),i=this.ma(Xi);if(!i&&!e)return t||{};var r=Nr({},t||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of s){var o,a,l=r[n],u=null==e?void 0:e[n],h=K(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=K(u)?l.variant:"string"==typeof u?u:void 0,v=null==i?void 0:i[n],c=_({},l,{enabled:h,variant:h?null!=d?d:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.aa||(Rl.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:r}),this.aa=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:b(r),variant:y(r),payload:m(e[i])}}))}getFlagVariants(){var t=this.ma(qi),e=this.ma(Qi);if(!e)return t||{};for(var i=Nr({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.aa||(Rl.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.aa=!0),i}getFlagPayloads(){var t=this.ma(Ki),e=this.ma(Xi);if(!e)return t||{};for(var i=Nr({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.aa||(Rl.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.aa=!0),i}reloadFeatureFlags(){this.ua||this.Pe.advanced_disable_feature_flags||this.ga()||this.ka||(this._instance.vn.emit("featureFlagsReloading",!0),this.ka=setTimeout((()=>{this.Sa()}),5))}Ca(){clearTimeout(this.ka),this.ka=void 0}ensureFlagsLoaded(){this.oa||this.la||this.ka||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ua=t}Sa(t){var e;if(this.Ca(),!this._instance.Ji()&&!this.ga())if(this.la)this.ha=!0;else{var i=this.Pe.token,r=this.ma(Ei),s={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},(null==(e=this.Tr)?void 0:e.get_initial_props())||{},this.ma(Zi)||{},{$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION}),group_properties:this.ma(tr),timezone:Mn()};Q(r)||K(r)||(s.$device_id=r),(null!=t&&t.disableFlags||this.Pe.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.wa()&&(s.evaluation_contexts=this._a());var n=this.xa();K(n)||(s.flag_keys=n);var o=!!this.Pe.advanced_only_evaluate_survey_feature_flags,a=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Pe.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.la=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this.Pe.disable_compression?void 0:Bn.Base64,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,n=!0;if(this.Ma(t.statusCode),200===t.statusCode&&(this.ha||(this.$anon_distinct_id=void 0),n=!1),this.la=!1,!s.disable_flags||this.ha){this.da=!n;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Tr)||r.register({[ur]:a}),u)Rl.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 s.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},n,{partialResponse:o}),this.ha&&(this.ha=!1,this.Sa())}}})}}ga(){return bn(this.fa,3)}Ma(t){this.fa=yn(t,this.fa,3,(()=>Rl.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else Rl.warn('getFeatureFlag for key "'+t+Ol)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],o=String(s),a=this.ma(Ji)||void 0,l=this.ma(hr)||void 0,u=this.ma(ar)||{};if(this.Pe.advanced_feature_flags_dedup_per_session){var h,d=this._instance.get_session_id(),v=this.ma(lr);d&&d!==v&&(u={},null==(h=this.Tr)||h.register({[ar]:u,[lr]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(o))){var c,f,p,_,g,b,y,w,x,E,S;q(u[t])?u[t].push(o):u[t]=[o],null==(c=this.Tr)||c.register({[ar]:u});var k=this.getFeatureFlagDetails(t),T=[...null!==(f=this.ma(ur))&&void 0!==f?f:[]];K(s)&&T.push("flag_missing");var R={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(p=this.Pe.bootstrap)||null==(p=p.featureFlags)?void 0:p[t])||null,$feature_flag_bootstrapped_payload:(null==(_=this.Pe.bootstrap)||null==(_=_.featureFlagPayloads)?void 0:_[t])||null,$used_bootstrap_value:!this.da};K(null==k||null==(g=k.metadata)?void 0:g.has_experiment)||(R.$feature_flag_has_experiment=k.metadata.has_experiment),K(null==k||null==(b=k.metadata)?void 0:b.version)||(R.$feature_flag_version=k.metadata.version);var P,O=null!==(y=null==k||null==(w=k.reason)?void 0:w.description)&&void 0!==y?y:null==k||null==(x=k.reason)?void 0:x.code;O&&(R.$feature_flag_reason=O),null!=k&&null!=(E=k.metadata)&&E.id&&(R.$feature_flag_id=k.metadata.id),K(null==k?void 0:k.original_variant)&&K(null==k?void 0:k.original_enabled)||(R.$feature_flag_original_response=K(k.original_variant)?k.original_enabled:k.original_variant),null!=k&&null!=(S=k.metadata)&&S.original_payload&&(R.$feature_flag_original_payload=null==k||null==(P=k.metadata)?void 0:P.original_payload),T.length&&(R.$feature_flag_error=T.join(",")),this._instance.capture("$feature_flag_called",R)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:m(n)}}}else Rl.warn('getFeatureFlagResult for key "'+t+Ol)}getRemoteConfigPayload(t,e){var i=this.Pe.token,r={distinct_id:this._instance.get_distinct_id(),token:i,person_properties:{$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION}};this.wa()&&(r.evaluation_contexts=this._a());var s=this.xa();K(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Pe.disable_compression?void 0:Bn.Base64,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.da)return e.defaultValue;if(!(this.oa||this.getFlags()&&this.getFlags().length>0))return Rl.warn('isFeatureEnabled for key "'+t+Ol),e.defaultValue;var i=this.getFeatureFlag(t,e);return K(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){if(this.Tr){this.oa=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(t,e,i,r,s,n){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):t.featureFlags&&Rl.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var h=t.requestId,d=t.evaluatedAt;if(q(l)){Rl.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;e&&e.register({[Vi]:l,[qi]:v,[Yi]:!1})}else{var f=l,p=u,g=a;if(null!=n&&n.partialResponse)f=_({},i,f),p=_({},r,p),g=_({},s,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var e;return!(null!=(e=a[t])&&e.failed)})));f=_({},i,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},r,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},s,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},i,f),p=_({},r,p),g=_({},s,g);e&&e.register(_({[Vi]:Object.keys(Cl(f)),[qi]:f||{},[Ki]:p||{},[Gi]:g||{},[Yi]:!0===t.minimalFlagCalledEvents},h?{[Ji]:h}:{},d?{[hr]:d}:{}))}}}(t,this.Tr,r,s,n,i),e||(this.ca=!1),this.Ta(e)}}override(t,e){void 0===e&&(e=!1),Rl.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Tr)return Rl.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Tr.unregister(Qi),this.Tr.unregister(Xi),this.Ta(),Pl.info("All overrides cleared");if(q(t)){var e=Il(t);return this.Tr.register({[Qi]:e}),this.Ta(),Pl.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.aa=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Tr.unregister(Qi),Pl.info("Flag overrides cleared");else if(r.flags){if(q(r.flags)){var s=Il(r.flags);this.Tr.register({[Qi]:s})}else this.Tr.register({[Qi]:r.flags});Pl.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Tr.unregister(Xi),Pl.info("Payload overrides cleared")):r.payloads&&(this.Tr.register({[Xi]:r.payloads}),Pl.info("Payload overrides set",{payloads:r.payloads}))),void this.Ta()}if(t&&"object"==typeof t)return this.Tr.register({[Qi]:t}),this.Ta(),Pl.info("Flag overrides set",{flags:t});Rl.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oa){var e=this.Ea(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){Rl.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var r,s=(this.ma(Wi)||[]).find((e=>e.flagKey===t)),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=_({},this.getFlagVariants(),{[t]:e});null==(r=this.Tr)||r.register({[Vi]:Object.keys(Cl(a)),[qi]:a}),this.Ta()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.ma(Wi),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Pe.token+s),method:"GET",timestampMode:"query",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Tr)||i.unregister(Wi),null==(r=this.Tr)||r.register({[Wi]:s}),t(s)}}})}Ea(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}Ta(t){var e=this.Ea(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((e=>{try{e(i,r,{errorsLoading:t})}catch(t){Rl.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.ma(Zi)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in i||(n[o]=s[o]));this._instance.register({[Zi]:_({},i,n,r)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=_({},this.ma(Zi)||{});t.forEach((t=>{delete i[t]})),this._instance.register({[Zi]:i}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Zi),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.ma(tr)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((e=>{i[e]=_({},i[e],t[e]),delete t[e]})),this._instance.register({[tr]:_({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.ma(tr)||{};this._instance.register({[tr]:_({},e,{[t]:{}})})}else this._instance.unregister(tr)}reset(){this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.$anon_distinct_id=void 0,this.Ca(),this.aa=!1,this.fa=0}}},ql={sessionRecording:class{get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Ia)||!t.isStarted)}get status(){var t,e;return this.Pa===ll||this.Pa===ul?this.Pa:null!==(t=null==(e=this.Ia)?void 0:e.status)&&void 0!==t?t:this.Pa}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Pa=ol,this.Ra=void 0,this._instance=t,!this._instance.sessionManager)throw dl.error("started without valid sessionManager"),new Error(hl+" started without valid sessionManager. This is a bug.");if(this.Pe.cookieless_mode===$r)throw new Error(hl+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get La(){var e,i=!(null==(e=this._instance.get_property(Di))||!e.enabled),r=!this.Pe.disable_session_recording,s=this.Pe.disable_session_recording||this._instance.consent.isOptedOut();return t&&i&&r&&!s}startIfEnabledOrStop(t){var e;if(!this.La||null==(e=this.Ia)||!e.isStarted){var i=!K(Object.assign)&&!K(Array.from);this.La&&i?(this.Oa(t),dl.info("starting")):(this.Pa=ol,this.stopRecording())}}Oa(t){var e,i,r;this.La&&(this.Pa!==ll&&this.Pa!==ul&&(this.Pa=al),null!=v&&null!=(e=v.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this.Fa(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Aa,(e=>{if(e)return dl.error("could not load recorder",e);this.Fa(t)})))}stopRecording(){var t,e;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(e=this.Ia)||e.stop()}Da(){var t,e;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(e=this.Ia)||e.discard()}$a(){var t,e;null==(t=this.Tr)||t.unregister(Hi),null==(e=this.Tr)||e.unregister(Ni)}Na(t,e){if(X(t))return null;var i,r=Z(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(dl.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}qa(t){if(this.Tr){var e,i,r=this.Tr,s=()=>{var e,i=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Na(null==(e=this.Pe.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),n=this.Na(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:n;X(o)&&this.$a();var a=null==i?void 0:i.minimumDurationMilliseconds;r.register({[Di]:_({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:K(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null==(e=this.Ra)||e.call(this),this.Ra=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.qa(e),void this.Da()):(this.qa(e),void this.startIfEnabledOrStop()):(this.Pa===ll&&(this.Pa=ul,dl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Ia)&&i.log?this.Ia.log(t,e):dl.warn("log called before recorder was ready")}get Aa(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Di);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}ja(){var t,e,i=this._instance.get_property(Di);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return dl.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Fa(t){var e,i;if(null==(e=v.__PosthogExtensions__)||!e.initSessionRecording)return dl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xr]:!0});if(this.Ia||(this.Ia=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Ia._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ja()){if(this.Pa===ul||this.Pa===ll)return;return this.Pa=ll,dl.info("persisted remote config is stale, requesting fresh config before starting"),void new no(this._instance).load()}this.Pa=al,this.Ia.start(t)}onRRwebEmit(t){var e;null==(e=this.Ia)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Ia||null==(e=this.Tr)||e.register({[Li]:!0}),null==(t=this.Ia)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Ia||null==(e=this.Tr)||e.register({[Ui]:!0}),null==(t=this.Ia)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Ia||null==(i=this.Tr)||i.register({["url"===t?ji:Bi]:!0}),null==(e=this.Ia)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Ia)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Ia)||!i.tryAddCustomEvent(t,e))}}},Vl={autocapture:class{constructor(t){this.Ba=!1,this.Ha=null,this.Ua=!1,this.za=!1,this.instance=t,this.rageclicks=new Ja(t.config.rageclick),this.Wa=null}initialize(){this.startIfEnabled()}get Pe(){var t,e,i=W(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Va(){if(this.isBrowserSupported()){if(t&&r){var e=e=>{e=e||(null==t?void 0:t.event);try{this.Za(e)}catch(t){Qa.error("Failed to capture event",t)}};if(qr(r,"submit",e,{capture:!0}),qr(r,"change",e,{capture:!0}),qr(r,"click",e,{capture:!0}),this.Pe.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event);try{this.Za(e,Ya)}catch(t){Qa.error("Failed to capture copy/cut event",t)}};qr(r,"copy",i,{capture:!0}),qr(r,"cut",i,{capture:!0})}}}else Qa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ba&&(this.Va(),this.Ba=!0)}onRemoteConfig(t){if(this.Ua=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.za=e.elementsChainAsString);var i=e.autocapture_opt_out;et(i)&&(this.instance.persistence&&this.instance.persistence.register({[Ti]:i}),this.Ha=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Wa=t}getElementSelectors(t){var e,i=[];return null==(e=this.Wa)||e.forEach((e=>{var s=null==r?void 0:r.querySelectorAll(e);null==s||s.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Ti],r=this.Ha,s=this.instance.Ji()&&!this.Ua;if(Q(r)&&!et(i)&&!s)return!1;var n=null!==(e=this.Ha)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!n}Za(e,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r,s=Ts(e);bs(s)&&(s=s.parentNode||null),"$autocapture"===i&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&Ns(s,this.instance.config.rageclick)&&this.Za(e,"$rageclick");var n=i===Ya;if(s&&function(e,i,r,s,n,o){var a;if(!t||Us(e))return!1;if(null!=r&&r.url_allowlist&&!Es(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Es(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>i.type===t)))return!1}var u=Ls(e,s),h=u.parentIsUsefulElement,d=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(K(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!Ps(d,null==r?void 0:r.css_selector_allowlist))return!1;if(Ps(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:Is))return!1;try{var v=t.getComputedStyle(e);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return h?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(Rs.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.Pe,n,n?["copy","cut"]:void 0,this.instance)){var o=tl(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Pe.element_attribute_ignorelist,elementsChainAsString:this.za,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=o.props;if(o.explicitNoCapture)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),i===Ya){var u,h=$s(null==t||null==(u=t.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!h)return!1;a.$selected_content=h,a.$copy_type=d}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return V(null==r?void 0:r.querySelectorAll)}},historyAutocapture:class{constructor(e){var i;this._instance=e,this.Ga=(null==t||null==(i=t.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Qa&&this.Qa(),this.Qa=void 0,mi.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Ja("pushState"),this.Ja("replaceState"),this.Ka())}Ja(e){var i;if(t&&(null==(i=t.history[e])||!i.__posthog_wrapped__)){var r=this;!function(t,e,i){try{if(!(e in t))return il;var r={next:t[e]},s=i((function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)}));return V(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=s,()=>{if(t[e]!==s)for(var i=t[e];V(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else t[e]=r.next}}catch(t){return il}}(t.history,e,(t=>function(i,s,n){t.call(this,i,s,n),r.Ya(e)}))}}Ya(e){try{var i,r=null==t||null==(i=t.location)?void 0:i.pathname;if(!r)return;r!==this.Ga&&this.isEnabled&&this._instance.capture(Ir,{navigation_type:e}),this.Ga=r}catch(t){mi.error("Error capturing "+e+" pageview",t)}}Ka(){if(!this.Qa){var e=()=>{this.Ya("popstate")};qr(t,"popstate",e),this.Qa=()=>{t&&t.removeEventListener("popstate",e)}}}},heatmaps:class{get Pe(){return this.instance.config}constructor(t){var e;this.Xa=!1,this.Ba=!1,this.eo=null,this.instance=t,this.Xa=!(null==(e=this.instance.persistence)||!e.props[Ri]),this.rageclicks=new Ja(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return W(this.Pe.capture_heatmaps)&&this.Pe.capture_heatmaps.flush_interval_milliseconds&&(t=this.Pe.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return X(this.Pe.capture_heatmaps)?X(this.Pe.enable_heatmaps)?this.Xa:this.Pe.enable_heatmaps:!1!==this.Pe.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ba)return;vl.info("starting..."),this.io(),this.Ie()}else{var t;clearInterval(null!==(t=this.eo)&&void 0!==t?t:void 0),this.ro(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ri]:i}),this.Xa=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.O;return this.O=void 0,t}no(t){cl(t.originalEvent)&&this.ke(t.originalEvent,"deadclick")}Ie(){this.eo&&clearInterval(this.eo),this.eo="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}io(){t&&r&&(this.so=this.pr.bind(this),qr(t,Or,this.so),this.ao=e=>this.ke(e||(null==t?void 0:t.event)),qr(r,"click",this.ao,{capture:!0}),this.oo=e=>this.lo(e||(null==t?void 0:t.event)),qr(r,"mousemove",this.oo,{capture:!0}),this.uo=new sn(this.instance,en,this.no.bind(this)),this.uo.startIfEnabledOrStop(),this.ho=this.Ie.bind(this),qr(r,Pr,this.ho),this.Ba=!0)}ro(){var e;t&&r&&(this.so&&t.removeEventListener(Or,this.so),this.ao&&r.removeEventListener("click",this.ao,{capture:!0}),this.oo&&r.removeEventListener("mousemove",this.oo,{capture:!0}),this.ho&&r.removeEventListener(Pr,this.ho),clearTimeout(this.do),null==(e=this.uo)||e.stop(),this.Ba=!1)}vo(e,i){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,i,r){for(var s=e;s&&gs(s)&&!ms(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(N(i,n))return!0;s=Os(s)}return!1}(Ts(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:i}}ke(t,e){var i;if(void 0===e&&(e="click"),!_s(t.target)&&cl(t)){var r=this.vo(t,e);null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Ns(Ts(t),this.instance.config.rageclick)&&this.Vt(_({},r,{type:"rageclick"})),this.Vt(r)}}lo(t){!_s(t.target)&&cl(t)&&(clearTimeout(this.do),this.do=setTimeout((()=>{this.Vt(this.vo(t,"mousemove"))}),500))}Vt(e){if(t){var i=this.Pe.disable_capture_url_hashes?ye(t.location.href):t.location.href,r=this.Pe.custom_personal_data_properties,s=this.Pe.mask_personal_data_properties?[...xn,...r||[]]:[],n=gn(i,s,Sn);this.O=this.O||{},this.O[n]||(this.O[n]=[]),this.O[n].push(e)}}pr(){this.O&&!G(this.O)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:sn,webVitalsAutocapture:class{constructor(t){var e;this.Xa=!1,this.Ba=!1,this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.co=()=>{clearTimeout(this.fo),this.fo=void 0,0!==this.O.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.O.url},this.O.metrics.reduce(((t,e)=>_({},t,{["$web_vitals_"+e.name+"_event"]:_({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{}))),this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.po=t=>{var e;if(this.O=this.O||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},X(null==t?void 0:t.name)||X(null==t?void 0:t.value))sl.error("Invalid metric received",t);else{var i="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.mo(i);if(!K(r)){var s=Z(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.yo||this.yo>t.value){this.O.navigationKey!==s&&(this.co(),this.fo=setTimeout(this.co,this.flushToCaptureTimeoutMs)),K(this.O.navigationKey)&&(this.O.navigationKey=s,this.O.url=r),this.O.firstMetricTimestamp=K(this.O.firstMetricTimestamp)?Date.now():this.O.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var n=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=_({},t,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});K(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.O.metrics.push(o),this.O.metrics.length===this.allowedMetrics.length&&this.co()}else sl.error("Ignoring metric with value >= "+this.yo,t)}}},this.bo=()=>{if(!this.Ba){var t,e,i,r,s=v.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this._o])||("web-vitals"===this._o&&K(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(K(o)||(t=o.onLCP,e=o.onCLS,i=o.onFCP,r=o.onINP),t&&e&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.po.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&e(this.po.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this.po.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this.po.bind(this),a),this.Ba=!0}else sl.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Xa=!(null==(e=this._instance.persistence)||!e.props[Ci]),this.startIfEnabled()}get wo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=W(this.wo)?null==(t=this.wo)?void 0:t.web_vitals_allowed_metrics:void 0;return X(i)?(null==(e=this._instance.persistence)?void 0:e.props[Fi])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(W(this.wo)?this.wo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=W(this.wo)?this.wo.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=W(this.wo)?this.wo.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get yo(){var t=W(this.wo)&&Z(this.wo.__web_vitals_max_value)?this.wo.__web_vitals_max_value:nl;return t>0&&6e4>=t?nl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return sl.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=W(this.wo)?this.wo.web_vitals:et(this.wo)?this.wo:void 0;return et(e)?e:this.Xa}startIfEnabled(){this.isEnabled&&!this.Ba&&(sl.info("enabled, starting..."),this.ai(this.bo))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=W(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=W(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ci]:i}),this._instance.persistence.register({[Fi]:r})),this.Xa=i,this.startIfEnabled()}}}get _o(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(t){var e=v.__PosthogExtensions__,i=this._o,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&K(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,(e=>{e?sl.error("failed to load script",e):t()}))}mo(e){var i=e||(null==t?void 0:t.location.href);if(i){var r=this._instance.config.disable_capture_url_hashes?ye(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...xn,...s||[]]:[];return gn(r,n,Sn)}sl.error("Could not determine current URL")}}},Wl={exceptionObserver:class{constructor(e){var i;this.bo=()=>{var e;if(t&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var i=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.xo&&this.Pe.capture_unhandled_errors&&(this.xo=i(this.captureException.bind(this))),!this.ko&&this.Pe.capture_unhandled_rejections&&(this.ko=r(this.captureException.bind(this))),!this.So&&this.Pe.capture_console_errors&&(this.So=s(this.captureException.bind(this)))}catch(t){el.error("failed to start",t),this.Co()}}},this._instance=e,this.Mo=!(null==(i=this._instance.persistence)||!i.props[Pi]),this.To=new ct(_({},function(t){var e,i,r,s;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,rt:el})),this.Pe=this.Eo(),this.startIfEnabledOrStop()}Eo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return W(t)?e=_({},e,t):(K(t)?this.Mo:t)&&(e=_({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Pe.capture_console_errors||this.Pe.capture_unhandled_errors||this.Pe.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(el.info("enabled"),this.Co(),this.ai(this.bo)):this.Co()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return el.error("failed to load script",e);t()}))}Co(){var t,e,i;null==(t=this.xo)||t.call(this),this.xo=void 0,null==(e=this.ko)||e.call(this),this.ko=void 0,null==(i=this.So)||i.call(this),this.So=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Mo=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pi]:this.Mo}),this.Pe=this.Eo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Pe=this.Eo()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.To.consumeRateLimit(s)?el.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.Io=[],this.Po=new Be([new Ze,new ui,new ei,new ti,new ai,new oi,new ri,new li],function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=Xe.test(a)?a.replace(Xe,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of i){var h=u(l,t);if(h){s.push(h);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(i=e,i[i.length-1]||{}).filename,function:t.function||ze});var i}))}(s)}}("web:javascript",Ke,Qe)),this._instance=t,this.Io=null!==(e=null==(i=this._instance.persistence)?void 0:i.get_property(Oi))&&void 0!==e?e:[],this.Ro=fi(this.Lo()),this.Oo=new pi(this.Ro)}onConfigChange(){this.Ro=fi(this.Lo()),this.Oo.setConfig(this.Ro)}onRemoteConfig(t){var e,i,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(e=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Io=n,this._instance.persistence&&this._instance.persistence.register({[Oi]:this.Io,[Ii]:o})}}}get Fo(){var t,e=!!this._instance.get_property(Ii),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Po.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.Ro.enabled)try{if(!J(t)||0===t.trim().length)return void Al.warn("Ignoring exception step because message must be a non-empty string");var i=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>vi.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(this.Ao(e)),r=i.sanitizedProperties,s=i.droppedKeys;s.length>0&&Al.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Oo.add(_({[hi]:t,[di]:(new Date).toISOString()},r))}catch(t){Al.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Do(e)){if(this.$o(e))return this.No("Exception dropped: matched a suppression rule"),void Al.info("Skipping exception capture because a suppression rule matched");if(!this.Fo&&this.qo(e))return this.No("Exception dropped: thrown by a browser extension"),void Al.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.jo(e))return this.No("Exception dropped: thrown by the PostHog SDK"),void Al.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Ro.enabled&&X(t.$exception_steps)?this.Bo(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(i.$release_id=r);try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",jn:!0});return s&&this.Oo.clear(),s}catch(t){return Al.error("Failed to capture exception event. Dropping this exception.",t),void this.Oo.clear()}}catch(t){return void Al.error("Failed to process exception event. Ignoring this exception.",t)}var n}Bo(t){try{var e=this.Oo.getAttachable();return 0===e.length?t:_({},t,{$exception_steps:e})}catch(e){return Al.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}No(t){this.Ro.enabled&&this.Oo.add({[hi]:t,[di]:(new Date).toISOString()})}Ao(t){return W(t)?_({},t):{}}Lo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}$o(t){if(0===t.length)return!1;try{var e=t.reduce(((t,e)=>{var i=e.type,r=e.value;return J(i)&&i.length>0&&t.$exception_types.push(i),J(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Io.some((t=>{var i=t.values.map((t=>{var i=fa[t.operator],r=e[t.key];if(!i||!r)return!1;var s=q(t.value)?t.value:[t.value];return s.length>0&&i(s,r)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}catch(t){return Al.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qo(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}jo(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],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}Do(t){return!X(t)&&q(t)}}},Gl=_({productTours:class{get Tr(){return this._instance.persistence}constructor(t){this.Ho=null,this.Uo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Tr&&this.Tr.register({[Mi]:!!e.productTours}),!pl(this._instance))return!this.Ho&&X(null==(i=this.Tr)?void 0:i.props[or])||fl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ho)||r.stop(),this.Ho=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ho&&pl(this._instance)&&this.ai((()=>this.zo()))}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?fl.error("Could not load product tours script",e):t()}))}zo(){var t;!this.Ho&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.Ho=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!q(this.Uo)||e){var i=this.Tr;if(i){var r=i.props[or];if(q(r)&&!e)return this.Uo=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(pl(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||fl.warn(s):fl.error(s),void t([],{isLoaded:!1,error:s})}var n=q(e.json.product_tours)?e.json.product_tours:[];this.Uo=n,i&&i.register({[or]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uo,{isLoaded:!0})}getActiveProductTours(t){X(this.Ho)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ho.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Ho)||e.showTourById(t)}previewTour(t){this.Ho?this.Ho.previewTour(t):this.ai((()=>{var e;this.zo(),null==(e=this.Ho)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Ho)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ho)||t.nextStep()}previousStep(){var t;null==(t=this.Ho)||t.previousStep()}clearCache(){var t;this.Uo=null,null==(t=this.Tr)||t.unregister(or)}resetTour(t){var e;null==(e=this.Ho)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Ho)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Ho)||e.cancelPendingTour(t)}}},Hl),Kl={siteApps:class{constructor(t){this.Wo=0,this._instance=t,this.Vo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zo(t,e){if(e){var i=this.globalsForEvent(e);this.Vo.push(i),this.Vo.length>1e3&&(this.Vo=this.Vo.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zo.bind(this));this.Go=()=>{t(),this.Vo=[],this.Go=void 0}}}globalsForEvent(t){var e,i,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(h)){var v=d[0];l[v]={id:u[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,_l),{properties:_({},t.properties,f?{$set:_({},null!==(e=null==(i=t.properties)?void 0:i.$set)&&void 0!==e?e:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}Qo(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(gl.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(gl.error("prepare_external_dependency_script returned null"),null):t}Jo(){var t,e,i,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var u=null==r?void 0:r.defaultView,h=null==u||null==(t=u.Node)?void 0:t.prototype;if(!u||!h)return()=>{};if(this.Wo++,this.Ko)return this.Yo();var d=[],v=this,c=new WeakSet,f=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),d.push((()=>{t[e]=r}))}},p=t=>{if(c.has(t))return t;var e=v.Qo(t);return e&&c.add(e),e},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!Q(t)));return f(h,"appendChild",(t=>function(e){var i=p(e);return i?t.call(this,i):e})),f(h,"insertBefore",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):e})),f(h,"replaceChild",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):i})),[null==(e=u.Element)?void 0:e.prototype,null==(i=u.Document)?void 0:i.prototype,null==(s=u.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))}))})),[null==(n=u.Element)?void 0:n.prototype,null==(o=u.CharacterData)?void 0:o.prototype,null==(a=u.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=_(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=u.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(e,i){var r=p(i);return r?t.call(this,e,r):null})),this.Ko=()=>{d.forEach((t=>t())),this.Ko=void 0},this.Yo()}Yo(){var t=!1;return()=>{var e;t||(t=!0,this.Wo--,0===this.Wo&&(null==(e=this.Ko)||e.call(this)))}}Xo(t,e){void 0===e&&(e=!0);var i=this.Jo();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.Vo.length&&(gl.info("Processing "+this.Vo.length+" events for site app with id "+t.id),this.Vo.forEach((t=>this.Xo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Go)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,gl.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this.Xo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1).processEvent;n&&(e.processEvent=n),r=!0}catch(e){gl.error(ml+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){gl.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}tl(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}el(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Xo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){gl.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.tl(),void this._instance.on("eventCaptured",(t=>this.el(t)))):void gl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Go)||i.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,e=a.id,i=a.url;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,i,(t=>{if(t)return gl.error(ml+e,t)}))};for(var a of n.siteApps)o()}else gl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Jl={tracingHeaders:class{constructor(t){this.il=void 0,this.rl=void 0,this.nl=void 0,this.bo=()=>{var t,e,i=this.sl();i?(K(this.il)&&(this.il=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),K(this.rl)&&(this.rl=null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return rl.error("failed to load script",e);t()}))}al(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}sl(){var t=this.al();return q(t)?(q(this.nl)?this.nl.splice(0,this.nl.length,...t):this.nl=[...t],t.length>0?this.nl:void 0):(q(this.nl)&&this.nl.splice(0),this.nl=t||void 0,this.nl)}Co(){var t,e;null==(t=this.il)||t.call(this),null==(e=this.rl)||e.call(this),this.il=void 0,this.rl=void 0}startIfEnabledOrStop(){this.sl()?this.ai(this.bo):this.Co()}}},Yl=_({surveys:class{get Pe(){return this._instance.config}constructor(t){this.ol=void 0,this._surveyManager=null,this.ll=!1,this.ul=[],this.hl=null,this.dl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Pe.disable_surveys){if(!t.ok)return xa.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(X(e))return xa.warn("Flags not loaded yet. Not loading surveys.");var i=q(e);this.ol=i?e.length>0:e,xa.info("flags response received, isSurveysEnabled: "+this.ol),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(Ea)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ll)xa.info("Already initializing surveys, skipping...");else if(this.Pe.disable_surveys)xa.info(Sl);else if(this.Pe.cookieless_mode&&this._instance.consent.isOptedOut())xa.info("Not loading surveys in cookieless mode without consent.");else{var t=null==v?void 0:v.__PosthogExtensions__;if(t){if(!K(this.ol)||this.Pe.advanced_enable_surveys){var e=this.ol||this.Pe.advanced_enable_surveys;this.ll=!0;try{var i=t.generateSurveys;if(i)return void this.vl(i,e);var r=t.loadExternalDependency;if(!r)return void this.cl(Er);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.cl("Could not load surveys script",i):this.vl(t.generateSurveys,e)}))}catch(t){throw this.cl("Error initializing surveys",t),t}finally{this.ll=!1}}}else xa.error("PostHog Extensions not found.")}}vl(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new xl(this._instance),xa.info("Surveys loaded successfully"),this.fl({isLoaded:!0})}cl(t,e){xa.error(t,e),this.fl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ul.push(t),this._surveyManager&&this.fl({isLoaded:!0}),()=>{this.ul=this.ul.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Pe.disable_surveys)return xa.info(Sl),t([]);var i,r=this._instance.get_property(er);if(r&&!e)return t(r,{isLoaded:!0}),void(this.pl()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.hl?this.hl.then((e=>t(e.surveys,e.context))):("undefined"!=typeof Promise&&(this.hl=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Pe.token),method:"GET",timestampMode:"query",timeout:this.Pe.surveys_request_timeout_ms,callback:e=>{var r;this.hl=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;0!==s?xa.error(n):e.error||xa.warn(n),this.dl=Date.now();var o={isLoaded:!1,error:n};return t([],o),void(null==i||i({surveys:[],context:o}))}this.dl=null;var a,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(wa(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[er]:l,[ir]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}pl(){return this.gl()&&!this.hl&&!this.ml()}gl(){var t=this._instance.get_property(ir);return Z(t)&&Date.now()-t>3e5}ml(){return Z(this.dl)&&3e5>Date.now()-this.dl}markSurveyAsSeen(t,e){var i,r={id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null};Sa(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}fl(t){for(var e of this.ul)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){xa.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!X(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);xa.warn("init was not called")}yl(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}bl(t){if(X(this._surveyManager))return{eligible:!1,reason:El};var e="string"==typeof t?this.yl(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}_l(t){if(X(this._surveyManager))return{eligible:!1,reason:El};var e="string"==typeof t?this.yl(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(X(this._surveyManager))return xa.warn("init was not called"),{visible:!1,disabledReason:El};var e=this._l(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return X(this._surveyManager)?(xa.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:El})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this._l(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(X(this._surveyManager))xa.warn("init was not called");else{var n="string"==typeof t?this.yl(t):t;if(null!=n&&n.id)if($a.includes(n.type)){var o=null==r?void 0:r.querySelector(e);if(o)return null!=(s=n.appearance)&&s.surveyPopupDelaySeconds?(xa.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;xa.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(n,o,i),xa.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,o,i);xa.warn("Survey element not found")}else xa.warn("Surveys of type "+n.type+" cannot be rendered in the app");else xa.warn("Survey not found")}}displaySurvey(t,e){var i;if(X(this._surveyManager))xa.warn("init was not called");else{var r=this.yl(t);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Xn.Popover&&e.initialResponses&&xa.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var n=this.bl(r);if(!n.eligible)return void xa.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==Xn.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else xa.warn("Survey not found")}}cancelPendingSurvey(t){X(this._surveyManager)?xa.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},Hl),Ql={toolbar:class{constructor(t){this.instance=t}wl(t){v.ph_toolbar_state=t}xl(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,i,s){if(void 0===e&&(e=void 0),void 0===i&&(i=void 0),void 0===s&&(s=void 0),Vr(this.instance.config))return!1;if(!t||!r)return!1;e=null!=e?e:t.location,s=null!=s?s:t.history;try{if(!i){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}i=null==t?void 0:t.localStorage}var n,o=$l||mn(e.hash,"__posthog")||mn(e.hash,"state"),a=o?Lr((()=>JSON.parse(atob(decodeURIComponent(o)))))||Lr((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(i.getItem(kl)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}kl(t){var e=v.ph_load_toolbar||v.ph_load_editor;!X(e)&&V(e)?e(t,this.instance):Tl.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==r||!r.getElementById(vs));if(!t||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(kl,JSON.stringify(_({},n,{source:void 0}))),2===this.xl())this.kl(n);else if(0===this.xl()){var o;this.wl(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Tl.error("[Toolbar] Failed to load",t),void this.wl(0);this.wl(2),this.kl(n)})),qr(t,"turbolinks:load",(()=>{this.wl(0),this.loadToolbar(n)}))}return!0}Sl(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Xl=_({experiments:Dl},Hl),Zl={conversations:class{constructor(t){this.Cl=void 0,this._conversationsManager=null,this.Ml=!1,this.Tl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&t.ok){var e=t.config.conversations;X(e)||(et(e)?this.Cl=e:(this.Cl=e.enabled,this.Tl=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Cl=void 0,this.Tl=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ml||this._instance.config.disable_conversations||Vr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!K(this.Cl)&&this.Cl)if(this.Tl&&this.Tl.token){this.Ml=!0;try{var e=t.initConversations;if(e)return this.El(e),void(this.Ml=!1);var i=t.loadExternalDependency;if(!i)return void this.Il(Er);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.Il("Could not load conversations script",e):this.El(t.initConversations),this.Ml=!1}))}catch(t){this.Il("Error initializing conversations",t),this.Ml=!1}}else Nl.error("Conversations enabled but missing token in remote config.")}}El(t){if(this.Tl)try{this._conversationsManager=t(this.Tl,this._instance),Nl.info("Conversations loaded successfully")}catch(t){this.Il("Error completing conversations initialization",t)}else Nl.error("Cannot complete initialization: remote config is null")}Il(t,e){Nl.error(t,e),this._conversationsManager=null,this.Ml=!1}show(){this._conversationsManager?this._conversationsManager.show():Nl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Cl&&!Q(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,i):(Nl.warn(Ul),null)}))()}getMessages(t,e){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Nl.warn(Ul),null)}))()}markAsRead(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Nl.warn(Ul),null)}))()}getTickets(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Nl.warn(Ul),null)}))()}requestRestoreLink(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Nl.warn(Ul),null)}))()}restoreFromToken(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Nl.warn(Ul),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Nl.warn(Ul),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}Gn(){var t;null==(t=this._conversationsManager)||t.setIdentity()}Qn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},tu={logs:class{constructor(e){var i,r=this;this.Pl=!1,this.Rl=!1,this.rt=bi("[logs]"),this.Ll=_({},this.rt,{error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];e.some(zl)||r.rt.error(...e)}}),this.er=[],this.Ol=[],this.fa=0,this.Fl=()=>{var t,e;this.fa=0,null==(t=this.Al)||t.onReconnect(),null==(e=this.Dl)||e.onReconnect()},this._instance=e,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Pl=!0),t&&qr(t,"online",this.Fl)}$l(t,e,i,r){var s,n=function(t,e){var i,r,s,n,o,a,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=K(d)?Math.max(h,2048):Math.max(h,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new Ce(this.Nl(t,e),n,this.Ll,(()=>this.ql()),(t=>t()),void 0,r),n]}jl(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Al||this.Bl!==e){var i;null==(i=this.Al)||i.reset(),this.Bl=e;var r=this.$l((()=>this.er),(t=>{this.er=t}));this.Al=r[0],this.Hl=r[1]}return this.Al}Ul(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Dl||this.zl!==e){var i;null==(i=this.Dl)||i.reset(),this.zl=e;var r=this.$l((()=>this.Ol),(t=>{this.Ol=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ll);this.Dl=r[0],this.Wl=r[1]}return this.Dl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var i=null==(e=t.config.logs)?void 0:e.captureConsoleLogs;!X(i)&&i&&(this.Pl=!0,this.loadIfEnabled())}}reset(){var t,e;this.er=[],null==(t=this.Al)||t.reset(),this.Ol=[],null==(e=this.Dl)||e.reset(),this.fa=0}captureLog(t){this.jl().captureLog(t)}he(t){this.Ul().captureLog(t)}get logger(){return this.Vl||(this.Vl={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Vl}flushLogs(t){t?this.Zl(t):(this.Al&&this.Al.flush().catch((t=>this.Gl(t))),this.Dl&&this.Dl.flush().catch((t=>this.Gl(t))))}Gl(t){zl(t)||this.rt.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Pl&&!this.Rl){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.rt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.Rl=!0)})):this.rt.error(Er)}else this.rt.error("PostHog Extensions not found.")}}Nl(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===E.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===E.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},At:t=>this.At(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}At(t){return new Promise((e=>{if(bn(this.fa,3))e({kind:"fatal",error:Bl(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>{this.rt.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Bl(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Ql(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var e=t.statusCode;if(this.Jl(e),e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;0===e?(t.error||this.rt.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Bl(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}}))}Jl(t){(0!==t||this._instance.__loaded)&&(this.fa=yn(t,this.fa,3,(()=>this.rt.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}Zl(t){this.er.length>0&&this.Kl(t,this.er,this.Hl,c.LIB_NAME,(t=>{this.er=t})),this.Ol.length>0&&this.Kl(t,this.Ol,this.Wl,Ll,(t=>{this.Ol=t}))}Kl(t,e,i,r,s){if(0!==e.length){var n=e.map((t=>t.record));s([]);var o=Ie(n,Oe(i,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Ql(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Ql(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ql(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=i.windowId,s=i.sessionStartTimestamp,n=i.lastActivityTimestamp;e.sessionId=i.sessionId,e.windowId=r,X(s)||(e.sessionStartTimestamp=s),X(n)||(e.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?ye(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},eu={metrics:class{constructor(t){this.rt=bi("[metrics]"),this._instance=t}initialize(){}jl(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Al&&this.Bl===i||(null==(e=this.Al)||e.reset(),this.Bl=i,this.Al=new De(this.Nl(),function(t){var e,i,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==o?void 0:o["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this.rt)),this.Al}count(t,e,i){void 0===e&&(e=1),this.jl().count(t,e,i)}gauge(t,e,i){this.jl().gauge(t,e,i)}histogram(t,e,i){this.jl().histogram(t,e,i)}flush(t){if(!this.Al)return Promise.resolve();if(t){var e=this.Al.drainWindow();return e&&this.Kt(e,t),Promise.resolve()}return this.Al.flush().catch((t=>this.rt.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Al)||t.reset()}Nl(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kt:t=>e.Kt(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Kt(t,e){return new Promise((i=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),i(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Yl(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)s({kind:"ok"});else if(413===e)s({kind:"too-large"});else if(0!==e&&429!==e&&500>e)s({kind:"fatal",error:new Error("metrics request failed with status "+e)});else{var i;s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}}))}))}Yl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},iu=_({},Hl,ql,Vl,Wl,Gl,Kl,Yl,Jl,Ql,Xl,Zl,tu,eu);Ka.__defaultExtensionClasses=_({},iu);var ru=function(){c.SDK_DIST_CHANNEL="npm";var e=Ma[za]=new Ka;return function(){function e(){e.done||(e.done=!0,Ha=!1,Dr(Ma,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?e():qr(r,"DOMContentLoaded",e,{capture:!1}):t&&mi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Bn as Compression,Zn as DEFAULT_PRODUCT_TOUR_APPEARANCE,Xn as DisplaySurveyType,Ka as PostHog,to as ProductTourEventName,eo as ProductTourEventProperties,Yn as SurveyEventName,Qn as SurveyEventProperties,zn as SurveyEventType,qn as SurveyPosition,Kn as SurveyQuestionBranchingType,Gn as SurveyQuestionType,Jn as SurveySchedule,Vn as SurveyTabPosition,Wn as SurveyType,Hn as SurveyWidgetType,ru as default,ru as posthog,oo as severityLevels};
1
+ var t="undefined"!=typeof window?window:void 0,e="undefined"!=typeof globalThis?globalThis:t,i=null==e?void 0:e.navigator,r=null==e?void 0:e.document,s=null==e?void 0:e.location,n=null==e?void 0:e.fetch,o=null!=e&&e.XMLHttpRequest&&"withCredentials"in new e.XMLHttpRequest?e.XMLHttpRequest:void 0,a=null==e?void 0:e.AbortController,l=null==e?void 0:e.CompressionStream,u=null==i?void 0:i.userAgent;function h(){return!(!t||!1===t.navigator.onLine)}var d="undefined"!=typeof globalThis?globalThis:t;d&&"undefined"==typeof self&&(d.self=d),d&&"undefined"==typeof File&&(d.File=function(){});var v=null!=t?t:{},c={DEBUG:!1,LIB_VERSION:"0.3.1",LIB_NAME:"browser-common"};function f(t,e,i,r,s,n,o){try{var a=t[n](o),l=a.value}catch(t){return void i(t)}a.done?e(l):Promise.resolve(l).then(r,s)}function p(t){return function(){var e=this,i=arguments;return new Promise((function(r,s){var n=t.apply(e,i);function o(t){f(n,r,s,o,a,"next",t)}function a(t){f(n,r,s,o,a,"throw",t)}o(void 0)}))}}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var r in i)({}).hasOwnProperty.call(i,r)&&(t[r]=i[r])}return t},_.apply(null,arguments)}function g(t,e){if(null==t)return{};var i={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(-1!==e.indexOf(r))continue;i[r]=t[r]}return i}var m=t=>{if("string"!=typeof t)return t;try{return JSON.parse(t)}catch(e){return t}};function b(t){return"string"==typeof t||t}function y(t){return"string"==typeof t?t:void 0}var w,x=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],E=function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t}({}),S=function(t){return t.GZipJS="gzip-js",t.Base64="base64",t}({}),k=["$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"],T=["token"],R="NativeGzipValidationError",P=t=>t.length>=2&&31===t[0]&&139===t[1],O=(t,e)=>t===S.GZipJS||e===S.GZipJS||"gzip"===e,I=t=>!(!t||"object"!=typeof t)&&"NotReadableError"===("name"in t?String(t.name):""),C=t=>{var e=new Error("Native gzip produced invalid output: "+t);throw e.name=R,e},A=function(){var t=p((function*(t,e){18>t.size&&C("too-short");var i=new Uint8Array(yield t.slice(0,10).arrayBuffer());P(i)&&8===i[2]||C("invalid-header");var r=new DataView(yield t.slice(t.size-8).arrayBuffer());r.getUint32(0,!0)!==(t=>{for(var e=(()=>{if(w)return w;w=[];for(var t=0;256>t;t++){for(var e=t,i=0;8>i;i++)e=1&e?3988292384^e>>>1:e>>>1;w[t]=e>>>0}return w})(),i=4294967295,r=0;t.length>r;r++)i=e[255&(i^t[r])]^i>>>8;return(4294967295^i)>>>0})(e)&&C("invalid-crc");var s=e.length>>>0;r.getUint32(4,!0)!==s&&C("invalid-size")}));return function(e,i){return t.apply(this,arguments)}}();function M(){return M=p((function*(t,e,i){void 0===e&&(e=!0);try{var r=(new TextEncoder).encode(t),s=new globalThis.CompressionStream("gzip"),n=s.writable.getWriter(),o=n.write(r).then((()=>n.close())).catch(function(){var t=p((function*(t){try{yield n.abort(t)}catch(t){}throw t}));return function(e){return t.apply(this,arguments)}}()),a=new Response(s.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield A(l,r),l}catch(t){if(null!=i&&i.rethrow)throw t;return e&&console.error("Failed to gzip compress data",t),null}})),M.apply(this,arguments)}var F=["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"],D=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return F.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function N(t,e){return-1!==t.indexOf(e)}var U=function(t){return t.trim()},L=function(t){return t.replace(/^\$/,"")};function j(t){var e,i=[];return null!==(e=JSON.stringify(t,(function(t,e){if("bigint"==typeof e)return e.toString();if("function"!=typeof e&&"symbol"!=typeof e){if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};if(e&&"object"==typeof e){for(;i.length>0&&i[i.length-1]!==this;)i.pop();if(i.includes(e))return"[Circular]";i.push(e)}return e}})))&&void 0!==e?e:"null"}var B=Object.prototype,z=B.hasOwnProperty,H=B.toString,q=Array.isArray||function(t){return"[object Array]"===H.call(t)},V=t=>"function"==typeof t,W=t=>t===Object(t)&&!q(t),G=t=>{if(W(t)){for(var e in t)if(z.call(t,e))return!1;return!0}return!1},K=t=>void 0===t,J=t=>"[object String]"==H.call(t),Y=t=>J(t)&&0===t.trim().length,Q=t=>null===t,X=t=>K(t)||Q(t),Z=t=>"[object Number]"==H.call(t)&&t==t,tt=t=>Z(t)&&t>0,et=t=>"[object Boolean]"===H.call(t),it=t=>t instanceof FormData,rt=t=>N(k,t),st=t=>N(T,t);function nt(t){return null===t||"object"!=typeof t}function ot(t,e){return{}.toString.call(t)==="[object "+e+"]"}function at(t){return"undefined"!=typeof Event&&lt(t,Event)}function lt(t,e){try{return t instanceof e}catch(t){return!1}}var ut=[!0,"true",1,"1","yes"],ht=t=>N(ut,t),dt=[!1,"false",0,"0","no"];function vt(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),Z(t)?t>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),vt(s||i,e,i,r))}class ct{constructor(t){this.tt={},this.et=t.et,this.it=vt(t.bucketSize,0,100,t.rt),this.nt=vt(t.refillRate,0,this.it,t.rt),this.st=vt(t.refillInterval,0,864e5,t.rt)}ot(t,e){var i=Math.floor((e-t.lastAccess)/this.st);i>0&&(t.tokens=Math.min(t.tokens+i*this.nt,this.it),t.lastAccess=t.lastAccess+i*this.st)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.tt[r];return s?this.ot(s,i):this.tt[r]=s={tokens:this.it,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.et)||e.call(this,t)),0===s.tokens)}stop(){this.tt={}}}var ft="Mobile",pt="iOS",_t="Android",gt="Tablet",mt=_t+" "+gt,bt="iPad",yt="Apple",wt=yt+" Watch",xt="Safari",Et="BlackBerry",St="Samsung",$t=St+"Browser",kt=St+" Internet",Tt="Chrome",Rt=Tt+" OS",Pt=Tt+" "+pt,Ot="Internet Explorer",It=Ot+" "+ft,Ct="Opera",At=Ct+" Mini",Mt="Edge",Ft="Microsoft "+Mt,Dt="Firefox",Nt=Dt+" "+pt,Ut="Nintendo",Lt="PlayStation",jt="Xbox",Bt=_t+" "+ft,zt=ft+" "+xt,Ht="Windows",qt=Ht+" Phone",Vt="Nokia",Wt="Ouya",Gt="Generic",Kt=Gt+" "+ft.toLowerCase(),Jt=Gt+" "+gt.toLowerCase(),Yt="Konqueror",Qt="Oculus Browser",Xt="Vivaldi",Zt="Yandex",te="Whale",ee="DuckDuckGo",ie="Pale Moon",re="Waterfox",se="Brave",ne="Google Search App",oe="(\\d+(\\.\\d+)?)",ae=new RegExp("Version/"+oe),le=new RegExp(jt,"i"),ue=new RegExp(Lt+" \\w+","i"),he=new RegExp(Ut+" \\w+","i"),de=new RegExp(Et+"|PlayBook|BB10","i"),ve={"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"},ce=function(t,e,i,r){e=e||"";var s=function(t){return null!=t&&t.brave?se:null}(i);return s||(null!=r&&r.detectGoogleSearchApp&&N(t,"GSA/")?ne:N(t," OPR/")&&N(t,"Mini")?At:N(t," OPR/")?Ct:de.test(t)?Et:N(t,"IE"+ft)||N(t,"WPDesktop")?It:N(t,"OculusBrowser")?Qt:N(t,$t)?kt:N(t,Mt)||N(t,"Edg/")?Ft:N(t,Xt+"/")?Xt:N(t,"YaBrowser/")?Zt:N(t,te+"/")?te:N(t,ee+"/")||N(t,"Ddg/")?ee:N(t,"FBIOS")?"Facebook "+ft:N(t,"UCWEB")||N(t,"UCBrowser")?"UC Browser":N(t,"CriOS")?Pt:N(t,"CrMo")||N(t,Tt)?Tt:N(t,_t)&&N(t,xt)?Bt:N(t,"FxiOS")?Nt:N(t.toLowerCase(),Yt.toLowerCase())?Yt:N(t,se+"/")?se:((t,e)=>e&&N(e,yt)||function(t){return N(t,xt)&&!N(t,Tt)&&!N(t,_t)}(t))(t,e)?N(t,ft)?zt:xt:N(t,"PaleMoon/")?ie:N(t,re+"/")?re:N(t,Dt)?Dt:N(t,"MSIE")||N(t,"Trident/")?Ot:N(t,"Gecko")?Dt:"")},fe={[It]:[new RegExp("rv:"+oe)],[Ft]:[new RegExp(Mt+"?\\/"+oe)],[Tt]:[new RegExp("("+Tt+"|CrMo)\\/"+oe)],[Pt]:[new RegExp("CriOS\\/"+oe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+oe)],[xt]:[ae],[zt]:[ae],[Ct]:[new RegExp("(Opera|OPR)\\/"+oe)],[Dt]:[new RegExp(Dt+"\\/"+oe)],[Nt]:[new RegExp("FxiOS\\/"+oe)],[Yt]:[new RegExp("Konqueror[:/]?"+oe,"i")],[Et]:[new RegExp(Et+" "+oe),ae],[Bt]:[new RegExp("android\\s"+oe,"i")],[kt]:[new RegExp($t+"\\/"+oe)],[Qt]:[new RegExp("OculusBrowser\\/"+oe)],[Xt]:[new RegExp(Xt+"\\/"+oe)],[Zt]:[new RegExp("YaBrowser\\/"+oe)],[te]:[new RegExp(te+"\\/"+oe)],[se]:[new RegExp(se+"\\/"+oe)],[ee]:[new RegExp("(DuckDuckGo|Ddg)\\/"+oe)],[ie]:[new RegExp("PaleMoon\\/"+oe)],[re]:[new RegExp(re+"\\/"+oe)],[ne]:[new RegExp("GSA\\/"+oe)],[Ot]:[new RegExp("(rv:|MSIE )"+oe)],Mozilla:[new RegExp("rv:"+oe)]},pe=function(t,e,i,r){var s=ce(t,e,i,r),n=fe[s];if(K(n))return null;for(var o=0;n.length>o;o++){var a=t.match(n[o]);if(a)return parseFloat(a[a.length-2])}return null},_e=[[new RegExp(jt+"; "+jt+" (.*?)[);]","i"),t=>[jt,t&&t[1]||""]],[new RegExp(Ut,"i"),[Ut,""]],[new RegExp(Lt,"i"),[Lt,""]],[de,[Et,""]],[new RegExp(Ht,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[qt,""];if(new RegExp(ft).test(e)&&!/IEMobile\b/.test(e))return[Ht+" "+ft,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var r=ve[i[1]]||"";return/arm/i.test(e)&&(r="RT"),[Ht,r]}return[Ht,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[pt,[t[3],t[4],t[5]||"0"].join(".")]:[pt,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=K(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+_t+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+_t+")","i"),t=>t&&t[2]?[_t,[t[2],t[3],t[4]||"0"].join(".")]:[_t,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Rt,""]],[/Linux|debian/i,["Linux",""]]],ge=function(t){return he.test(t)?Ut:ue.test(t)?Lt:le.test(t)?jt:new RegExp(Wt,"i").test(t)?Wt:new RegExp("("+qt+"|WPDesktop)","i").test(t)?qt:/iPad/.test(t)?bt:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?wt:de.test(t)?Et:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Vt,"i").test(t)?Vt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(ft).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?_t:mt:new RegExp("(pda|"+ft+")","i").test(t)?Kt:new RegExp(gt,"i").test(t)&&!new RegExp(gt+" pc","i").test(t)?Jt:""},me=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function be(t,e){return"string"==typeof(i=t)&&me.test(i)?t:e();var i}function ye(t){return t?t.split("#")[0]:t}function we(t,e){var i=setTimeout(t,e);return(null==i?void 0:i.unref)&&(null==i||i.unref()),i}function xe(t,e,i){return Ee.apply(this,arguments)}function Ee(){return(Ee=p((function*(t,e,i){var r;try{return yield Promise.race([t,new Promise(((t,s)=>{r=we((()=>{try{null==i||i(),t()}catch(t){s(t)}}),e)}))])}finally{clearTimeout(r)}}))).apply(this,arguments)}var Se=t=>t instanceof Error,$e={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}},ke=$e.info;function Te(t){if(et(t))return{boolValue:t};if("number"==typeof t)return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if("string"==typeof t)return{stringValue:t};if(q(t))return{arrayValue:{values:t.map((t=>Te(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function Re(t){var e=[];for(var i in t){var r=t[i];Q(r)||K(r)||e.push({key:i,value:Te(r)})}return e}function Pe(t,e){var i=$e[t.level||"info"]||ke,r=i.text,s=i.number,n=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),e.windowId&&(o["window.id"]=e.windowId),X(e.sessionStartTimestamp)||(o.sessionStartTimestamp=String(e.sessionStartTimestamp)),X(e.lastActivityTimestamp)||(o.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(o["url.full"]=e.currentUrl),e.screenName&&(o["screen.name"]=e.screenName),e.appState&&(o["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(o.feature_flags=e.activeFeatureFlags);var a=_({},o,t.attributes||{}),l={timeUnixNano:n,observedTimeUnixNano:n,severityNumber:s,severityText:r,body:{stringValue:t.body},attributes:Re(a)};return t.trace_id&&(l.traceId=t.trace_id),t.span_id&&(l.spanId=t.span_id),K(t.trace_flags)||(l.flags=t.trace_flags),l}function Oe(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}function Ie(t,e,i,r){return{resourceLogs:[{resource:{attributes:Re(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}let Ce=class{constructor(t,e,i,r,s,n,o){var a;void 0===n&&(n=()=>Promise.resolve()),this._instance=t,this.Pe=e,this.rt=i,this.ut=r,this.ht=s,this.dt=n,this.vt=o,this.ct=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=e.maxBufferSize,this.kt=Math.max(null!==(a=e.maxQueueSize)&&void 0!==a?a:e.maxBufferSize,e.maxBufferSize),this.St=e.flushIntervalMs,this.Ct=e.maxBatchRecordsPerPost,this.Mt=e.rateCapWindowMs,this.Tt=e.maxLogsPerInterval}reset(){this.Et(),this.ct=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Pe.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.It()}captureLog(t){if(!this._instance.isDisabled&&!this._instance.optedOut&&null!=t&&t.body){var e=this.Pt(t);if(null!==e)if(e.body){if(this.Rt()){var i={record:Pe(e,this.ut())};this.ht((()=>this.Lt(i)))}}else this.rt.info("Log was rejected in beforeSend function")}}Pt(t){var e=this.Pe.beforeSend;if(!e)return t;var i=q(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.rt.info("Log was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for log:",t),null}return r}Rt(){if(void 0===this.Tt)return!0;var t=Date.now(),e=t-this.bt;return this.Mt>e&&e>=0||(this.bt=t,this._t=0,this.wt=!1),this.Tt>this._t?(this._t++,!0):(this.wt||(this.rt.warn("captureLog dropping logs: exceeded "+this.Tt+" logs per "+this.Mt+"ms"),this.wt=!0),!1)}flush(){var t=this;return p((function*(){if(!t._instance.isDisabled)return t.ct||(t.ct=t.Ot().finally((()=>{t.ct=null}))),t.ct}))()}Ot(){var t=this;return p((function*(){var e;t.Et();var i=null!==(e=t._instance.getPersistedProperty(E.LogsQueue))&&void 0!==e?e:[];if(0!==i.length)for(var r=i.length,s=0;i.length>0&&r>s;){var n,o;t.ft=0;var a=Math.min(i.length,t.Ct),l=i.slice(0,a),u=Ie(l.map((t=>t.record)),t.Ft(),null!==(n=t.vt)&&void 0!==n?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.At(u);if("too-large"===h.kind&&l.length>1)t.Ct=Math.max(1,Math.floor(l.length/2)),t.rt.warn("Received 413 when sending logs batch of size "+l.length+", reducing batch size to "+t.Ct);else{if("retry-later"===h.kind)throw h.error;if("too-large"===h.kind?t.rt.warn("Dropping a single log record after 413 with batch size 1 — the record is larger than the server cap and cannot be split further."):"ok"===h.kind&&t.Pe.maxBatchRecordsPerPost>t.Ct&&(t.Ct=Math.min(t.Pe.maxBatchRecordsPerPost,t.Ct+1)),yield t.Dt(l.length),i=null!==(o=t._instance.getPersistedProperty(E.LogsQueue))&&void 0!==o?o:[],s+=l.length,"fatal"===h.kind)throw h.error}}}))()}Dt(t){var e=this;return p((function*(){var i,r=Math.max(0,t-e.ft),s=null!==(i=e._instance.getPersistedProperty(E.LogsQueue))&&void 0!==i?i:[];e._instance.setPersistedProperty(E.LogsQueue,s.slice(r)),yield e.dt()}))()}Ft(){return Oe(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Lt(t){var e;if(!this._instance.optedOut){var i=null!==(e=this._instance.getPersistedProperty(E.LogsQueue))&&void 0!==e?e:[];this.kt>i.length||(i.shift(),this.ft++,this.rt.info("Logs queue is full, dropping oldest record.")),i.push(t),this._instance.setPersistedProperty(E.LogsQueue,i),this.xt>i.length?this.$t():this.It()}}$t(t){void 0===t&&(t=this.St),this.Nt||(this.Nt=we((()=>{this.Nt=void 0,this.It()}),t))}qt(){var t=Math.min(Math.max(0,this.yt-1),6);return this.St*Math.pow(2,t)}jt(){var t=this._instance.getPersistedProperty(E.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return p((function*(){e.Et();var i=e.flush().catch((()=>{}));void 0!==t?yield xe(i,t):yield i}))()}flushWithTimeout(t){var e=this;return p((function*(){var i=e.flush();yield xe(i,t,(()=>{i.catch((()=>{}))}))}))()}It(){this.flush().then((()=>{this.yt=0}),(t=>{this.yt++,this.rt.error("PostHog logs flush failed:",t)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.$t(this.qt())}))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}};var Ae=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Me(t){return String(t)+"000000"}function Fe(t,e,i,r){var s="";return r&&(s=Object.keys(r).sort().map((t=>JSON.stringify(t)+":"+JSON.stringify(r[t]))).join(",")),t+"\0"+e+"\0"+(null!=i?i:"")+"\0"+s}let De=class{constructor(t,e,i){this._instance=t,this.Pe=e,this.rt=i,this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Wt=0}count(t,e,i){void 0===e&&(e=1),this.Vt({name:t,type:"count",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}gauge(t,e,i){this.Vt({name:t,type:"gauge",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}histogram(t,e,i){this.Vt({name:t,type:"histogram",value:e,unit:null==i?void 0:i.unit,attributes:null==i?void 0:i.attributes})}flush(){var t=this,e=this.ct,i=function(){var i=p((function*(){e&&(yield e.catch((()=>{}))),yield t.Zt()}));return function(){return i.apply(this,arguments)}}(),r=i().finally((()=>{this.ct===r&&(this.ct=null)}));return this.ct=r,r}drainWindow(){if(0===this.Bt.size)return null;var t=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(t)}reset(){this.Wt++,this.Et(),this.Bt=new Map,this.ct=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Vt(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.Pt(t);if(null!==e)if(e.name&&"string"==typeof e.name)if("number"==typeof e.value&&Number.isFinite(e.value))if("count"===e.type&&0>e.value)this.rt.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var i,r;try{i=e.attributes?_({},e.attributes):void 0,r=Fe(e.type,e.name,e.unit,i)}catch(t){return void this.rt.warn("Dropping metric '"+e.name+"': attributes could not be serialized",t)}var s=this.Bt.get(r);if(!s){if(!this.Qt())return;s={name:e.name,type:e.type,unit:e.unit,attributes:i,windowStartMs:Date.now()},this.Bt.set(r,s)}var n=this.Ut.get(e.name);void 0===n?this.Ut.set(e.name,e.type):n===e.type||this.zt.has(e.name)||(this.zt.add(e.name),this.rt.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.Jt(s,e.value),this.$t()}else this.rt.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.rt.warn("Dropping metric with empty name")}}Qt(){return this.Pe.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.rt.warn("Metric series cap reached ("+this.Pe.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}Jt(t,e){var i;switch(t.type){case"count":t.total=(null!==(i=t.total)&&void 0!==i?i:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Ae.length+1).fill(0)});var r=t.hist;r.count+=1,r.sum+=e,r.min=Math.min(r.min,e),r.max=Math.max(r.max,e),r.bucketCounts[function(t,e){for(var i=0;e.length>i;i++)if(e[i]>=t)return i;return e.length}(e,Ae)]+=1}}Pt(t){var e=this.Pe.beforeSend;if(!e)return t;var i=q(e)?e:[e],r=t;for(var s of i)try{var n=s(r);if(!n)return this.rt.info("Metric was rejected in beforeSend function"),null;r=n}catch(t){return this.rt.error("Error in beforeSend function for metric:",t),null}return r}$t(){this.Nt||(this.Nt=we((()=>{this.Nt=void 0,this.flush().catch((t=>{this.rt.error("Metrics flush failed:",t)}))}),this.Pe.flushIntervalMs))}Et(){this.Nt&&(clearTimeout(this.Nt),this.Nt=void 0)}Zt(){var t=this;return p((function*(){if(0!==t.Bt.size){var e=t.Bt;t.Bt=new Map,t.Ht=!1,t.Ut=new Map,t.zt=new Set;var i=t.Wt,r=yield t._instance.Kt(t.Gt(e));if(i===t.Wt)switch(r.kind){case"ok":return;case"retry-later":return t.Yt(e),void t.$t();case"too-large":return void t.rt.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.rt.error("Failed to send metrics batch:",r.error)}}}))()}Gt(t){return e=this.Xt(t),i=function(t,e,i){return _({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":i})}(this.Pe,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),s=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Re(i)},scopeMetrics:[{scope:{name:r,version:s},metrics:e}]}]};var e,i,r,s}Xt(t){var e=Me(Date.now()),i=new Map;for(var r of t.values()){var s,n=Fe(r.type,r.name,r.unit,void 0),o=i.get(n);o||(o=_({name:r.name},r.unit&&{unit:r.unit}),"count"===r.type?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:"gauge"===r.type?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},i.set(n,o));var a=Re(null!==(s=r.attributes)&&void 0!==s?s:{}),l=Me(r.windowStartMs);if("count"===r.type){var u,h={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:null!==(u=r.total)&&void 0!==u?u:0};o.sum.dataPoints.push(h)}else if("gauge"===r.type){var d,v={attributes:a,timeUnixNano:e,asDouble:null!==(d=r.last)&&void 0!==d?d:0};o.gauge.dataPoints.push(v)}else r.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:Ae})}return Array.from(i.values())}Yt(t){var e,i;for(var r of t){var s=r[0],n=r[1],o=this.Bt.get(s);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=(null!==(e=o.total)&&void 0!==e?e:0)+(null!==(i=n.total)&&void 0!==i?i:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Qt()&&this.Bt.set(s,n)}}};var Ne,Ue,Le;function je(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Le&&i.length===Ue||(Ue=i.length,Le=i.reduce(((i,r)=>{Ne||(Ne={});var s=Ne[r];if(s)i[s[0]]=s[1];else for(var n=t(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,u=e[r];if(l&&u){i[l]=u,Ne[r]=[l,u];break}}return i}),{})),Le}}class Be{constructor(t,e,i){void 0===i&&(i=[]),this.coercers=t,this.stackParser=e,this.modifiers=i}buildFromUnknown(t,e){void 0===e&&(e={});var i=e&&e.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,e,0).apply(t),s=this.buildParsingContext(e),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(t){var e=this;return p((function*(){for(var i of t)i.stacktrace&&i.stacktrace.frames&&q(i.stacktrace.frames)&&(i.stacktrace.frames=yield e.applyModifiers(i.stacktrace.frames));return t}))()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:null==(e=t.syntheticException)?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var i,r;return null!=t.cause&&(i=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(r=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),_({},t,{cause:i,stack:r})}applyChunkIds(t,e){return t.map((t=>(t.filename&&e&&(t.chunk_id=e[t.filename]),t)))}applyCoercers(t,e){for(var i of this.coercers)if(i.match(t))return i.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return p((function*(){var i=t;for(var r of e.modifiers)i=yield r(i);return i}))()}convertToExceptionList(t,e){var i,r,s,n={type:t.type,value:t.value,mechanism:{type:null!==(i=e.type)&&void 0!==i?i:"generic",handled:null===(r=e.handled)||void 0===r||r,synthetic:null!==(s=t.synthetic)&&void 0!==s&&s}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,_({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:je(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,i){void 0===i&&(i=0);var r=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return _({},e,{syntheticException:0==i?e.syntheticException:void 0,mechanism:t,apply:t=>r(t,i),next:t=>r(t,i+1)})}}var ze="?";function He(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?ze:i,in_app:!0};return K(r)||(n.lineno=r),K(s)||(n.colno=s),n}var qe=(t,e)=>{var i=-1!==t.indexOf("safari-extension"),r=-1!==t.indexOf("safari-web-extension");return i||r?[-1!==t.indexOf("@")?t.split("@")[0]:ze,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Ve=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,We=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ge=/\((\S*)(?::(\d+))(?::(\d+))\)/,Ke=(t,e)=>{var i=Ve.exec(t);if(i)return He(e,i[1],ze,+i[2],+i[3]);var r=We.exec(t);if(r){if(r[2]&&0===r[2].indexOf("eval")){var s=Ge.exec(r[2]);s&&(r[2]=s[1],r[3]=s[2],r[4]=s[3])}var n=qe(r[1]||ze,r[2]);return He(e,n[1],n[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},Je=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ye=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Qe=(t,e)=>{var i=Je.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=Ye.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]||ze,o=qe(n,s);return He(e,s=o[1],n=o[0],i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},Xe=/\(error: (.*)\)/;class Ze{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=J(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:i?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return ot(t,"DOMException")}isDOMError(t){return ot(t,"DOMError")}}class ti{match(t){return function(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return lt(t,Error)}}(t)}coerce(t,e){return{type:this.getType(t),value:this.getMessage(t,e),stack:this.getStack(t),cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var i=t.message;return String(i.error&&"string"==typeof i.error.message?i.error.message:i)}getStack(t){return t.stacktrace||t.stack||void 0}}class ei{constructor(){}match(t){return!!ot(t,"ErrorEvent")&&(null!=t.error||this.fe(t))}coerce(t,e){var i;if(null!=t.error)return e.apply(t.error);var r=e.apply(t.message);return _({},r,{stack:null!==(i=this.pe(t))&&void 0!==i?i:r.stack,synthetic:!0})}fe(t){return J(t.message)&&t.message.length>0}pe(t){var e=t;if(J(e.filename)&&e.filename.length>0){var i,r,s=null!==(i=e.lineno)&&void 0!==i?i:0,n=null!==(r=e.colno)&&void 0!==r?r:0;return"Error\n at "+e.filename+":"+s+":"+n}}}var ii=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ri{match(t){return"string"==typeof t}coerce(t,e){var i,r=this.getInfos(t),s=r[0],n=r[1];return{type:null!=s?s:"Error",value:null!=n?n:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(ii);return r&&(e=r[1],i=r[2]),[e,i]}}var si=["fatal","error","warning","log","info","debug"];function ni(t,e){void 0===e&&(e=40);var i=Object.keys(t);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(e>=s.length)return r===i.length?s:s.length>e?s.slice(0,e)+"...":s}return""}class oi{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r,s=this.getErrorPropertyFromObject(t);return s?e.apply(s):{type:this.getType(t),value:this.getValue(t),stack:null!==(i=this.getStack(t))&&void 0!==i?i:null==(r=e.syntheticException)?void 0:r.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return at(t)?t.constructor.name:"Error"}getValue(t){if("name"in t&&"string"==typeof t.name){var e="'"+t.name+"' captured as exception";return"message"in t&&"string"==typeof t.message&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&"string"==typeof t.message)return t.message;var i=this.getObjectClassName(t);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+ni(t)}isSeverityLevel(t){return J(t)&&!Y(t)&&si.indexOf(t)>=0}getStack(t){try{return J(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:J(t.stack)&&t.stack.length>0?t.stack:void 0}catch(t){return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(Se(i))return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class ai{match(t){return at(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+ni(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class li{match(t){return nt(t)}coerce(t,e){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class ui{match(t){return ot(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!at(t))return!1;try{var e=t.detail;return null!=e&&"object"==typeof e&&"reason"in e}catch(t){return!1}}coerce(t,e){var i,r=this.getUnhandledRejectionReason(t);return nt(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}:e.apply(r)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&null!=t.detail&&"object"==typeof t.detail&&"reason"in t.detail)return t.detail.reason}catch(t){}return t}}var hi="$message",di="$timestamp",vi=new Set([hi,di]),ci={enabled:!0,max_bytes:32768};function fi(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:ci.enabled,max_bytes:_i(t.max_bytes,ci.max_bytes)}:_({},ci)}class pi{constructor(t){this.Je=[],this.Ke=0,this.Pe=fi(t)}setConfig(t){this.Pe=fi(t),this.Xe()}add(t){var e=function(t){var e;try{e=j(t)}catch(t){return}try{var i=JSON.parse(e);if(!W(i))return;var r=i,s=r[hi],n=r[di];if(!J(s)||0===s.trim().length)return;if(!J(n)&&!Z(n))return;return{step:r,json:e}}catch(t){return}}(t);if(e){var i=function(t){if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t).length;for(var e=encodeURIComponent(t),i=0,r=0;e.length>r;r++)"%"===e[r]?(i+=1,r+=2):i+=1;return i}(e.json);i>this.Pe.max_bytes||(this.Je.push({step:e.step,bytes:i}),this.Ke+=i,this.Xe())}}getAttachable(){return this.Je.map((t=>t.step))}clear(){this.Je=[],this.Ke=0}size(){return this.Je.length}Xe(){for(;this.Ke>this.Pe.max_bytes&&this.Je.length>0;){var t=this.Je.shift();t&&(this.Ke-=t.bytes)}}}function _i(t,e){if(!Z(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var gi=function(e,i){var r=(void 0===i?{}:i).debugEnabled,s={k(i){if(t&&(c.DEBUG||t.POSTHOG_DEBUG||r)&&!K(t.console)&&t.console){for(var s=("__rrweb_original__"in t.console[i]?t.console[i].__rrweb_original__:t.console[i]),n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];s(e,...o)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];s.k("error",...e)},critical(){for(var t=arguments.length,i=new Array(t),r=0;t>r;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning(t){s.error("You must initialize PostHog before calling "+t)},createLogger:(t,i)=>gi(e+" "+t,i)};return s},mi=gi("[PostHog.js]"),bi=mi.createLogger,yi=bi("[ExternalScriptsLoader]"),wi=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return yi.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=null==r?void 0:r.querySelectorAll("script");if(s)for(var n,o=function(){if(s[a].src===e){var t=s[a];return t.__posthog_loading_callback_fired?{v:i()}:(t.addEventListener("load",(e=>{t.__posthog_loading_callback_fired=!0,i(void 0,e)})),t.onerror=t=>i(t),{v:void 0})}},a=0;s.length>a;a++)if(n=o())return n.v;var l=()=>{if(!r)return i("document not found");var s=r.createElement("script");if(s.type="text/javascript",s.crossOrigin="anonymous",s.src=e,s.onload=t=>{s.__posthog_loading_callback_fired=!0,i(void 0,t)},s.onerror=t=>i(t),t.config.prepare_external_dependency_script&&(s=t.config.prepare_external_dependency_script(s)),!s)return i("prepare_external_dependency_script returned null");if("head"===t.config.external_scripts_inject_target)r.head.appendChild(s);else{var n,o=r.querySelectorAll("body > script");o.length>0?null==(n=o[0].parentNode)||n.insertBefore(s,o[0]):r.body.appendChild(s)}};null!=r&&r.body?l():null==r||r.addEventListener("DOMContentLoaded",l)};v.__PosthogExtensions__=v.__PosthogExtensions__||{},v.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if("remote-config"!==e){var r;if(t.config.strict_script_versioning)r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var s="/static/"+e+".js?v="+t.version;if("toolbar"===e){var n=3e5;s=s+"&t="+Math.floor(Date.now()/n)*n}r=t.requestRouter.endpointFor("assets",s)}wi(t,r,i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");wi(t,o,i)}},v.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var r=t.requestRouter.endpointFor("api",e);wi(t,r,i)};c.DEBUG=!1,c.LIB_VERSION="1.412.1",c.LIB_NAME="web";var xi="$people_distinct_id",Ei="$device_id",Si="$device_model",$i="__alias",ki="__timers",Ti="$autocapture_disabled_server_side",Ri="$heatmaps_enabled_server_side",Pi="$exception_capture_enabled_server_side",Oi="$error_tracking_suppression_rules",Ii="$error_tracking_capture_extension_exceptions",Ci="$web_vitals_enabled_server_side",Ai="$dead_clicks_enabled_server_side",Mi="$product_tours_enabled_server_side",Fi="$web_vitals_allowed_metrics",Di="$session_recording_remote_config",Ni="$replay_sample_rate",Ui="$replay_override_sampling",Li="$replay_override_linked_flag",ji="$replay_override_url_trigger",Bi="$replay_override_event_trigger",zi="$sesid",Hi="$session_is_sampled",qi="$enabled_feature_flags",Vi="$active_feature_flags",Wi="$early_access_features",Gi="$feature_flag_details",Ki="$feature_flag_payloads",Ji="$feature_flag_request_id",Yi="$minimal_flag_called_events",Qi="$override_feature_flags",Xi="$override_feature_flag_payloads",Zi="$stored_person_properties",tr="$stored_group_properties",er="$surveys",ir="$surveys_loaded_at",rr="$surveys_activated",sr="$surveys_activated_session",nr="$surveys_activated_timestamps",or="ph_product_tours",ar="$flag_call_reported",lr="$flag_call_reported_session_id",ur="$feature_flag_errors",hr="$feature_flag_evaluated_at",dr="$user_state",vr="$client_session_props",cr="$capture_rate_limit",fr="$initial_campaign_params",pr="$initial_referrer_info",_r="$initial_person_info",gr="$epp",mr="$posthog_cookieless",br="$cookieless_mode",yr="$sdk_debug_extensions_init_method",wr="$sdk_debug_extensions_init_time_ms",xr="$sdk_debug_recording_script_not_loaded",Er="PostHog loadExternalDependency extension not found.",Sr="on_reject",$r="always",kr="anonymous",Tr="identified",Rr="identified_only",Pr="visibilitychange",Or="beforeunload",Ir="$pageview",Cr="$pageleave",Ar="$identify",Mr="$groupidentify";function Fr(t,e){q(t)&&t.forEach(e)}function Dr(t,e){if(!X(t))if(q(t))t.forEach(e);else if(it(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)z.call(t,i)&&e(t[i],i)}var Nr=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];for(var s of i)for(var n in s)void 0!==s[n]&&(t[n]=s[n]);return t};function Ur(t){for(var e=Object.keys(t),i=e.length,r=new Array(i);i--;)r[i]=[e[i],t[e[i]]];return r}var Lr=function(t){try{return t()}catch(t){return}},jr=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,i)}catch(t){mi.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),mi.critical(t)}}},Br=function(t){var e={};return Dr(t,(function(t,i){(J(t)&&t.length>0||Z(t))&&(e[i]=t)})),e};var zr=["herokuapp.com","vercel.app","netlify.app"];function Hr(t){var e=null==t?void 0:t.hostname;if(!J(e))return!1;var i=e.split(".").slice(-2).join(".");for(var r of zr)if(i===r)return!1;return!0}function qr(t,e,i,r){var s=null!=r?r:{},n=s.capture,o=s.passive;null==t||t.addEventListener(e,i,{capture:void 0!==n&&n,passive:void 0===o||o})}function Vr(t){return"ph_toolbar_internal"===t.name}var Wr=t=>{if(r){try{for(var e=t+"=",i=r.cookie.split(";").filter((t=>t.length)),s=0;i.length>s;s++){for(var n=i[s];" "==n.charAt(0);)n=n.substring(1,n.length);if(0===n.indexOf(e))return decodeURIComponent(n.substring(e.length,n.length))}}catch(t){}return null}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Z(t)&&isFinite(t)&&Math.floor(t)===t});class Gr{constructor(t){if(this.bytes=t,16!==t.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(t,e,i,r){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(r)||0>t||0>e||0>i||0>r||t>0xffffffffffff||e>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=t/Math.pow(2,40),s[1]=t/Math.pow(2,32),s[2]=t/Math.pow(2,24),s[3]=t/Math.pow(2,16),s[4]=t/256,s[5]=t,s[6]=112|e>>>8,s[7]=e,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 Gr(s)}toString(){for(var t="",e=0;this.bytes.length>e;e++)t=t+(this.bytes[e]>>>4).toString(16)+(15&this.bytes[e]).toString(16),3!==e&&5!==e&&7!==e&&9!==e||(t+="-");if(36!==t.length)throw new Error("Invalid UUIDv7 was generated");return t}clone(){return new Gr(this.bytes.slice(0))}equals(t){return 0===this.compareTo(t)}compareTo(t){for(var e=0;16>e;e++){var i=this.bytes[e]-t.bytes[e];if(0!==i)return Math.sign(i)}return 0}}class Kr{generate(){var t=this.generateOrAbort();if(!K(t))return t;this.S=0;var e=this.generateOrAbort();if(K(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.C();else{if(this.S>=t+1e4)return;this.I++,this.I>4398046511103&&(this.S++,this.C())}return Gr.fromFieldsV7(this.S,Math.trunc(this.I/Math.pow(2,30)),this.I&Math.pow(2,30)-1,this.R.nextUint32())}C(){this.I=1024*this.R.nextUint32()+(1023&this.R.nextUint32())}constructor(){this.S=0,this.I=0,this.R=new Qr}}var Jr,Yr=t=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};t&&!K(t.crypto)&&crypto.getRandomValues&&(Yr=t=>crypto.getRandomValues(t));class Qr{nextUint32(){return this.O.length>this.N||(Yr(this.O),this.N=0),this.O[this.N++]}constructor(){this.O=new Uint32Array(8),this.N=1/0}}var Xr=()=>Zr().toString(),Zr=()=>(Jr||(Jr=new Kr)).generate(),ts="",es=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;var is={P:()=>!!r,j(t){mi.error("cookieStore error: "+t)},q:Wr,H(t){var e;try{e=JSON.parse(is.q(t))||{}}catch(t){}return e},A(t,e,i,s,n){if(!r)return!1;try{var o="",a="",l=function(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=r),ts)return ts;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),s=Math.min(i.length,8),n="dmn_chk_"+Xr();!ts&&s--;){var o=i.slice(s).join("."),a=n+"=1;domain=."+o+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(n)&&(e.cookie=a+";max-age=0",ts=o)}return ts}(t);if(!i){var s=(t=>{var e=t.match(es);return e?e[0]:""})(t);s!==i&&mi.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}(r.location.hostname,s);if(i){var u=new Date;u.setTime(u.getTime()+864e5*i),o="; expires="+u.toUTCString()}n&&(a="; secure");var h=t+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+l+a;return h.length>3686.4&&mi.warn("cookieStore warning: large cookie, len="+h.length),r.cookie=h,!0}catch(t){return!1}},F(t,e){if(null!=r&&r.cookie)try{is.A(t,"",-1,e)}catch(t){return}}},rs=null,ss={P(){if(!Q(rs))return rs;var e=!0;if(K(t))e=!1;else try{var i="__mplssupport__";ss.A(i,"xyz"),'"xyz"'!==ss.q(i)&&(e=!1),ss.F(i)}catch(t){e=!1}return e||mi.error("localStorage unsupported; falling back to cookie store"),rs=e,e},j(t){mi.error("localStorage error: "+t)},q(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(t){ss.j(t)}return null},H(t){try{return JSON.parse(ss.q(t))||{}}catch(t){}return null},A(e,i){try{return null==t||t.localStorage.setItem(e,JSON.stringify(i)),!0}catch(t){ss.j(t)}return!1},F(e){try{null==t||t.localStorage.removeItem(e)}catch(t){ss.j(t)}}},ns=[Ei,"distinct_id",zi,Hi,gr,_r,dr],os={},as={P:()=>!0,j(t){mi.error("memoryStorage error: "+t)},q:t=>os[t]||null,H:t=>os[t]||null,A:(t,e)=>(os[t]=e,!0),F(t){delete os[t]}},ls=null,us={P(){if(!Q(ls))return ls;if(ls=!0,K(t))ls=!1;else try{var e="__support__";us.A(e,"xyz"),'"xyz"'!==us.q(e)&&(ls=!1),us.F(e)}catch(t){ls=!1}return ls},j(t){mi.error("sessionStorage error: ",t)},q(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(t){us.j(t)}return null},H(t){try{return JSON.parse(us.q(t))||null}catch(t){}return null},A(e,i){try{return null==t||t.sessionStorage.setItem(e,JSON.stringify(i)),!0}catch(t){us.j(t)}return!1},F(e){try{null==t||t.sessionStorage.removeItem(e)}catch(t){us.j(t)}}};class hs{constructor(t){this._instance=t}get Pe(){return this._instance.config}get consent(){return this.ti()?0:this.ei}isOptedOut(){return this.Pe.cookieless_mode===$r||this.isRejected()||-1===this.consent&&this.Pe.cookieless_mode===Sr}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return 0===this.consent}isRejected(){return 0===this.consent||-1===this.consent&&this.Pe.opt_out_capturing_by_default}optInOut(t){this.ii.A(this.ri,t?1:0,this.Pe.cookie_expiration,this.Pe.cross_subdomain_cookie,this.Pe.secure_cookie)}reset(){this.ii.F(this.ri,this.Pe.cross_subdomain_cookie)}get ri(){var t=this._instance.config,e=t.token,i=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(i?i+e:"__ph_opt_in_out_"+e)}get ei(){var t=this.ii.q(this.ri);return ht(t)?1:N(dt,t)?0:-1}get ii(){var t=this.Pe.opt_out_capturing_persistence_type,e="localStorage"===t?ss:is;if(!this.ni||this.ni!==e){this.ni=e;var i="localStorage"===t?is:ss;i.q(this.ri)&&(this.ni.q(this.ri)||this.optInOut(ht(i.q(this.ri))),i.F(this.ri,this.Pe.cross_subdomain_cookie))}return this.ni}ti(){return!!this.Pe.respect_dnt&&[null==i?void 0:i.doNotTrack,null==i?void 0:i.msDoNotTrack,v.doNotTrack].some((t=>ht(t)))}}function ds(t,e){var i,r=null==t||null==(i=t.config)?void 0:i.get_current_url;if(!V(r))return e;try{var s=r(e);return J(s)&&s?s:e}catch(t){return mi.error("Error in get_current_url, falling back to window.location.href",t),e}}var vs="__POSTHOG_TOOLBAR__",cs=1,fs=3,ps=11;function _s(t){return t instanceof Element&&(t.id===vs||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function gs(t){return!!t&&t.nodeType===cs}function ms(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function bs(t){return!!t&&t.nodeType===fs}function ys(t){return!!t&&t.nodeType===ps&&gs(t.host)}var ws=1e3;function xs(t){return t?U(t).split(/\s+/):[]}function Es(e,i){var r=function(e){var i,r=null==t||null==(i=t.location)?void 0:i.href;return K(r)?void 0:ds(e,r)}(i);return!!(r&&e&&e.some((t=>r.match(t))))}function Ss(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return xs(e)}function $s(t){return X(t)?null:U(t).split(/(\s+)/).filter((t=>Js(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function ks(t){var e="";return js(t)&&!Bs(t)&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,(function(t){var i;bs(t)&&t.textContent&&(e+=null!==(i=$s(t.textContent))&&void 0!==i?i:"")})),U(e)}function Ts(t){var e;return K(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}var Rs=["a","button","form","input","select","textarea","label"];function Ps(t,e){if(K(e))return!0;var i,r=function(t){if(e.some((e=>function(t,e){var i=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!i&&i.call(t,e)}catch(t){return!1}}(t,e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function Os(t){var e=t.parentNode;return!(!e||!gs(e))&&e}var Is=[".ph-no-autocapture","[data-ph-no-autocapture]"],Cs=["next","previous","prev",">","<"],As=[...Cs,"+","-","−","–"],Ms=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,Fs=[".ph-no-rageclick",".ph-no-capture"],Ds=["","text","search","email","password","url","tel","number"];function Ns(e,i){if(!t||Us(e))return!1;var r,s,n,o,a;if(et(i)?(r=!!i&&Fs,s=void 0,n=!1):(r=null!==(o=null==i?void 0:i.css_selector_ignorelist)&&void 0!==o?o:Fs,s=null==i?void 0:i.content_ignorelist,n=null!==(a=null==i?void 0:i.ignore_text_selection)&&void 0!==a&&a),!1===r)return!1;if(n&&function(t){return!(!t||!gs(t))&&(!!ms(t,"textarea")||(ms(t,"input")?N(Ds,(t.getAttribute("type")||"").toLowerCase()):function(t){if(t.isContentEditable)return!0;var e=null==t.getAttribute?void 0:t.getAttribute("contenteditable");return"true"===e||""===e}(t)))}(e))return!1;var l=Ls(e,!1).targetElementList;return!function(t,e){if(!1===t||K(t))return!1;var i;if(!0===t)i=Cs;else{if(!q(t))return!1;if(t.length>10)return mi.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=t.map((t=>t.toLowerCase()))}return e.some((t=>{var e=t.safeText,r=t.ariaLabel;return i.some((t=>Ms(e,t)||Ms(r,t)))}))}(s,l.map((t=>{var e;return{safeText:ks(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!Ps(l,r)}var Us=t=>!t||ms(t,"html")||!gs(t),Ls=(e,i)=>{if(!t||Us(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,s=[e],n=e;n.parentNode&&!ms(n,"body");)if(ys(n.parentNode))s.push(n.parentNode.host),n=n.parentNode.host;else{var o=Os(n);if(!o)break;if(i||Rs.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var a=t.getComputedStyle(o);a&&"pointer"===a.getPropertyValue("cursor")&&(r=!0)}catch(t){}s.push(o),n=o}return{parentIsUsefulElement:r,targetElementList:s}};function js(t){for(var e=new Set,i=0,r=t;r.parentNode&&!ms(r,"body");r=r.parentNode){if(i++>=ws||e.has(r))return!1;e.add(r);var s=Ss(r);if(N(s,"ph-sensitive")||N(s,"ph-no-capture"))return!1}if(N(Ss(t),"ph-include"))return!0;var n=t.type||"";if(J(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!J(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function Bs(t){return!!(ms(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ms(t,"select")||ms(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var zs=new RegExp("^(?:(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}))$"),Hs=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,qs=[16,15,14,13],Vs=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),Ws=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),Gs=/[0-9A-Za-z_]/;function Ks(t){for(var e=0,i=!1,r=t.length-1;r>=0;r--){var s=t.charCodeAt(r)-48;i&&(s*=2)>9&&(s-=9),e+=s,i=!i}return e%10==0}function Js(t,e){if(void 0===e&&(e=!0),X(t))return!1;if(J(t)){t=U(t);var i=e?zs.test((t||"").replace(/[- ]/g,"")):function(t){var e;for(Hs.lastIndex=0;e=Hs.exec(t);){var i=e[2];if(i)for(var r=i.replace(/[- ]/g,""),s=0;r.length>s;s++)for(var n of qs){var o=s+n;if(r.length>=o){var a=r.slice(s,o);if(zs.test(a)&&Ks(a))return!0}}}return!1}(t);if(i)return!1;var r=e?Vs.test(t):function(t){var e;for(Ws.lastIndex=0;e=Ws.exec(t);){var i=e[1],r=e[3];if(!(i&&r&&Gs.test(i)&&Gs.test(r)))return!0}return!1}(t);if(r)return!1}return!0}function Ys(t){var e=ks(t);return Js(e=(e+" "+Qs(t)).trim())?e:""}function Qs(t){var e="";return t&&t.childNodes&&t.childNodes.length&&Dr(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=ks(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Qs(t)).trim())}catch(t){mi.error("[AutoCapture]",t)}})),e}function Xs(t){return t.replace(/"|\\"/g,'\\"')}function Zs(t){var e=t.attr__class;if(e)return q(e)?e:xs(e)}var tn=bi("[Dead Clicks]"),en=()=>!0,rn=t=>{var e,i=!(null==(e=t.instance.persistence)||!e.get_property(Ai)),r=t.instance.config.capture_dead_clicks;return et(r)?r:!!W(r)||i};class sn{get lazyLoadedDeadClicksAutocapture(){return this.si}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Ai]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.ai((()=>{this.oi()})):this.stop()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.initDeadClicksAutocapture?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?tn.error("failed to load script",e):t()}))}oi(){var t;if(r){if(!this.si&&null!=(t=v.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=W(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.si=v.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.si.start(r),tn.info("starting...")}}else tn.error("`document` not found. Cannot start.")}stop(){this.si&&(this.si.stop(),this.si=void 0,tn.info("stopping..."))}}var nn=bi("[SegmentIntegration]");var on="posthog-js";function an(t,e){var i=void 0===e?{}:e,r=i.organization,s=i.projectId,n=i.prefix,o=i.severityAllowList,a=void 0===o?["error"]:o,l=i.sendExceptionsToPostHog,u=void 0===l||l;return e=>{var i,o,l,h,d;if("*"!==a&&!a.includes(e.level)||!t.__loaded)return e;e.tags||(e.tags={});var v=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());e.tags["PostHog Person URL"]=v,t.sessionRecordingStarted()&&(e.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var c,f=(null==(i=e.exception)?void 0:i.values)||[],p=f.map((t=>_({},t,{stacktrace:t.stacktrace?_({},t.stacktrace,{type:"raw",frames:(t.stacktrace.frames||[]).map((t=>_({},t,{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null==(o=f[0])?void 0:o.value)||e.message,$exception_type:null==(l=f[0])?void 0:l.type,$exception_level:e.level,$exception_list:p,$sentry_event_id:e.event_id,$sentry_exception:e.exception,$sentry_exception_message:(null==(h=f[0])?void 0:h.value)||e.message,$sentry_exception_type:null==(d=f[0])?void 0:d.type,$sentry_tags:e.tags};return r&&s&&(g.$sentry_url=(n||"https://sentry.io/organizations/")+r+"/issues/?project="+s+"&query="+e.event_id),u&&(null==(c=t.exceptions)||c.sendExceptionEvent(g)),e}}class ln{constructor(t,e,i,r,s,n){this.name=on,this.setupOnce=function(o){o(an(t,{organization:e,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}class un{constructor(t){this.li=(t,e,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(mi.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.ui=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.hi()}hi(){var t;this.di=null==(t=this._instance.sessionManager)?void 0:t.onSessionId(this.li)}destroy(){var t;null==(t=this.di)||t.call(this),this.di=void 0}doPageView(e,i){var r,s=this.vi(e,i);return this.ui={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(t){var e;return this.vi(t,null==(e=this.ui)?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:null==(t=this.ui)?void 0:t.pageViewId}}vi(t,e){var i=this.ui;if(!i)return{$pageview_id:e};var r={$pageview_id:e,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var n=s.maxScrollHeight,o=s.lastScrollY,a=s.maxScrollY,l=s.maxContentHeight,u=s.lastContentY,h=s.maxContentY;if(!(K(n)||K(o)||K(a)||K(l)||K(u)||K(h))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),h=Math.ceil(h);var d=n>1?vt(o/n,0,1,mi):1,v=n>1?vt(a/n,0,1,mi):1,c=l>1?vt(u/l,0,1,mi):1,f=l>1?vt(h/l,0,1,mi):1;r=Nr(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:v,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:c,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:f})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(t.getTime()-i.timestamp.getTime())/1e3),r}}var hn=["flags","surveys"],dn={[xi]:{exposure:"hidden"},[$i]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ki]:{exposure:"hidden"},[Ti]:{exposure:"event"},[Ri]:{exposure:"hidden"},[Pi]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ii]:{exposure:"event"},[Ci]:{exposure:"event"},[Ai]:{exposure:"event"},[Mi]:{exposure:"hidden"},[Fi]:{exposure:"event"},[Di]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[zi]:{exposure:"hidden"},[Hi]:{exposure:"event"},[Ni]:{exposure:"event",shouldSkipFromEventProperties:t=>Q(t)},$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"},$sess_rec_flush_size:{exposure:"hidden"},[qi]:{exposure:"derived",storageGroup:"flags",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!W(t))return{};for(var e={},i=Object.keys(t),r=0;i.length>r;r++)e["$feature/"+i[r]]=t[i[r]];return e}},[Vi]:{exposure:"event",storageGroup:"flags"},[Wi]:{exposure:"hidden"},[Gi]:{exposure:"hidden",storageGroup:"flags"},[Ki]:{exposure:"event",storageGroup:"flags"},[Ji]:{exposure:"event",storageGroup:"flags",volatile:!0},[Yi]:{exposure:"hidden",storageGroup:"flags"},[Qi]:{exposure:"event"},[Xi]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[er]:{exposure:"hidden",storageGroup:"surveys"},[ir]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[rr]:{exposure:"event"},[sr]:{exposure:"hidden"},[nr]:{exposure:"hidden"},[or]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$product_tours_activated_session:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[ar]:{exposure:"hidden"},[lr]:{exposure:"hidden"},[ur]:{exposure:"hidden"},[hr]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[dr]:{exposure:"hidden"},[vr]:{exposure:"hidden"},[cr]:{exposure:"hidden"},[fr]:{exposure:"hidden"},[pr]:{exposure:"hidden"},[_r]:{exposure:"hidden"},[gr]:{exposure:"hidden"},[Ui]:{exposure:"event"},[Li]:{exposure:"event"},[ji]:{exposure:"event"},[Bi]:{exposure:"event"},[yr]:{exposure:"event"},[wr]:{exposure:"event"},[xr]:{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"}},vn=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],cn=t=>{var e=dn[t];if(e)return e;for(var i of vn){var r=i[1];if(0===t.indexOf(i[0]))return r}},fn=(t,e)=>{try{return JSON.stringify(t,((t,e)=>"bigint"==typeof e?e.toString():e),e)}catch(e){return j(t)}},pn=t=>{var e=null==r?void 0:r.createElement("a");return K(e)?null:(e.href=t,e)},_n=function(t,e){for(var i,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;r.length>s;s++){var n=r[s].split("=");if(n[0]===e){i=n;break}}if(!q(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(t){mi.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},gn=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],h=0;l.length>h;h++){var d=l[h].split("=");q(d)&&(e.includes(d[0])?u.push(d[0]+"="+i):u.push(l[h]))}var v=a;return null!=o&&(v+="?"+u.join("&")),null!=s&&(v+="#"+s),v},mn=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},bn=(t,e)=>t>=e&&h(),yn=(t,e,i,r)=>{if(0===t){if(h()){var s=e+1;return s===i&&r(),s}return e}return 0},wn="https?://(.*)",xn=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],En=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...xn],Sn="<masked>",$n=["li_fat_id"];function kn(t,e,i){if(!r)return{};var s,n=e?[...xn,...i||[]]:[],o=Tn(gn(r.URL,n,Sn),t),a=(s={},Dr($n,(function(t){var e=Wr(t);s[t]=e||null})),s);return Nr(a,o)}function Tn(t,e){var i=En.concat(e||[]),r={};return Dr(i,(function(e){var i=_n(t,e);r[e]=i||null})),r}function Rn(t){var e=function(t){return t?0===t.search(wn+"google.([^/?]*)")?"google":0===t.search(wn+"bing.com")?"bing":0===t.search(wn+"yahoo.com")?"yahoo":0===t.search(wn+"duckduckgo.com")?"duckduckgo":null:null}(t),i="yahoo"!=e?"q":"p",s={};if(!Q(e)){s.$search_engine=e;var n=r?_n(r.referrer,i):"";n.length&&(s.ph_keyword=n)}return s}function Pn(){return navigator.language||navigator.userLanguage}var On="$direct";function In(){return(null==r?void 0:r.referrer)||On}function Cn(t,e,i){void 0===i&&(i=!1);var r=t?[...xn,...e||[]]:[],n=i?ye(null==s?void 0:s.href):null==s?void 0:s.href,o=null==n?void 0:n.substring(0,1e3);return{r:In().substring(0,1e3),u:o?gn(o,r,Sn):void 0}}function An(t,e){var i;void 0===e&&(e=!1);var r=t.r,s=t.u,n=e?ye(s):s,o={$referrer:r,$referring_domain:null==r?void 0:r==On?On:null==(i=pn(r))?void 0:i.host};if(n){o.$current_url=n;var a=pn(n);o.$host=null==a?void 0:a.host,o.$pathname=null==a?void 0:a.pathname;var l=Tn(n);Nr(o,l)}if(r){var u=Rn(r);Nr(o,u)}return o}function Mn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function Fn(){try{return(new Date).getTimezoneOffset()}catch(t){return}}var Dn={flags:hr,surveys:ir},Nn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Un="main";class Ln{constructor(e,i,r){if(void 0===r&&(r=!0),this.ci={},this.fi=!1,this.pi=!1,this.Pe=e,this.gi=r,this.props={},this.mi=void 0,this.yi=(t=>{var e="";return t.token&&(e=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+e+"_posthog"})(e),this.ii=this.bi(e),this.pi=this.wi(e),this.load(),e.debug&&mi.info("Persistence loaded",e.persistence,_({},this.props)),this.update_config(e,e,i),this.save(),t){var s=()=>this.flush();qr(t,"beforeunload",s,{capture:!1}),qr(t,"pagehide",s,{capture:!1})}}xi(){var t,e=null==(t=this.Pe)?void 0:t.persistence_save_debounce_ms;return Z(e)&&e>0?e:0}isDisabled(){return!!this.ki}bi(e){-1===Nn.indexOf(e.persistence.toLowerCase())&&(mi.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i,r=function(e,i){void 0===e&&(e=[]),void 0===i&&(i=!1);var r=[...ns,...e];return _({},ss,{H(t){try{var e={};try{e=is.H(t)||{}}catch(t){}var r,s=JSON.parse(ss.q(t)||"{}");if(i){var n={};for(var o in e){var a=e[o];Q(a)||""===a||(n[o]=a)}r=Nr(s,n)}else r=Nr(e,s);return ss.A(t,r),r}catch(t){}return null},A(t,e,i,s,n,o){var a=ss.A(t,e,void 0,void 0,o);try{var l={};r.forEach((t=>{e[t]&&(l[t]=e[t])})),Object.keys(l).length&&is.A(t,l,i,s,n,o)}catch(t){ss.j(t)}return a},F(e,i){try{null==t||t.localStorage.removeItem(e),is.F(e,i)}catch(t){ss.j(t)}}})}(e.cookie_persisted_properties||[],e.__preview_cookie_wins_on_conflict||!1),s=!1,n=e.persistence.toLowerCase();return"localstorage"===n&&ss.P()?(i=ss,s=!0):"localstorage+cookie"===n&&r.P()?(i=r,s=!0):"sessionstorage"===n&&us.P()?i=us:"memory"===n?i=as:"cookie"===n?i=is:r.P()?(i=r,s=!0):i=is,this.fi=s,i}Si(t){return this.yi+"__"+t}wi(t){return this.fi&&!!t.split_storage}Ci(t){var e=null!=t?t:this.Pe.feature_flag_cache_ttl_ms;if(!e||0>=e)return!1;var i=this.props[hr];return!i||"number"!=typeof i||Date.now()-i>e}properties(){var t={};return Dr(this.props,((e,i)=>{var r=cn(i);if("derived"===(null==r?void 0:r.exposure)){if(null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e,i===qi?()=>this.Ci():()=>!1))return;r.transformToEventProperties&&Nr(t,r.transformToEventProperties(e))}else if(!r||"event"===r.exposure){if(null!=r&&null!=r.shouldSkipFromEventProperties&&r.shouldSkipFromEventProperties(e,(()=>!1)))return;t[i]=e}})),t}load(){if(!this.ki){var t=this.ii.H(this.yi);t&&(this.props=Nr({},t)),this.pi&&this.Mi()}}Mi(){for(var t of hn){var e=ss.H(this.Si(t));if(e&&!G(e)){var i=this.Ti(t);i.persisted=!0,this.Ei(t)||(i.fingerprint=this.Ii(e,t)),this.Pi(t,e)||Nr(this.props,e)}}}Ei(t){return Object.keys(this.props).some((e=>{var i;return(null==(i=cn(e))?void 0:i.storageGroup)===t}))}Pi(t,e){var i=Dn[t];if(!i)return!1;var r=e[i],s=this.props[i];return Z(r)&&Z(s)&&s>r}refreshKey(t){var e;if(!this.ki){var i=this.pi?null==(e=cn(t))?void 0:e.storageGroup:void 0,r=i?ss.H(this.Si(i)):this.ii.H(this.yi);if(r&&t in r)this.Ri(t,r[t]);else{if(i){var s=this.ii.H(this.yi);if(s&&t in s)return void this.Ri(t,s[t])}this.Li(t)}}}save(){if(!this.ki){var t=this.xi();t>0?K(this.Oi)&&(this.Oi=setTimeout((()=>{this.Oi=void 0,this.Fi()}),t)):this.Fi()}}flush(){K(this.Oi)||(clearTimeout(this.Oi),this.Oi=void 0,this.Fi())}Fi(){this.ki||(this.pi?this.Ai():this.Di(this.ii,this.yi,this.props,Un))}Ai(){var t=this.$i(),e=t.main,i=t.groups;for(var r of(this.Di(this.ii,this.yi,e,Un),hn)){var s,n=i[r];(!G(n)||null!=(s=this.ci[r])&&s.persisted)&&this.Di(ss,this.Si(r),n,r)}}$i(){var t={},e={flags:{},surveys:{}};return Dr(this.props,((i,r)=>{var s,n=null==(s=cn(r))?void 0:s.storageGroup;n?e[n][r]=i:t[r]=i})),{main:t,groups:e}}Ii(t,e){if(e===Un)return JSON.stringify(t)+"|"+this.Ni+"|"+this.qi+"|"+this.ji;var i={};return Dr(t,((t,e)=>{var r;i[e]=null!=(r=cn(e))&&r.volatile?"__volatile__":t})),JSON.stringify(i)}Di(t,e,i,r){var s=this.Ti(r);if(r===Un||s.dirty||K(s.fingerprint)){var n;try{if((n=this.Ii(i,r))===s.fingerprint)return void(s.dirty=!1)}catch(t){n=void 0}t.A(e,i,this.Ni,this.qi,this.ji,this.Pe.debug)?(s.dirty=!1,r!==Un&&(s.persisted=!0),K(n)||(s.fingerprint=n)):this.Pe.debug&&mi.warn('failed to persist storage entry "'+e+'"; will retry on next save')}}remove(t){var e=(void 0===t?{}:t).keepGroupEntries,i=void 0!==e&&e;if(K(this.Oi)||(clearTimeout(this.Oi),this.Oi=void 0),this.ii.F(this.yi,!1),this.ii.F(this.yi,!0),!i&&this.gi)for(var r of hn)ss.F(this.Si(r));i?delete this.ci[Un]:this.ci={}}clear(){this.remove(),this.props={}}register_once(t,e,i){if(W(t)){K(e)&&(e="None"),this.Ni=K(i)?this.Bi:i;var r=!1;if(Dr(t,((t,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==e||(this.Ri(i,t),r=!0)})),r)return this.save(),!0}return!1}register(t,e){if(W(t)){this.Ni=K(e)?this.Bi:e;var i=!1;if(Dr(t,((e,r)=>{t.hasOwnProperty(r)&&this.props[r]!==e&&(this.Ri(r,e),i=!0)})),i)return this.save(),!0}return!1}unregister(t){t in this.props&&(this.Li(t),this.save())}update_campaign_params(){var t=null==r?void 0:r.URL;if(t!==this.mi){var e=kn(this.Pe.custom_campaign_params,this.Pe.mask_personal_data_properties,this.Pe.custom_personal_data_properties);G(Br(e))||this.register(e),this.mi=t}}update_search_keyword(){var t;this.register((t=null==r?void 0:r.referrer)?Rn(t):{})}update_referrer_info(){var t;this.register_once({$referrer:In(),$referring_domain:null!=r&&r.referrer&&(null==(t=pn(r.referrer))?void 0:t.host)||On},void 0)}set_initial_person_info(){this.props[fr]||this.props[pr]||this.register_once({[_r]:Cn(this.Pe.mask_personal_data_properties,this.Pe.custom_personal_data_properties,this.Pe.disable_capture_url_hashes)},void 0)}get_initial_props(){var t={};Dr([pr,fr],(e=>{var i=this.props[e];i&&Dr(i,(function(e,i){t["$initial_"+L(i)]=e}))}));var e=this.props[_r];if(e){var i=function(t,e){void 0===e&&(e=!1);var i=An(t,e),r={};return Dr(i,(function(t,e){r["$initial_"+L(e)]=t})),r}(e,this.Pe.disable_capture_url_hashes);Nr(t,i)}return t}safe_merge(t){return Dr(this.props,(function(e,i){i in t||(t[i]=e)})),t}update_config(t,e,i){this.Bi=this.Ni=t.cookie_expiration,this.set_disabled(t.disable_persistence||!!i),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie);var r=t.persistence!==e.persistence||!((t,e)=>{if(t.length!==e.length)return!1;var i=[...t].sort(),r=[...e].sort();return i.every(((t,e)=>t===r[e]))})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),s=r?this.bi(t):this.ii,n=this.wi(t);if(r||n!==this.pi){var o=this.props;this.clear(),this.ii=s,this.pi=n,this.props=o,this.save()}}set_disabled(t){this.ki=t,this.ki?this.remove():this.save()}set_cross_subdomain(t){t!==this.qi&&(this.qi=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.ji&&(this.ji=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var i=this.props[ki]||{};i[t]=e,this.Ri(ki,i),this.save()}remove_event_timer(t){var e=this.props[ki]||{},i=e[t];return K(i)||(delete e[t],this.Ri(ki,e),this.save()),i}get_property(t){return this.props[t]}set_property(t,e){this.Ri(t,e),this.save()}Ri(t,e){var i;this.props[t]=e,null!=(i=cn(t))&&i.volatile||this.Hi(t)}Li(t){delete this.props[t],this.Hi(t)}Hi(t){var e,i=null==(e=cn(t))?void 0:e.storageGroup;i&&(this.Ti(i).dirty=!0)}Ti(t){return this.ci[t]||(this.ci[t]={})}}function jn(t){var e=!0;return{dispose(){if(e){e=!1;var i=t();i&&V(i.then)&&i.then(void 0,(()=>{}))}}}}var Bn={GZipJS:"gzip-js",Base64:"base64"},zn={Activation:"events",Cancellation:"cancelEvents"},Hn={Button:"button",Tab:"tab",Selector:"selector"},qn={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"},Vn={Top:"top",Left:"left",Right:"right",Bottom:"bottom"},Wn={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Gn={Open:"open",MultipleChoice:"multiple_choice",SingleChoice:"single_choice",Rating:"rating",Link:"link"},Kn={NextQuestion:"next_question",End:"end",ResponseBased:"response_based",SpecificQuestion:"specific_question"},Jn={Once:"once",Recurring:"recurring",Always:"always"},Yn={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Qn={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"},Xn={Popover:"popover",Inline:"inline"},Zn={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},to={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"},eo={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"},io=bi("[RateLimiter]");class ro{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var e=t.text;if(e&&e.length)try{(JSON.parse(e).quota_limited||[]).forEach((t=>{io.info((t||"events")+" is quota limited."),this.serverLimits[t]=(new Date).getTime()+6e4}))}catch(t){return void io.warn('could not rate limit - continuing. Error: "'+(null==t?void 0:t.message)+'"',{text:e})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return(null==(t=this.instance.config.rate_limiting)?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max((null==(t=this.instance.config.rate_limiting)?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,i,r;void 0===t&&(t=!1);var s=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=(new Date).getTime(),a=null!==(e=null==(i=this.instance.persistence)?void 0:i.get_property(cr))&&void 0!==e?e:{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;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(Z(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ui(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(cr,a),{isRateLimited:l,remainingTokens:a.tokens}}zi(t){var e=this.instance.config.property_denylist;return!q(e)||!e.includes(t)}Wi(){var t;if(this.zi("$current_url")&&this.zi("$pathname")&&null!=s&&s.pathname)return""+(null!==(t=s.origin)&&void 0!==t?t:"")+s.pathname}Ui(t){var e,i,r=this.captureEventsBurstLimit,s=this.captureEventsPerSecond,n=this.Wi(),o=this.zi("$session_id")?null==(e=(i=this.instance).get_session_id)?void 0:e.call(i):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+s+" events per second and "+r+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return!1!==e&&(new Date).getTime()<e}}var so=bi("[RemoteConfig]");class no{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Vi(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Zi(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return so.info("Using preloaded remote config",this.remoteConfig),this.Gi(this.remoteConfig),void this.Qi();if(this._instance.Ji())return void so.warn("Remote config is disabled. Falling back to local config.");this.Vi((t=>{if(!t)return so.info("No config found after loading remote JS config. Falling back to JSON."),void this.Zi((t=>{this.Gi(t.json,t),this.Qi()}));this.Gi(t),this.Qi()}))}catch(t){so.error("Error loading remote config",t),this.Gi()}}stop(){this.Ki&&(clearInterval(this.Ki),this.Ki=void 0)}refresh(){!this._instance.Ji()&&r&&"hidden"!==r.visibilityState&&this._instance.reloadFeatureFlags()}Qi(){var t;if(!this.Ki){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Ki=setInterval((()=>{this.refresh()}),e))}}Gi(t,e){!t&&e&&(0===e.statusCode?e.error||so.warn("Failed to fetch remote config from PostHog."):so.error("Failed to fetch remote config from PostHog."));try{this._instance.Gi(t?{ok:!0,config:t}:{ok:!1})}catch(t){so.error("Error applying remote config",t)}if(!1!==(null==t?void 0:t.hasFeatureFlags)&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var i;null==(i=this._instance.featureFlags)||i.ensureFlagsLoaded()}catch(t){so.error("Error loading feature flags",t)}}}var oo=["fatal","error","warning","log","info","debug"],ao=Uint8Array,lo=Uint16Array,uo=Uint32Array,ho=new ao([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]),vo=new ao([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]),co=new ao([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fo=function(t,e){for(var i=new lo(31),r=0;31>r;++r)i[r]=e+=1<<t[r-1];var s=new uo(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]},po=fo(ho,2),_o=po[1];po[0][28]=258,_o[258]=28;for(var go=fo(vo,0)[1],mo=new lo(32768),bo=0;32768>bo;++bo){var yo=(43690&bo)>>>1|(21845&bo)<<1;mo[bo]=((65280&(yo=(61680&(yo=(52428&yo)>>>2|(13107&yo)<<2))>>>4|(3855&yo)<<4))>>>8|(255&yo)<<8)>>>1}var wo=function(t,e,i){for(var r=t.length,s=0,n=new lo(e);r>s;++s)++n[t[s]-1];var o,a=new lo(e);for(s=0;e>s;++s)a[s]=a[s-1]+n[s-1]<<1;if(i){o=new lo(1<<e);var l=15-e;for(s=0;r>s;++s)if(t[s])for(var u=s<<4|t[s],h=e-t[s],d=a[t[s]-1]++<<h,v=d|(1<<h)-1;v>=d;++d)o[mo[d]>>>l]=u}else for(o=new lo(r),s=0;r>s;++s)o[s]=mo[a[t[s]-1]++]>>>15-t[s];return o},xo=new ao(288);for(bo=0;144>bo;++bo)xo[bo]=8;for(bo=144;256>bo;++bo)xo[bo]=9;for(bo=256;280>bo;++bo)xo[bo]=7;for(bo=280;288>bo;++bo)xo[bo]=8;var Eo=new ao(32);for(bo=0;32>bo;++bo)Eo[bo]=5;var So=wo(xo,9,0),$o=wo(Eo,5,0),ko=function(t){return(t/8>>0)+(7&t&&1)},To=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var r=new(t instanceof lo?lo:t instanceof uo?uo:ao)(i-e);return r.set(t.subarray(e,i)),r},Ro=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8},Po=function(t,e,i){var r=e/8>>0;t[r]|=i<<=7&e,t[r+1]|=i>>>8,t[r+2]|=i>>>16},Oo=function(t,e){for(var i=[],r=0;t.length>r;++r)t[r]&&i.push({s:r,f:t[r]});var s=i.length,n=i.slice();if(!s)return[new ao(0),0];if(1==s){var o=new ao(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(t,e){return t.f-e.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,h=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=s-1;)a=i[i[d].f>i[u].f?u++:d++],l=i[u!=h&&i[d].f>i[u].f?u++:d++],i[h++]={s:-1,f:a.f+l.f,l:a,r:l};var v=n[0].s;for(r=1;s>r;++r)n[r].s>v&&(v=n[r].s);var c=new lo(v+1),f=Io(i[h-1],c,0);if(f>e){r=0;var p=0,_=f-e,g=1<<_;for(n.sort((function(t,e){return c[e.s]-c[t.s]||t.f-e.f}));s>r;++r){var m=n[r].s;if(e>=c[m])break;p+=g-(1<<f-c[m]),c[m]=e}for(p>>>=_;p>0;){var b=n[r].s;e>c[b]?p-=1<<e-c[b]++-1:++r}for(;r>=0&&p;--r){var y=n[r].s;c[y]==e&&(--c[y],++p)}f=e}return[new ao(c),f]},Io=function(t,e,i){return-1==t.s?Math.max(Io(t.l,e,i+1),Io(t.r,e,i+1)):e[t.s]=i},Co=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new lo(++e),r=0,s=t[0],n=1,o=function(t){i[r++]=t},a=1;e>=a;++a)if(t[a]==s&&a!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=t[a]}return[i.subarray(0,r),e]},Ao=function(t,e){for(var i=0,r=0;e.length>r;++r)i+=t[r]*e[r];return i},Mo=function(t,e,i){var r=i.length,s=ko(e+2);t[s]=255&r,t[s+1]=r>>>8,t[s+2]=255^t[s],t[s+3]=255^t[s+1];for(var n=0;r>n;++n)t[s+n+4]=i[n];return 8*(s+4+r)},Fo=function(t,e,i,r,s,n,o,a,l,u,h){Ro(e,h++,i),++s[256];for(var d=Oo(s,15),v=d[0],c=d[1],f=Oo(n,15),p=f[0],_=f[1],g=Co(v),m=g[0],b=g[1],y=Co(p),w=y[0],x=y[1],E=new lo(19),S=0;m.length>S;++S)E[31&m[S]]++;for(S=0;w.length>S;++S)E[31&w[S]]++;for(var k=Oo(E,7),T=k[0],R=k[1],P=19;P>4&&!T[co[P-1]];--P);var O,I,C,A,M=u+5<<3,F=Ao(s,xo)+Ao(n,Eo)+o,D=Ao(s,v)+Ao(n,p)+o+14+3*P+Ao(E,T)+(2*E[16]+3*E[17]+7*E[18]);if(F>=M&&D>=M)return Mo(e,h,t.subarray(l,l+u));if(Ro(e,h,1+(F>D)),h+=2,F>D){O=wo(v,c,0),I=v,C=wo(p,_,0),A=p;var N=wo(T,R,0);for(Ro(e,h,b-257),Ro(e,h+5,x-1),Ro(e,h+10,P-4),h+=14,S=0;P>S;++S)Ro(e,h+3*S,T[co[S]]);h+=3*P;for(var U=[m,w],L=0;2>L;++L){var j=U[L];for(S=0;j.length>S;++S)Ro(e,h,N[B=31&j[S]]),h+=T[B],B>15&&(Ro(e,h,j[S]>>>5&127),h+=j[S]>>>12)}}else O=So,I=xo,C=$o,A=Eo;for(S=0;a>S;++S)if(r[S]>255){var B;Po(e,h,O[257+(B=r[S]>>>18&31)]),h+=I[B+257],B>7&&(Ro(e,h,r[S]>>>23&31),h+=ho[B]);var z=31&r[S];Po(e,h,C[z]),h+=A[z],z>3&&(Po(e,h,r[S]>>>5&8191),h+=vo[z])}else Po(e,h,O[r[S]]),h+=I[r[S]];return Po(e,h,O[256]),h+I[256]},Do=new uo([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),No=function(){for(var t=new uo(256),e=0;256>e;++e){for(var i=e,r=9;--r;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),Uo=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};function Lo(t,e){void 0===e&&(e={});var i=function(){var t=4294967295;return{p(e){for(var i=t,r=0;e.length>r;++r)i=No[255&i^e[r]]^i>>>8;t=i},d(){return 4294967295^t}}}(),r=t.length;i.p(t);var s,n,o,a,l,u=(a=10+((s=e).filename&&s.filename.length+1||0),l=8,function(t,e,i,r,s,n){var o=t.length,a=new ao(r+o+5*(1+Math.floor(o/7e3))+s),l=a.subarray(r,a.length-s),u=0;if(!e||8>o)for(var h=0;o>=h;h+=65535){var d=h+65535;o>d?u=Mo(l,u,t.subarray(h,d)):(l[h]=!0,u=Mo(l,u,t.subarray(h,o)))}else{for(var v=Do[e-1],c=v>>>13,f=8191&v,p=(1<<i)-1,_=new lo(32768),g=new lo(p+1),m=Math.ceil(i/3),b=2*m,y=function(e){return(t[e]^t[e+1]<<m^t[e+2]<<b)&p},w=new uo(25e3),x=new lo(288),E=new lo(32),S=0,k=0,T=(h=0,0),R=0,P=0;o>h;++h){var O=y(h),I=32767&h,C=g[O];if(_[I]=C,g[O]=I,h>=R){var A=o-h;if((S>7e3||T>24576)&&A>423){u=Fo(t,l,0,w,x,E,k,T,P,h-P,u),T=S=k=0,P=h;for(var M=0;286>M;++M)x[M]=0;for(M=0;30>M;++M)E[M]=0}var F=2,D=0,N=f,U=I-C&32767;if(A>2&&O==y(h-U))for(var L=Math.min(c,A)-1,j=Math.min(32767,h),B=Math.min(258,A);j>=U&&--N&&I!=C;){if(t[h+F]==t[h+F-U]){for(var z=0;B>z&&t[h+z]==t[h+z-U];++z);if(z>F){if(F=z,D=U,z>L)break;var H=Math.min(U,z-2),q=0;for(M=0;H>M;++M){var V=h-U+M+32768&32767,W=V-_[V]+32768&32767;W>q&&(q=W,C=V)}}}U+=(I=C)-(C=_[I])+32768&32767}if(D){w[T++]=268435456|_o[F]<<18|go[D];var G=31&_o[F],K=31&go[D];k+=ho[G]+vo[K],++x[257+G],++E[K],R=h+F,++S}else w[T++]=t[h],++x[t[h]]}}u=Fo(t,l,!0,w,x,E,k,T,P,h-P,u)}return To(a,0,r+ko(u)+s)}(n=t,null==(o=e).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)),h=u.length;return function(t,e){var i=e.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=2>e.level?4:9==e.level?2:0,t[9]=3,0!=e.mtime&&Uo(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var r=0;i.length>=r;++r)t[r+10]=i.charCodeAt(r)}}(u,e),Uo(u,h-8,i.d()),Uo(u,h-4,r),u}var jo=!!o||!!n,Bo="text/plain",zo=!1,Ho=(t,e)=>{var i=t.split("#"),r=i[1],s=i[0].split("?"),n=s[0],o=s[1];if(!o)return t;var a=o.split("&").filter((t=>t.split("=")[0]!==e)).join("&");return n+(a?"?"+a:"")+(r?"#"+r:"")},qo=function(t,e,i){var r;void 0===i&&(i=!0);var s=t.split("?"),n=s[0],o=s[1],a=_({},e),l=null!==(r=null==o?void 0:o.split("&").map((t=>{var e,r=t.split("="),s=r[0],n=i&&null!==(e=a[s])&&void 0!==e?e:r[1];return delete a[s],s+"="+n})))&&void 0!==r?r:[],u=function(t,e){var i,r;void 0===e&&(e="&");var s=[];return Dr(t,(function(t,e){K(t)||K(e)||"undefined"===e||(i=encodeURIComponent((t=>t instanceof File)(t)?t.name:t.toString()),r=encodeURIComponent(e),s[s.length]=r+"="+i)})),s.join(e)}(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},Vo=t=>{if(t.Yi)return t.Yi;var e=t.data,i=t.compression;if(e){if(i===Bn.GZipJS){var r=Lo(function(t,e){var i=t.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(t);for(var r=new ao(t.length+(t.length>>>1)),s=0,n=function(t){r[s++]=t},o=0;i>o;++o){if(s+5>r.length){var a=new ao(s+8+(i-o<<1));a.set(r),r=a}var l=t.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&t.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 To(r,0,s)}(fn(e)),{mtime:0});return{contentType:Bo,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(i===Bn.Base64){var s=function(t){return t?btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(parseInt(e,16))))):t}(fn(e)),n=(t=>"data="+encodeURIComponent("string"==typeof t?t:fn(t)))(s);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=fn(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Wo=t=>{var e,i,r=()=>"sendBeacon"===t.transport?{url:qo(t.url,{compression:Bn.Base64}),encodedBody:Vo(_({},t,{compression:Bn.Base64,Yi:void 0}))}:{url:Ho(t.url,"compression"),encodedBody:Vo(_({},t,{compression:void 0,Yi:void 0}))};try{e=Vo(t)}catch(e){if(O(t.compression,_n(t.url,"compression")))return mi.error("Failed to gzip request body, sending uncompressed payload",e),r();throw e}return e&&O(t.compression,_n(t.url,"compression"))&&!((i=e.body)instanceof ArrayBuffer?P(new Uint8Array(i)):ArrayBuffer.isView(i)&&P(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(zo=!0,r()):{url:t.url,encodedBody:e}},Go=t=>{try{return Wo(t)}catch(e){return mi.error(e),void(null==t.callback||t.callback({statusCode:0,error:e}))}},Ko=function(){var t=p((function*(t){var e=fn(t.data),i=yield function(t,e,i){return M.apply(this,arguments)}(e,c.DEBUG,{rethrow:!0});if(!i)return t;var r=yield i.arrayBuffer();return _({},t,{Yi:{contentType:Bo,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}}(),Jo=/Failed to fetch|NetworkError|Load failed/i,Yo=t=>{var e=Go(t);if(e){var i=e.url,r=e.encodedBody,s=null!=r?r:{},o=s.contentType,l=s.body,u=s.estimatedSize,h=new Headers;Dr(t.headers,(function(t,e){h.append(e,t)})),o&&h.append("Content-Type",o);var d=null,v=!1;if(a){var c=new a;d={signal:c.signal,timeout:setTimeout((()=>{var e,i;v=!0,c.abort((e=t.timeout,(i=new Error("PostHog request timed out"+(e?" after "+e+"ms":""))).name="AbortError",i))}),t.timeout)}}var f=e=>{v&&"AbortError"===(null==e?void 0:e.name)||(t=>"TypeError"===(null==t?void 0:t.name)&&Jo.test((null==t?void 0:t.message)||""))(e)?mi.warn(e):mi.error(e),null==t.callback||t.callback({statusCode:0,error:e})};try{var p;n(i,_({method:(null==t?void 0:t.method)||"GET",headers:h,keepalive:"POST"===t.method&&!t.Xi&&52428.8>(u||0),body:l,signal:null==(p=d)?void 0:p.signal},t.fetchOptions)).then((e=>e.text().then((i=>{var r={statusCode:e.status,text:i};if(200===e.status)try{r.json=JSON.parse(i)}catch(t){mi.error(t)}null==t.callback||t.callback(r)})))).catch(f).finally((()=>d?clearTimeout(d.timeout):null))}catch(t){d&&clearTimeout(d.timeout),f(t)}}},Qo=t=>{try{var e,r=Wo(t),s=r.url,n=r.encodedBody,o=null!=n?n:{},a=o.body,l=o.estimatedSize;if(!a)return;var u=a instanceof Blob?a:new Blob([a],{type:o.contentType});if(i.sendBeacon(s,u))return;var h=q(t.data)?t.data:null==(e=t.data)?void 0:e.batch;if(q(h)&&h.length>1&&(null!=l?l:0)>16384){var d=Math.ceil(h.length/2),v=e=>q(t.data)?e:_({},t.data,{batch:e});return Qo(_({},t,{data:v(h.slice(0,d))})),void Qo(_({},t,{data:v(h.slice(d))}))}mi.warn("Beacon of ~"+(null!=l?l:0)+" bytes was rejected by the browser, falling back to fetch"),Yo(_({},t,{Xi:!0}))}catch(t){mi.warn("Beacon send failed",t)}},Xo=(t,e,i,r)=>{var s="query"===r?"POST"===e?"sent_at":"_":void 0;return qo(i===Bn.GZipJS?Ho(t,"compression"):t,_({},s?{[s]:Date.now().toString()}:{},i===Bn.GZipJS?{}:{compression:i}))},Zo=[];n&&Zo.push({transport:"fetch",method:Yo}),o&&Zo.push({transport:"XHR",method(t){var e=Go(t);if(e){var i=new o,r=e.encodedBody;i.open(t.method||"GET",e.url,!0);var s=null!=r?r:{},n=s.contentType,a=s.body;Dr(t.headers,(function(t,e){i.setRequestHeader(e,t)})),n&&i.setRequestHeader("Content-Type",n),t.timeout&&(i.timeout=t.timeout),i.onreadystatechange=()=>{if(4===i.readyState){var e={statusCode:i.status,text:i.responseText};if(200===i.status)try{e.json=JSON.parse(i.responseText)}catch(t){}null==t.callback||t.callback(e)}},i.send(a)}}}),null!=i&&i.sendBeacon&&Zo.push({transport:"sendBeacon",method:Qo});var ta=3e3;class ea{constructor(t,e){this.tr=!0,this.er=[],this.ir=vt((null==e?void 0:e.flush_interval_ms)||ta,250,5e3,mi.createLogger("flush interval"),ta),this.rr=t}enqueue(t){this.er.push(t),this.nr||this.sr()}unload(){this.ar();var t=this.er.length>0?this.lr():{},e=Object.values(t);[...e.filter((t=>0===t.url.indexOf("/e"))),...e.filter((t=>0!==t.url.indexOf("/e")))].map((t=>{this.ur(_({},t,{transport:"sendBeacon"}))}))}enable(){this.tr=!1,this.sr()}sr(){var t=this;this.tr||(this.nr=setTimeout((()=>{if(this.ar(),this.er.length>0){var e=this.lr(),i=function(){var i=e[r],s=(new Date).getTime();i.data&&q(i.data)&&Dr(i.data,(t=>{t.offset=Math.abs(t.timestamp-s),delete t.timestamp})),t.ur(i)};for(var r in e)i()}}),this.ir))}ur(t){try{this.rr(t)}catch(t){mi.error(t)}}ar(){clearTimeout(this.nr),this.nr=void 0}lr(){var t={};return Dr(this.er,(e=>{var i,r=e,s=(r?r.batchKey:null)||r.url;K(t[s])&&(t[s]=_({},r,{data:[]})),null==(i=t[s].data)||i.push(r.data)})),this.er=[],t}}var ia=["retriesPerformedSoFar"];class ra{constructor(e){this.hr=!1,this.dr=3e3,this.er=[],this._instance=e,this.er=[],this.vr=!0,!K(t)&&"onLine"in t.navigator&&(this.vr=t.navigator.onLine,this.cr=()=>{this.vr=!0,this.pr()},this.gr=()=>{this.vr=!1},qr(t,"online",this.cr),qr(t,"offline",this.gr))}get length(){return this.er.length}retriableRequest(t){var e=t.retriesPerformedSoFar,i=g(t,ia);tt(e)&&(i.url=qo(i.url,{retry_count:e})),this._instance._send_request(_({},i,{callback:t=>{if(200!==t.statusCode&&(400>t.statusCode||t.statusCode>=500)){if((0===t.statusCode?3:10)>(null!=e?e:0))return void this.Lt(_({retriesPerformedSoFar:e},i));0===t.statusCode&&mi.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(null!=e?e:0)+" retries.")}null==i.callback||i.callback(t)}}))}Lt(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var i=function(t){var e=3e3*Math.pow(2,t),i=e/2,r=Math.min(18e5,e),s=Math.random()-.5;return Math.ceil(r+s*(r-i))}(e),r=Date.now()+i;this.er.push({retryAt:r,requestOptions:t});var s="Enqueued failed request for retry in "+i;navigator.onLine||(s+=" (Browser is offline)"),mi.warn(s),this.hr||(this.hr=!0,this.mr())}mr(){if(this.yr&&clearTimeout(this.yr),0===this.er.length)return this.hr=!1,void(this.yr=void 0);this.yr=setTimeout((()=>{this.vr&&this.er.length>0&&this.pr(),this.mr()}),this.dr)}pr(){var t=Date.now(),e=[],i=this.er.filter((i=>t>i.retryAt||(e.push(i),!1)));if(this.er=e,i.length>0)for(var r of i)this.retriableRequest(r.requestOptions)}unload(){for(var e of(this.yr&&(clearTimeout(this.yr),this.yr=void 0),this.hr=!1,K(t)||(this.cr&&(t.removeEventListener("online",this.cr),this.cr=void 0),this.gr&&(t.removeEventListener("offline",this.gr),this.gr=void 0)),this.er)){var i=e.requestOptions;try{this._instance._send_request(_({},i,{transport:"sendBeacon"}))}catch(t){mi.error(t)}}this.er=[]}}class sa{constructor(t){this.br=()=>{var t,e,i,r;this._r||(this._r={});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._r.lastScrollY=Math.ceil(n),this._r.maxScrollY=Math.max(n,null!==(t=this._r.maxScrollY)&&void 0!==t?t:0),this._r.maxScrollHeight=Math.max(o,null!==(e=this._r.maxScrollHeight)&&void 0!==e?e:0),this._r.lastContentY=a,this._r.maxContentY=Math.max(a,null!==(i=this._r.maxContentY)&&void 0!==i?i:0),this._r.maxContentHeight=Math.max(l,null!==(r=this._r.maxContentHeight)&&void 0!==r?r:0)},this._instance=t}get wr(){return this._instance.config.scroll_root_selector}getContext(){return this._r}resetContext(){var t=this._r;return setTimeout(this.br,0),t}startMeasuringScrollPosition(){qr(t,"scroll",this.br,{capture:!0}),qr(t,"scrollend",this.br,{capture:!0}),qr(t,"resize",this.br)}scrollElement(){if(!this.wr)return null==t?void 0:t.document.documentElement;var e=q(this.wr)?this.wr:[this.wr];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}kr(e){var i="y"===e?"scrollTop":"scrollLeft";if(this.wr){var r=this.scrollElement();return r&&r[i]||0}return t?"y"===e?t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop||0:t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft||0:0}scrollY(){return this.kr("y")}scrollX(){return this.kr("x")}}var na=t=>Cn(null==t?void 0:t.config.mask_personal_data_properties,null==t?void 0:t.config.custom_personal_data_properties,null==t?void 0:t.config.disable_capture_url_hashes);class oa{constructor(t,e,i,r){this.Sr=t=>{var e=this.Cr();if(!e||e.sessionId!==t){var i={sessionId:t,props:this.Mr(this._instance)};this.Tr.register({[vr]:i})}},this._instance=t,this.Er=e,this.Tr=i,this.Mr=r||na,this.Er.onSessionId(this.Sr)}Cr(){return this.Tr.props[vr]}getSetOnceProps(){var t,e=null==(t=this.Cr())?void 0:t.props;return e?"r"in e?An(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return Dr(Br(this.getSetOnceProps()),((e,i)=>{"$current_url"===i&&(i="url"),t["$session_entry_"+L(i)]=e})),t}}class aa{on(t,e){return this.Ir[t]||(this.Ir[t]=[]),this.Ir[t].push(e),()=>{this.Ir[t]=this.Ir[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.Ir[t]||[])i(e);for(var r of this.Ir["*"]||[])r(t,e)}constructor(){this.Ir={}}}var la=bi("[SessionId]");class ua{on(t,e){return this.Pr.on(t,e)}constructor(t,e,i){var r;if(this.Rr=null,this.Lr=[],this.Or=void 0,this.Fr=!1,this.Pr=new aa,this.Ar=(t,e)=>!(!tt(t)||!tt(e))&&Math.abs(t-e)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode===$r)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Pe=t.config,this.Tr=t.persistence,this.Dr=void 0,this.$r=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Nr=e||Xr,this.qr=i||Xr;var s=this.Pe.persistence_name||this.Pe.token;if(this._sessionTimeoutMs=1e3*vt(this.Pe.session_idle_timeout_seconds||1800,60,36e3,la.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.jr(),this.Br="ph_"+s+"_window_id",this.Hr="ph_"+s+"_primary_window_exists",this.Ur()){var n=us.H(this.Br),o=us.H(this.Hr);n&&!o?this.Dr=n:us.F(this.Br),us.A(this.Hr,!0)}if(null!=(r=this.Pe.bootstrap)&&r.sessionID)try{var a=(t=>{var e=this.Pe.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.zr(this.Pe.bootstrap.sessionID,(new Date).getTime(),a)}catch(t){la.error("Invalid sessionID in bootstrap",t)}this.Wr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return K(this.Lr)&&(this.Lr=[]),this.Lr.push(t),this.$r&&t(this.$r,this.Dr),()=>{this.Lr=this.Lr.filter((e=>e!==t))}}Ur(){return"memory"!==this.Pe.persistence&&!this.Tr.ki&&us.P()}Vr(t){t!==this.Dr&&(this.Dr=t,this.Ur()&&us.A(this.Br,t))}Zr(){return this.Dr?this.Dr:this.Ur()?us.H(this.Br):null}Gr(t){var e=this.Rr;return!Q(e)&&!Q(t)&&5e3>Math.abs(t-e)}zr(t,e,i){var r=e!==this._sessionActivityTimestamp,s=!(t!==this.$r||i!==this._sessionStartTimestamp);this._sessionStartTimestamp=i,this._sessionActivityTimestamp=e,this.$r=t,s&&!r||s&&this.Gr(e)||(this.Rr=e,this.Tr.register({[zi]:[e,t,i]}))}Qr(){var t,e=null==(t=this.Pe)?void 0:t.persistence_save_debounce_ms;return tt(e)&&e>0}Jr(){this.Qr()?this.Tr.refreshKey(zi):(this.Tr.flush(),this.Tr.load())}Kr(){var t;if(!Q(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.Rr){this.Jr();var e=this.Yr();e[1]===this.$r&&e[2]===this._sessionStartTimestamp&&(this.Rr=this._sessionActivityTimestamp,this.Tr.register({[zi]:[this._sessionActivityTimestamp,null!==(t=this.$r)&&void 0!==t?t:null,this._sessionStartTimestamp]}),this.Tr.flush())}}Xr(){var t=this.Yr()[0],e=tt(t)?t:0,i=tt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,i)}tn(t){return this.Jr(),this.Ar(t,this.Xr())}Yr(){var t=this.Tr.props[zi];return q(t)&&2===t.length&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rr=null,clearTimeout(this.en),this.en=void 0,this.zr(null,null,null)}destroy(){this.Fr=!0,this.Kr(),clearTimeout(this.en),this.en=void 0,this.Or&&t&&(t.removeEventListener(Or,this.Or,{capture:!1}),this.Or=void 0),this.Lr=[]}Wr(){this.Or=()=>{this.Kr(),this.Ur()&&us.F(this.Hr)},qr(t,Or,this.Or,{capture:!1})}checkAndGetSessionAndWindowId(t,e){if(void 0===t&&(t=!1),void 0===e&&(e=null),this.Pe.cookieless_mode===$r)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=e||(new Date).getTime(),r=this.Yr(),s=r[1],n=r[2],o=this.Xr(),a=this.Zr(),l=tt(n)&&Math.abs(i-n)>864e5,u=!1,h=!1,d=!s,v=s,c=!d&&!t&&this.Ar(i,o);if(c){(c=this.tn(i))||la.info("cross-tab refresh kept the session alive",{sessionId:s});var f=this.Yr();s=f[1],n=f[2]}d||c||l?(s=this.Nr(),a=this.qr(),la.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:d,activityTimeout:c,sessionPastMaximumLength:l}}),n=i,u=!0):(a||(a=this.qr(),u=!0),(h=s!==v)&&(la.info("adopted cross-tab session id",{sessionId:s,windowId:a}),u=!0));var p=tt(o)&&t&&!l?o:i,_=tt(n)?n:(new Date).getTime();this.Vr(a),this.zr(s,p,_),t||this.jr();var g={noSessionId:d,activityTimeout:c,sessionPastMaximumLength:l,crossTabAdoption:h};return u&&this.Lr.forEach((t=>t(s,a,g))),{sessionId:s,windowId:a,sessionStartTimestamp:_,changeReason:u?g:void 0,lastActivityTimestamp:o}}jr(){this.Fr||(clearTimeout(this.en),this.en=setTimeout((()=>{if(!this.Fr)if(this.tn((new Date).getTime())){var t=this.$r;this.resetSessionId(),this.Pr.emit("forcedIdleReset",{idleSessionId:t})}else this.jr()}),1.1*this.sessionTimeoutMs))}}var ha=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&D(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>D(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver};function da(){return(da=p((function*(){var t=null==i?void 0:i.userAgentData;if(null!=t&&t.getHighEntropyValues)try{var e=yield t.getHighEntropyValues(["model"]),r=null==e?void 0:e.model;return J(r)&&r.length>0?r:void 0}catch(t){return void mi.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",t)}}))).apply(this,arguments)}var va=function(t,e){if(!function(t){try{new RegExp(t)}catch(t){return!1}return!0}(e))return!1;try{return new RegExp(e).test(t)}catch(t){return!1}};function ca(t,e,i){return fn({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}var fa={exact:(t,e)=>e.some((e=>t.some((t=>e===t)))),is_not:(t,e)=>e.every((e=>t.every((t=>e!==t)))),regex:(t,e)=>e.some((e=>t.some((t=>va(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!va(e,t))))),icontains:(t,e)=>e.map(pa).some((e=>t.map(pa).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(pa).every((e=>t.map(pa).every((t=>!e.includes(t))))),gt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i>parseFloat(t)))})),lt:(t,e)=>e.some((e=>{var i=parseFloat(e);return!isNaN(i)&&t.some((t=>i<parseFloat(t)))}))},pa=t=>t.toLowerCase();function _a(t,e){return!t||Object.entries(t).every((t=>{var i=t[1],r=null==e?void 0:e[t[0]];if(K(r)||Q(r))return!1;var s=[String(r)],n=fa[i.operator];return!!n&&n(i.values,s)}))}var ga="custom",ma="i.posthog.com",ba=/^\/static\//;class ya{constructor(t){this.rn={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===t?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=null==(t=this.instance.config.ui_host)?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+ma,".posthog.com")),"https://app.posthog.com"===e?"https://us.posthog.com":e}get region(){return this.rn[this.apiHost]||(this.rn[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":ga),this.rn[this.apiHost]}nn(t){if(ba.test(t)){var e=this.instance.config.asset_host;if("string"==typeof e)return e.trim().replace(/\/$/,"")||void 0}}endpointFor(t,e){if(void 0===e&&(e=""),e&&(e="/"===e[0]?e:"/"+e),"ui"===t)return this.uiHost+e;if("flags"===t)return this.flagsApiHost+e;if("assets"===t){var i=this.nn(e);if(i)return""+i+e}if(this.region===ga)return this.apiHost+e;var r=ma+e;switch(t){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}function wa(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}var xa=bi("[Surveys]"),Ea="seenSurvey_",Sa=t=>{try{var e=(t=>((t,e)=>""+Ea+function(t){return t.current_iteration&&t.current_iteration>0?t.id+"_"+t.current_iteration:t.id}(e))(0,t))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(t){xa.error("Failed to persist survey seen state",t)}},$a=[Wn.Popover,Wn.Widget,Wn.API],ka={ignoreConditions:!1,ignoreDelay:!1,displayType:Xn.Popover},Ta=bi("[PostHog ExternalIntegrations]"),Ra={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Pa{constructor(t){this._instance=t}ai(t,e){var i;null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,t,(t=>{if(t)return Ta.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var t=this,e=function(){var e,r,s,n=i[0],o=i[1];!o||null!=(e=v.__PosthogExtensions__)&&null!=(e=e.integrations)&&e[n]||t.ai(Ra[n],(()=>{var e;null==(e=v.__PosthogExtensions__)||null==(e=e.integrations)||null==(e=e[n])||e.start(t._instance)})),!o&&null!=(r=v.__PosthogExtensions__)&&null!=(r=r.integrations)&&r[n]&&(null==(s=v.__PosthogExtensions__)||null==(s=s.integrations)||null==(s=s[n])||s.stop())};for(var i of Object.entries(null!==(r=this._instance.config.integrations)&&void 0!==r?r:{})){var r;e()}}}class Oa{constructor(t,e){this.rt=t,this.sn=e,this.an=new Map,this.ln=!1}add(t){var e=this;return p((function*(){if(e.ln)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.an.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.an.set(t.name,t);try{var i=t.setup(e.sn);i&&(yield i)}catch(i){var r=e.an.get(t.name)===t;r&&e.an.delete(t.name),e.rt.error('Failed to set up browser extension "'+t.name+'"',i),r&&e.un(t)}}))()}dispose(){if(!this.ln){this.ln=!0;var t=Array.from(this.an.values()).reverse();for(var e of(this.an.clear(),t))this.un(e)}}un(t){try{var e=null==t.dispose?void 0:t.dispose();e&&V(e.then)&&e.then(void 0,(e=>{this.rt.error('Failed to dispose browser extension "'+t.name+'"',e)}))}catch(e){this.rt.error('Failed to dispose browser extension "'+t.name+'"',e)}}}class Ia{constructor(t){this._instance=t}get(t){var e;return null==(e=this._instance.persistence)?void 0:e.get_property(t)}set(t,e){var i;null==(i=this._instance.persistence)||i.set_property(t,e)}remove(t){var e;null==(e=this._instance.persistence)||e.unregister(t)}}var Ca="extensionsRemoteConfig";class Aa{constructor(t){this.ln=!1,this.instance=t,this.rt=mi.createLogger("[BrowserExtensions]"),this.hn=t.dn,this.kv=new Ia(t),this.onEvent=t=>jn(this.instance.on("eventCaptured",(e=>{try{t({event:e.event,properties:e.properties})}catch(t){this.rt.error("Browser extension event listener failed",t)}}))),this.onRemoteConfig=t=>{if(this.ln)return jn((()=>{}));var e=e=>{try{t(e)}catch(t){this.rt.error("Browser extension remote config listener failed",t)}},i=this.instance.vn.on(Ca,e);return this.hn&&e(this.hn),jn(i)},this.cn=new Oa(this.rt,this)}get logger(){return this.rt}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return null!==(t=this.instance.get_property(Ei))&&void 0!==t?t:this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var t,e,i,r,s=null==(t=this.instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:null!==(e=null==s?void 0:s.sessionId)&&void 0!==e?e:"",windowId:null!==(i=null==s?void 0:s.windowId)&&void 0!==i?i:"",sessionStartTimestamp:null!==(r=null==s?void 0:s.sessionStartTimestamp)&&void 0!==r?r:0}}catch(t){return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(t){return this.cn.add(t)}capture(t,e,i){var r=this;return p((function*(){i?r.instance.capture(t,e,{timestamp:i.timestamp,uuid:i.uuid,$set:i.set,$set_once:i.setOnce}):r.instance.capture(t,e)}))()}registerDynamicEventProperties(t){return jn(this.instance.fn(t))}handleRemoteConfig(t){this.ln||(this.hn=t,this.instance.vn.emit(Ca,t))}sendRequest(t,e){var i=this;return p((function*(){var r;void 0===e&&(e={});var s=i.instance.requestRouter.endpointFor(null!==(r=e.target)&&void 0!==r?r:"api",t),n={method:e.method,url:e.query?qo(s,e.query):s,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport};return"sendBeacon"===e.transport?(i.instance._send_request(n),{statusCode:202}):new Promise((t=>{n.callback=t,i.instance._send_request(n)}))}))()}dispose(){this.ln||(this.ln=!0,this.cn.dispose())}}var Ma={},Fa=0,Da=()=>{},Na='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Ua="Surveys module not available",La="sanitize_properties is deprecated. Use before_send instead",ja="Invalid value for property_denylist config: ",Ba=["token","distinct_id",br],za="posthog",Ha=!jo&&-1===(null==u?void 0:u.indexOf("MSIE"))&&-1===(null==u?void 0:u.indexOf("Mozilla")),qa=e=>{var i;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Hr(null==r?void 0:r.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Da,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,__preview_cookie_wins_on_conflict:!1,debug:s&&J(null==s?void 0:s.search)&&-1!==s.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,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==t||null==(i=t.location)?void 0:i.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(t){mi.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Rr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:ta},error_tracking:{},_onCapture:Da},(t=>({rageclick:t&&t>="2026-05-30"?{content_ignorelist:As,ignore_text_selection:!0}:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2026-06-25"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:t&&t>="2026-05-30"?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:t&&t>="2026-05-30"?250:0,split_storage:!(!t||"2026-05-30">t),detect_google_search_app:!(!t||"2026-05-30">t),disable_capture_url_hashes:!(!t||"2026-06-25">t)}))(e))},Va=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"]],Wa=t=>{var e={};for(var i of Va){var r=i[0],s=i[1];K(t[r])||(e[s]=t[r])}var n=Nr({},e,t),o=t.__preview_external_dependency_versioned_paths;return K(o)||(K(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),J(o)&&K(t.asset_host)&&(n.asset_host=o)),q(t.property_blacklist)&&(K(t.property_denylist)?n.property_denylist=t.property_blacklist:q(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:mi.error(ja+t.property_denylist)),n};class Ga{constructor(){this.__forceAllowLocalhost=!1}get pn(){return this.__forceAllowLocalhost}set pn(t){mi.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}}class Ka{gn(t,e){if(t){var i=this.an.indexOf(t);-1!==i&&this.an.splice(i,1)}return this.an.push(e),null==e.initialize||e.initialize(),e}mn(){return this.config.cookieless_mode===$r||this.config.cookieless_mode===Sr&&this.consent.isRejected()}get decideEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}get flagsEndpointWasHit(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.hasLoadedFlags)&&void 0!==t&&t}constructor(){var t;this.webPerformance=new Ga,this.yn=!1,this.version=c.LIB_VERSION,this.vn=new aa,this.an=[],this.bn=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=qa(),this.SentryIntegration=ln,this.sentryIntegration=t=>function(t,e){var i=an(t,e);return{name:on,processEvent:t=>i(t)}}(this,t),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._n=!1,this.wn=null,this.xn=null,this.kn=null,this.scrollManager=new sa(this),this.pageViewManager=new un(this),this.rateLimiter=new ro(this),this.requestRouter=new ya(this),this.consent=new hs(this),this.externalIntegrations=new Pa(this);var e=null!==(t=Ka.__defaultExtensionClasses)&&void 0!==t?t:{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(t,e,i)=>{var r=J(t)?{[t]:e}:t;this.setPersonProperties(r),null==i||i({})},set_once:(t,e,i)=>{var r=J(t)?{[t]:e}:t;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(t=>mi.info('send "'+(null==t?void 0:t.event)+'"',t)))}init(t,e,i){if(i&&i!==za){var r,s=null!==(r=Ma[i])&&void 0!==r?r:new Ka;return s._init(t,e,i),Ma[i]=s,Ma[za][i]=s,s}return this._init(t,e,i)}_init(e,i,r){var s,n;void 0===i&&(i={});var o,a=J(e)?e.trim():"";if(!a)return mi.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 a!==(null==(o=this.config)?void 0:o.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+a+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=qa(i.defaults),i.debug=this.Sn(i.debug),this.Cn=i,this.Mn=[],i.person_profiles?this.xn=i.person_profiles:i.process_person&&(this.xn=i.process_person);var l=qa(i.defaults),u=Wa(i),h=Nr({},l,u,{name:r,token:a});W(l.rageclick)&&W(u.rageclick)&&(h.rageclick=Nr({},l.rageclick,u.rageclick)),W(l.session_recording)&&W(u.session_recording)&&(h.session_recording=Nr({},l.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&mi.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:Bn.GZipJS;var d=this.Tn();this.persistence=new Ln(this.config,d),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ln(_({},this.config,{persistence:"sessionStorage"}),d,!1);var v=_({},this.persistence.props),f=_({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.En=new ea((t=>this.In(t)),this.config.request_queue_config),this.Pn=new ra(this),this.__request_queue=[];var p=this.mn();if(p||(this.sessionManager=new ua(this),this.sessionPropsManager=new oa(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(mi.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Rn(p)}),0)):(mi.info("Initializing extensions synchronously"),this.Rn(p)),c.DEBUG=c.DEBUG||this.config.debug,c.DEBUG&&mi.info("Starting in debug mode",{this:this,config:i,thisC:_({},this.config),p:v,s:f}),!this.config.identity_distinct_id||null!=(s=i.bootstrap)&&s.distinctID||(i.bootstrap=_({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),void 0!==(null==(n=i.bootstrap)?void 0:n.distinctID)){var g=i.bootstrap.distinctID,m=this.get_distinct_id(),b=this.persistence.get_property(dr);if(i.bootstrap.isIdentifiedID&&null!=m&&m!==g&&b===kr)this.identify(g);else if(i.bootstrap.isIdentifiedID&&null!=m&&m!==g&&b===Tr)mi.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 y=this.config.get_device_id(Xr()),w=i.bootstrap.isIdentifiedID?y:g;this.persistence.set_property(dr,i.bootstrap.isIdentifiedID?Tr:kr),this.register({distinct_id:g,$device_id:w})}}if(p)this.register_once({distinct_id:mr,$device_id:null},"");else if(!this.get_distinct_id()){var x=this.config.get_device_id(Xr());this.register_once({distinct_id:x,$device_id:x},""),this.persistence.set_property(dr,kr)}return qr(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?function(t,e){var i=t.config.segment;if(!i)return e();!function(t,e){var i=t.config.segment;if(!i)return e();var r=i=>{var r=()=>i.anonymousId()||Xr();t.config.get_device_id=r,i.id()&&(t.register({distinct_id:i.id(),$device_id:r()}),t.persistence.set_property(dr,Tr)),e()},s=i.user();"then"in s&&V(s.then)?s.then(r):r(s)}(t,(()=>{i.register((t=>{"undefined"!=typeof Promise&&Promise.resolve||nn.warn("This browser does not have Promise support, and can not use the segment integration");var e=(e,i)=>{if(!i)return e;e.event.userId||e.event.anonymousId===t.get_distinct_id()||(nn.info("No userId set, resetting PostHog"),t.reset()),e.event.userId&&e.event.userId!==t.get_distinct_id()&&(nn.info("UserId set, identifying with PostHog"),t.identify(e.event.userId));var r=t.calculateEventProperties(i,e.event.properties);return e.event.properties=Object.assign({},r,e.event.properties),e};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:t=>e(t,t.event.event),page:t=>e(t,Ir),identify:t=>e(t,Ar),screen:t=>e(t,"$screen")}})(t)).then((()=>{e()}))}))}(this,(()=>this.Ln())):this.Ln(),V(this.config._onCapture)&&this.config._onCapture!==Da&&(mi.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(t=>this.config._onCapture(t.event,t)))),this.config.ip&&mi.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.config.disableDeviceModel||function(){return da.apply(this,arguments)}().then((t=>{t&&this.register({[Si]:t})})).catch(Da),this}Rn(t){var e,i,r,s,n,o,a,l,u=performance.now(),h=_({},Ka.__defaultExtensionClasses,this.config.__extensionClasses),d=[];h.featureFlags&&this.an.push(this.featureFlags=null!==(e=this.featureFlags)&&void 0!==e?e:new h.featureFlags(this)),h.exceptions&&this.an.push(this.exceptions=null!==(i=this.exceptions)&&void 0!==i?i:new h.exceptions(this)),h.historyAutocapture&&this.an.push(this.historyAutocapture=new h.historyAutocapture(this)),h.tracingHeaders&&this.an.push(this.tracingHeaders=new h.tracingHeaders(this)),h.siteApps&&this.an.push(this.siteApps=new h.siteApps(this)),h.sessionRecording&&!t&&this.an.push(this.sessionRecording=new h.sessionRecording(this)),this.config.disable_scroll_properties||d.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),h.autocapture&&this.an.push(this.autocapture=new h.autocapture(this)),h.surveys&&this.an.push(this.surveys=null!==(r=this.surveys)&&void 0!==r?r:new h.surveys(this)),h.logs&&this.an.push(this.logs=null!==(s=this.logs)&&void 0!==s?s:new h.logs(this)),h.metrics&&this.an.push(this.metrics=null!==(n=this.metrics)&&void 0!==n?n:new h.metrics(this)),h.conversations&&this.an.push(this.conversations=null!==(o=this.conversations)&&void 0!==o?o:new h.conversations(this)),h.productTours&&this.an.push(this.productTours=new h.productTours(this)),h.heatmaps&&this.an.push(this.heatmaps=new h.heatmaps(this)),h.webVitalsAutocapture&&this.an.push(this.webVitalsAutocapture=new h.webVitalsAutocapture(this)),h.exceptionObserver&&this.an.push(this.exceptionObserver=new h.exceptionObserver(this)),h.deadClicksAutocapture&&this.an.push(this.deadClicksAutocapture=new h.deadClicksAutocapture(this,rn)),h.toolbar&&this.an.push(this.toolbar=null!==(a=this.toolbar)&&void 0!==a?a:new h.toolbar(this)),h.experiments&&this.an.push(this.experiments=null!==(l=this.experiments)&&void 0!==l?l:new h.experiments(this)),this.an.forEach((t=>{t.initialize&&d.push((()=>{null==t.initialize||t.initialize()}))})),d.push((()=>{if(this.On){var t=this.On;this.On=void 0,this.an.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}})),this.Fn(d,u)}Fn(t,e){for(;t.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-e>=30&&t.length>0)return void setTimeout((()=>{this.Fn(t,e)}),0);var i=t.shift();if(i)try{i()}catch(t){mi.error("Error initializing extension:",t)}}var r=Math.round(performance.now()-e);this.register_for_session({[yr]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[wr]:r}),this.config.__preview_deferred_init_extensions&&mi.info("PostHog extensions initialized ("+r+"ms)")}Gi(t){var e;if(!r||!r.body)return mi.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Gi(t)}),500);if(this.config.__preview_deferred_init_extensions&&(this.On=t),this.dn=t,this.compression=void 0,t.ok){var i,s=t.config;s.supportedCompression&&!this.config.disable_compression&&(this.compression=N(s.supportedCompression,Bn.GZipJS)?Bn.GZipJS:N(s.supportedCompression,Bn.Base64)?Bn.Base64:void 0),null!=(i=s.analytics)&&i.endpoint&&(this.analyticsDefaultEndpoint=s.analytics.endpoint)}this.set_config({person_profiles:this.xn?this.xn:Rr}),null==(e=this.An)||e.handleRemoteConfig(t),this.an.forEach((e=>null==e.onRemoteConfig?void 0:e.onRemoteConfig(t)))}Ln(){try{this.config.loaded(this)}catch(t){mi.critical("`loaded` function failed",t)}if(this.Dn(),this.config.internal_or_test_user_hostname&&null!=s&&s.hostname){var t=s.hostname,e=this.config.internal_or_test_user_hostname;("string"==typeof e?t===e:e.test(t))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.mn())&&this.$n()}),1),this.Nn=new no(this),this.Nn.load()}Dn(){var t;this.is_capturing()&&this.config.request_batching&&(null==(t=this.En)||t.enable())}_dom_loaded(){this.is_capturing()&&Fr(this.__request_queue,(t=>this.In(t))),this.__request_queue=[],this.Dn()}_handle_unload(){var t,e,i,r,s;null==(t=this.surveys)||null==t.handlePageUnload||t.handlePageUnload(),null==(e=this.metrics)||e.flush("sendBeacon"),this.config.request_batching?(this.qn()&&this.capture(Cr),null==(i=this.logs)||i.flushLogs("sendBeacon"),null==(r=this.En)||r.unload(),null==(s=this.Pn)||s.unload()):this.qn()&&this.capture(Cr,null,{transport:"sendBeacon"})}_send_request(t){this.__loaded?Ha?this.__request_queue.push(t):this.rateLimiter.isServerRateLimited(t.batchKey)?t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:429})):(t.transport=t.transport||this.config.api_transport,t.headers=_({},this.config.request_headers,t.headers),t.compression="best-available"===t.compression?this.compression:t.compression,(K(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(t.disableTransport=["sendBeacon"]),t.fetchOptions=t.fetchOptions||this.config.fetch_options,(t=>{var e,i,r,s=_({},t);s.timeout=s.timeout||6e4;var n,o,a,u,h,d=null!==(e=s.transport)&&void 0!==e?e:"fetch";"sendBeacon"===d&&K(s.compression)&&s.data&&(s.compression=Bn.Base64),"POST"===s.method&&s.data&&("capture-body"===s.timestampMode?s.data={api_key:null!==(o=null==(h=(u=q(n=s.data)?n:[n])[0])||null==(a=h.properties)?void 0:a.token)&&void 0!==o?o:null==h?void 0:h.token,batch:u,sent_at:(new Date).toISOString()}:"body"===s.timestampMode&&(s.data=function(t,e){return void 0===e&&(e=(new Date).toISOString()),q(t)?t.map((t=>_({},t,{sent_at:e}))):_({},t,{sent_at:e})}(s.data))),s.url=Xo(s.url,s.method,s.compression,s.timestampMode);var v=Zo.filter((t=>!s.disableTransport||!t.transport||!s.disableTransport.includes(t.transport))),c=null!==(i=null==(r=function(t,e){for(var i=0;t.length>i;i++)if(t[i].transport===d)return t[i]}(v))?void 0:r.method)&&void 0!==i?i:v[0].method;if(!c)throw new Error("No available transport method");"sendBeacon"!==d&&s.data&&s.compression===Bn.GZipJS&&l&&"undefined"!=typeof Promise&&!zo?Ko(s).then((t=>{c(t)})).catch((e=>{if(I(e))return zo=!0,void c(_({},s,{compression:void 0,url:Xo(t.url,t.method,void 0,t.timestampMode)}));(t=>{if(!t||"object"!=typeof t)return!1;var e="name"in t?String(t.name):"";return I(t)||e===R})(e)&&(zo=!0),c(s)})):c(s)})(_({},t,{callback:e=>{var i,r;this.rateLimiter.checkForLimiting(e),400>e.statusCode||null==(i=(r=this.config).on_request_error)||i.call(r,e),null==t.callback||t.callback(e)}}))):t.fireCallbackOnDrop&&(null==t.callback||t.callback({statusCode:0}))}In(t){this.Pn?this.Pn.retriableRequest(t):this._send_request(t)}_execute_array(t){Fa++;try{var e,i=[],r=[],s=[];Fr(t,(t=>{if(t)if(q(e=t[0]))s.push(t);else if(V(t))try{t.call(this)}catch(e){mi.error("Error executing queued PostHog call",t,e)}else q(t)&&"alias"===e?i.push(t):q(t)&&-1!==e.indexOf("capture")&&V(this[e])?s.push(t):r.push(t)}));var n=function(t,e){Fr(t,(function(t){try{if(q(t[0])){var i=e;Dr(t,(function(t){i=i[t[0]].apply(i,t.slice(1))}))}else e[t[0]].apply(e,t.slice(1))}catch(e){mi.error("Error executing queued PostHog call",t,e)}}))};n(i,this),n(r,this),n(s,this)}finally{Fa--}}push(t){if(Fa>0&&q(t)&&J(t[0])){var e=Ka.prototype[t[0]];V(e)&&e.apply(this,t.slice(1))}else this._execute_array([t])}capture(t,e,i){var r,s,n,o,a,l,u;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.En){if(this.is_capturing())if(!K(t)&&J(t)){var h=!this.config.opt_out_useragent_filter&&this._is_bot();if(!h||this.config.__preview_capture_bot_pageviews){var d=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==d||!d.isRateLimited){if(this.bn.length>0){var v={};for(var c of this.bn.slice())try{Nr(v,c())}catch(t){mi.error("Failed to produce browser extension event properties",t)}e=_({},v,null!=e?e:{})}var f;null!=(r=e)&&r.$current_url&&!J(null==(s=e)?void 0:s.$current_url)&&(mi.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==(f=e)||delete f.$current_url),"$exception"!==t||null!=i&&i.jn||mi.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 p=new Date,g=(null==i?void 0:i.timestamp)||p,m=be(null==i?void 0:i.uuid,Xr),b={uuid:m,event:t,properties:this.calculateEventProperties(t,e||{},g,m)};t===Ir&&this.config.__preview_capture_bot_pageviews&&h&&(b.event="$bot_pageview",b.properties.$browser_type="bot"),d&&(b.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens);var y="$feature_flag_called"===t&&!1===b.properties.$feature_flag_has_experiment&&!0===this.get_property(Yi);(null==i?void 0:i.$set)&&!y&&(b.$set=null==i?void 0:i.$set);var w=null==i?void 0:i.$unset;w&&(b.$unset=w);var E,S,k,T=y?void 0:this.Bn(null==i?void 0:i.$set_once,t!==Mr,t===Ar);if(T&&(b.$set_once=T),null!=i&&i._noTruncate||(o=this.config.properties_string_max_length,a=b,l=t=>J(t)?t.slice(0,o):t,u=new Set,b=function t(e,i){if(e!==Object(e))return l?l(e):e;if(!u.has(e)){var r;if(u.add(e),q(e))r=[],Fr(e,(e=>{r.push(t(e))}));else{var s={};Dr(e,((e,i)=>{u.has(e)||(s[i]=t(e,i))})),r=s}return r}}(a)),b.timestamp=g,K(null==i?void 0:i.timestamp)||(b.properties.$event_time_override_provided=!0,b.properties.$event_time_override_system_time=p),y&&(b.properties=function(t,e){void 0===e&&(e=[]);var i={},r=e=>{void 0!==t[e]&&(i[e]=t[e])};return x.forEach(r),e.forEach(r),i}(b.properties,Ba)),t===Yn.DISMISSED||t===Yn.SENT){var R,P,O=null==(R=e)?void 0:R[Qn.SURVEY_ID],I=null==(P=e)?void 0:P[Qn.SURVEY_ITERATION];Sa({id:O,current_iteration:I}),b.$set=_({},b.$set,{[(E={id:O,current_iteration:I},S=t===Yn.SENT?"responded":"dismissed",k="$survey_"+S+"/"+E.id,E.current_iteration&&E.current_iteration>0&&(k="$survey_"+S+"/"+E.id+"/"+E.current_iteration),k)]:!0})}else t===Yn.SHOWN&&(b.$set=_({},b.$set,{[Qn.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));if(t===to.SHOWN){var C,A=null==(C=e)?void 0:C[eo.TOUR_TYPE];A&&(b.$set=_({},b.$set,{[eo.TOUR_LAST_SEEN_DATE+"/"+A]:(new Date).toISOString()}))}var M=_({},b.properties.$set,b.$set);if(G(M)||this.setPersonPropertiesForFlags(M),!X(this.config.before_send)){var F=this.Pt(b);if(!F)return;(b=F).uuid=be(b.uuid,Xr)}this.vn.emit("eventCaptured",b);var D=null!==(n=null==i?void 0:i._url)&&void 0!==n?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),N={method:"POST",url:D,data:b,compression:"best-available",timestampMode:"recordings"===(null==i?void 0:i._batchKey)||/\/s\/(?:\?|$)/.test(D)?"body":"capture-body",batchKey:null==i?void 0:i._batchKey,transport:null==i?void 0:i.transport};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.In(N):this.En.enqueue(N),b}mi.critical("This capture call is ignored due to client rate limiting.")}}else mi.error("No event name provided to posthog.capture")}else mi.uninitializedWarning("posthog.capture")}_addCaptureHook(t){return this.on("eventCaptured",(e=>t(e.event,e)))}Hn(){var t;return null!==(t=this.An)&&void 0!==t?t:this.An=new Aa(this)}fn(t){this.bn.push(t);var e=!0;return()=>{if(e){e=!1;var i=this.bn.indexOf(t);-1!==i&&this.bn.splice(i,1)}}}calculateEventProperties(e,i,n,o,a){if(n=n||new Date,!this.persistence||!this.sessionPersistence)return i;var l=a?void 0:this.persistence.remove_event_timer(e),h=_({},i);if(h.token=this.config.token,h.$config_defaults=this.config.defaults,this.mn()&&(h[br]=!0),"$snapshot"===e){var d=_({},this.persistence.properties(),this.sessionPersistence.properties());return h.distinct_id=d.distinct_id,(!J(h.distinct_id)&&!Z(h.distinct_id)||Y(h.distinct_id))&&mi.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),h}var v,f=function(e,i,r,n){var o,a,l,h;if(void 0===n&&(n=!1),!u)return{};var d,v=e?[...xn,...i||[]]:[],f=function(t){for(var e=0;_e.length>e;e++){var i=_e[e],r=i[1],s=i[0].exec(t),n=s&&(V(r)?r(s,t):r);if(n)return n}return["",""]}(u),p=f[0],_=f[1],g=null!=(d="undefined"!=typeof navigator?navigator:void 0)&&d.brave?{brave:!0}:{},m={};K(r)||(m.detectGoogleSearchApp=r);var b={},y=null==(o=navigator)||null==(o=o.userAgentData)?void 0:o.platform,w=null==(a=navigator)?void 0:a.maxTouchPoints,x=null==t||null==(l=t.screen)?void 0:l.width,E=null==t||null==(h=t.screen)?void 0:h.height,S=null==t?void 0:t.devicePixelRatio;K(y)||(b.userAgentDataPlatform=y),K(w)||(b.maxTouchPoints=w),K(x)||(b.screenWidth=x),K(E)||(b.screenHeight=E),K(S)||(b.devicePixelRatio=S);var k,T,R,P,O,I,C,A,M=Nr(Br({$os:p,$os_version:_,$browser:ce(u,navigator.vendor,g,m),$device:ge(u),$device_type:(T=u,R=b,A=ge(T),A===bt||A===mt||"Kobo"===A||"Kindle Fire"===A||A===Jt?gt:A===Ut||A===jt||A===Lt||A===Wt?"Console":A===wt?"Wearable":A?ft:"Android"===(null==R?void 0:R.userAgentDataPlatform)&&(null!==(P=null==R?void 0:R.maxTouchPoints)&&void 0!==P?P:0)>0?600>Math.min(null!==(O=null==R?void 0:R.screenWidth)&&void 0!==O?O:0,null!==(I=null==R?void 0:R.screenHeight)&&void 0!==I?I:0)/(null!==(C=null==R?void 0:R.devicePixelRatio)&&void 0!==C?C:1)?ft:gt:"Desktop"),$timezone:Mn(),$timezone_offset:Fn()}),{$current_url:gn(n?ye(null==s?void 0:s.href):null==s?void 0:s.href,v,Sn),$host:null==s?void 0:s.host,$pathname:null==s?void 0:s.pathname,$raw_user_agent:u.length>1e3?u.substring(0,997)+"...":u,$browser_version:pe(u,navigator.vendor,g,m),$browser_language:Pn(),$browser_language_prefix:(k=Pn(),"string"==typeof k?k.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return c.SDK_DIST_CHANNEL&&(M.$sdk_dist_channel=c.SDK_DIST_CHANNEL),M}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var p=this.sessionManager.checkAndGetSessionAndWindowId(a,n.getTime()),g=p.windowId;h.$session_id=p.sessionId,h.$window_id=g}this.sessionPropsManager&&Nr(h,this.sessionPropsManager.getSessionProps());try{var m;this.sessionRecording&&Nr(h,this.sessionRecording.sdkDebugProperties),h.$sdk_debug_retry_queue_size=null==(m=this.Pn)?void 0:m.length}catch(t){h.$sdk_debug_error_capturing_properties=String(t)}if(this.requestRouter.region===ga&&(h.$lib_custom_api_host=this.config.api_host),v=e!==Ir||a?e!==Cr||a?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(n):this.pageViewManager.doPageView(n,o),h=Nr(h,v),e===Ir&&r&&(h.title=r.title),!K(l)){var b=n.getTime()-l;h.$duration=parseFloat((b/1e3).toFixed(3))}u&&this.config.opt_out_useragent_filter&&(h.$browser_type=this._is_bot()?"bot":"browser");var y=this.persistence.properties(),w=this.sessionPersistence.properties();Dr(["$referrer","$referring_domain"],(t=>{t in y&&delete w[t]})),(h=Nr({},f,y,w,h)).$is_identified=this._isIdentified(),q(this.config.property_denylist)?Dr(this.config.property_denylist,(function(t){delete h[t]})):mi.error(ja+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(mi.error(La),h=x(h,e));var E=this.Un();return h.$process_person_profile=E,E&&!a&&this.zn("_calculate_event_properties"),h}Bn(t,e,i){var r;if(void 0===e&&(e=!0),void 0===i&&(i=!1),!this.persistence||!this.Un())return t;if(this.yn&&!i)return t;var s=this.persistence.get_initial_props(),n=null==(r=this.sessionPropsManager)?void 0:r.getSetOnceProps(),o=Nr({},s,n||{},t||{}),a=this.config.sanitize_properties;return a&&(mi.error(La),o=a(o,"$set_once")),e&&(this.yn=!0),G(o)?void 0:o}register(t,e){var i;null==(i=this.persistence)||i.register(t,e)}register_once(t,e,i){var r;null==(r=this.persistence)||r.register_once(t,e,i)}register_for_session(t){var e;null==(e=this.sessionPersistence)||e.register(t)}unregister(t){var e;null==(e=this.persistence)||e.unregister(t)}unregister_for_session(t){var e;null==(e=this.sessionPersistence)||e.unregister(t)}Wn(t,e){this.register({[t]:e})}getFeatureFlag(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlag(t,e)}getFeatureFlagPayload(t){var e;return null==(e=this.featureFlags)?void 0:e.getFeatureFlagPayload(t)}getFeatureFlagResult(t,e){var i;return null==(i=this.featureFlags)?void 0:i.getFeatureFlagResult(t,e)}getAllFeatureFlags(){var t,e;return null!==(t=null==(e=this.featureFlags)?void 0:e.getAllFeatureFlags())&&void 0!==t?t:[]}isFeatureEnabled(t,e){var i,r;return null!==(i=null==(r=this.featureFlags)?void 0:r.isFeatureEnabled(t,e))&&void 0!==i?i:null==e?void 0:e.defaultValue}reloadFeatureFlags(){var t;null==(t=this.featureFlags)||t.reloadFeatureFlags()}updateFlags(t,e,i){var r;null==(r=this.featureFlags)||r.updateFlags(t,e,i)}updateEarlyAccessFeatureEnrollment(t,e,i){var r;null==(r=this.featureFlags)||r.updateEarlyAccessFeatureEnrollment(t,e,i)}getEarlyAccessFeatures(t,e,i){var r;return void 0===e&&(e=!1),null==(r=this.featureFlags)?void 0:r.getEarlyAccessFeatures(t,e,i)}on(t,e){return this.vn.on(t,e)}onFeatureFlags(t){return this.featureFlags?this.featureFlags.onFeatureFlags(t):(t([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(t){return this.surveys?this.surveys.onSurveysLoaded(t):(t([],{isLoaded:!1,error:Ua}),()=>{})}onSessionId(t){var e,i;return null!==(e=null==(i=this.sessionManager)?void 0:i.onSessionId(t))&&void 0!==e?e:()=>{}}getSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getSurveys(t,e):t([],{isLoaded:!1,error:Ua})}getActiveMatchingSurveys(t,e){void 0===e&&(e=!1),this.surveys?this.surveys.getActiveMatchingSurveys(t,e):t([],{isLoaded:!1,error:Ua})}renderSurvey(t,e){var i;null==(i=this.surveys)||i.renderSurvey(t,e)}displaySurvey(t,e){var i;void 0===e&&(e=ka),null==(i=this.surveys)||i.displaySurvey(t,e)}cancelPendingSurvey(t){var e;null==(e=this.surveys)||e.cancelPendingSurvey(t)}canRenderSurvey(t){var e,i;return null!==(e=null==(i=this.surveys)?void 0:i.canRenderSurvey(t))&&void 0!==e?e:{visible:!1,disabledReason:Ua}}canRenderSurveyAsync(t,e){var i,r;return void 0===e&&(e=!1),null!==(i=null==(r=this.surveys)?void 0:r.canRenderSurveyAsync(t,e))&&void 0!==i?i:Promise.resolve({visible:!1,disabledReason:Ua})}Vn(t){return!t||Y(t)?(mi.critical("Unique user id has not been set in posthog.identify"),!1):t===mr?(mi.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(t.toLowerCase())&&!["undefined","null"].includes(t.toLowerCase())||(mi.critical('The string "'+t+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(t,e,i){if(!this.__loaded||!this.persistence)return mi.uninitializedWarning("posthog.identify");if(Z(t)&&(t=t.toString(),mi.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Vn(t)&&this.zn("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:t}),this.get_property(Ei)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),t!==r&&t!==this.get_property($i)&&(this.unregister($i),this.register({distinct_id:t}));var s,n=(this.persistence.get_property(dr)||kr)===kr,o=t!==r,a=!o&&n;if(o&&n)this.persistence.set_property(dr,Tr),this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!1),this.capture(Ar,{distinct_id:t,$anon_distinct_id:r},{$set:e||{},$set_once:i||{}}),this.kn=ca(t,e,i),null==(s=this.featureFlags)||s.setAnonymousDistinctId(r);else if(a){this.persistence.set_property(dr,Tr);var l=e||{},u=i||{};this.setPersonPropertiesForFlags({$set:l,$set_once:u},!1),this.capture("$set",{$set:l,$set_once:u}),this.kn=ca(t,e,i)}else(e||i)&&this.setPersonProperties(e,i);o?(this.reloadFeatureFlags(),this.unregister(ar)):a&&(e||i)&&this.reloadFeatureFlags()}}setPersonProperties(t,e){if((t||e)&&this.zn("posthog.setPersonProperties")){var i=ca(this.get_distinct_id(),t,e);this.kn!==i?(this.setPersonPropertiesForFlags({$set:t||{},$set_once:e||{}},!0),this.capture("$set",{$set:t||{},$set_once:e||{}}),this.kn=i):mi.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(t){var e,i=(q(t)?t:[t]).filter((t=>J(t)&&t.length>0));0!==i.length&&this.zn("posthog.unsetPersonProperties")&&(null==(e=this.featureFlags)||e.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.kn=null)}group(t,e,i){if(t&&e){var r=this.getGroups(),s=r[t]!==e;if(s&&this.resetGroupPropertiesForFlags(t),this.register({$groups:_({},r,{[t]:e})}),s||i){var n={$group_type:t,$group_key:e};i&&(n.$group_set=i),this.capture(Mr,n)}i&&this.setGroupPropertiesForFlags({[t]:i}),s&&!i&&this.reloadFeatureFlags()}else mi.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),null==(i=this.featureFlags)||i.setPersonPropertiesForFlags(t,e)}resetPersonPropertiesForFlags(t){var e;void 0===t&&(t=!0),null==(e=this.featureFlags)||e.resetPersonPropertiesForFlags(t)}setGroupPropertiesForFlags(t,e){var i;void 0===e&&(e=!0),this.zn("posthog.setGroupPropertiesForFlags")&&(null==(i=this.featureFlags)||i.setGroupPropertiesForFlags(t,e))}resetGroupPropertiesForFlags(t){var e;null==(e=this.featureFlags)||e.resetGroupPropertiesForFlags(t)}reset(t){this.Zn(t)}Zn(t,e){var i,r,s,n,o,a,l,u,h,d;if(void 0===e&&(e=!1),mi.info("reset"),!this.__loaded)return mi.uninitializedWarning("posthog.reset");var v,c=this.get_property(Ei),f=this.get_property(Si),p=this.get_property(Di),_=this.is_capturing();if(this.consent.reset(),e||!_||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after."),null==(i=this.persistence)||i.clear(),null==(r=this.sessionPersistence)||r.clear(),K(p)||null==(v=this.persistence)||v.register({[Di]:p}),null==(s=this.surveys)||s.reset(),null==(n=this.Nn)||n.stop(),null==(o=this.featureFlags)||o.reset(),null==(a=this.conversations)||a.reset(),null==(l=this.logs)||l.reset(),null==(u=this.metrics)||u.reset(),null==(h=this.persistence)||h.set_property(dr,kr),null==(d=this.sessionManager)||d.resetSessionId(),this.kn=null,this.config.cookieless_mode===$r)this.register_once({distinct_id:mr,$device_id:null},"");else{var g=this.config.get_device_id(Xr());this.register_once({distinct_id:g,$device_id:t?g:c},""),t||K(f)||this.register({[Si]:f})}this.register({$last_posthog_reset:(new Date).toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(t){var e=this;return p((function*(){var t,i,r,s,n,o,a;e.__loaded?(null==(t=e.Nn)||t.stop(),null==(i=e.An)||i.dispose(),null==(r=e.logs)||r.flushLogs("sendBeacon"),null==(s=e.metrics)||s.flush("sendBeacon"),null==(n=e.En)||n.unload(),null==(o=e.Pn)||o.unload(),null==(a=e.featureFlags)||a.destroy()):mi.uninitializedWarning("posthog.shutdown")}))()}setIdentity(t,e){var i;this.config.identity_distinct_id=t,this.config.identity_hash=e,this.alias(t),null==(i=this.conversations)||i.Gn()}clearIdentity(){var t;delete this.config.identity_distinct_id,delete this.config.identity_hash,null==(t=this.conversations)||t.Qn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var t,e;return null!==(t=null==(e=this.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==t?t:""}get_session_replay_url(t){if(!this.sessionManager)return"";var e=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=e.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+e.sessionId);if(null!=t&&t.withTimestamp&&i){var s,n=null!==(s=t.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(t,e){return t===this.get_property(xi)?(mi.critical("Attempting to create alias for existing People user - aborting."),-2):this.zn("posthog.alias")?(K(e)&&(e=this.get_distinct_id()),t!==e?(this.Wn($i,t),this.capture("$create_alias",{alias:t,distinct_id:e})):(mi.warn("alias matches current distinct_id - skipping api call."),this.identify(t),-1)):void 0}set_config(t){var e=_({},this.config);if(W(t)){var i,r,s,n,o,a,l,u,h,d,v;Nr(this.config,Wa(t));var f=this.Tn();null==(i=this.persistence)||i.update_config(this.config,e,f),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ln(_({},this.config,{persistence:"sessionStorage"}),f,!1);var p=this.Sn(this.config.debug);et(p)&&(this.config.debug=p),et(this.config.debug)&&(this.config.debug?(c.DEBUG=!0,ss.P()&&ss.A("ph_debug",!0),mi.info("set_config",{config:t,oldConfig:e,newConfig:_({},this.config)})):(c.DEBUG=!1,ss.P()&&ss.F("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(s=this.exceptions)||s.onConfigChange(),null==(n=this.sessionRecording)||n.startIfEnabledOrStop(),null==(o=this.tracingHeaders)||o.startIfEnabledOrStop(),null==(a=this.autocapture)||a.startIfEnabled(),null==(l=this.heatmaps)||l.startIfEnabled(),null==(u=this.exceptionObserver)||u.startIfEnabledOrStop(),null==(h=this.deadClicksAutocapture)||h.startIfEnabledOrStop(),null==(d=this.surveys)||d.loadIfEnabled(),this.Jn(),null==(v=this.externalIntegrations)||v.startIfEnabledOrStop()}}_overrideSDKInfo(t,e){c.LIB_NAME=t,c.LIB_VERSION=e}startSessionRecording(t){var e,i,r,s,n,o=!0===t,a={sampling:o||!(null==t||!t.sampling),linked_flag:o||!(null==t||!t.linked_flag),url_trigger:o||!(null==t||!t.url_trigger),event_trigger:o||!(null==t||!t.event_trigger)};Object.values(a).some(Boolean)&&(null==(e=this.sessionManager)||e.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 t;return!(null==(t=this.sessionRecording)||!t.started)}captureException(t,e){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(t,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(_({},r,e))}}addExceptionStep(t,e){var i;null==(i=this.exceptions)||i.addExceptionStep(t,e)}captureLog(t){var e;null==(e=this.logs)||e.captureLog(t)}get logger(){var t,e;return null!==(t=null==(e=this.logs)?void 0:e.logger)&&void 0!==t?t:Ka.Kn}startExceptionAutocapture(t){this.set_config({capture_exceptions:null==t||t})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(t){var e,i;return null!==(e=null==(i=this.toolbar)?void 0:i.loadToolbar(t))&&void 0!==e&&e}get_property(t){var e;return null==(e=this.persistence)?void 0:e.props[t]}getSessionProperty(t){var e;return null==(e=this.sessionPersistence)?void 0:e.props[t]}toString(){var t,e=null!==(t=this.config.name)&&void 0!==t?t:za;return e!==za&&(e=za+"."+e),e}_isIdentified(){var t,e;return(null==(t=this.persistence)?void 0:t.get_property(dr))===Tr||(null==(e=this.sessionPersistence)?void 0:e.get_property(dr))===Tr}Un(){var t,e;return!("never"===this.config.person_profiles||this.config.person_profiles===Rr&&!this._isIdentified()&&G(this.getGroups())&&(null==(t=this.persistence)||null==(t=t.props)||!t[$i])&&(null==(e=this.persistence)||null==(e=e.props)||!e[gr]))}qn(){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.Un()||this.zn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.zn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}zn(t){return"never"===this.config.person_profiles?(mi.error(t+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Wn(gr,!0),!0)}Tn(){if("always"===this.config.cookieless_mode)return!0;var t=this.consent.isOptedOut();return this.config.disable_persistence||t&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Sr)}Jn(){var t,e,i,r,s=this.Tn();return(null==(t=this.persistence)?void 0:t.ki)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(e=this.sessionPersistence)?void 0:e.ki)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(t){var e;if(this.config.cookieless_mode!==$r){if(this.mn()){var i,r,s,n,o;this.Zn(!0,!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new ua(this),this.pageViewManager=new un(this),this.persistence&&(this.sessionPropsManager=new oa(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=Ka.__defaultExtensionClasses)?void 0:o.sessionRecording;l&&(this.sessionRecording=this.gn(this.sessionRecording,new l(this)),this.dn&&(null==(a=this.sessionRecording)||null==a.onRemoteConfig||a.onRemoteConfig(this.dn)))}var u,h;this.consent.optInOut(!0),this.Jn(),this.Dn(),null==(e=this.sessionRecording)||e.startIfEnabledOrStop(),this.config.cookieless_mode==Sr&&(null==(u=this.surveys)||u.loadIfEnabled()),(K(null==t?void 0:t.captureEventName)||null!=t&&t.captureEventName)&&this.capture(null!==(h=null==t?void 0:t.captureEventName)&&void 0!==h?h:"$opt_in",null==t?void 0:t.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$n()}else mi.warn(Na)}opt_out_capturing(){var t,e,i;this.config.cookieless_mode!==$r?(this.config.cookieless_mode===Sr&&this.consent.isOptedIn()&&this.Zn(!0,!0),this.consent.optInOut(!1),this.Jn(),this.config.cookieless_mode===Sr&&(this.register({distinct_id:mr,$device_id:null}),null==(t=this.sessionRecording)||t.stopRecording(),this.sessionRecording=void 0,null==(e=this.sessionManager)||e.destroy(),null==(i=this.pageViewManager)||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.$n(),this.Dn())):mi.warn(Na)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var t=this.consent.consent;return 1===t?"granted":0===t?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===$r||(this.config.cookieless_mode===Sr?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.Jn()}_is_bot(){return i?ha(i,this.config.custom_blocked_useragents):void 0}$n(){r&&("visible"===r.visibilityState?this._n||(this._n=!0,this.capture(Ir,{title:r.title},{send_instantly:!0}),this.wn&&(r.removeEventListener(Pr,this.wn),this.wn=null)):this.wn||(this.wn=this.$n.bind(this),qr(r,Pr,this.wn)))}debug(e){!1===e?(null==t||t.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==t||t.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}))}Ji(){var t=this.Cn||{};return"advanced_disable_flags"in t?!!t.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(mi.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):function(t,e,i,r,s){var n=e in t&&!X(t[e]),o=i in t&&!X(t[i]);return n?t[e]:!!o&&(s&&s.warn("Config field '"+i+"' is deprecated. Please use '"+e+"' instead. The old field will be removed in a future major version."),t[i])}(t,"advanced_disable_flags","advanced_disable_decide",0,mi)}Pt(t){var e;if(X(this.config.before_send))return t;var i=Object.keys(null!==(e=t.properties)&&void 0!==e?e:{}).filter(st),r=q(this.config.before_send)?this.config.before_send:[this.config.before_send],s=t;for(var n of r){if(s=n(s),X(s)){var o="Event '"+t.event+"' was rejected in beforeSend function";return rt(t.event)?mi.warn(o+". This can cause unexpected behavior."):mi.info(o),null}s.properties&&!G(s.properties)||mi.warn("Event '"+t.event+"' has no properties after beforeSend function, this is likely an error.")}for(var a of i)if(s.properties&&X(s.properties[a]))return mi.warn("Event '"+t.event+"' had its '"+a+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return s}getPageViewId(){var t;return null==(t=this.pageViewManager.ui)?void 0:t.pageViewId}captureTraceFeedback(t,e){this.capture("$ai_feedback",{$ai_trace_id:String(t),$ai_feedback_text:e})}captureTraceMetric(t,e,i){this.capture("$ai_metric",{$ai_trace_id:String(t),$ai_metric_name:e,$ai_metric_value:String(i)})}Sn(t){var e=et(t)&&!t,i=ss.P()&&"true"===ss.q("ph_debug");return!e&&(!!i||t)}}Ka.__defaultExtensionClasses={},Ka.Kn=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=jr(t.prototype[e[i]])}(Ka,["identify"]);class Ja{constructor(t){this.disabled=!1===t;var e=W(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(t-r.x)+Math.abs(e-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:t,y:e,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:i}];return!1}}var Ya="$copy_autocapture",Qa=bi("[AutoCapture]");function Xa(t,e){return e.length>t?e.slice(0,t)+"...":e}function Za(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!gs(e));return e}function tl(e,i){var r,s,n=i.e,o=i.maskAllElementAttributes,a=i.maskAllText,l=i.elementAttributeIgnoreList,u=i.elementsChainAsString,h=i.disableCaptureUrlHashes;if(!gs(e))return{props:{}};for(var d=[e],v=new Set([e]),c=e;c.parentNode&&!ms(c,"body")&&ws>d.length;)if(ys(c.parentNode)){var f=c.parentNode.host;if(v.has(f))break;v.add(f),d.push(f),c=f}else{if(!gs(c.parentNode))break;if(v.has(c.parentNode))break;v.add(c.parentNode),d.push(c.parentNode),c=c.parentNode}var p,g,m=[],b={},y=!1,w=!1;if(Dr(d,(t=>{var e=js(t);if(ms(t,"a")){var i=t.getAttribute("href");y=!!(e&&i&&Js(i))&&(h?ye(i):i)}N(Ss(t),"ph-no-capture")&&(w=!0),m.push(function(t,e,i,r,s){void 0===s&&(s=!1);var n=t.tagName.toLowerCase(),o={tag_name:n};Rs.indexOf(n)>-1&&!i&&(o.$el_text="a"===n.toLowerCase()||"button"===n.toLowerCase()?Xa(1024,Ys(t)):Xa(1024,ks(t)));var a=Ss(t);a.length>0&&(o.classes=a.filter((function(t){return""!==t}))),Dr(t.attributes,(function(i){var n;if((!Bs(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Js(i.value)&&(!J(n=i.name)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7))){var a=i.value;"class"===i.name&&(a=xs(a).join(" ")),o["attr__"+i.name]=Xa(1024,"href"===i.name&&s?ye(a):a)}}));for(var l=1,u=1,h=t;h=Za(h);)l++,h.tagName===t.tagName&&u++;return o.nth_child=l,o.nth_of_type=u,o}(t,o,a,l,h));var r=function(t){if(!js(t))return{};var e={};return Dr(t.attributes,(function(t){if(t.name&&0===t.name.indexOf("data-ph-capture-attribute")){var i=t.name.replace("data-ph-capture-attribute-",""),r=t.value;i&&r&&Js(r)&&(e[i]=r)}})),e}(t);Nr(b,r)})),w)return{props:{},explicitNoCapture:w};if(a||(m[0].$el_text=ms(e,"a")||ms(e,"button")?Ys(e):ks(e)),y){var x,E;m[0].attr__href=y;var S=null==(x=pn(y))?void 0:x.host,k=null==t||null==(E=t.location)?void 0:E.host;S&&k&&S!==k&&(p=y)}return{props:Nr({$event_type:n.type,$ce_version:1},u?{}:{$elements:m},{$elements_chain:(g=m,function(t){return t.map((t=>{var e,i,r="";if(t.tag_name&&(r+=t.tag_name),t.attr_class)for(var s of(t.attr_class.sort(),t.attr_class))r+="."+s.replace(/"/g,"");var n=_({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(i=t.nth_of_type)&&void 0!==i?i:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Ur(n).sort(((t,e)=>t[0].localeCompare(e[0]))).forEach((t=>{var e=t[1];return o[Xs(t[0].toString())]=Xs(e.toString())})),(r+=":")+Ur(o).map((t=>t[0]+'="'+t[1]+'"')).join("")})).join(";")}(function(t){return t.map((t=>{var e,i,r={text:null==(e=t.$el_text)?void 0:e.slice(0,400),tag_name:t.tag_name,href:null==(i=t.attr__href)?void 0:i.slice(0,2048),attr_class:Zs(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Ur(t).filter((t=>0===t[0].indexOf("attr__"))).forEach((t=>r.attributes[t[0]]=t[1])),r}))}(g)))},null!=(r=m[0])&&r.$el_text?{$el_text:null==(s=m[0])?void 0:s.$el_text}:{},p&&"click"===n.type?{$external_click_url:p}:{},b)}}var el=bi("[ExceptionAutocapture]"),il=()=>{},rl=bi("[TracingHeaders]"),sl=bi("[Web Vitals]"),nl=9e5,ol="disabled",al="lazy_loading",ll="awaiting_config",ul="missing_config";bi("[SessionRecording]"),bi("[SessionRecording]");var hl="[SessionRecording]",dl=bi(hl),vl=bi("[Heatmaps]");function cl(t){return W(t)&&"clientX"in t&&"clientY"in t&&Z(t.clientX)&&Z(t.clientY)}var fl=bi("[Product Tours]"),pl=t=>{var e;return!t.config.disable_product_tours&&!(null==(e=t.persistence)||!e.get_property(Mi))},_l=["$set_once","$set"],gl=bi("[SiteApps]"),ml="Error while initializing PostHog app with config id ";function bl(t,e,i){if(X(t))return!1;switch(i){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(t){return!1}default:return!1}}class yl{constructor(t){this.Yn=new aa,this.Xn=(t,e)=>this.ts(t,e)&&this.es(t,e)&&this.rs(t,e)&&this.ns(t,e),this.ts=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.ss=new Set,this.os=new Set}init(){var t,e;K(null==(t=this._instance)?void 0:t._addCaptureHook)||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.on(t,e)})))}register(t){var e,i;if(!K(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this.os)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.ss)||e.add((null==t?void 0:t.event)||"")}))})),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;t.forEach((t=>{var e;null==(e=t.steps)||e.forEach((t=>{null!=t&&t.selector&&s.add(null==t?void 0:t.selector)}))})),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(t,e){var i;null!=e&&0!=t.length&&(this.ss.has(t)||this.ss.has(e.event))&&this.os&&(null==(i=this.os)?void 0:i.size)>0&&this.os.forEach((t=>{this.ls(e,t)&&this.Yn.emit("actionCaptured",t.name)}))}us(t){this.onAction("actionCaptured",(e=>t(e)))}ls(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.Xn(t,i))return!0;return!1}onAction(t,e){return this.Yn.on(t,e)}es(t,e){if(null!=e&&e.url){var i,r=null==t||null==(i=t.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!bl(r,e.url,e.url_matching||"contains"))return!1}return!0}rs(t,e){return!!this.hs(t,e)&&!!this.ds(t,e)&&!!this.vs(t,e)}hs(t,e){var i;if(null==e||!e.href)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>bl(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&bl((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}ds(t,e){var i;if(null==e||!e.text)return!0;var r=this.cs(t);if(r.length>0)return r.some((t=>bl(t.text,e.text,e.text_matching||"exact")||bl(t.$el_text,e.text,e.text_matching||"exact")));var s,n,o,a=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!X(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(a),n=e.text,o=e.text_matching||"exact",s.some((t=>bl(t,n,o))))}vs(t,e){var i,r;if(null==e||!e.selector)return!0;var s=null==t||null==(i=t.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(e.selector))return!0;var n=(null==t||null==(r=t.properties)?void 0:r.$elements_chain)||"";if(e.selector_regex&&n)try{return new RegExp(e.selector_regex).test(n)}catch(t){return!1}return!1}cs(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}ns(t,e){return null==e||!e.properties||0===e.properties.length||_a(e.properties.reduce(((t,e)=>{var i=q(e.value)?e.value.map(String):null!=e.value?[String(e.value)]:[];return t[e.key]={values:i,operator:e.operator||"exact"},t}),{}),null==t?void 0:t.properties)}}class wl{constructor(t){var e;this.fs=[],this._instance=t,this.ps=new Map,this.gs=new Map,this.ys=new Map,null==(e=this._instance)||null==e.onSessionId||e.onSessionId((t=>this.bs(t)))}_s(t){return!1}ws(){return null}xs(t){}ks(){}Ss(t,e){return!!t&&_a(t.propertyFilters,null==e?void 0:e.properties)}Cs(t,e){var i=new Map;return t.forEach((t=>{var r;null==(r=t.conditions)||null==(r=r[e])||null==(r=r.values)||r.forEach((e=>{if(null!=e&&e.name){var r=i.get(e.name)||[];r.push(t.id),i.set(e.name,r)}}))})),i}Ms(t,e,i){var r=(i===zn.Activation?this.ps:this.gs).get(t),s=[];return this.Ts((t=>{s=t.filter((t=>null==r?void 0:r.includes(t.id)))})),s.filter((r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find((e=>e.name===t));return this.Ss(n,e)}))}register(t){var e;K(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Es(t),this.Is(t))}Is(t){var e=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.actions)&&(null==(i=t.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0}));0!==e.length&&(null==this.Ps&&(this.Ps=new yl(this._instance),this.Ps.init(),this.Ps.us((t=>{this.onAction(t)}))),e.forEach((t=>{var e,i,r,s,n;t.conditions&&null!=(e=t.conditions)&&e.actions&&null!=(i=t.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=t.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.Ps)||s.register(t.conditions.actions.values),null==(n=t.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach((e=>{if(e&&e.name){var i=this.ys.get(e.name);i&&i.push(t.id),this.ys.set(e.name,i||[t.id])}})))})))}Es(t){var e,i=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.events)&&(null==(i=t.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0})),r=t.filter((t=>{var e,i;return(null==(e=t.conditions)?void 0:e.cancelEvents)&&(null==(i=t.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0}));0===i.length&&0===r.length||(null==(e=this._instance)||e._addCaptureHook(((t,e)=>{this.onEvent(t,e)})),this.ps=this.Cs(t,zn.Activation),this.gs=this.Cs(t,zn.Cancellation))}onEvent(t,e){var i,r,s=this.Rs(),n=(null==e||null==(i=e.properties)?void 0:i.$survey_id)||(null==e||null==(r=e.properties)?void 0:r.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Ls(t,n);if("consume"===o)return s.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Os([n]);if("persist"===o)return s.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.Fs(n),void this.As([n])}if(this.gs.has(t)){var a=this.Ms(t,e,zn.Cancellation);a.length>0&&(s.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map((t=>t.id))}),this.Os(a.map((t=>t.id))),a.forEach((t=>this.Ds(t.id))))}if(this.ps.has(t)){s.info("event name matched",{event:t,eventPayload:e,items:this.ps.get(t)});var l=this.Ms(t,e,zn.Activation);this.$s(l.map((t=>t.id)))}}onAction(t){this.ys.has(t)&&this.$s(this.ys.get(t)||[])}$s(t){var e;if(0!==t.length){var i=!(null==(e=this._instance)||null==e.get_session_id||!e.get_session_id()),r=[];for(var s of t)i&&this._s(s)?this.Fs(s)&&this.Ns(s):r.push(s);r.length>0&&(this.fs=[...new Set([...this.fs,...r])]),this.Rs().info("updating activated items",{activatedItems:this.getActivatedIds()})}}Fs(t){this.fs=this.fs.filter((e=>e!==t));var e=this.qs();return!e.includes(t)&&(this.js([...e,t]),this.Bs(),!0)}Os(t){var e=new Set(t);this.fs=this.fs.filter((t=>!e.has(t)));var i=this.Hs(),r=i.filter((t=>!e.has(t)));r.length!==i.length&&(this.js(r),0===r.length&&this.Us()),this.As(t)}zs(){var t,e=this.ws();if(!e)return{};var i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e];return i&&"object"==typeof i?i:{}}Ns(t){if(this.ws()){var e=this.zs();this.xs(_({},e,{[t]:Date.now()}))}}As(t){if(this.ws()){var e=this.zs(),i={},r=!1;for(var s of Object.entries(e)){var n=s[0],o=s[1];t.includes(n)?r=!0:i[n]=o}r&&(G(i)?this.ks():this.xs(i))}}Ws(){this.ws()&&this.ks()}getActivationTimestamp(t){if(this.qs().includes(t)){var e=this.zs()[t];return Z(e)?e:void 0}}Hs(){var t,e=this.Vs();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}qs(){var t,e,i=this.Hs();if(0===i.length)return[];var r=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[this.Zs()],s=null==(e=this._instance)||null==e.get_session_id?void 0:e.get_session_id();return s&&r===s?i:[]}Bs(){var t,e=null==(t=this._instance)||null==t.get_session_id?void 0:t.get_session_id();e&&this.Gs(e)}Us(){this.Qs()}bs(t){var e,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[this.Zs()];if(i&&i!==t){var r=this.Hs(),s=this.zs();r.length>0&&(this.js([]),r.filter((t=>Z(s[t]))).forEach((t=>this.Ds(t)))),this.Us(),this.Ws()}}getActivatedIds(){return[...new Set([...this.qs(),...this.fs])].filter((t=>!this.Js(t)))}reset(){this.fs=[],this.Hs().length>0&&this.js([]),this.Us(),this.Ws()}getEventToItemsMap(){return this.ps}Ks(){return this.Ps}}class xl extends wl{constructor(t){super(t)}Vs(){return rr}Zs(){return sr}ws(){return nr}xs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[nr]:t})}ks(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(nr)}_s(t){var e,i;this.Ts((e=>{i=e.find((e=>e.id===t))}));var r=null==(e=i)||null==(e=e.appearance)?void 0:e.surveyPopupDelaySeconds;return Z(r)&&r>0}Ys(){return Yn.SHOWN}Ts(t){var e;null==(e=this._instance)||e.getSurveys(t)}Ds(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}Rs(){return xa}js(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[rr]:t})}Gs(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[sr]:t})}Qs(){var t;null==(t=this._instance)||null==(t=t.persistence)||t.unregister(sr)}Js(){return!1}Ls(t,e){var i;this.Ts((t=>{i=t.find((t=>t.id===e))}));var r=!i||function(t){var e;return wa(t)&&!(null==(e=t.conditions)||null==(e=e.events)||!e.repeatedActivation)||"always"===t.schedule}(i);return r?t===Yn.SHOWN?"consume":"ignore":t===Yn.SHOWN?"persist":t===Yn.DISMISSED||t===Yn.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var El="SDK is not enabled or survey functionality is not yet loaded",Sl="Disabled. Not loading surveys.",$l=null!=t&&t.location?mn(t.location.hash,"__posthog")||mn(location.hash,"state"):null,kl="_postHogToolbarParams",Tl=bi("[Toolbar]"),Rl=bi("[FeatureFlags]"),Pl=bi("[FeatureFlags]",{debugEnabled:!0}),Ol="\" failed. Feature flags didn't load in time.",Il=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Cl=t=>{var e={};for(var i of Ur(t||{})){var r=i[1];r&&(e[i[0]]=r)}return e},Al=bi("[Error tracking]"),Ml="Refusing to render web experiment since the viewer is a likely bot",Fl={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>-1===e.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>va(e,t),not_regex:(t,e)=>!va(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t};class Dl{get Pe(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{Dl.Xs("retrieved web experiments from the server"),e.ta=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.ta&&(Dl.Xs("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.ta)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);J(r)&&t.variants[r]&&e.ea(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];Dl.ia(n,e._instance)&&e.ea(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())Dl.Xs(Ml);else if(!this.Pe.disable_web_experiments){if(X(this.ta))return this.ta=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Dl.Xs("applying feature flags",t),t.forEach((t=>{var e;if(this.ta&&null!=(e=this.ta)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.ta)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.ea(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=Dl.getWindowLocation();if(null!=t&&t.search){var e=_n(null==t?void 0:t.search,"__experiment_id"),i=_n(null==t?void 0:t.search,"__experiment_variant");e&&i&&(Dl.Xs("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.ra(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.Pe.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.Pe.disable_web_experiments&&!i)return t([]);var r=this._instance.get_property("$web_experiments");if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Pe.token),method:"GET",timestampMode:"query",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}ra(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(Dl.Xs("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.ea(r[0].name,e,r[0].variants[e].transforms))}static ia(t,e){return!X(t.conditions)&&Dl.na(t,e)&&Dl.sa(t)}static na(t,e){var i;if(X(t.conditions)||X(null==(i=t.conditions)?void 0:i.url))return!0;var r=Dl.getWindowLocation();if(r){var s,n,o,a=ds(e,r.href);return null==(s=t.conditions)||!s.url||Fl[null!==(n=null==(o=t.conditions)?void 0:o.urlMatchType)&&void 0!==n?n:"icontains"](t.conditions.url,a)}return!1}static getWindowLocation(){return null==t?void 0:t.location}static sa(t){var e;if(X(t.conditions)||X(null==(e=t.conditions)?void 0:e.utm))return!0;var i=kn();if(i.utm_source){var r,s,n,o,a,l,u,h,d=null==(r=t.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=t.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,v=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=t.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,c=null==(a=t.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=t.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,f=null==(u=t.conditions)||null==(u=u.utm)||!u.utm_term||(null==(h=t.conditions)||null==(h=h.utm)?void 0:h.utm_term)==i.utm_term;return d&&c&&f&&v}return!1}static Xs(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mi.info("[WebExperiments] "+t,i)}ea(t,e,i){this._is_bot()?Dl.Xs(Ml):"control"!==e?i.forEach((i=>{if(i.selector){var r;Dl.Xs("applying transform of variant "+e+" for experiment "+t+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach((t=>{var e=t;i.html&&(e.innerHTML=i.html),i.css&&e.setAttribute("style",i.css)}))}})):Dl.Xs("Control variants leave the page unmodified.")}_is_bot(){return i&&this._instance?ha(i,this.Pe.custom_blocked_useragents):void 0}}var Nl=bi("[Conversations]"),Ul="Conversations not available yet.",Ll="console",jl="__posthogHandledLogsRequestError",Bl=(t,e)=>{var i=t instanceof Error?t:new Error(e);return i[jl]=!0,i},zl=t=>!!t&&"object"==typeof t&&!0===t[jl],Hl={featureFlags:class{constructor(e){this.aa=!1,this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.va=!1,this.ca=!1,this.fa=0,this.pa=()=>{var t=this.ga();this.fa=0,t&&this.reloadFeatureFlags()},this._instance=e,this.featureFlagEventHandlers=[],t&&qr(t,"online",this.pa)}destroy(){null==t||t.removeEventListener("online",this.pa)}get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}ma(t){return this._instance.get_property(t)}ya(){var t,e;return null!==(t=null==(e=this.Tr)?void 0:e.Ci(this.Pe.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ba(){return!!this.ya()&&(this.ca||this.la||(this.ca=!0,Rl.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}_a(){var t,e=null!==(t=this.Pe.evaluation_contexts)&&void 0!==t?t:this.Pe.evaluation_environments;return!this.Pe.evaluation_environments||this.Pe.evaluation_contexts||this.va||(Rl.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.va=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Rl.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}wa(){return this._a().length>0}xa(){var t=this.Pe.flag_keys;if(!K(t)){if(q(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Rl.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Rl.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,i=this._instance.config,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};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((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(o).filter((t=>a[t])).reduce(((t,e)=>(o[e]&&(t[e]=o[e]),t)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var r,s,n=null!=i&&i.merge&&null!==(r=this.ma(qi))&&void 0!==r?r:{},o=null!=i&&i.merge&&null!==(s=this.ma(Ki))&&void 0!==s?s:{},a=_({},n,t),l=_({},o,e),u={};for(var h of Object.entries(a)){var d=h[0],v=h[1];u[d]={key:d,enabled:b(v),variant:y(v),reason:void 0,metadata:K(null==l?void 0:l[d])?void 0:{id:0,version:void 0,description:void 0,payload:l[d]}}}this.receivedFeatureFlags({flags:u})}get hasLoadedFlags(){return this.oa}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.ma(Gi),e=this.ma(Qi),i=this.ma(Xi);if(!i&&!e)return t||{};var r=Nr({},t||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of s){var o,a,l=r[n],u=null==e?void 0:e[n],h=K(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=K(u)?l.variant:"string"==typeof u?u:void 0,v=null==i?void 0:i[n],c=_({},l,{enabled:h,variant:h?null!=d?d:null==l?void 0:l.variant:void 0});h!==(null==l?void 0:l.enabled)&&(c.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(c.original_variant=null==l?void 0:l.variant),v&&(c.metadata=_({},null==l?void 0:l.metadata,{payload:v,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=c}return this.aa||(Rl.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:r}),this.aa=!0),r}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map((i=>{var r=t[i];return{key:i,enabled:b(r),variant:y(r),payload:m(e[i])}}))}getFlagVariants(){var t=this.ma(qi),e=this.ma(Qi);if(!e)return t||{};for(var i=Nr({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.aa||(Rl.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.aa=!0),i}getFlagPayloads(){var t=this.ma(Ki),e=this.ma(Xi);if(!e)return t||{};for(var i=Nr({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.aa||(Rl.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.aa=!0),i}reloadFeatureFlags(){this.ua||this.Pe.advanced_disable_feature_flags||this.ga()||this.ka||(this._instance.vn.emit("featureFlagsReloading",!0),this.ka=setTimeout((()=>{this.Sa()}),5))}Ca(){clearTimeout(this.ka),this.ka=void 0}ensureFlagsLoaded(){this.oa||this.la||this.ka||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.ua=t}Sa(t){var e;if(this.Ca(),!this._instance.Ji()&&!this.ga())if(this.la)this.ha=!0;else{var i=this.Pe.token,r=this.ma(Ei),s={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:_({},(null==(e=this.Tr)?void 0:e.get_initial_props())||{},this.ma(Zi)||{},{$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION}),group_properties:this.ma(tr),timezone:Mn()};Q(r)||K(r)||(s.$device_id=r),(null!=t&&t.disableFlags||this.Pe.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.wa()&&(s.evaluation_contexts=this._a());var n=this.xa();K(n)||(s.flag_keys=n);var o=!!this.Pe.advanced_only_evaluate_survey_feature_flags,a=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Pe.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.la=!0,this._instance._send_request({method:"POST",url:a,data:s,compression:this.Pe.disable_compression?void 0:Bn.Base64,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,n=!0;if(this.Ma(t.statusCode),200===t.statusCode&&(this.ha||(this.$anon_distinct_id=void 0),n=!1),this.la=!1,!s.disable_flags||this.ha){this.da=!n;var a=[];t.error?t.error instanceof Error?a.push("AbortError"===t.error.name?"timeout":"connection_error"):a.push("unknown_error"):200!==t.statusCode&&a.push("api_error_"+t.statusCode),null!=(e=t.json)&&e.errorsWhileComputingFlags&&a.push("errors_while_computing_flags");var l,u=!(null==(i=t.json)||null==(i=i.quotaLimited)||!i.includes("feature_flags"));if(u&&a.push("quota_limited"),null==(r=this.Tr)||r.register({[ur]:a}),u)Rl.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 s.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},n,{partialResponse:o}),this.ha&&(this.ha=!1,this.Sa())}}})}}ga(){return bn(this.fa,3)}Ma(t){this.fa=yn(t,this.fa,3,(()=>Rl.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.")))}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var r=this.getFeatureFlagResult(t,e);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}}else Rl.warn('getFeatureFlag for key "'+t+Ol)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return null==e?void 0:e.payload}getFeatureFlagResult(t,e){if(void 0===e&&(e={}),!e.fresh||this.da)if(this.oa||this.getFlags()&&this.getFlags().length>0){if(!this.ba()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],o=String(s),a=this.ma(Ji)||void 0,l=this.ma(hr)||void 0,u=this.ma(ar)||{};if(this.Pe.advanced_feature_flags_dedup_per_session){var h,d=this._instance.get_session_id(),v=this.ma(lr);d&&d!==v&&(u={},null==(h=this.Tr)||h.register({[ar]:u,[lr]:d}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(o))){var c,f,p,_,g,b,y,w,x,E,S;q(u[t])?u[t].push(o):u[t]=[o],null==(c=this.Tr)||c.register({[ar]:u});var k=this.getFeatureFlagDetails(t),T=[...null!==(f=this.ma(ur))&&void 0!==f?f:[]];K(s)&&T.push("flag_missing");var R={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(p=this.Pe.bootstrap)||null==(p=p.featureFlags)?void 0:p[t])||null,$feature_flag_bootstrapped_payload:(null==(_=this.Pe.bootstrap)||null==(_=_.featureFlagPayloads)?void 0:_[t])||null,$used_bootstrap_value:!this.da};K(null==k||null==(g=k.metadata)?void 0:g.has_experiment)||(R.$feature_flag_has_experiment=k.metadata.has_experiment),K(null==k||null==(b=k.metadata)?void 0:b.version)||(R.$feature_flag_version=k.metadata.version);var P,O=null!==(y=null==k||null==(w=k.reason)?void 0:w.description)&&void 0!==y?y:null==k||null==(x=k.reason)?void 0:x.code;O&&(R.$feature_flag_reason=O),null!=k&&null!=(E=k.metadata)&&E.id&&(R.$feature_flag_id=k.metadata.id),K(null==k?void 0:k.original_variant)&&K(null==k?void 0:k.original_enabled)||(R.$feature_flag_original_response=K(k.original_variant)?k.original_enabled:k.original_variant),null!=k&&null!=(S=k.metadata)&&S.original_payload&&(R.$feature_flag_original_payload=null==k||null==(P=k.metadata)?void 0:P.original_payload),T.length&&(R.$feature_flag_error=T.join(",")),this._instance.capture("$feature_flag_called",R)}if(r)return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:m(n)}}}else Rl.warn('getFeatureFlagResult for key "'+t+Ol)}getRemoteConfigPayload(t,e){var i=this.Pe.token,r={distinct_id:this._instance.get_distinct_id(),token:i,person_properties:{$lib:c.LIB_NAME,$lib_version:c.LIB_VERSION}};this.wa()&&(r.evaluation_contexts=this._a());var s=this.xa();K(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.Pe.disable_compression?void 0:Bn.Base64,timestampMode:"body",timeout:this.Pe.feature_flag_request_timeout_ms,callback(i){var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;e((null==s?void 0:s[t])||void 0)}})}isFeatureEnabled(t,e){if(void 0===e&&(e={}),e.fresh&&!this.da)return e.defaultValue;if(!(this.oa||this.getFlags()&&this.getFlags().length>0))return Rl.warn('isFeatureEnabled for key "'+t+Ol),e.defaultValue;var i=this.getFeatureFlag(t,e);return K(i)?e.defaultValue:!!i}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){if(this.Tr){this.oa=!0;var r=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(t,e,i,r,s,n){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={});var o=(t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,null!==(i=e[t].variant)&&void 0!==i?i:e[t].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return null==(i=e[t].metadata)?void 0:i.payload})).map((t=>{var i;return[t,null==(i=e[t].metadata)?void 0:i.payload]})))):t.featureFlags&&Rl.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),a=o.flags,l=o.featureFlags,u=o.featureFlagPayloads;if(l){var h=t.requestId,d=t.evaluatedAt;if(q(l)){Rl.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var v={};if(l)for(var c=0;l.length>c;c++)v[l[c]]=!0;e&&e.register({[Vi]:l,[qi]:v,[Yi]:!1})}else{var f=l,p=u,g=a;if(null!=n&&n.partialResponse)f=_({},i,f),p=_({},r,p),g=_({},s,g);else if(t.errorsWhileComputingFlags)if(a){var m=new Set(Object.keys(a).filter((t=>{var e;return!(null!=(e=a[t])&&e.failed)})));f=_({},i,Object.fromEntries(Object.entries(f).filter((t=>m.has(t[0]))))),p=_({},r,Object.fromEntries(Object.entries(p||{}).filter((t=>m.has(t[0]))))),g=_({},s,Object.fromEntries(Object.entries(g||{}).filter((t=>m.has(t[0])))))}else f=_({},i,f),p=_({},r,p),g=_({},s,g);e&&e.register(_({[Vi]:Object.keys(Cl(f)),[qi]:f||{},[Ki]:p||{},[Gi]:g||{},[Yi]:!0===t.minimalFlagCalledEvents},h?{[Ji]:h}:{},d?{[hr]:d}:{}))}}}(t,this.Tr,r,s,n,i),e||(this.ca=!1),this.Ta(e)}}override(t,e){void 0===e&&(e=!1),Rl.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.Tr)return Rl.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.Tr.unregister(Qi),this.Tr.unregister(Xi),this.Ta(),Pl.info("All overrides cleared");if(q(t)){var e=Il(t);return this.Tr.register({[Qi]:e}),this.Ta(),Pl.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.aa=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.Tr.unregister(Qi),Pl.info("Flag overrides cleared");else if(r.flags){if(q(r.flags)){var s=Il(r.flags);this.Tr.register({[Qi]:s})}else this.Tr.register({[Qi]:r.flags});Pl.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.Tr.unregister(Xi),Pl.info("Payload overrides cleared")):r.payloads&&(this.Tr.register({[Xi]:r.payloads}),Pl.info("Payload overrides set",{payloads:r.payloads}))),void this.Ta()}if(t&&"object"==typeof t)return this.Tr.register({[Qi]:t}),this.Ta(),Pl.info("Flag overrides set",{flags:t});Rl.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.oa){var e=this.Ea(),i=e.flags,r=e.flagVariants;try{t(i,r)}catch(t){Rl.error("Error while running feature flags callback",t)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var r,s=(this.ma(Wi)||[]).find((e=>e.flagKey===t)),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=_({},this.getFlagVariants(),{[t]:e});null==(r=this.Tr)||r.register({[Vi]:Object.keys(Cl(a)),[qi]:a}),this.Ta()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.ma(Wi),s=i?"&"+i.map((t=>"stage="+t)).join("&"):"";if(r&&!e)return t(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Pe.token+s),method:"GET",timestampMode:"query",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.Tr)||i.unregister(Wi),null==(r=this.Tr)||r.register({[Wi]:s}),t(s)}}})}Ea(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}Ta(t){var e=this.Ea(),i=e.flags,r=e.flagVariants;this.featureFlagEventHandlers.forEach((e=>{try{e(i,r,{errorsLoading:t})}catch(t){Rl.error("Error while running feature flags callback",t)}}))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.ma(Zi)||{},r=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),s=null==t?void 0:t.$set_once,n={};if(s)for(var o in s)({}).hasOwnProperty.call(s,o)&&(o in i||(n[o]=s[o]));this._instance.register({[Zi]:_({},i,n,r)}),e&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=_({},this.ma(Zi)||{});t.forEach((t=>{delete i[t]})),this._instance.register({[Zi]:i}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){void 0===t&&(t=!0),this._instance.unregister(Zi),t&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var i=this.ma(tr)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((e=>{i[e]=_({},i[e],t[e]),delete t[e]})),this._instance.register({[tr]:_({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.ma(tr)||{};this._instance.register({[tr]:_({},e,{[t]:{}})})}else this._instance.unregister(tr)}reset(){this.oa=!1,this.la=!1,this.ua=!1,this.ha=!1,this.da=!1,this.$anon_distinct_id=void 0,this.Ca(),this.aa=!1,this.fa=0}}},ql={sessionRecording:class{get Pe(){return this._instance.config}get Tr(){return this._instance.persistence}get started(){var t;return!(null==(t=this.Ia)||!t.isStarted)}get status(){var t,e;return this.Pa===ll||this.Pa===ul?this.Pa:null!==(t=null==(e=this.Ia)?void 0:e.status)&&void 0!==t?t:this.Pa}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.Pa=ol,this.Ra=void 0,this._instance=t,!this._instance.sessionManager)throw dl.error("started without valid sessionManager"),new Error(hl+" started without valid sessionManager. This is a bug.");if(this.Pe.cookieless_mode===$r)throw new Error(hl+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get La(){var e,i=!(null==(e=this._instance.get_property(Di))||!e.enabled),r=!this.Pe.disable_session_recording,s=this.Pe.disable_session_recording||this._instance.consent.isOptedOut();return t&&i&&r&&!s}startIfEnabledOrStop(t){var e;if(!this.La||null==(e=this.Ia)||!e.isStarted){var i=!K(Object.assign)&&!K(Array.from);this.La&&i?(this.Oa(t),dl.info("starting")):(this.Pa=ol,this.stopRecording())}}Oa(t){var e,i,r;this.La&&(this.Pa!==ll&&this.Pa!==ul&&(this.Pa=al),null!=v&&null!=(e=v.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=v.__PosthogExtensions__)&&i.initSessionRecording?this.Fa(t):null==(r=v.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Aa,(e=>{if(e)return dl.error("could not load recorder",e);this.Fa(t)})))}stopRecording(){var t,e;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(e=this.Ia)||e.stop()}Da(){var t,e;null==(t=this.Ra)||t.call(this),this.Ra=void 0,null==(e=this.Ia)||e.discard()}$a(){var t,e;null==(t=this.Tr)||t.unregister(Hi),null==(e=this.Tr)||e.unregister(Ni)}Na(t,e){if(X(t))return null;var i,r=Z(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(dl.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}qa(t){if(this.Tr){var e,i,r=this.Tr,s=()=>{var e,i=!1===t.sessionRecording?void 0:t.sessionRecording,s=this.Na(null==(e=this.Pe.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),n=this.Na(null==i?void 0:i.sampleRate,"remote config sampleRate"),o=null!=s?s:n;X(o)&&this.$a();var a=null==i?void 0:i.minimumDurationMilliseconds;r.register({[Di]:_({cache_timestamp:Date.now(),enabled:!!i},i,{networkPayloadCapture:_({capturePerformance:t.capturePerformance},null==i?void 0:i.networkPayloadCapture),canvasRecording:{enabled:null==i?void 0:i.recordCanvas,fps:null==i?void 0:i.canvasFps,quality:null==i?void 0:i.canvasQuality},sampleRate:o,minimumDurationMilliseconds:K(a)?null:a,endpoint:null==i?void 0:i.endpoint,triggerMatchType:null==i?void 0:i.triggerMatchType,masking:null==i?void 0:i.masking,urlTriggers:null==i?void 0:i.urlTriggers,version:null==i?void 0:i.version,triggerGroups:null==i?void 0:i.triggerGroups})})};s(),null==(e=this.Ra)||e.call(this),this.Ra=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?!1===e.sessionRecording?(this.qa(e),void this.Da()):(this.qa(e),void this.startIfEnabledOrStop()):(this.Pa===ll&&(this.Pa=ul,dl.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;void 0===e&&(e="log"),null!=(i=this.Ia)&&i.log?this.Ia.log(t,e):dl.warn("log called before recorder was ready")}get Aa(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(Di);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}ja(){var t,e,i=this._instance.get_property(Di);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return dl.warn("persisted remote config for session recording is invalid and will be ignored",t),!1}var r=null!==(t=e.cache_timestamp)&&void 0!==t?t:Date.now();return 36e5>=Date.now()-r}Fa(t){var e,i;if(null==(e=v.__PosthogExtensions__)||!e.initSessionRecording)return dl.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[xr]:!0});if(this.Ia||(this.Ia=null==(i=v.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Ia._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ja()){if(this.Pa===ul||this.Pa===ll)return;return this.Pa=ll,dl.info("persisted remote config is stale, requesting fresh config before starting"),void new no(this._instance).load()}this.Pa=al,this.Ia.start(t)}onRRwebEmit(t){var e;null==(e=this.Ia)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.Ia||null==(e=this.Tr)||e.register({[Li]:!0}),null==(t=this.Ia)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.Ia||null==(e=this.Tr)||e.register({[Ui]:!0}),null==(t=this.Ia)||t.overrideSampling()}overrideTrigger(t){var e,i;this.Ia||null==(i=this.Tr)||i.register({["url"===t?ji:Bi]:!0}),null==(e=this.Ia)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.Ia)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.Ia)||!i.tryAddCustomEvent(t,e))}}},Vl={autocapture:class{constructor(t){this.Ba=!1,this.Ha=null,this.Ua=!1,this.za=!1,this.instance=t,this.rageclicks=new Ja(t.config.rageclick),this.Wa=null}initialize(){this.startIfEnabled()}get Pe(){var t,e,i=W(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(t=i.url_allowlist)?void 0:t.map((t=>new RegExp(t))),i.url_ignorelist=null==(e=i.url_ignorelist)?void 0:e.map((t=>new RegExp(t))),i}Va(){if(this.isBrowserSupported()){if(t&&r){var e=e=>{e=e||(null==t?void 0:t.event);try{this.Za(e)}catch(t){Qa.error("Failed to capture event",t)}};if(qr(r,"submit",e,{capture:!0}),qr(r,"change",e,{capture:!0}),qr(r,"click",e,{capture:!0}),this.Pe.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event);try{this.Za(e,Ya)}catch(t){Qa.error("Failed to capture copy/cut event",t)}};qr(r,"copy",i,{capture:!0}),qr(r,"cut",i,{capture:!0})}}}else Qa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ba&&(this.Va(),this.Ba=!0)}onRemoteConfig(t){if(this.Ua=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.za=e.elementsChainAsString);var i=e.autocapture_opt_out;et(i)&&(this.instance.persistence&&this.instance.persistence.register({[Ti]:i}),this.Ha=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.Wa=t}getElementSelectors(t){var e,i=[];return null==(e=this.Wa)||e.forEach((e=>{var s=null==r?void 0:r.querySelectorAll(e);null==s||s.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Ti],r=this.Ha,s=this.instance.Ji()&&!this.Ua;if(Q(r)&&!et(i)&&!s)return!1;var n=null!==(e=this.Ha)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!n}Za(e,i){if(void 0===i&&(i="$autocapture"),this.isEnabled){var r,s=Ts(e);bs(s)&&(s=s.parentNode||null),"$autocapture"===i&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(r=this.rageclicks)&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&Ns(s,this.instance.config.rageclick)&&this.Za(e,"$rageclick");var n=i===Ya;if(s&&function(e,i,r,s,n,o){var a;if(!t||Us(e))return!1;if(null!=r&&r.url_allowlist&&!Es(r.url_allowlist,o))return!1;if(null!=r&&r.url_ignorelist&&Es(r.url_ignorelist,o))return!1;if(null!=r&&r.dom_event_allowlist){var l=r.dom_event_allowlist;if(l&&!l.some((t=>i.type===t)))return!1}var u=Ls(e,s),h=u.parentIsUsefulElement,d=u.targetElementList;if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(K(i))return!0;var r,s=function(t){if(i.some((e=>t.tagName.toLowerCase()===e)))return{v:!0}};for(var n of t)if(r=s(n))return r.v;return!1}(d,r))return!1;if(!Ps(d,null==r?void 0:r.css_selector_allowlist))return!1;if(Ps(d,null!==(a=null==r?void 0:r.css_selector_ignorelist)&&void 0!==a?a:Is))return!1;try{var v=t.getComputedStyle(e);if(v&&"pointer"===v.getPropertyValue("cursor")&&"click"===i.type)return!0}catch(t){}var c=e.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(n||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(n||["change","click"]).indexOf(i.type)>=0;default:return h?(n||["click"]).indexOf(i.type)>=0:(n||["click"]).indexOf(i.type)>=0&&(Rs.indexOf(c)>-1||"true"===e.getAttribute("contenteditable"))}}(s,e,this.Pe,n,n?["copy","cut"]:void 0,this.instance)){var o=tl(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Pe.element_attribute_ignorelist,elementsChainAsString:this.za,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),a=o.props;if(o.explicitNoCapture)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),i===Ya){var u,h=$s(null==t||null==(u=t.getSelection())?void 0:u.toString()),d=e.type||"clipboard";if(!h)return!1;a.$selected_content=h,a.$copy_type=d}return this.instance.capture(i,a),!0}}}isBrowserSupported(){return V(null==r?void 0:r.querySelectorAll)}},historyAutocapture:class{constructor(e){var i;this._instance=e,this.Ga=(null==t||null==(i=t.location)?void 0:i.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mi.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Qa&&this.Qa(),this.Qa=void 0,mi.info("History API monitoring stopped")}monitorHistoryChanges(){t&&t.history&&(this.Ja("pushState"),this.Ja("replaceState"),this.Ka())}Ja(e){var i;if(t&&(null==(i=t.history[e])||!i.__posthog_wrapped__)){var r=this;!function(t,e,i){try{if(!(e in t))return il;var r={next:t[e]},s=i((function(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];return r.next.apply(this,e)}));return V(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),t[e]=s,()=>{if(t[e]!==s)for(var i=t[e];V(i)&&i.__posthog_layer__;){var n=i.__posthog_layer__;if(n.next===s)return void(n.next=r.next);i=n.next}else t[e]=r.next}}catch(t){return il}}(t.history,e,(t=>function(i,s,n){t.call(this,i,s,n),r.Ya(e)}))}}Ya(e){try{var i,r=null==t||null==(i=t.location)?void 0:i.pathname;if(!r)return;r!==this.Ga&&this.isEnabled&&this._instance.capture(Ir,{navigation_type:e}),this.Ga=r}catch(t){mi.error("Error capturing "+e+" pageview",t)}}Ka(){if(!this.Qa){var e=()=>{this.Ya("popstate")};qr(t,"popstate",e),this.Qa=()=>{t&&t.removeEventListener("popstate",e)}}}},heatmaps:class{get Pe(){return this.instance.config}constructor(t){var e;this.Xa=!1,this.Ba=!1,this.eo=null,this.instance=t,this.Xa=!(null==(e=this.instance.persistence)||!e.props[Ri]),this.rageclicks=new Ja(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return W(this.Pe.capture_heatmaps)&&this.Pe.capture_heatmaps.flush_interval_milliseconds&&(t=this.Pe.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return X(this.Pe.capture_heatmaps)?X(this.Pe.enable_heatmaps)?this.Xa:this.Pe.enable_heatmaps:!1!==this.Pe.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Ba)return;vl.info("starting..."),this.io(),this.Ie()}else{var t;clearInterval(null!==(t=this.eo)&&void 0!==t?t:void 0),this.ro(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var i=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ri]:i}),this.Xa=i,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.O;return this.O=void 0,t}no(t){cl(t.originalEvent)&&this.ke(t.originalEvent,"deadclick")}Ie(){this.eo&&clearInterval(this.eo),this.eo="visible"===(null==r?void 0:r.visibilityState)?setInterval(this.pr.bind(this),this.flushIntervalMilliseconds):null}io(){t&&r&&(this.so=this.pr.bind(this),qr(t,Or,this.so),this.ao=e=>this.ke(e||(null==t?void 0:t.event)),qr(r,"click",this.ao,{capture:!0}),this.oo=e=>this.lo(e||(null==t?void 0:t.event)),qr(r,"mousemove",this.oo,{capture:!0}),this.uo=new sn(this.instance,en,this.no.bind(this)),this.uo.startIfEnabledOrStop(),this.ho=this.Ie.bind(this),qr(r,Pr,this.ho),this.Ba=!0)}ro(){var e;t&&r&&(this.so&&t.removeEventListener(Or,this.so),this.ao&&r.removeEventListener("click",this.ao,{capture:!0}),this.oo&&r.removeEventListener("mousemove",this.oo,{capture:!0}),this.ho&&r.removeEventListener(Pr,this.ho),clearTimeout(this.do),null==(e=this.uo)||e.stop(),this.Ba=!1)}vo(e,i){var r=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),o=function(e,i,r){for(var s=e;s&&gs(s)&&!ms(s,"body");){if(s===r)return!1;var n=void 0;try{var o,a,l;n=null==(o=null!==(a=null==(l=s.ownerDocument)?void 0:l.defaultView)&&void 0!==a?a:t)?void 0:o.getComputedStyle(s).position}catch(t){return!1}if(N(i,n))return!0;s=Os(s)}return!1}(Ts(e),["fixed","sticky"],n);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:r),target_fixed:o,type:i}}ke(t,e){var i;if(void 0===e&&(e="click"),!_s(t.target)&&cl(t)){var r=this.vo(t,e);null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&Ns(Ts(t),this.instance.config.rageclick)&&this.Vt(_({},r,{type:"rageclick"})),this.Vt(r)}}lo(t){!_s(t.target)&&cl(t)&&(clearTimeout(this.do),this.do=setTimeout((()=>{this.Vt(this.vo(t,"mousemove"))}),500))}Vt(e){if(t){var i=this.Pe.disable_capture_url_hashes?ye(t.location.href):t.location.href,r=this.Pe.custom_personal_data_properties,s=this.Pe.mask_personal_data_properties?[...xn,...r||[]]:[],n=gn(i,s,Sn);this.O=this.O||{},this.O[n]||(this.O[n]=[]),this.O[n].push(e)}}pr(){this.O&&!G(this.O)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:sn,webVitalsAutocapture:class{constructor(t){var e;this.Xa=!1,this.Ba=!1,this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.co=()=>{clearTimeout(this.fo),this.fo=void 0,0!==this.O.metrics.length&&(this._instance.capture("$web_vitals",_({$current_url:this.O.url},this.O.metrics.reduce(((t,e)=>_({},t,{["$web_vitals_"+e.name+"_event"]:_({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{}))),this.O={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.po=t=>{var e;if(this.O=this.O||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},X(null==t?void 0:t.name)||X(null==t?void 0:t.value))sl.error("Invalid metric received",t);else{var i="string"==typeof t.navigationURL?t.navigationURL:void 0,r=this.mo(i);if(!K(r)){var s=Z(t.navigationId)||"string"==typeof t.navigationId?"navigation:"+t.navigationId:"url:"+r;if(!this.yo||this.yo>t.value){this.O.navigationKey!==s&&(this.co(),this.fo=setTimeout(this.co,this.flushToCaptureTimeoutMs)),K(this.O.navigationKey)&&(this.O.navigationKey=s,this.O.url=r),this.O.firstMetricTimestamp=K(this.O.firstMetricTimestamp)?Date.now():this.O.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var n=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),o=_({},t,i?{navigationURL:r}:{},{$current_url:r,timestamp:Date.now()});K(n)||(o.$session_id=n.sessionId,o.$window_id=n.windowId),this.O.metrics.push(o),this.O.metrics.length===this.allowedMetrics.length&&this.co()}else sl.error("Ignoring metric with value >= "+this.yo,t)}}},this.bo=()=>{if(!this.Ba){var t,e,i,r,s=v.__PosthogExtensions__,n=null==s?void 0:s.postHogWebVitalsCallbacksByFlavor,o=(null==n?void 0:n[this._o])||("web-vitals"===this._o&&K(n)?null==s?void 0:s.postHogWebVitalsCallbacks:void 0);if(K(o)||(t=o.onLCP,e=o.onCLS,i=o.onFCP,r=o.onINP),t&&e&&i&&r){var a={reportSoftNavs:this.useSoftNavs};this.allowedMetrics.indexOf("LCP")>-1&&t(this.po.bind(this),a),this.allowedMetrics.indexOf("CLS")>-1&&e(this.po.bind(this),a),this.allowedMetrics.indexOf("FCP")>-1&&i(this.po.bind(this),a),this.allowedMetrics.indexOf("INP")>-1&&r(this.po.bind(this),a),this.Ba=!0}else sl.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Xa=!(null==(e=this._instance.persistence)||!e.props[Ci]),this.startIfEnabled()}get wo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=W(this.wo)?null==(t=this.wo)?void 0:t.web_vitals_allowed_metrics:void 0;return X(i)?(null==(e=this._instance.persistence)?void 0:e.props[Fi])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(W(this.wo)?this.wo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=W(this.wo)?this.wo.web_vitals_attribution:void 0;return null!=t&&t}get useSoftNavs(){var t=W(this.wo)?this.wo.__preview_web_vitals_soft_navs:void 0;return null!=t&&t}get yo(){var t=W(this.wo)&&Z(this.wo.__web_vitals_max_value)?this.wo.__web_vitals_max_value:nl;return t>0&&6e4>=t?nl:t}get isEnabled(){var t=null==s?void 0:s.protocol;if("http:"!==t&&"https:"!==t)return sl.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=W(this.wo)?this.wo.web_vitals:et(this.wo)?this.wo:void 0;return et(e)?e:this.Xa}startIfEnabled(){this.isEnabled&&!this.Ba&&(sl.info("enabled, starting..."),this.ai(this.bo))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var i=W(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=W(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ci]:i}),this._instance.persistence.register({[Fi]:r})),this.Xa=i,this.startIfEnabled()}}}get _o(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}ai(t){var e=v.__PosthogExtensions__,i=this._o,r=null==e?void 0:e.postHogWebVitalsCallbacksByFlavor;null!=r&&r[i]||"web-vitals"===i&&K(r)&&null!=e&&e.postHogWebVitalsCallbacks?t():null==e||null==e.loadExternalDependency||e.loadExternalDependency(this._instance,i,(e=>{e?sl.error("failed to load script",e):t()}))}mo(e){var i=e||(null==t?void 0:t.location.href);if(i){var r=this._instance.config.disable_capture_url_hashes?ye(i):i,s=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[...xn,...s||[]]:[];return gn(r,n,Sn)}sl.error("Could not determine current URL")}}},Wl={exceptionObserver:class{constructor(e){var i;this.bo=()=>{var e;if(t&&this.isEnabled&&null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions){var i=v.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=v.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,s=v.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.xo&&this.Pe.capture_unhandled_errors&&(this.xo=i(this.captureException.bind(this))),!this.ko&&this.Pe.capture_unhandled_rejections&&(this.ko=r(this.captureException.bind(this))),!this.So&&this.Pe.capture_console_errors&&(this.So=s(this.captureException.bind(this)))}catch(t){el.error("failed to start",t),this.Co()}}},this._instance=e,this.Mo=!(null==(i=this._instance.persistence)||!i.props[Pi]),this.To=new ct(_({},function(t){var e,i,r,s;return void 0===t&&(t={}),{refillRate:null!==(e=null!==(i=t.exceptionRateLimiterRefillRate)&&void 0!==i?i:t.__exceptionRateLimiterRefillRate)&&void 0!==e?e:1,bucketSize:null!==(r=null!==(s=t.exceptionRateLimiterBucketSize)&&void 0!==s?s:t.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10}}(this._instance.config.error_tracking),{refillInterval:1e4,rt:el})),this.Pe=this.Eo(),this.startIfEnabledOrStop()}Eo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return W(t)?e=_({},e,t):(K(t)?this.Mo:t)&&(e=_({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Pe.capture_console_errors||this.Pe.capture_unhandled_errors||this.Pe.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(el.info("enabled"),this.Co(),this.ai(this.bo)):this.Co()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.errorWrappingFunctions?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return el.error("failed to load script",e);t()}))}Co(){var t,e,i;null==(t=this.xo)||t.call(this),this.xo=void 0,null==(e=this.ko)||e.call(this),this.ko=void 0,null==(i=this.So)||i.call(this),this.So=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.Mo=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pi]:this.Mo}),this.Pe=this.Eo(),this.startIfEnabledOrStop())}}onConfigChange(){this.Pe=this.Eo()}captureException(t){var e,i,r,s=null!==(e=null==t||null==(i=t.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==e?e:"Exception";this.To.consumeRateLimit(s)?el.info("Skipping exception capture because of client rate limiting.",{exception:s}):null==(r=this._instance.exceptions)||r.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.Io=[],this.Po=new Be([new Ze,new ui,new ei,new ti,new ai,new oi,new ri,new li],function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];return function(e,r){void 0===r&&(r=0);for(var s=[],n=e.split("\n"),o=r;n.length>o;o++){var a=n[o];if(1024>=a.length){var l=Xe.test(a)?a.replace(Xe,"$1"):a;if(!l.match(/\S*Error: /)){for(var u of i){var h=u(l,t);if(h){s.push(h);break}}if(s.length>=50)break}}}return function(t){if(!t.length)return[];var e=Array.from(t);return e.reverse(),e.slice(0,50).map((t=>{return _({},t,{filename:t.filename||(i=e,i[i.length-1]||{}).filename,function:t.function||ze});var i}))}(s)}}("web:javascript",Ke,Qe)),this._instance=t,this.Io=null!==(e=null==(i=this._instance.persistence)?void 0:i.get_property(Oi))&&void 0!==e?e:[],this.Ro=fi(this.Lo()),this.Oo=new pi(this.Ro)}onConfigChange(){this.Ro=fi(this.Lo()),this.Oo.setConfig(this.Ro)}onRemoteConfig(t){var e,i,r;if(t.ok){var s=t.config;if("errorTracking"in s){var n=null!==(e=null==(i=s.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],o=null==(r=s.errorTracking)?void 0:r.captureExtensionExceptions;this.Io=n,this._instance.persistence&&this._instance.persistence.register({[Oi]:this.Io,[Ii]:o})}}}get Fo(){var t,e=!!this._instance.get_property(Ii),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.Po.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.Ro.enabled)try{if(!J(t)||0===t.trim().length)return void Al.warn("Ignoring exception step because message must be a non-empty string");var i=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>vi.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(this.Ao(e)),r=i.sanitizedProperties,s=i.droppedKeys;s.length>0&&Al.warn("Ignoring reserved exception step fields",{droppedKeys:s}),this.Oo.add(_({[hi]:t,[di]:(new Date).toISOString()},r))}catch(t){Al.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Do(e)){if(this.$o(e))return this.No("Exception dropped: matched a suppression rule"),void Al.info("Skipping exception capture because a suppression rule matched");if(!this.Fo&&this.qo(e))return this.No("Exception dropped: thrown by a browser extension"),void Al.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.jo(e))return this.No("Exception dropped: thrown by the PostHog SDK"),void Al.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.Ro.enabled&&X(t.$exception_steps)?this.Bo(t):t,r="string"==typeof(n=globalThis._posthogReleaseId)&&n.length>0?n:void 0;r&&(i.$release_id=r);try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",jn:!0});return s&&this.Oo.clear(),s}catch(t){return Al.error("Failed to capture exception event. Dropping this exception.",t),void this.Oo.clear()}}catch(t){return void Al.error("Failed to process exception event. Ignoring this exception.",t)}var n}Bo(t){try{var e=this.Oo.getAttachable();return 0===e.length?t:_({},t,{$exception_steps:e})}catch(e){return Al.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}No(t){this.Ro.enabled&&this.Oo.add({[hi]:t,[di]:(new Date).toISOString()})}Ao(t){return W(t)?_({},t):{}}Lo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}$o(t){if(0===t.length)return!1;try{var e=t.reduce(((t,e)=>{var i=e.type,r=e.value;return J(i)&&i.length>0&&t.$exception_types.push(i),J(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.Io.some((t=>{var i=t.values.map((t=>{var i=fa[t.operator],r=e[t.key];if(!i||!r)return!1;var s=q(t.value)?t.value:[t.value];return s.length>0&&i(s,r)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}catch(t){return Al.warn("Failed to evaluate suppression rules. Capturing the exception.",t),!1}}qo(t){return t.flatMap((t=>{var e,i;return null!==(e=null==(i=t.stacktrace)?void 0:i.frames)&&void 0!==e?e:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}jo(t){if(t.length>0){var e,i,r,s,n=null!==(e=null==(i=t[0].stacktrace)?void 0:i.frames)&&void 0!==e?e:[],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}Do(t){return!X(t)&&q(t)}}},Gl=_({productTours:class{get Tr(){return this._instance.persistence}constructor(t){this.Ho=null,this.Uo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var i,r;if(this.Tr&&this.Tr.register({[Mi]:!!e.productTours}),!pl(this._instance))return!this.Ho&&X(null==(i=this.Tr)?void 0:i.props[or])||fl.info("product tours disabled; stopping and clearing cached tours"),null==(r=this.Ho)||r.stop(),this.Ho=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Ho&&pl(this._instance)&&this.ai((()=>this.zo()))}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?fl.error("Could not load product tours script",e):t()}))}zo(){var t;!this.Ho&&null!=(t=v.__PosthogExtensions__)&&t.generateProductTours&&(this.Ho=v.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!q(this.Uo)||e){var i=this.Tr;if(i){var r=i.props[or];if(q(r)&&!e)return this.Uo=r,void t(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:e=>{if(pl(this._instance)){var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return 0===r?e.error||fl.warn(s):fl.error(s),void t([],{isLoaded:!1,error:s})}var n=q(e.json.product_tours)?e.json.product_tours:[];this.Uo=n,i&&i.register({[or]:n}),t(n,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Uo,{isLoaded:!0})}getActiveProductTours(t){X(this.Ho)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ho.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Ho)||e.showTourById(t)}previewTour(t){this.Ho?this.Ho.previewTour(t):this.ai((()=>{var e;this.zo(),null==(e=this.Ho)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Ho)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Ho)||t.nextStep()}previousStep(){var t;null==(t=this.Ho)||t.previousStep()}clearCache(){var t;this.Uo=null,null==(t=this.Tr)||t.unregister(or)}resetTour(t){var e;null==(e=this.Ho)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Ho)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Ho)||e.cancelPendingTour(t)}}},Hl),Kl={siteApps:class{constructor(t){this.Wo=0,this._instance=t,this.Vo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Zo(t,e){if(e){var i=this.globalsForEvent(e);this.Vo.push(i),this.Vo.length>1e3&&(this.Vo=this.Vo.slice(10))}}get siteAppLoaders(){var t;return null==(t=v._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Zo.bind(this));this.Go=()=>{t(),this.Vo=[],this.Go=void 0}}}globalsForEvent(t){var e,i,r,s,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var d of Object.entries(h)){var v=d[0];l[v]={id:u[v],type:v,properties:d[1]}}var c=t.$set_once,f=t.$set;return{event:_({},g(t,_l),{properties:_({},t.properties,f?{$set:_({},null!==(e=null==(i=t.properties)?void 0:i.$set)&&void 0!==e?e:{},f)}:{},c?{$set_once:_({},null!==(r=null==(s=t.properties)?void 0:s.$set_once)&&void 0!==r?r:{},c)}:{}),elements_chain:null!==(n=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=t.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}Qo(t){var e,i=null==(e=t.tagName)?void 0:e.toLowerCase();return"style"===i&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(gl.error("prepare_external_dependency_stylesheet returned null"),null):"script"===i&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(gl.error("prepare_external_dependency_script returned null"),null):t}Jo(){var t,e,i,s,n,o,a,l;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var u=null==r?void 0:r.defaultView,h=null==u||null==(t=u.Node)?void 0:t.prototype;if(!u||!h)return()=>{};if(this.Wo++,this.Ko)return this.Yo();var d=[],v=this,c=new WeakSet,f=(t,e,i)=>{if(null!=t&&t[e]){var r=t[e];t[e]=i(r),d.push((()=>{t[e]=r}))}},p=t=>{if(c.has(t))return t;var e=v.Qo(t);return e&&c.add(e),e},_=t=>t.map((t=>"string"==typeof t?t:p(t))).filter((t=>!Q(t)));return f(h,"appendChild",(t=>function(e){var i=p(e);return i?t.call(this,i):e})),f(h,"insertBefore",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):e})),f(h,"replaceChild",(t=>function(e,i){var r=p(e);return r?t.call(this,r,i):i})),[null==(e=u.Element)?void 0:e.prototype,null==(i=u.Document)?void 0:i.prototype,null==(s=u.DocumentFragment)?void 0:s.prototype].forEach((t=>{f(t,"append",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"prepend",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))}))})),[null==(n=u.Element)?void 0:n.prototype,null==(o=u.CharacterData)?void 0:o.prototype,null==(a=u.DocumentType)?void 0:a.prototype].forEach((t=>{f(t,"before",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"after",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];return t.apply(this,_(i))})),f(t,"replaceWith",(t=>function(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];var s=_(i);return i.length&&!s.length?void 0:t.apply(this,s)}))})),f(null==(l=u.Element)?void 0:l.prototype,"insertAdjacentElement",(t=>function(e,i){var r=p(i);return r?t.call(this,e,r):null})),this.Ko=()=>{d.forEach((t=>t())),this.Ko=void 0},this.Yo()}Yo(){var t=!1;return()=>{var e;t||(t=!0,this.Wo--,0===this.Wo&&(null==(e=this.Ko)||e.call(this)))}}Xo(t,e){void 0===e&&(e=!0);var i=this.Jo();try{var r=t(i);return e&&i(),r}catch(t){throw i(),t}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.Vo.length&&(gl.info("Processing "+this.Vo.length+" events for site app with id "+t.id),this.Vo.forEach((t=>this.Xo((()=>null==e.processEvent?void 0:e.processEvent(t))))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Go)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,gl.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var n=this.Xo((e=>t.init({posthog:this._instance,callback(t){e(),s(t)}})),!1).processEvent;n&&(e.processEvent=n),r=!0}catch(e){gl.error(ml+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){gl.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}tl(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}el(t){var e=this;if(0!==Object.keys(this.apps).length){var i=this.globalsForEvent(t),r=function(r){try{e.Xo((()=>null==r.processEvent?void 0:r.processEvent(i)))}catch(e){gl.error("Error while processing event "+t.event+" for site app "+r.id,e)}};for(var s of Object.values(this.apps))r(s)}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.tl(),void this._instance.on("eventCaptured",(t=>this.el(t)))):void gl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Go)||i.call(this),t.ok){var n=t.config;if(null!=(r=n.siteApps)&&r.length)if(this.isEnabled){var o=function(){var t,e=a.id,i=a.url;v["__$$ph_site_app_"+e]=s._instance,null==(t=v.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,i,(t=>{if(t)return gl.error(ml+e,t)}))};for(var a of n.siteApps)o()}else gl.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Jl={tracingHeaders:class{constructor(t){this.il=void 0,this.rl=void 0,this.nl=void 0,this.bo=()=>{var t,e,i=this.sl();i?(K(this.il)&&(this.il=null==(t=v.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)?void 0:t._patchXHR(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),K(this.rl)&&(this.rl=null==(e=v.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)?void 0:e._patchFetch(i,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.Co()},this._instance=t}initialize(){this.startIfEnabledOrStop()}ai(t){var e,i;null!=(e=v.__PosthogExtensions__)&&e.tracingHeadersPatchFns?t():null==(i=v.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return rl.error("failed to load script",e);t()}))}al(){var t,e;return null!==(t=null!==(e=this._instance.config.tracing_headers)&&void 0!==e?e:this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}sl(){var t=this.al();return q(t)?(q(this.nl)?this.nl.splice(0,this.nl.length,...t):this.nl=[...t],t.length>0?this.nl:void 0):(q(this.nl)&&this.nl.splice(0),this.nl=t||void 0,this.nl)}Co(){var t,e;null==(t=this.il)||t.call(this),null==(e=this.rl)||e.call(this),this.il=void 0,this.rl=void 0}startIfEnabledOrStop(){this.sl()?this.ai(this.bo):this.Co()}}},Yl=_({surveys:class{get Pe(){return this._instance.config}constructor(t){this.ol=void 0,this._surveyManager=null,this.ll=!1,this.ul=[],this.hl=null,this.dl=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.Pe.disable_surveys){if(!t.ok)return xa.warn("Remote config unavailable. Not loading surveys.");var e=t.config.surveys;if(X(e))return xa.warn("Flags not loaded yet. Not loading surveys.");var i=q(e);this.ol=i?e.length>0:e,xa.info("flags response received, isSurveysEnabled: "+this.ol),this.loadIfEnabled()}}reset(){try{var t;null==(t=this._surveyEventReceiver)||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],i=0;i<localStorage.length;i++){var r=localStorage.key(i);(null!=r&&r.startsWith(Ea)||null!=r&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((t=>localStorage.removeItem(t)))}catch(t){}}loadIfEnabled(){if(!this._surveyManager)if(this.ll)xa.info("Already initializing surveys, skipping...");else if(this.Pe.disable_surveys)xa.info(Sl);else if(this.Pe.cookieless_mode&&this._instance.consent.isOptedOut())xa.info("Not loading surveys in cookieless mode without consent.");else{var t=null==v?void 0:v.__PosthogExtensions__;if(t){if(!K(this.ol)||this.Pe.advanced_enable_surveys){var e=this.ol||this.Pe.advanced_enable_surveys;this.ll=!0;try{var i=t.generateSurveys;if(i)return void this.vl(i,e);var r=t.loadExternalDependency;if(!r)return void this.cl(Er);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.cl("Could not load surveys script",i):this.vl(t.generateSurveys,e)}))}catch(t){throw this.cl("Error initializing surveys",t),t}finally{this.ll=!1}}}else xa.error("PostHog Extensions not found.")}}vl(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new xl(this._instance),xa.info("Surveys loaded successfully"),this.fl({isLoaded:!0})}cl(t,e){xa.error(t,e),this.fl({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.ul.push(t),this._surveyManager&&this.fl({isLoaded:!0}),()=>{this.ul=this.ul.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.Pe.disable_surveys)return xa.info(Sl),t([]);var i,r=this._instance.get_property(er);if(r&&!e)return t(r,{isLoaded:!0}),void(this.pl()&&this.getSurveys((()=>{}),!0));"undefined"!=typeof Promise&&this.hl?this.hl.then((e=>t(e.surveys,e.context))):("undefined"!=typeof Promise&&(this.hl=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Pe.token),method:"GET",timestampMode:"query",timeout:this.Pe.surveys_request_timeout_ms,callback:e=>{var r;this.hl=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;0!==s?xa.error(n):e.error||xa.warn(n),this.dl=Date.now();var o={isLoaded:!1,error:n};return t([],o),void(null==i||i({surveys:[],context:o}))}this.dl=null;var a,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(wa(t)||function(t){var e;return!(null==(e=t.conditions)||null==(e=e.actions)||null==(e=e.values)||!e.length)}(t))));u.length>0&&(null==(a=this._surveyEventReceiver)||a.register(u)),null==(r=this._instance.persistence)||r.register({[er]:l,[ir]:Date.now()});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}pl(){return this.gl()&&!this.hl&&!this.ml()}gl(){var t=this._instance.get_property(ir);return Z(t)&&Date.now()-t>3e5}ml(){return Z(this.dl)&&3e5>Date.now()-this.dl}markSurveyAsSeen(t,e){var i,r={id:t,current_iteration:null!==(i=null==e?void 0:e.iteration)&&void 0!==i?i:null};Sa(r);try{localStorage.setItem("lastSeenSurveyDate",(new Date).toISOString())}catch(t){}}fl(t){for(var e of this.ul)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){xa.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!X(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);xa.warn("init was not called")}yl(t){var e=null;return this.getSurveys((i=>{var r;e=null!==(r=i.find((e=>e.id===t)))&&void 0!==r?r:null})),e}bl(t){if(X(this._surveyManager))return{eligible:!1,reason:El};var e="string"==typeof t?this.yl(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}_l(t){if(X(this._surveyManager))return{eligible:!1,reason:El};var e="string"==typeof t?this.yl(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(X(this._surveyManager))return xa.warn("init was not called"),{visible:!1,disabledReason:El};var e=this._l(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return X(this._surveyManager)?(xa.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:El})):new Promise((i=>{this.getSurveys((e=>{var r,s=null!==(r=e.find((e=>e.id===t)))&&void 0!==r?r:null;if(s){var n=this._l(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(X(this._surveyManager))xa.warn("init was not called");else{var n="string"==typeof t?this.yl(t):t;if(null!=n&&n.id)if($a.includes(n.type)){var o=null==r?void 0:r.querySelector(e);if(o)return null!=(s=n.appearance)&&s.surveyPopupDelaySeconds?(xa.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;xa.info("Rendering survey "+n.id+" with delay of "+(null==(t=n.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(n,o,i),xa.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,o,i);xa.warn("Survey element not found")}else xa.warn("Surveys of type "+n.type+" cannot be rendered in the app");else xa.warn("Survey not found")}}displaySurvey(t,e){var i;if(X(this._surveyManager))xa.warn("init was not called");else{var r=this.yl(t);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(s=_({},r,{appearance:_({},r.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Xn.Popover&&e.initialResponses&&xa.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var n=this.bl(r);if(!n.eligible)return void xa.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==Xn.Inline?this._surveyManager.handlePopoverSurvey(s,e):this.renderSurvey(s,e.selector,e.properties)}else xa.warn("Survey not found")}}cancelPendingSurvey(t){X(this._surveyManager)?xa.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||null==t.handlePageUnload||t.handlePageUnload()}}},Hl),Ql={toolbar:class{constructor(t){this.instance=t}wl(t){v.ph_toolbar_state=t}xl(){var t;return null!==(t=v.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(e,i,s){if(void 0===e&&(e=void 0),void 0===i&&(i=void 0),void 0===s&&(s=void 0),Vr(this.instance.config))return!1;if(!t||!r)return!1;e=null!=e?e:t.location,s=null!=s?s:t.history;try{if(!i){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(t){return!1}i=null==t?void 0:t.localStorage}var n,o=$l||mn(e.hash,"__posthog")||mn(e.hash,"state"),a=o?Lr((()=>JSON.parse(atob(decodeURIComponent(o)))))||Lr((()=>JSON.parse(decodeURIComponent(o)))):null;return a&&"ph_authorize"===a.action?((n=a).source="url",n&&Object.keys(n).length>0&&(a.desiredHash?e.hash=a.desiredHash:s?s.replaceState(s.state,"",e.pathname+e.search):e.hash="")):((n=JSON.parse(i.getItem(kl)||"{}")).source="localstorage",delete n.userIntent),!(!n.token||this.instance.config.token!==n.token||(this.loadToolbar(n),0))}catch(t){return!1}}kl(t){var e=v.ph_load_toolbar||v.ph_load_editor;!X(e)&&V(e)?e(t,this.instance):Tl.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==r||!r.getElementById(vs));if(!t||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=_({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(t.localStorage.setItem(kl,JSON.stringify(_({},n,{source:void 0}))),2===this.xl())this.kl(n);else if(0===this.xl()){var o;this.wl(1),null==(o=v.__PosthogExtensions__)||null==o.loadExternalDependency||o.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return Tl.error("[Toolbar] Failed to load",t),void this.wl(0);this.wl(2),this.kl(n)})),qr(t,"turbolinks:load",(()=>{this.wl(0),this.loadToolbar(n)}))}return!0}Sl(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},Xl=_({experiments:Dl},Hl),Zl={conversations:class{constructor(t){this.Cl=void 0,this._conversationsManager=null,this.Ml=!1,this.Tl=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&t.ok){var e=t.config.conversations;X(e)||(et(e)?this.Cl=e:(this.Cl=e.enabled,this.Tl=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Cl=void 0,this.Tl=null}loadIfEnabled(){if(!(this._conversationsManager||this.Ml||this._instance.config.disable_conversations||Vr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==v?void 0:v.__PosthogExtensions__;if(t&&!K(this.Cl)&&this.Cl)if(this.Tl&&this.Tl.token){this.Ml=!0;try{var e=t.initConversations;if(e)return this.El(e),void(this.Ml=!1);var i=t.loadExternalDependency;if(!i)return void this.Il(Er);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.Il("Could not load conversations script",e):this.El(t.initConversations),this.Ml=!1}))}catch(t){this.Il("Error initializing conversations",t),this.Ml=!1}}else Nl.error("Conversations enabled but missing token in remote config.")}}El(t){if(this.Tl)try{this._conversationsManager=t(this.Tl,this._instance),Nl.info("Conversations loaded successfully")}catch(t){this.Il("Error completing conversations initialization",t)}else Nl.error("Cannot complete initialization: remote config is null")}Il(t,e){Nl.error(t,e),this._conversationsManager=null,this.Ml=!1}show(){this._conversationsManager?this._conversationsManager.show():Nl.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Cl&&!Q(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,e,i){var r=this;return p((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(t,e,i):(Nl.warn(Ul),null)}))()}getMessages(t,e){var i=this;return p((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Nl.warn(Ul),null)}))()}markAsRead(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Nl.warn(Ul),null)}))()}getTickets(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Nl.warn(Ul),null)}))()}requestRestoreLink(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Nl.warn(Ul),null)}))()}restoreFromToken(t){var e=this;return p((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Nl.warn(Ul),null)}))()}restoreFromUrlToken(){var t=this;return p((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Nl.warn(Ul),null)}))()}getCurrentTicketId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getCurrentTicketId())&&void 0!==t?t:null}getWidgetSessionId(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.getWidgetSessionId())&&void 0!==t?t:null}Gn(){var t;null==(t=this._conversationsManager)||t.setIdentity()}Qn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},tu={logs:class{constructor(e){var i,r=this;this.Pl=!1,this.Rl=!1,this.rt=bi("[logs]"),this.Ll=_({},this.rt,{error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];e.some(zl)||r.rt.error(...e)}}),this.er=[],this.Ol=[],this.fa=0,this.Fl=()=>{var t,e;this.fa=0,null==(t=this.Al)||t.onReconnect(),null==(e=this.Dl)||e.onReconnect()},this._instance=e,this._instance&&null!=(i=this._instance.config.logs)&&i.captureConsoleLogs&&(this.Pl=!0),t&&qr(t,"online",this.Fl)}$l(t,e,i,r){var s,n=function(t,e){var i,r,s,n,o,a,l,u=null!==(i=null==t?void 0:t.flushIntervalMs)&&void 0!==i?i:3e3,h=null!==(r=null==t?void 0:t.maxBufferSize)&&void 0!==r?r:100,d=null!=e&&e.consoleCapture?void 0:null!==(s=null==t?void 0:t.maxLogsPerInterval)&&void 0!==s?s:1e3,v=K(d)?Math.max(h,2048):Math.max(h,d),c=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(n=null!==(o=null==c?void 0:c["service.name"])&&void 0!==o?o:null==t?void 0:t.serviceName)&&void 0!==n?n:null==e?void 0:e.serviceNameDefault,serviceVersion:null!==(a=null==c?void 0:c["service.version"])&&void 0!==a?a:null==t?void 0:t.serviceVersion,environment:null!==(l=null==c?void 0:c["deployment.environment"])&&void 0!==l?l:null==t?void 0:t.environment,resourceAttributes:c,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:u,maxBufferSize:h,maxQueueSize:v,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:d,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}(null==(s=this._instance)||null==(s=s.config)?void 0:s.logs,i);return[new Ce(this.Nl(t,e),n,this.Ll,(()=>this.ql()),(t=>t()),void 0,r),n]}jl(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Al||this.Bl!==e){var i;null==(i=this.Al)||i.reset(),this.Bl=e;var r=this.$l((()=>this.er),(t=>{this.er=t}));this.Al=r[0],this.Hl=r[1]}return this.Al}Ul(){var t,e=null==(t=this._instance)||null==(t=t.config)?void 0:t.logs;if(!this.Dl||this.zl!==e){var i;null==(i=this.Dl)||i.reset(),this.zl=e;var r=this.$l((()=>this.Ol),(t=>{this.Ol=t}),{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},Ll);this.Dl=r[0],this.Wl=r[1]}return this.Dl}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e;if(t.ok){var i=null==(e=t.config.logs)?void 0:e.captureConsoleLogs;!X(i)&&i&&(this.Pl=!0,this.loadIfEnabled())}}reset(){var t,e;this.er=[],null==(t=this.Al)||t.reset(),this.Ol=[],null==(e=this.Dl)||e.reset(),this.fa=0}captureLog(t){this.jl().captureLog(t)}he(t){this.Ul().captureLog(t)}get logger(){return this.Vl||(this.Vl={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Vl}flushLogs(t){t?this.Zl(t):(this.Al&&this.Al.flush().catch((t=>this.Gl(t))),this.Dl&&this.Dl.flush().catch((t=>this.Gl(t))))}Gl(t){zl(t)||this.rt.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.Pl&&!this.Rl){var t=null==v?void 0:v.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.rt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.Rl=!0)})):this.rt.error(Er)}else this.rt.error("PostHog Extensions not found.")}}Nl(t,e){var i=this._instance;return{get isDisabled(){return!1},get optedOut(){return!i.is_capturing()},getPersistedProperty:e=>e===E.LogsQueue?t():void 0,setPersistedProperty(t,i){var r;t===E.LogsQueue&&e(null!==(r=i)&&void 0!==r?r:[])},At:t=>this.At(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}At(t){return new Promise((e=>{if(bn(this.fa,3))e({kind:"fatal",error:Bl(void 0,"logs endpoint is unreachable, dropping batch")});else{var i=!1,r=t=>{i||(i=!0,clearTimeout(s),e(t))},s=setTimeout((()=>{this.rt.warn("Logs request timed out before receiving a response"),r({kind:"retry-later",error:Bl(void 0,"logs request timed out")})}),9e4);this._instance._send_request({method:"POST",url:this.Ql(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:t=>{var e=t.statusCode;if(this.Jl(e),e>=200&&300>e)r({kind:"ok"});else if(413===e)r({kind:"too-large"});else if(0!==e&&429!==e&&500>e)r({kind:"fatal",error:new Error("logs request failed with status "+e)});else{var i;0===e?(t.error||this.rt.warn("Logs request failed before receiving an HTTP response"),r({kind:"retry-later",error:Bl(t.error,"logs request failed before receiving an HTTP response")})):r({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("logs request failed with status "+e)})}}})}}))}Jl(t){(0!==t||this._instance.__loaded)&&(this.fa=yn(t,this.fa,3,(()=>this.rt.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes."))))}Zl(t){this.er.length>0&&this.Kl(t,this.er,this.Hl,c.LIB_NAME,(t=>{this.er=t})),this.Ol.length>0&&this.Kl(t,this.Ol,this.Wl,Ll,(t=>{this.Ol=t}))}Kl(t,e,i,r,s){if(0!==e.length){var n=e.map((t=>t.record));s([]);var o=Ie(n,Oe(i,c.LIB_NAME,c.LIB_VERSION),r,c.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Ql(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Ql(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}ql(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var i=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=i.windowId,s=i.sessionStartTimestamp,n=i.lastActivityTimestamp;e.sessionId=i.sessionId,e.windowId=r,X(s)||(e.sessionStartTimestamp=s),X(n)||(e.lastActivityTimestamp=n)}if(null!=v&&null!=(t=v.location)&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?ye(v.location.href):v.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},eu={metrics:class{constructor(t){this.rt=bi("[metrics]"),this._instance=t}initialize(){}jl(){var t,e,i=null==(t=this._instance)||null==(t=t.config)?void 0:t.metrics;return this.Al&&this.Bl===i||(null==(e=this.Al)||e.reset(),this.Bl=i,this.Al=new De(this.Nl(),function(t){var e,i,r,s,n,o=null==t?void 0:t.resourceAttributes;return{serviceName:null!==(e=null==o?void 0:o["service.name"])&&void 0!==e?e:null==t?void 0:t.serviceName,serviceVersion:null!==(i=null==o?void 0:o["service.version"])&&void 0!==i?i:null==t?void 0:t.serviceVersion,environment:null!==(r=null==o?void 0:o["deployment.environment"])&&void 0!==r?r:null==t?void 0:t.environment,resourceAttributes:o,beforeSend:null==t?void 0:t.beforeSend,flushIntervalMs:null!==(s=null==t?void 0:t.flushIntervalMs)&&void 0!==s?s:1e4,maxSeriesPerFlush:null!==(n=null==t?void 0:t.maxSeriesPerFlush)&&void 0!==n?n:1e3}}(i),this.rt)),this.Al}count(t,e,i){void 0===e&&(e=1),this.jl().count(t,e,i)}gauge(t,e,i){this.jl().gauge(t,e,i)}histogram(t,e,i){this.jl().histogram(t,e,i)}flush(t){if(!this.Al)return Promise.resolve();if(t){var e=this.Al.drainWindow();return e&&this.Kt(e,t),Promise.resolve()}return this.Al.flush().catch((t=>this.rt.error("PostHog metrics flush failed:",t)))}reset(){var t;null==(t=this.Al)||t.reset()}Nl(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Kt:t=>e.Kt(t),getLibraryId:()=>c.LIB_NAME,getLibraryVersion:()=>c.LIB_VERSION}}Kt(t,e){return new Promise((i=>{var r=!1,s=t=>{r||(r=!0,clearTimeout(n),i(t))},n=setTimeout((()=>s({kind:"retry-later",error:new Error("metrics request timed out")})),9e4);this._instance._send_request(_({method:"POST",url:this.Yl(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(t){var e=t.statusCode;if(e>=200&&300>e)s({kind:"ok"});else if(413===e)s({kind:"too-large"});else if(0!==e&&429!==e&&500>e)s({kind:"fatal",error:new Error("metrics request failed with status "+e)});else{var i;s({kind:"retry-later",error:null!==(i=t.error)&&void 0!==i?i:new Error("metrics request failed with status "+e)})}}}))}))}Yl(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},iu=_({},Hl,ql,Vl,Wl,Gl,Kl,Yl,Jl,Ql,Xl,Zl,tu,eu);Ka.__defaultExtensionClasses=_({},iu);var ru=function(){c.SDK_DIST_CHANNEL="npm";var e=Ma[za]=new Ka;return function(){function e(){e.done||(e.done=!0,Ha=!1,Dr(Ma,(function(t){t._dom_loaded()})))}null!=r&&r.addEventListener?"complete"===r.readyState?e():qr(r,"DOMContentLoaded",e,{capture:!1}):t&&mi.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),e}();export{Bn as Compression,Zn as DEFAULT_PRODUCT_TOUR_APPEARANCE,Xn as DisplaySurveyType,Ka as PostHog,to as ProductTourEventName,eo as ProductTourEventProperties,Yn as SurveyEventName,Qn as SurveyEventProperties,zn as SurveyEventType,qn as SurveyPosition,Kn as SurveyQuestionBranchingType,Gn as SurveyQuestionType,Jn as SurveySchedule,Vn as SurveyTabPosition,Wn as SurveyType,Hn as SurveyWidgetType,ru as default,ru as posthog,oo as severityLevels};
2
2
  //# sourceMappingURL=module.js.map