posthog-js 1.376.0 → 1.376.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.
@@ -1,2 +1,2 @@
1
- function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=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},i.apply(null,arguments)}var r="1.376.0",s="web",n=["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"],a=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return n.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function o(t,e){return-1!==t.indexOf(e)}var l=function(t){return t.trim()},u=Object.prototype,h=u.hasOwnProperty,v=u.toString,d=Array.isArray||function(t){return"[object Array]"===v.call(t)},c=t=>"function"==typeof t,f=t=>t===Object(t)&&!d(t),p=t=>void 0===t,g=t=>"[object String]"==v.call(t),b=t=>null===t,_=t=>p(t)||b(t),m=t=>"[object Number]"==v.call(t)&&t==t,y=t=>"[object Boolean]"===v.call(t),w=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function E(t,e){return{}.toString.call(t)==="[object "+e+"]"}function k(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function S(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),m(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),S(i,e,i,r))}class F{constructor(t){this.$t={},this.zt=t.zt,this.Zt=S(t.bucketSize,0,100,t.Gt),this.Qt=S(t.refillRate,0,this.Zt,t.Gt),this.Jt=S(t.refillInterval,0,864e5,t.Gt)}Kt(t,e){var i=Math.floor((e-t.lastAccess)/this.Jt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Qt,this.Zt),t.lastAccess=t.lastAccess+i*this.Jt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Kt(s,i):this.$t[r]=s={tokens:this.Zt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.zt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}var C,R,P,I={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}},T=I.info;function O(t){if(y(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(d(t))return{arrayValue:{values:t.map((t=>O(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function A(t){var e=[];for(var i in t){var r=t[i];b(r)||p(r)||e.push({key:i,value:O(r)})}return e}function j(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return P&&i.length===R?P:(R=i.length,P=i.reduce(((i,r)=>{C||(C={});var s=C[r];if(s)i[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=e[r];if(l&&u){i[l]=u,C[r]=[l,u];break}}return i}),{}))}}class L{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 i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&d(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.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 r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}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 i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:j(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var M="?";function D(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?M:i,in_app:!0};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var N=(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]:M,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},U=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,z=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,H=/\((\S*)(?::(\d+))(?::(\d+))\)/,V=(t,e)=>{var i=U.exec(t);if(i){var[,r,s,n]=i;return D(e,r,M,+s,+n)}var a=z.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=H.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=N(a[1]||M,a[2]);return D(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},W=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,B=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,J=(t,e)=>{var i=W.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=B.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]||M;return[n,s]=N(n,s),D(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},q=/\(error: (.*)\)/;class G{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=g(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 E(t,"DOMException")}isDOMError(t){return E(t,"DOMError")}}class K{match(t){return t instanceof Error}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 Y{constructor(){}match(t){return E(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var X=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Z{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(X);return r&&(e=r[1],i=r[2]),[e,i]}}var Q=["fatal","error","warning","log","info","debug"];function tt(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 et{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return k(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: "+tt(t)}isSeverityLevel(t){return g(t)&&!(t=>g(t)&&0===t.trim().length)(t)&&Q.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class it{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+tt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class rt{match(t){return x(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 st{match(t){return E(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(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 x(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 nt="$message",at="$timestamp",ot=new Set([nt,at]),lt={enabled:!0,max_bytes:32768};function ut(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:lt.enabled,max_bytes:vt(t.max_bytes,lt.max_bytes)}:i({},lt)}class ht{constructor(t){this.Yt=[],this.Xt=0,this.qt=ut(t)}setConfig(t){this.qt=ut(t),this.er()}add(t){var e=function(t){var e=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!f(i))return;var r=i,s=r[nt],n=r[at];if(!g(s)||0===s.trim().length)return;if(!g(n)&&!m(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.qt.max_bytes||(this.Yt.push({step:e.step,bytes:i}),this.Xt+=i,this.er())}}getAttachable(){return this.Yt.map((t=>t.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var t=this.Yt.shift();t&&(this.Xt-=t.bytes)}}}function vt(t,e){if(!m(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var dt="undefined"!=typeof window?window:void 0,ct="undefined"!=typeof globalThis?globalThis:dt;"undefined"==typeof self&&(ct.self=ct),"undefined"==typeof File&&(ct.File=function(){});var ft=null==ct?void 0:ct.navigator,pt=null==ct?void 0:ct.document,gt=null==ct?void 0:ct.location;null!=ct&&ct.XMLHttpRequest&&new ct.XMLHttpRequest;var bt=null!=dt?dt:{},_t=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(dt&&(bt.POSTHOG_DEBUG||i)&&!p(dt.console)&&dt.console){for(var r=("__rrweb_original__"in dt.console[e]?dt.console[e].__rrweb_original__:dt.console[e]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>_t(t+" "+e,i)};return r},mt=_t("[PostHog.js]"),yt=mt.createLogger;function wt(t,e){if(!_(t))if(d(t))t.forEach(e);else if(w(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)h.call(t,i)&&e(t[i],i)}var xt=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 Et(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 kt=function(t){try{return t()}catch(t){return}};function St(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Ft(t){return"ph_toolbar_internal"===t.name}var Ct="$autocapture_disabled_server_side",Rt="$heatmaps_enabled_server_side",Pt="$exception_capture_enabled_server_side",$t="$error_tracking_suppression_rules",It="$error_tracking_capture_extension_exceptions",Tt="$web_vitals_enabled_server_side",Ot="$product_tours_enabled_server_side",At="$web_vitals_allowed_metrics",jt="$session_recording_remote_config",Lt="$enabled_feature_flags",Mt="$active_feature_flags",Dt="$early_access_features",Nt="$feature_flag_details",Ut="$feature_flag_payloads",zt="$feature_flag_request_id",Ht="$override_feature_flags",Vt="$override_feature_flag_payloads",Wt="$stored_person_properties",Bt="$stored_group_properties",Jt="$surveys",qt="$surveys_activated",Gt="ph_product_tours",Kt="$flag_call_reported",Yt="$flag_call_reported_session_id",Xt="$feature_flag_errors",Zt="$feature_flag_evaluated_at",Qt="__POSTHOG_TOOLBAR__",te="PostHog loadExternalDependency extension not found.",ee="visibilitychange",ie="beforeunload",re=1,se=3,ne=11;function ae(t){return t instanceof Element&&(t.id===Qt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function oe(t){return!!t&&t.nodeType===re}function le(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ue(t){return!!t&&t.nodeType===se}function he(t){return!!t&&t.nodeType===ne&&oe(t.host)}function ve(t){return t?l(t).split(/\s+/):[]}function de(t){var e=null==dt?void 0:dt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function ce(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 ve(e)}function fe(t){return _(t)?null:l(t).split(/(\s+)/).filter((t=>Te(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pe(t){var e="";return ke(t)&&!Se(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;ue(t)&&t.textContent&&(e+=null!==(i=fe(t.textContent))&&void 0!==i?i:"")})),l(e)}function ge(t){return p(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var be=["a","button","form","input","select","textarea","label"];function _e(t,e){if(p(e))return!0;var i,r=function(t){if(e.some((e=>t.matches(e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function me(t){var e=t.parentNode;return!(!e||!oe(e))&&e}var ye=["next","previous","prev",">","<"],we=[".ph-no-rageclick",".ph-no-capture"];var xe=t=>!t||le(t,"html")||!oe(t),Ee=(t,e)=>{if(!dt||xe(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!le(s,"body");)if(he(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=me(s);if(!n)break;if(e||be.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=dt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function ke(t){for(var e=t;e.parentNode&&!le(e,"body");e=e.parentNode){var i=ce(e);if(o(i,"ph-sensitive")||o(i,"ph-no-capture"))return!1}if(o(ce(t),"ph-include"))return!0;var r=t.type||"";if(g(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!g(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function Se(t){return!!(le(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||le(t,"select")||le(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Fe="(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})",Ce=new RegExp("^(?:"+Fe+")$"),Re=new RegExp(Fe),Pe="\\d{3}-?\\d{2}-?\\d{4}",$e=new RegExp("^("+Pe+")$"),Ie=new RegExp("("+Pe+")");function Te(t,e){if(void 0===e&&(e=!0),_(t))return!1;if(g(t)){if(t=l(t),(e?Ce:Re).test((t||"").replace(/[- ]/g,"")))return!1;if((e?$e:Ie).test(t))return!1}return!0}function Oe(t){var e=pe(t);return Te(e=(e+" "+Ae(t)).trim())?e:""}function Ae(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Ae(t)).trim())}catch(t){mt.error("[AutoCapture]",t)}})),e}function je(t){return t.replace(/"|\\"/g,'\\"')}function Le(t){var e=t.attr__class;return e?d(e)?e:ve(e):void 0}class Me{constructor(t){this.disabled=!1===t;var e=f(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 De=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(!d(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){mt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ne=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){var v=l[h].split("=");d(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},Ue=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ze="$copy_autocapture",He=yt("[AutoCapture]");function Ve(t,e){return e.length>t?e.slice(0,t)+"...":e}function We(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!oe(e));return e}function Be(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:u,elementsChainAsString:h}=e;if(!oe(t))return{props:{}};for(var v=[t],d=t;d.parentNode&&!le(d,"body");)if(he(d.parentNode))v.push(d.parentNode.host),d=d.parentNode.host;else{if(!oe(d.parentNode))break;v.push(d.parentNode),d=d.parentNode}var c,f,b=[],_={},m=!1,y=!1;if(wt(v,(t=>{var e=ke(t);if(le(t,"a")){var i=t.getAttribute("href");m=e&&!!i&&Te(i)&&i}o(ce(t),"ph-no-capture")&&(y=!0),b.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};be.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Ve(1024,Oe(t)):Ve(1024,pe(t)));var a=ce(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),wt(t.attributes,(function(i){var s;if((!Se(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Te(i.value)&&(!g(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ve(a).join(" ")),n["attr__"+i.name]=Ve(1024,a)}}));for(var o=1,l=1,u=t;u=We(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,l,u));var r=function(t){if(!ke(t))return{};var e={};return wt(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&&Te(r)&&(e[i]=r)}})),e}(t);xt(_,r)})),y)return{props:{},explicitNoCapture:y};if(l||(b[0].$el_text=le(t,"a")||le(t,"button")?Oe(t):pe(t)),m){var w,x;b[0].attr__href=m;var E=null==(w=(t=>{var e=null==pt?void 0:pt.createElement("a");return p(e)?null:(e.href=t,e)})(m))?void 0:w.host,k=null==dt||null==(x=dt.location)?void 0:x.host;E&&k&&E!==k&&(c=m)}return{props:xt({$event_type:n.type,$ce_version:1},h?{}:{$elements:b},{$elements_chain:(f=b,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Et(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[je(e.toString())]=je(i.toString())})),(s+=":")+Et(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).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:Le(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Et(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(f)))},null!=(r=b[0])&&r.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},_)}}var Je=yt("[Dead Clicks]"),qe=()=>!0;class Ge{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.initDeadClicksAutocapture&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Je.error("failed to load script",e):t()}))}hr(){var t;if(pt){if(!this.ur&&null!=(t=bt.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=f(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.ur=bt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.ur.start(pt),Je.info("starting...")}}else Je.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Je.info("stopping..."))}}var Ke=yt("[ExceptionAutocapture]");function Ye(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return c(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]=r}}catch(t){return()=>{}}}var Xe=yt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return m(t)&&isFinite(t)&&Math.floor(t)===t});class Ze{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/Math.pow(2,8),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 Ze(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 Ze(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 Qe{constructor(){this.S=0,this.C=0,this.I=new ii}generate(){var t=this.generateOrAbort();if(p(t)){this.S=0;var e=this.generateOrAbort();if(p(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.T();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return Ze.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var ti,ei=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};dt&&!p(dt.crypto)&&crypto.getRandomValues&&(ei=t=>crypto.getRandomValues(t));class ii{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||(ei(this.M),this.O=0),this.M[this.O++]}}var ri=()=>(ti||(ti=new Qe)).generate(),si="",ni=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function ai(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=pt),si)return si;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+ri().toString();!si&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",si=n)}return si}(t);if(!i){var r=(t=>{var e=t.match(ni);return e?e[0]:""})(t);r!==i&&mt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var oi={R:()=>!!pt,D(t){mt.error("cookieStore error: "+t)},A(t){if(pt){try{for(var e=t+"=",i=pt.cookie.split(";").filter((t=>t.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(oi.A(t))||{}}catch(t){}return e},N(t,e,i,r,s){if(pt)try{var n="",a="",o=ai(pt.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&mt.warn("cookieStore warning: large cookie, len="+u.length),pt.cookie=u,u}catch(t){return}},q(t,e){if(null!=pt&&pt.cookie)try{oi.N(t,"",-1,e)}catch(t){return}}},li=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ui=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...li],hi="<masked>",vi=["li_fat_id"];function di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var ci=yt("[Web Vitals]"),fi=9e5,pi=yt("[RemoteConfig]");class gi{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=bt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Mr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Pr(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return pi.info("Using preloaded remote config",this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void pi.warn("Remote config is disabled. Falling back to local config.");this.Mr((t=>{if(!t)return pi.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pr((t=>{this.Rr(t),this.Or()}));this.Rr(t),this.Or()}))}catch(t){pi.error("Error loading remote config",t)}}stop(){this.Fr&&(clearInterval(this.Fr),this.Fr=void 0)}refresh(){!this._instance.Lr()&&pt&&"hidden"!==pt.visibilityState&&this._instance.reloadFeatureFlags()}Or(){var t;if(!this.Fr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Fr=setInterval((()=>{this.refresh()}),e))}}Rr(t){var e;t||pi.error("Failed to fetch remote config from PostHog."),this._instance.Rr(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var bi="disabled",_i="lazy_loading",mi="awaiting_config",yi="missing_config",wi="base64",xi=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}},Ei={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=>xi(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!xi(e,t))))),icontains:(t,e)=>e.map(ki).some((e=>t.map(ki).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(ki).every((e=>t.map(ki).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)))}))},ki=t=>t.toLowerCase();function Si(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(p(s)||b(s))return!1;var n=[String(s)],a=Ei[r.operator];return!!a&&a(r.values,n)}))}yt("[SessionRecording]"),yt("[SessionRecording]");var Fi="[SessionRecording]",Ci=yt(Fi),Ri=yt("[Heatmaps]");function Pi(t){return f(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var $i=yt("[Product Tours]"),Ii=["$set_once","$set"],Ti=yt("[SiteApps]"),Oi="Error while initializing PostHog app with config id ",Ai="events",ji="cancelEvents",Li=yt("[Surveys]"),Mi=["popover","widget","api"];class Di{constructor(){this.oi={}}on(t,e){return this.oi[t]||(this.oi[t]=[]),this.oi[t].push(e),()=>{this.oi[t]=this.oi[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.oi[t]||[])i(e);for(var r of this.oi["*"]||[])r(t,e)}}function Ni(t,e,i){if(_(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 Ui{constructor(t){this.vn=new Di,this.fn=(t,e)=>this.pn(t,e)&&this.gn(t,e)&&this.mn(t,e)&&this.yn(t,e),this.pn=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.bn=new Set,this._n=new Set}init(){var t,e;p(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(!p(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this._n)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.bn)||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.bn.has(t)||this.bn.has(null==e?void 0:e.event))&&this._n&&(null==(i=this._n)?void 0:i.size)>0&&this._n.forEach((t=>{this.wn(e,t)&&this.vn.emit("actionCaptured",t.name)}))}xn(t){this.onAction("actionCaptured",(e=>t(e)))}wn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.fn(t,i))return!0;return!1}onAction(t,e){return this.vn.on(t,e)}gn(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(!Ni(r,e.url,e.url_matching||"contains"))return!1}return!0}mn(t,e){return!!this.Sn(t,e)&&!!this.kn(t,e)&&!!this.Cn(t,e)}Sn(t,e){var i;if(null==e||!e.href)return!0;var r=this.In(t);if(r.length>0)return r.some((t=>Ni(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ni((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}kn(t,e){var i;if(null==e||!e.text)return!0;var r=this.In(t);if(r.length>0)return r.some((t=>Ni(t.text,e.text,e.text_matching||"exact")||Ni(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!_(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>Ni(t,n,a))))}Cn(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}In(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}yn(t,e){return null==e||!e.properties||0===e.properties.length||Si(e.properties.reduce(((t,e)=>{var i=d(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 zi{constructor(t){this._instance=t,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(t,e){return!!t&&Si(t.propertyFilters,null==e?void 0:e.properties)}Rn(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}On(t,e,i){var r=(i===Ai?this.Tn:this.En).get(t),s=[];return this.Ln((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.Pn(n,e)}))}register(t){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Fn(t),this.An(t))}An(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.Nn&&(this.Nn=new Ui(this._instance),this.Nn.init(),this.Nn.xn((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.Nn)||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.Mn.get(e.name);i&&i.push(t.id),this.Mn.set(e.name,i||[t.id])}})))})))}Fn(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.Tn=this.Rn(t,Ai),this.En=this.Rn(t,ji))}onEvent(t,e){var i,r=this.le(),s=this.$n(),n=this.Dn(),a=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===t&&e&&a.length>0){var o,l;r.info("event matched, removing item from activated items",{event:t,eventPayload:e,existingActivatedItems:a});var u=(null==e||null==(o=e.properties)?void 0:o.$survey_id)||(null==e||null==(l=e.properties)?void 0:l.$product_tour_id);if(u){var h=a.indexOf(u);0>h||(a.splice(h,1),this.qn(a))}}else{if(this.En.has(t)){var v=this.On(t,e,ji);v.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:v.map((t=>t.id))}),v.forEach((t=>{var e=a.indexOf(t.id);0>e||a.splice(e,1),this.jn(t.id)})),this.qn(a))}if(this.Tn.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Tn.get(t)});var d=this.On(t,e,Ai);this.qn(a.concat(d.map((t=>t.id))||[]))}}}onAction(t){var e,i=this.$n(),r=(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[i])||[];this.Mn.has(t)&&this.qn(r.concat(this.Mn.get(t)||[]))}qn(t){var e=this.le(),i=[...new Set(t)].filter((t=>!this.Hn(t)));e.info("updating activated items",{activatedItems:i}),this.Un(i)}getActivatedIds(){var t,e=this.$n();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}}class Hi extends zi{constructor(t){super(t)}$n(){return qt}Dn(){return"survey shown"}Ln(t){var e;null==(e=this._instance)||e.getSurveys(t)}jn(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}le(){return Li}Un(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[qt]:t})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Vi="SDK is not enabled or survey functionality is not yet loaded",Wi="Disabled. Not loading surveys.",Bi=null!=dt&&dt.location?Ue(dt.location.hash,"__posthog")||Ue(location.hash,"state"):null,Ji="_postHogToolbarParams",qi=yt("[Toolbar]"),Gi=yt("[FeatureFlags]"),Ki=yt("[FeatureFlags]",{debugEnabled:!0}),Yi="\" failed. Feature flags didn't load in time.",Xi=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Zi=t=>{var e={};for(var[i,r]of Et(t||{}))r&&(e[i]=r);return e},Qi=yt("[Error tracking]"),tr="Refusing to render web experiment since the viewer is a likely bot",er={icontains:(t,e)=>!!dt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!dt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!dt&&xi(e.href,t),not_regex:(t,e)=>!!dt&&!xi(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class ir{get qt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{ir.zn("retrieved web experiments from the server"),e.Vn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.Vn&&(ir.zn("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.Vn)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);g(r)&&t.variants[r]&&e.Wn(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];ir.Zn(n)&&e.Wn(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())ir.zn(tr);else if(!this.qt.disable_web_experiments){if(_(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ir.zn("applying feature flags",t),t.forEach((t=>{var e;if(this.Vn&&null!=(e=this.Vn)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.Vn)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Wn(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=ir.getWindowLocation();if(null!=t&&t.search){var e=De(null==t?void 0:t.search,"__experiment_id"),i=De(null==t?void 0:t.search,"__experiment_variant");e&&i&&(ir.zn("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.Gn(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.qt.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.qt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gn(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(ir.zn("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Wn(r[0].name,e,r[0].variants[e].transforms))}static Zn(t){return!_(t.conditions)&&ir.Qn(t)&&ir.Jn(t)}static Qn(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=ir.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||er[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==dt?void 0:dt.location}static Jn(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!pt)return{};var r,s,n,a=(r=Ne(pt.URL,[],hi),s=ui.concat([]),n={},wt(s,(function(t){var e=De(r,t);n[t]=e||null})),n),o=function(){var t={};return wt(vi,(function(e){var i=oi.A(e);t[e]=i||null})),t}();return xt(o,a)}();if(i.utm_source){var r,s,n,a,o,l,u,h,v=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,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.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 v&&c&&f&&d}return!1}static zn(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mt.info("[WebExperiments] "+t,i)}Wn(t,e,i){this._is_bot()?ir.zn(tr):"control"!==e?i.forEach((i=>{if(i.selector){var r;ir.zn("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)}))}})):ir.zn("Control variants leave the page unmodified.")}_is_bot(){return ft&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&a(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>a(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(ft,this.qt.custom_blocked_useragents):void 0}}var rr=yt("[Conversations]"),sr="Conversations not available yet.",nr={featureFlags:class{constructor(t){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(t){return this._instance.get_property(t)}us(){var t,e;return null!==(t=null==(e=this.ni)?void 0:e.wr(this.qt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,Gi.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hs(){var t,e=null!==(t=this.qt.evaluation_contexts)&&void 0!==t?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(Gi.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ns=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Gi.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}cs(){return this.hs().length>0}ds(){var t=this.qt.flag_keys;if(!p(t)){if(d(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Gi.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Gi.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},a=i({},s,t),o=i({},n,e),l={};for(var[u,h]of Object.entries(a)){var v="string"==typeof h;l[u]={key:u,enabled:!!v||Boolean(h),variant:v?h:void 0,reason:void 0,metadata:p(null==o?void 0:o[u])?void 0:{id:0,version:void 0,description:void 0,payload:o[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.os(Nt),e=this.os(Ht),r=this.os(Vt);if(!r&&!e)return t||{};var s=xt({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=i({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}return this.Kn||(Gi.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Lt),e=this.os(Ht);if(!e)return t||{};for(var i=xt({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Kn||(Gi.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kn=!0),i}getFlagPayloads(){var t=this.os(Ut),e=this.os(Vt);if(!e)return t||{};for(var i=xt({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Kn||(Gi.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kn=!0),i}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.vs||(this._instance.Li.emit("featureFlagsReloading",!0),this.vs=setTimeout((()=>{this.fs()}),5))}ps(){clearTimeout(this.vs),this.vs=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.vs||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.es=t}fs(t){var e;if(this.ps(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var r=this.qt.token,s=this.os("$device_id"),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(e=this.ni)?void 0:e.get_initial_props())||{},this.os(Wt)||{}),group_properties:this.os(Bt),timezone:di()};b(s)||p(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.cs()&&(n.evaluation_contexts=this.hs());var a=this.ds();p(a)||(n.flag_keys=a);var o=!!this.qt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Xn=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.qt.disable_compression?void 0:wi,timeout:this.qt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.ts||(this.$anon_distinct_id=void 0),s=!1),this.Xn=!1,!n.disable_flags||this.ts){this.rs=!s;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.ni)||r.register({[Xt]:a}),u)Gi.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else n.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.ts&&(this.ts=!1,this.fs())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){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 Gi.warn('getFeatureFlag for key "'+t+Yi)}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.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],a=String(s),o=this.os(zt)||void 0,l=this.os(Zt)||void 0,u=this.os(Kt)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var h,v=this._instance.get_session_id(),c=this.os(Yt);v&&v!==c&&(u={},null==(h=this.ni)||h.register({[Kt]:u,[Yt]:v}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(a))){var f,g,b,_,m,y,w,x,E,k;d(u[t])?u[t].push(a):u[t]=[a],null==(f=this.ni)||f.register({[Kt]:u});var S=this.getFeatureFlagDetails(t),F=[...null!==(g=this.os(Xt))&&void 0!==g?g:[]];p(s)&&F.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(b=this.qt.bootstrap)||null==(b=b.featureFlags)?void 0:b[t])||null,$feature_flag_bootstrapped_payload:(null==(_=this.qt.bootstrap)||null==(_=_.featureFlagPayloads)?void 0:_[t])||null,$used_bootstrap_value:!this.rs};p(null==S||null==(m=S.metadata)?void 0:m.version)||(C.$feature_flag_version=S.metadata.version);var R,P=null!==(y=null==S||null==(w=S.reason)?void 0:w.description)&&void 0!==y?y:null==S||null==(x=S.reason)?void 0:x.code;P&&(C.$feature_flag_reason=P),null!=S&&null!=(E=S.metadata)&&E.id&&(C.$feature_flag_id=S.metadata.id),p(null==S?void 0:S.original_variant)&&p(null==S?void 0:S.original_enabled)||(C.$feature_flag_original_response=p(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(k=S.metadata)&&k.original_payload&&(C.$feature_flag_original_payload=null==S||null==(R=S.metadata)?void 0:R.original_payload),F.length&&(C.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",C)}if(r){var I=n;if(!p(n))try{I=JSON.parse(n)}catch(t){}return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:I}}}}else Gi.warn('getFeatureFlagResult for key "'+t+Yi)}getRemoteConfigPayload(t,e){var i=this.qt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.cs()&&(r.evaluation_contexts=this.hs());var s=this.ds();p(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.qt.disable_compression?void 0:wi,timeout:this.qt.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.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return p(i)?void 0:!!i}Gi.warn('isFeatureEnabled for key "'+t+Yi)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.ni){this.Yn=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});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]})))):Gi.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,c=t.evaluatedAt;if(d(u)){Gi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var p=0;u.length>p;p++)f[u[p]]=!0;e&&e.register({[Mt]:u,[Lt]:f})}else{var g=u,b=h,_=l;if(null!=a&&a.partialResponse)g=i({},r,g),b=i({},s,b),_=i({},n,_);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},s,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},n,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else g=i({},r,g),b=i({},s,b),_=i({},n,_);e&&e.register(i({[Mt]:Object.keys(Zi(g)),[Lt]:g||{},[Ut]:b||{},[Nt]:_||{}},v?{[zt]:v}:{},c?{[Zt]:c}:{}))}}}(t,this.ni,s,n,a,r),e||(this.ss=!1),this.gs(e)}}override(t,e){void 0===e&&(e=!1),Gi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return Gi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.ni.unregister(Ht),this.ni.unregister(Vt),this.gs(),Ki.info("All overrides cleared");if(d(t)){var e=Xi(t);return this.ni.register({[Ht]:e}),this.gs(),Ki.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Kn=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.ni.unregister(Ht),Ki.info("Flag overrides cleared");else if(r.flags){if(d(r.flags)){var s=Xi(r.flags);this.ni.register({[Ht]:s})}else this.ni.register({[Ht]:r.flags});Ki.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.ni.unregister(Vt),Ki.info("Payload overrides cleared")):r.payloads&&(this.ni.register({[Vt]:r.payloads}),Ki.info("Payload overrides set",{payloads:r.payloads}))),void this.gs()}if(t&&"object"==typeof t)return this.ni.register({[Ht]:t}),this.gs(),Ki.info("Flag overrides set",{flags:t});Gi.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.ys();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.os(Dt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.ni)||s.register({[Mt]:Object.keys(Zi(l)),[Lt]:l}),this.gs()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.os(Dt),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.qt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.ni)||i.unregister(Dt),null==(r=this.ni)||r.register({[Dt]:s}),t(s)}}})}ys(){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)),{})}}gs(t){var{flags:e,flagVariants:i}=this.ys();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.os(Wt)||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this._instance.register({[Wt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Wt)}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.os(Bt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[Bt]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(Bt)||{};this._instance.register({[Bt]:i({},e,{[t]:{}})})}else this._instance.unregister(Bt)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.ps(),this.Kn=!1}}},ar={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var t;return!(null==(t=this.bs)||!t.isStarted)}get status(){var t,e;return this._s===mi||this._s===yi?this._s:null!==(t=null==(e=this.bs)?void 0:e.status)&&void 0!==t?t:this._s}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this._s=bi,this.ws=void 0,this._instance=t,!this._instance.sessionManager)throw Ci.error("started without valid sessionManager"),new Error(Fi+" started without valid sessionManager. This is a bug.");if("always"===this.qt.cookieless_mode)throw new Error(Fi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get xs(){var t,e=!(null==(t=this._instance.get_property(jt))||!t.enabled),i=!this.qt.disable_session_recording,r=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return dt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.xs||null==(e=this.bs)||!e.isStarted){var i=!p(Object.assign)&&!p(Array.from);this.xs&&i?(this.Ss(t),Ci.info("starting")):(this._s=bi,this.stopRecording())}}Ss(t){var e,i,r;this.xs&&(this._s!==mi&&this._s!==yi&&(this._s=_i),null!=bt&&null!=(e=bt.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=bt.__PosthogExtensions__)&&i.initSessionRecording?this.ks(t):null==(r=bt.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Cs,(e=>{if(e)return Ci.error("could not load recorder",e);this.ks(t)})))}stopRecording(){var t,e;null==(t=this.ws)||t.call(this),this.ws=void 0,null==(e=this.bs)||e.stop()}Is(){var t,e;null==(t=this.ws)||t.call(this),this.ws=void 0,null==(e=this.bs)||e.discard()}Ts(){var t;null==(t=this.ni)||t.unregister("$session_is_sampled")}Es(t,e){if(_(t))return null;var i,r=m(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ci.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Ms(t){if(this.ni){var e,r,s=this.ni,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Es(null==(e=this.qt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Es(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;_(o)&&this.Ts();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[jt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:p(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.ws)||e.call(this),this.ws=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Ms(t),void this.Is()):(this.Ms(t),void this.startIfEnabledOrStop()):(this._s===mi&&(this._s=yi,Ci.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.bs)&&i.log?this.bs.log(t,e):Ci.warn("log called before recorder was ready")}get Cs(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ps(){var t,e,i=this._instance.get_property(jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ci.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}ks(t){var e,i;if(null==(e=bt.__PosthogExtensions__)||!e.initSessionRecording)return Ci.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.bs||(this.bs=null==(i=bt.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.bs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ps()){if(this._s===yi||this._s===mi)return;return this._s=mi,Ci.info("persisted remote config is stale, requesting fresh config before starting"),void new gi(this._instance).load()}this._s=_i,this.bs.start(t)}onRRwebEmit(t){var e;null==(e=this.bs)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.bs||null==(e=this.ni)||e.register({$replay_override_linked_flag:!0}),null==(t=this.bs)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.bs||null==(e=this.ni)||e.register({$replay_override_sampling:!0}),null==(t=this.bs)||t.overrideSampling()}overrideTrigger(t){var e,i;this.bs||null==(i=this.ni)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.bs)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.bs)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.bs)||!i.tryAddCustomEvent(t,e))}}},or={autocapture:class{constructor(t){this.Rs=!1,this.Os=null,this.Ls=!1,this.instance=t,this.rageclicks=new Me(t.config.rageclick),this.Fs=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=f(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}As(){if(this.isBrowserSupported()){if(dt&&pt){var t=t=>{t=t||(null==dt?void 0:dt.event);try{this.Ns(t)}catch(t){He.error("Failed to capture event",t)}};if(St(pt,"submit",t,{capture:!0}),St(pt,"change",t,{capture:!0}),St(pt,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=t=>{t=t||(null==dt?void 0:dt.event);try{this.Ns(t,ze)}catch(t){He.error("Failed to capture copy/cut event",t)}};St(pt,"copy",e,{capture:!0}),St(pt,"cut",e,{capture:!0})}}}else He.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Rs&&(this.As(),this.Rs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Ls=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ct]:!!t.autocapture_opt_out}),this.Os=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Fs=t}getElementSelectors(t){var e,i=[];return null==(e=this.Fs)||e.forEach((e=>{var r=null==pt?void 0:pt.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Ct];if(b(this.Os)&&!y(i)&&!this.instance.Lr())return!1;var r=null!==(e=this.Os)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}Ns(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=ge(t);ue(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&function(t,e){if(!dt||xe(t))return!1;var i,r,s;if(y(e)?(i=!!e&&we,r=void 0):(i=null!==(s=null==e?void 0:e.css_selector_ignorelist)&&void 0!==s?s:we,r=null==e?void 0:e.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Ee(t,!1);return!function(t,e){if(!1===t||p(t))return!1;var i;if(!0===t)i=ye;else{if(!d(t))return!1;if(t.length>10)return mt.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{safeText:e,ariaLabel:r}=t;return i.some((t=>e.includes(t)||r.includes(t)))}))}(r,n.map((t=>{var e;return{safeText:pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!_e(n,i)}(r,this.instance.config.rageclick)&&this.Ns(t,"$rageclick");var s=e===ze;if(r&&function(t,e,i,r,s){var n,a,o,l;if(void 0===i&&(i=void 0),!dt||xe(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!de(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&de(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:h,targetElementList:v}=Ee(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(p(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}(v,i))return!1;if(!_e(v,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var d=dt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===e.type)return!0;var c=t.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return h?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(be.indexOf(c)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.qt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=Be(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Ls});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===ze){var l,u=fe(null==dt||null==(l=dt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return c(null==pt?void 0:pt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.$s=(null==dt||null==(e=dt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,mt.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(dt&&dt.history){var i=this;null!=(t=dt.history.pushState)&&t.__posthog_wrapped__||Ye(dt.history,"pushState",(t=>function(e,r,s){t.call(this,e,r,s),i.qs("pushState")})),null!=(e=dt.history.replaceState)&&e.__posthog_wrapped__||Ye(dt.history,"replaceState",(t=>function(e,r,s){t.call(this,e,r,s),i.qs("replaceState")})),this.js()}}qs(t){try{var e,i=null==dt||null==(e=dt.location)?void 0:e.pathname;if(!i)return;i!==this.$s&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.$s=i}catch(e){mt.error("Error capturing "+t+" pageview",e)}}js(){if(!this.Ds){var t=()=>{this.qs("popstate")};St(dt,"popstate",t),this.Ds=()=>{dt&&dt.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.Hs=!1,this.Rs=!1,this.Us=null,this.instance=t,this.Hs=!(null==(e=this.instance.persistence)||!e.props[Rt]),this.rageclicks=new Me(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return f(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return _(this.qt.capture_heatmaps)?_(this.qt.enable_heatmaps)?this.Hs:this.qt.enable_heatmaps:!1!==this.qt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;Ri.info("starting..."),this.Bs(),this.At()}else{var t;clearInterval(null!==(t=this.Us)&&void 0!==t?t:void 0),this.zs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Rt]:e}),this.Hs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}Vs(t){this.Mt(t.originalEvent,"deadclick")}At(){this.Us&&clearInterval(this.Us),this.Us="visible"===(null==pt?void 0:pt.visibilityState)?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Bs(){dt&&pt&&(this.Ws=this.Zr.bind(this),St(dt,ie,this.Ws),this.Zs=t=>this.Mt(t||(null==dt?void 0:dt.event)),St(pt,"click",this.Zs,{capture:!0}),this.Gs=t=>this.Qs(t||(null==dt?void 0:dt.event)),St(pt,"mousemove",this.Gs,{capture:!0}),this.Js=new Ge(this.instance,qe,this.Vs.bind(this)),this.Js.startIfEnabledOrStop(),this.Ks=this.At.bind(this),St(pt,ee,this.Ks),this.Rs=!0)}zs(){var t;dt&&pt&&(this.Ws&&dt.removeEventListener(ie,this.Ws),this.Zs&&pt.removeEventListener("click",this.Zs,{capture:!0}),this.Gs&&pt.removeEventListener("mousemove",this.Gs,{capture:!0}),this.Ks&&pt.removeEventListener(ee,this.Ks),clearTimeout(this.Ys),null==(t=this.Js)||t.stop(),this.Rs=!1)}Xs(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&oe(r)&&!le(r,"body");){if(r===i)return!1;if(o(e,null==dt?void 0:dt.getComputedStyle(r).position))return!0;r=me(r)}return!1}(ge(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var r;if(void 0===e&&(e="click"),!ae(t.target)&&Pi(t)){var s=this.Xs(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&this.eo(i({},s,{type:"rageclick"})),this.eo(s)}}Qs(t){!ae(t.target)&&Pi(t)&&(clearTimeout(this.Ys),this.Ys=setTimeout((()=>{this.eo(this.Xs(t,"mousemove"))}),500))}eo(t){if(dt){var e=dt.location.href,i=this.qt.custom_personal_data_properties,r=this.qt.mask_personal_data_properties?[...li,...i||[]]:[],s=Ne(e,r,hi);this.M=this.M||{},this.M[s]||(this.M[s]=[]),this.M[s].push(t)}}Zr(){this.M&&!(t=>{if(f(t)){for(var e in t)if(h.call(t,e))return!1;return!0}return!1})(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ge,webVitalsAutocapture:class{constructor(t){var e;this.Hs=!1,this.Rs=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ro=()=>{clearTimeout(this.io),0!==this.M.metrics.length&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=t=>{var e;this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.no();if(!p(r))if(_(null==t?void 0:t.name)||_(null==t?void 0:t.value))ci.error("Invalid metric received",t);else if(!this.so||this.so>t.value){this.M.url!==r&&(this.ro(),this.io=setTimeout(this.ro,this.flushToCaptureTimeoutMs)),p(this.M.url)&&(this.M.url=r),this.M.firstMetricTimestamp=p(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});p(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.M.metrics.push(n),this.M.metrics.length===this.allowedMetrics.length&&this.ro()}else ci.error("Ignoring metric with value >= "+this.so,t)},this.oo=()=>{if(!this.Rs){var t,e,i,r,s=bt.__PosthogExtensions__;p(s)||p(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ht.bind(this)),this.Rs=!0):ci.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Hs=!(null==(e=this._instance.persistence)||!e.props[Tt]),this.startIfEnabled()}get ao(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=f(this.ao)?null==(t=this.ao)?void 0:t.web_vitals_allowed_metrics:void 0;return _(i)?(null==(e=this._instance.persistence)?void 0:e.props[At])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(f(this.ao)?this.ao.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=f(this.ao)?this.ao.web_vitals_attribution:void 0;return null!=t&&t}get so(){var t=f(this.ao)&&m(this.ao.__web_vitals_max_value)?this.ao.__web_vitals_max_value:fi;return t>0&&6e4>=t?fi:t}get isEnabled(){var t=null==gt?void 0:gt.protocol;if("http:"!==t&&"https:"!==t)return ci.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=f(this.ao)?this.ao.web_vitals:y(this.ao)?this.ao:void 0;return y(e)?e:this.Hs}startIfEnabled(){this.isEnabled&&!this.Rs&&(ci.info("enabled, starting..."),this.lr(this.oo))}onRemoteConfig(t){if("capturePerformance"in t){var e=f(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=f(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Tt]:e}),this._instance.persistence.register({[At]:i})),this.Hs=e,this.startIfEnabled()}}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?ci.error("failed to load script",e):t()}))}no(){var t=dt?dt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...li,...e||[]]:[];return Ne(t,i,hi)}ci.error("Could not determine current URL")}}},lr={exceptionObserver:class{constructor(t){var e,i,r;this.oo=()=>{var t;if(dt&&this.isEnabled&&null!=(t=bt.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=bt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=bt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=bt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.uo&&this.qt.capture_unhandled_errors&&(this.uo=e(this.captureException.bind(this))),!this.lo&&this.qt.capture_unhandled_rejections&&(this.lo=i(this.captureException.bind(this))),!this.ho&&this.qt.capture_console_errors&&(this.ho=r(this.captureException.bind(this)))}catch(t){Ke.error("failed to start",t),this.co()}}},this._instance=t,this.do=!(null==(e=this._instance.persistence)||!e.props[Pt]),this.vo=new F({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,Gt:Ke}),this.qt=this.fo(),this.startIfEnabledOrStop()}fo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return f(t)?e=i({},e,t):(p(t)?this.do:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ke.info("enabled"),this.co(),this.lr(this.oo)):this.co()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.errorWrappingFunctions&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Ke.error("failed to load script",e);t()}))}co(){var t,e,i;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.lo)||e.call(this),this.lo=void 0,null==(i=this.ho)||i.call(this),this.ho=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.do=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pt]:this.do}),this.qt=this.fo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.fo()}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.vo.consumeRateLimit(s)?Ke.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,r;this.po=[],this.mo=new L([new G,new st,new Y,new K,new it,new et,new Z,new rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=q.test(l)?l.replace(q,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.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 i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||M});var r}))}(n)}}("web:javascript",V,J)),this._instance=t,this.po=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property($t))&&void 0!==e?e:[],this.yo=ut(this.bo()),this._o=new ht(this.yo)}onConfigChange(){this.yo=ut(this.bo()),this._o.setConfig(this.yo)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.po=s,this._instance.persistence&&this._instance.persistence.register({[$t]:this.po,[It]:n})}}get wo(){var t,e=!!this._instance.get_property(It),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.mo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.yo.enabled)try{if(!g(t)||0===t.trim().length)return void Qi.warn("Ignoring exception step because message must be a non-empty string");var r=this.xo(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ot.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&Qi.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._o.add(i({[nt]:t,[at]:(new Date).toISOString()},s))}catch(t){Qi.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.So(e)){if(this.ko(e))return this.Co("Exception dropped: matched a suppression rule"),void Qi.info("Skipping exception capture because a suppression rule matched");if(!this.wo&&this.Io(e))return this.Co("Exception dropped: thrown by a browser extension"),void Qi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.To(e))return this.Co("Exception dropped: thrown by the PostHog SDK"),void Qi.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.yo.enabled&&_(t.$exception_steps)?this.Eo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",en:!0});return r&&this._o.clear(),r}catch(t){return Qi.error("Failed to capture exception event. Dropping this exception.",t),void this._o.clear()}}catch(t){return void Qi.error("Failed to process exception event. Ignoring this exception.",t)}}Eo(t){try{var e=this._o.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return Qi.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Co(t){this.yo.enabled&&this._o.add({[nt]:t,[at]:(new Date).toISOString()})}xo(t){return f(t)?i({},t):{}}bo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}ko(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return g(i)&&i.length>0&&t.$exception_types.push(i),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.po.some((t=>{var i=t.values.map((t=>{var i,r=Ei[t.operator],s=d(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Io(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://")))}To(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:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}So(t){return!_(t)&&d(t)}}},ur=i({productTours:class{get ni(){return this._instance.persistence}constructor(t){this.Mo=null,this.Po=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.ni&&this.ni.register({[Ot]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.Mo||(t=this._instance).config.disable_product_tours||null==(e=t.persistence)||!e.get_property(Ot)||this.lr((()=>this.Ro()))}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?$i.error("Could not load product tours script",e):t()}))}Ro(){var t;!this.Mo&&null!=(t=bt.__PosthogExtensions__)&&t.generateProductTours&&(this.Mo=bt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!d(this.Po)||e){var i=this.ni;if(i){var r=i.props[Gt];if(d(r)&&!e)return this.Po=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",callback:e=>{var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return $i.error(s),void t([],{isLoaded:!1,error:s})}var n=d(e.json.product_tours)?e.json.product_tours:[];this.Po=n,i&&i.register({[Gt]:n}),t(n,{isLoaded:!0})}})}else t(this.Po,{isLoaded:!0})}getActiveProductTours(t){_(this.Mo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Mo.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Mo)||e.showTourById(t)}previewTour(t){this.Mo?this.Mo.previewTour(t):this.lr((()=>{var e;this.Ro(),null==(e=this.Mo)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Mo)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Mo)||t.nextStep()}previousStep(){var t;null==(t=this.Mo)||t.previousStep()}clearCache(){var t;this.Po=null,null==(t=this.ni)||t.unregister(Gt)}resetTour(t){var e;null==(e=this.Mo)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Mo)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Mo)||e.cancelPendingTour(t)}}},nr),hr={siteApps:class{constructor(t){this._instance=t,this.Oo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lo(t,e){if(e){var i=this.globalsForEvent(e);this.Oo.push(i),this.Oo.length>1e3&&(this.Oo=this.Oo.slice(10))}}get siteAppLoaders(){var t;return null==(t=bt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Lo.bind(this));this.Fo=()=>{t(),this.Oo=[],this.Fo=void 0}}}globalsForEvent(t){var e,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var[d,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(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}(t,Ii),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.Oo.length&&(Ti.info("Processing "+this.Oo.length+" events for site app with id "+t.id),this.Oo.forEach((t=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Fo)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ti.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(t){s(t)}});n&&(e.processEvent=n),r=!0}catch(e){Ti.error(Oi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ti.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Ao(){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)}No(t){if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(e)}catch(e){Ti.error("Error while processing event "+t.event+" for site app "+i.id,e)}}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Ao(),void this._instance.on("eventCaptured",(t=>this.No(t)))):void Ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Fo)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;bt["__$$ph_site_app_"+t]=s._instance,null==(e=bt.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ti.error(Oi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},vr={tracingHeaders:class{constructor(t){this.$o=void 0,this.Do=void 0,this.oo=()=>{var t,e,i=this.qo()||[];p(this.$o)&&(null==(t=bt.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),p(this.Do)&&(null==(e=bt.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchFetch(i,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.tracingHeadersPatchFns&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Xe.error("failed to load script",e);t()}))}qo(){var t;return null!==(t=this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var t,e;this.qo()?this.lr(this.oo):(null==(t=this.$o)||t.call(this),null==(e=this.Do)||e.call(this),this.$o=void 0,this.Do=void 0)}}},dr=i({surveys:class{get qt(){return this._instance.config}constructor(t){this.jo=void 0,this._surveyManager=null,this.Ho=!1,this.Uo=[],this.Bo=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(_(e))return Li.warn("Flags not loaded yet. Not loading surveys.");var i=d(e);this.jo=i?e.length>0:e,Li.info("flags response received, isSurveysEnabled: "+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(null!=i&&i.startsWith("seenSurvey_")||null!=i&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((t=>localStorage.removeItem(t)))}loadIfEnabled(){if(!this._surveyManager)if(this.Ho)Li.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)Li.info(Wi);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())Li.info("Not loading surveys in cookieless mode without consent.");else{var t=null==bt?void 0:bt.__PosthogExtensions__;if(t){if(!p(this.jo)||this.qt.advanced_enable_surveys){var e=this.jo||this.qt.advanced_enable_surveys;this.Ho=!0;try{var i=t.generateSurveys;if(i)return void this.zo(i,e);var r=t.loadExternalDependency;if(!r)return void this.Vo(te);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.Vo("Could not load surveys script",i):this.zo(t.generateSurveys,e)}))}catch(t){throw this.Vo("Error initializing surveys",t),t}finally{this.Ho=!1}}}else Li.error("PostHog Extensions not found.")}}zo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new Hi(this._instance),Li.info("Surveys loaded successfully"),this.Wo({isLoaded:!0})}Vo(t,e){Li.error(t,e),this.Wo({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Uo.push(t),this._surveyManager&&this.Wo({isLoaded:!0}),()=>{this.Uo=this.Uo.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.qt.disable_surveys)return Li.info(Wi),t([]);var i,r=this._instance.get_property(Jt);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.Bo?this.Bo.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.Bo=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:e=>{var r;this.Bo=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Li.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(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==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[Jt]:l});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}Wo(t){for(var e of this.Uo)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Li.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!_(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Li.warn("init was not called")}Zo(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}Go(t){if(_(this._surveyManager))return{eligible:!1,reason:Vi};var e="string"==typeof t?this.Zo(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(_(this._surveyManager))return Li.warn("init was not called"),{visible:!1,disabledReason:Vi};var e=this.Go(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return _(this._surveyManager)?(Li.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Vi})):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.Go(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(_(this._surveyManager))Li.warn("init was not called");else{var s="string"==typeof t?this.Zo(t):t;if(null!=s&&s.id)if(Mi.includes(s.type)){var n=null==pt?void 0:pt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Li.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Li.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),Li.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Li.warn("Survey element not found")}else Li.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Li.warn("Survey not found")}}displaySurvey(t,e){var r;if(_(this._surveyManager))Li.warn("init was not called");else{var s=this.Zo(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Li.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void Li.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Li.warn("Survey not found")}}cancelPendingSurvey(t){_(this._surveyManager)?Li.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},nr),cr={toolbar:class{constructor(t){this.instance=t}Qo(t){bt.ph_toolbar_state=t}Jo(){var t;return null!==(t=bt.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Ft(this.instance.config))return!1;if(!dt||!pt)return!1;t=null!=t?t:dt.location,i=null!=i?i:dt.history;try{if(!e){try{dt.localStorage.setItem("test","test"),dt.localStorage.removeItem("test")}catch(t){return!1}e=null==dt?void 0:dt.localStorage}var r,s=Bi||Ue(t.hash,"__posthog")||Ue(t.hash,"state"),n=s?kt((()=>JSON.parse(atob(decodeURIComponent(s)))))||kt((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Ji)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Ko(t){var e=bt.ph_load_toolbar||bt.ph_load_editor;!_(e)&&c(e)?e(t,this.instance):qi.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==pt||!pt.getElementById(Qt));if(!dt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(dt.localStorage.setItem(Ji,JSON.stringify(i({},s,{source:void 0}))),2===this.Jo())this.Ko(s);else if(0===this.Jo()){var n;this.Qo(1),null==(n=bt.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return qi.error("[Toolbar] Failed to load",t),void this.Qo(0);this.Qo(2),this.Ko(s)})),St(dt,"turbolinks:load",(()=>{this.Qo(0),this.loadToolbar(s)}))}return!0}Yo(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)}}},fr=i({experiments:ir},nr),pr={conversations:class{constructor(t){this.Xo=void 0,this._conversationsManager=null,this.ea=!1,this.ta=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;_(e)||(y(e)?this.Xo=e:(this.Xo=e.enabled,this.ta=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Xo=void 0,this.ta=null}loadIfEnabled(){if(!(this._conversationsManager||this.ea||this._instance.config.disable_conversations||Ft(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==bt?void 0:bt.__PosthogExtensions__;if(t&&!p(this.Xo)&&this.Xo)if(this.ta&&this.ta.token){this.ea=!0;try{var e=t.initConversations;if(e)return this.ra(e),void(this.ea=!1);var i=t.loadExternalDependency;if(!i)return void this.ia(te);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ia("Could not load conversations script",e):this.ra(t.initConversations),this.ea=!1}))}catch(t){this.ia("Error initializing conversations",t),this.ea=!1}}else rr.error("Conversations enabled but missing token in remote config.")}}ra(t){if(this.ta)try{this._conversationsManager=t(this.ta,this._instance),rr.info("Conversations loaded successfully")}catch(t){this.ia("Error completing conversations initialization",t)}else rr.error("Cannot complete initialization: remote config is null")}ia(t,e){rr.error(t,e),this._conversationsManager=null,this.ea=!1}show(){this._conversationsManager?this._conversationsManager.show():rr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Xo&&!b(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(rr.warn(sr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(rr.warn(sr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(rr.warn(sr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(rr.warn(sr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(rr.warn(sr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(rr.warn(sr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(rr.warn(sr),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}ln(){var t;null==(t=this._conversationsManager)||t.setIdentity()}hn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},gr={logs:class{constructor(t){var e;this.na=!1,this.sa=!1,this.Gt=yt("[logs]"),this.oa=[],this.aa=0,this.ua=0,this.la=!1,this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.na=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!_(i)&&i&&(this.na=!0,this.loadIfEnabled())}reset(){this.oa=[],this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.aa=0,this.ua=0,this.la=!1}loadIfEnabled(){if(this.na&&!this.sa){var t=null==bt?void 0:bt.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Gt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.sa=!0)})):this.Gt.error(te)}else this.Gt.error("PostHog Extensions not found.")}}captureLog(t){var e,r,s,n,a,o;if(this._instance.is_capturing())if(t&&t.body){var l=null!==(e=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s:1e3,h=Date.now();if(l>h-this.ua||(this.ua=h,this.aa=0,this.la=!1),u>this.aa){this.aa++;var v=function(t,e){var r=t.level||"info",{text:s,number:n}=I[r]||T,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),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 l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:A(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),p(t.trace_flags)||(u.flags=t.trace_flags),u}(t,this.ha());this.oa.push({record:v}),(null!==(a=null==(o=this._instance.config.logs)?void 0:o.maxBufferSize)&&void 0!==a?a:100)>this.oa.length?this.ca():this.flushLogs()}else this.la||(this.Gt.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this.la=!0)}else this.Gt.warn("captureLog requires a body")}get logger(){return this.da||(this.da={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.da}flushLogs(t){if(this.qr&&(clearTimeout(this.qr),this.qr=void 0),0!==this.oa.length){var e=this.oa;this.oa=[];var n=this._instance.config.logs,a=i({"service.name":(null==n?void 0:n.serviceName)||"unknown_service"},(null==n?void 0:n.environment)&&{"deployment.environment":n.environment},(null==n?void 0:n.serviceVersion)&&{"service.version":n.serviceVersion},null==n?void 0:n.resourceAttributes),o=function(t,e,i,r){return{resourceLogs:[{resource:{attributes:A(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}(e.map((t=>t.record)),a,s,r),l=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:"POST",url:l,data:o,compression:"best-available",batchKey:"logs",transport:t})}}ca(){var t,e;this.qr||(this.qr=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),null!==(t=null==(e=this._instance.config.logs)?void 0:e.flushIntervalMs)&&void 0!==t?t:3e3))}ha(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(null!=bt&&null!=(t=bt.location)&&t.href&&(e.currentUrl=bt.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},br=i({},nr,ar,or,lr,ur,hr,dr,vr,cr,fr,pr,gr),_r=nr,mr=ar,yr=or,wr=lr,xr=ur,Er=hr,kr=dr,Sr=vr,Fr=cr,Cr=fr,Rr=pr,Pr=gr;export{br as AllExtensions,yr as AnalyticsExtensions,Rr as ConversationsExtensions,wr as ErrorTrackingExtensions,Cr as ExperimentsExtensions,_r as FeatureFlagsExtensions,Pr as LogsExtensions,xr as ProductToursExtensions,mr as SessionReplayExtensions,Er as SiteAppsExtensions,kr as SurveysExtensions,Fr as ToolbarExtensions,Sr as TracingExtensions};
1
+ function t(t,e,i,r,s,n,a){try{var o=t[n](a),l=o.value}catch(t){return void i(t)}o.done?e(l):Promise.resolve(l).then(r,s)}function e(e){return function(){var i=this,r=arguments;return new Promise((function(s,n){var a=e.apply(i,r);function o(e){t(a,s,n,o,l,"next",e)}function l(e){t(a,s,n,o,l,"throw",e)}o(void 0)}))}}function i(){return i=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},i.apply(null,arguments)}var r="1.376.1",s="web",n=["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"],a=function(t,e){if(void 0===e&&(e=[]),!t)return!1;var i=t.toLowerCase();return n.concat(e).some((t=>{var e=t.toLowerCase();return-1!==i.indexOf(e)}))};function o(t,e){return-1!==t.indexOf(e)}var l=function(t){return t.trim()},u=Object.prototype,h=u.hasOwnProperty,v=u.toString,d=Array.isArray||function(t){return"[object Array]"===v.call(t)},c=t=>"function"==typeof t,f=t=>t===Object(t)&&!d(t),p=t=>void 0===t,g=t=>"[object String]"==v.call(t),b=t=>null===t,_=t=>p(t)||b(t),m=t=>"[object Number]"==v.call(t)&&t==t,y=t=>"[object Boolean]"===v.call(t),w=t=>t instanceof FormData;function x(t){return null===t||"object"!=typeof t}function E(t,e){return{}.toString.call(t)==="[object "+e+"]"}function k(t){return"undefined"!=typeof Event&&function(t,e){try{return t instanceof e}catch(t){return!1}}(t,Event)}function S(t,e,i,r,s){return e>i&&(r.warn("min cannot be greater than max."),e=i),m(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),S(i,e,i,r))}class F{constructor(t){this.$t={},this.zt=t.zt,this.Zt=S(t.bucketSize,0,100,t.Gt),this.Qt=S(t.refillRate,0,this.Zt,t.Gt),this.Jt=S(t.refillInterval,0,864e5,t.Gt)}Kt(t,e){var i=Math.floor((e-t.lastAccess)/this.Jt);i>0&&(t.tokens=Math.min(t.tokens+i*this.Qt,this.Zt),t.lastAccess=t.lastAccess+i*this.Jt)}consumeRateLimit(t){var e,i=Date.now(),r=String(t),s=this.$t[r];return s?this.Kt(s,i):this.$t[r]=s={tokens:this.Zt,lastAccess:i},0===s.tokens||(s.tokens--,0===s.tokens&&(null==(e=this.zt)||e.call(this,t)),0===s.tokens)}stop(){this.$t={}}}var C,R,P,I={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}},T=I.info;function O(t){if(y(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(d(t))return{arrayValue:{values:t.map((t=>O(t)))}};try{return{stringValue:JSON.stringify(t)}}catch(e){return{stringValue:String(t)}}}function A(t){var e=[];for(var i in t){var r=t[i];b(r)||p(r)||e.push({key:i,value:O(r)})}return e}function j(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return P&&i.length===R?P:(R=i.length,P=i.reduce(((i,r)=>{C||(C={});var s=C[r];if(s)i[s[0]]=s[1];else for(var n=t(r),a=n.length-1;a>=0;a--){var o=n[a],l=null==o?void 0:o.filename,u=e[r];if(l&&u){i[l]=u,C[r]=[l,u];break}}return i}),{}))}}class L{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 i=this;return e((function*(){for(var e of t)e.stacktrace&&e.stacktrace.frames&&d(e.stacktrace.frames)&&(e.stacktrace.frames=yield i.applyModifiers(e.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 r,s;return null!=t.cause&&(r=this.parseStacktrace(t.cause,e)),""!=t.stack&&null!=t.stack&&(s=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),i({},t,{cause:r,stack:s})}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 i=this;return e((function*(){var e=t;for(var r of i.modifiers)e=yield r(e);return e}))()}convertToExceptionList(t,e){var r,s,n,a={type:t.type,value:t.value,mechanism:{type:null!==(r=e.type)&&void 0!==r?r:"generic",handled:null===(s=e.handled)||void 0===s||s,synthetic:null!==(n=t.synthetic)&&void 0!==n&&n}};t.stack&&(a.stacktrace={type:"raw",frames:t.stack});var o=[a];return null!=t.cause&&o.push(...this.convertToExceptionList(t.cause,i({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:j(this.stackParser),skipFirstLines:null!==(e=t.skipFirstLines)&&void 0!==e?e:1}}buildCoercingContext(t,e,r){void 0===r&&(r=0);var s=(i,r)=>{if(4>=r){var s=this.buildCoercingContext(t,e,r);return this.applyCoercers(i,s)}};return i({},e,{syntheticException:0==r?e.syntheticException:void 0,mechanism:t,apply:t=>s(t,r),next:t=>s(t,r+1)})}}var M="?";function D(t,e,i,r,s){var n={platform:t,filename:e,function:"<anonymous>"===i?M:i,in_app:!0};return p(r)||(n.lineno=r),p(s)||(n.colno=s),n}var N=(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]:M,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},U=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,z=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,H=/\((\S*)(?::(\d+))(?::(\d+))\)/,V=(t,e)=>{var i=U.exec(t);if(i){var[,r,s,n]=i;return D(e,r,M,+s,+n)}var a=z.exec(t);if(a){if(a[2]&&0===a[2].indexOf("eval")){var o=H.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,u]=N(a[1]||M,a[2]);return D(e,u,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},W=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,B=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,J=(t,e)=>{var i=W.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=B.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]||M;return[n,s]=N(n,s),D(e,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},q=/\(error: (.*)\)/;class G{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var i=g(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 E(t,"DOMException")}isDOMError(t){return E(t,"DOMError")}}class K{match(t){return t instanceof Error}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 Y{constructor(){}match(t){return E(t,"ErrorEvent")&&null!=t.error}coerce(t,e){var i;return e.apply(t.error)||{type:"ErrorEvent",value:t.message,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}var X=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class Z{match(t){return"string"==typeof t}coerce(t,e){var i,[r,s]=this.getInfos(t);return{type:null!=r?r:"Error",value:null!=s?s:t,stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(t){var e="Error",i=t,r=t.match(X);return r&&(e=r[1],i=r[2]),[e,i]}}var Q=["fatal","error","warning","log","info","debug"];function tt(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 et{match(t){return"object"==typeof t&&null!==t}coerce(t,e){var i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:null==(i=e.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){return k(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: "+tt(t)}isSeverityLevel(t){return g(t)&&!(t=>g(t)&&0===t.trim().length)(t)&&Q.indexOf(t)>=0}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var i=t[e];if(i instanceof Error)return i}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch(t){return}}}class it{match(t){return k(t)}coerce(t,e){var i,r=t.constructor.name;return{type:r,value:r+" captured as exception with keys: "+tt(t),stack:null==(i=e.syntheticException)?void 0:i.stack,synthetic:!0}}}class rt{match(t){return x(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 st{match(t){return E(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!k(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 x(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 nt="$message",at="$timestamp",ot=new Set([nt,at]),lt={enabled:!0,max_bytes:32768};function ut(t){var e;return t?{enabled:null!==(e=t.enabled)&&void 0!==e?e:lt.enabled,max_bytes:vt(t.max_bytes,lt.max_bytes)}:i({},lt)}class ht{constructor(t){this.Yt=[],this.Xt=0,this.qt=ut(t)}setConfig(t){this.qt=ut(t),this.er()}add(t){var e=function(t){var e=function(t){var e=new WeakSet;try{return JSON.stringify(t,((t,i)=>{if("bigint"==typeof i)return i.toString();if("function"!=typeof i&&"symbol"!=typeof i){if(i instanceof Date)return i.toISOString();if(i instanceof Error)return{name:i.name,message:i.message,stack:i.stack};if(i&&"object"==typeof i){if(e.has(i))return"[Circular]";e.add(i)}return i}}))}catch(t){return}}(t);if(e)try{var i=JSON.parse(e);if(!f(i))return;var r=i,s=r[nt],n=r[at];if(!g(s)||0===s.trim().length)return;if(!g(n)&&!m(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.qt.max_bytes||(this.Yt.push({step:e.step,bytes:i}),this.Xt+=i,this.er())}}getAttachable(){return this.Yt.map((t=>t.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var t=this.Yt.shift();t&&(this.Xt-=t.bytes)}}}function vt(t,e){if(!m(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}var dt="undefined"!=typeof window?window:void 0,ct="undefined"!=typeof globalThis?globalThis:dt;"undefined"==typeof self&&(ct.self=ct),"undefined"==typeof File&&(ct.File=function(){});var ft=null==ct?void 0:ct.navigator,pt=null==ct?void 0:ct.document,gt=null==ct?void 0:ct.location;null!=ct&&ct.XMLHttpRequest&&new ct.XMLHttpRequest;var bt=null!=dt?dt:{},_t=function(t,e){var{debugEnabled:i}=void 0===e?{}:e,r={k(e){if(dt&&(bt.POSTHOG_DEBUG||i)&&!p(dt.console)&&dt.console){for(var r=("__rrweb_original__"in dt.console[e]?dt.console[e].__rrweb_original__:dt.console[e]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;s>a;a++)n[a-1]=arguments[a];r(t,...n)}},debug(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("debug",...e)},info(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("log",...e)},warn(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("warn",...e)},error(){for(var t=arguments.length,e=new Array(t),i=0;t>i;i++)e[i]=arguments[i];r.k("error",...e)},critical(){for(var e=arguments.length,i=new Array(e),r=0;e>r;r++)i[r]=arguments[r];console.error(t,...i)},uninitializedWarning(t){r.error("You must initialize PostHog before calling "+t)},createLogger:(e,i)=>_t(t+" "+e,i)};return r},mt=_t("[PostHog.js]"),yt=mt.createLogger;function wt(t,e){if(!_(t))if(d(t))t.forEach(e);else if(w(t))t.forEach(((t,i)=>e(t,i)));else for(var i in t)h.call(t,i)&&e(t[i],i)}var xt=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 Et(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 kt=function(t){try{return t()}catch(t){return}};function St(t,e,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==t||t.addEventListener(e,i,{capture:s,passive:n})}function Ft(t){return"ph_toolbar_internal"===t.name}var Ct="$autocapture_disabled_server_side",Rt="$heatmaps_enabled_server_side",Pt="$exception_capture_enabled_server_side",$t="$error_tracking_suppression_rules",It="$error_tracking_capture_extension_exceptions",Tt="$web_vitals_enabled_server_side",Ot="$product_tours_enabled_server_side",At="$web_vitals_allowed_metrics",jt="$session_recording_remote_config",Lt="$enabled_feature_flags",Mt="$active_feature_flags",Dt="$early_access_features",Nt="$feature_flag_details",Ut="$feature_flag_payloads",zt="$feature_flag_request_id",Ht="$override_feature_flags",Vt="$override_feature_flag_payloads",Wt="$stored_person_properties",Bt="$stored_group_properties",Jt="$surveys",qt="$surveys_activated",Gt="ph_product_tours",Kt="$flag_call_reported",Yt="$flag_call_reported_session_id",Xt="$feature_flag_errors",Zt="$feature_flag_evaluated_at",Qt="__POSTHOG_TOOLBAR__",te="PostHog loadExternalDependency extension not found.",ee="visibilitychange",ie="beforeunload",re=1,se=3,ne=11;function ae(t){return t instanceof Element&&(t.id===Qt||!(null==t.closest||!t.closest(".toolbar-global-fade-container")))}function oe(t){return!!t&&t.nodeType===re}function le(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function ue(t){return!!t&&t.nodeType===se}function he(t){return!!t&&t.nodeType===ne&&oe(t.host)}function ve(t){return t?l(t).split(/\s+/):[]}function de(t){var e=null==dt?void 0:dt.location.href;return!!(e&&t&&t.some((t=>e.match(t))))}function ce(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 ve(e)}function fe(t){return _(t)?null:l(t).split(/(\s+)/).filter((t=>Te(t))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function pe(t){var e="";return ke(t)&&!Se(t)&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;ue(t)&&t.textContent&&(e+=null!==(i=fe(t.textContent))&&void 0!==i?i:"")})),l(e)}function ge(t){return p(t.target)?t.srcElement||null:null!=(e=t.target)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var be=["a","button","form","input","select","textarea","label"];function _e(t,e){if(p(e))return!0;var i,r=function(t){if(e.some((e=>t.matches(e))))return{v:!0}};for(var s of t)if(i=r(s))return i.v;return!1}function me(t){var e=t.parentNode;return!(!e||!oe(e))&&e}var ye=["next","previous","prev",">","<"],we=[".ph-no-rageclick",".ph-no-capture"];var xe=t=>!t||le(t,"html")||!oe(t),Ee=(t,e)=>{if(!dt||xe(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[t],s=t;s.parentNode&&!le(s,"body");)if(he(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=me(s);if(!n)break;if(e||be.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=dt.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function ke(t){for(var e=t;e.parentNode&&!le(e,"body");e=e.parentNode){var i=ce(e);if(o(i,"ph-sensitive")||o(i,"ph-no-capture"))return!1}if(o(ce(t),"ph-include"))return!0;var r=t.type||"";if(g(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=t.name||t.id||"";return!g(s)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,""))}function Se(t){return!!(le(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||le(t,"select")||le(t,"textarea")||"true"===t.getAttribute("contenteditable"))}var Fe="(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})",Ce=new RegExp("^(?:"+Fe+")$"),Re=new RegExp(Fe),Pe="\\d{3}-?\\d{2}-?\\d{4}",$e=new RegExp("^("+Pe+")$"),Ie=new RegExp("("+Pe+")");function Te(t,e){if(void 0===e&&(e=!0),_(t))return!1;if(g(t)){if(t=l(t),(e?Ce:Re).test((t||"").replace(/[- ]/g,"")))return!1;if((e?$e:Ie).test(t))return!1}return!0}function Oe(t){var e=pe(t);return Te(e=(e+" "+Ae(t)).trim())?e:""}function Ae(t){var e="";return t&&t.childNodes&&t.childNodes.length&&wt(t.childNodes,(function(t){var i;if(t&&"span"===(null==(i=t.tagName)?void 0:i.toLowerCase()))try{var r=pe(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Ae(t)).trim())}catch(t){mt.error("[AutoCapture]",t)}})),e}function je(t){return t.replace(/"|\\"/g,'\\"')}function Le(t){var e=t.attr__class;return e?d(e)?e:ve(e):void 0}class Me{constructor(t){this.disabled=!1===t;var e=f(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 De=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(!d(i)||2>i.length)return"";var a=i[1];try{a=decodeURIComponent(a)}catch(t){mt.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Ne=function(t,e,i){if(!t||!e||!e.length)return t;for(var r=t.split("#"),s=r[1],n=(r[0]||"").split("?"),a=n[1],o=n[0],l=(a||"").split("&"),u=[],h=0;l.length>h;h++){var v=l[h].split("=");d(v)&&(e.includes(v[0])?u.push(v[0]+"="+i):u.push(l[h]))}var c=o;return null!=a&&(c+="?"+u.join("&")),null!=s&&(c+="#"+s),c},Ue=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},ze="$copy_autocapture",He=yt("[AutoCapture]");function Ve(t,e){return e.length>t?e.slice(0,t)+"...":e}function We(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do{e=e.previousSibling}while(e&&!oe(e));return e}function Be(t,e){var r,s,{e:n,maskAllElementAttributes:a,maskAllText:l,elementAttributeIgnoreList:u,elementsChainAsString:h}=e;if(!oe(t))return{props:{}};for(var v=[t],d=t;d.parentNode&&!le(d,"body");)if(he(d.parentNode))v.push(d.parentNode.host),d=d.parentNode.host;else{if(!oe(d.parentNode))break;v.push(d.parentNode),d=d.parentNode}var c,f,b=[],_={},m=!1,y=!1;if(wt(v,(t=>{var e=ke(t);if(le(t,"a")){var i=t.getAttribute("href");m=e&&!!i&&Te(i)&&i}o(ce(t),"ph-no-capture")&&(y=!0),b.push(function(t,e,i,r){var s=t.tagName.toLowerCase(),n={tag_name:s};be.indexOf(s)>-1&&!i&&(n.$el_text="a"===s.toLowerCase()||"button"===s.toLowerCase()?Ve(1024,Oe(t)):Ve(1024,pe(t)));var a=ce(t);a.length>0&&(n.classes=a.filter((function(t){return""!==t}))),wt(t.attributes,(function(i){var s;if((!Se(t)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!e&&Te(i.value)&&(!g(s=i.name)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var a=i.value;"class"===i.name&&(a=ve(a).join(" ")),n["attr__"+i.name]=Ve(1024,a)}}));for(var o=1,l=1,u=t;u=We(u);)o++,u.tagName===t.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}(t,a,l,u));var r=function(t){if(!ke(t))return{};var e={};return wt(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&&Te(r)&&(e[i]=r)}})),e}(t);xt(_,r)})),y)return{props:{},explicitNoCapture:y};if(l||(b[0].$el_text=le(t,"a")||le(t,"button")?Oe(t):pe(t)),m){var w,x;b[0].attr__href=m;var E=null==(w=(t=>{var e=null==pt?void 0:pt.createElement("a");return p(e)?null:(e.href=t,e)})(m))?void 0:w.host,k=null==dt||null==(x=dt.location)?void 0:x.host;E&&k&&E!==k&&(c=m)}return{props:xt({$event_type:n.type,$ce_version:1},h?{}:{$elements:b},{$elements_chain:(f=b,function(t){return t.map((t=>{var e,r,s="";if(t.tag_name&&(s+=t.tag_name),t.attr_class)for(var n of(t.attr_class.sort(),t.attr_class))s+="."+n.replace(/"/g,"");var a=i({},t.text?{text:t.text}:{},{"nth-child":null!==(e=t.nth_child)&&void 0!==e?e:0,"nth-of-type":null!==(r=t.nth_of_type)&&void 0!==r?r:0},t.href?{href:t.href}:{},t.attr_id?{attr_id:t.attr_id}:{},t.attributes),o={};return Et(a).sort(((t,e)=>{var[i]=t,[r]=e;return i.localeCompare(r)})).forEach((t=>{var[e,i]=t;return o[je(e.toString())]=je(i.toString())})),(s+=":")+Et(o).map((t=>{var[e,i]=t;return e+'="'+i+'"'})).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:Le(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Et(t).filter((t=>{var[e]=t;return 0===e.indexOf("attr__")})).forEach((t=>{var[e,i]=t;return r.attributes[e]=i})),r}))}(f)))},null!=(r=b[0])&&r.$el_text?{$el_text:null==(s=b[0])?void 0:s.$el_text}:{},c&&"click"===n.type?{$external_click_url:c}:{},_)}}var Je=yt("[Dead Clicks]"),qe=()=>!0;class Ge{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(t,e,i){this.instance=t,this.isEnabled=e,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(t){"captureDeadClicks"in t&&(this.instance.persistence&&this.instance.persistence.register({$dead_clicks_enabled_server_side:t.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.initDeadClicksAutocapture&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(e=>{e?Je.error("failed to load script",e):t()}))}hr(){var t;if(pt){if(!this.ur&&null!=(t=bt.__PosthogExtensions__)&&t.initDeadClicksAutocapture){var e=f(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};e.__onCapture=this.onCapture,this.ur=bt.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.ur.start(pt),Je.info("starting...")}}else Je.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Je.info("stopping..."))}}var Ke=yt("[ExceptionAutocapture]");function Ye(t,e,i){try{if(!(e in t))return()=>{};var r=t[e],s=i(r);return c(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=s,()=>{t[e]=r}}catch(t){return()=>{}}}var Xe=yt("[TracingHeaders]");Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return m(t)&&isFinite(t)&&Math.floor(t)===t});class Ze{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/Math.pow(2,8),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 Ze(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 Ze(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 Qe{constructor(){this.S=0,this.C=0,this.I=new ii}generate(){var t=this.generateOrAbort();if(p(t)){this.S=0;var e=this.generateOrAbort();if(p(e))throw new Error("Could not generate UUID after timestamp reset");return e}return t}generateOrAbort(){var t=Date.now();if(t>this.S)this.S=t,this.T();else{if(this.S>=t+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return Ze.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}}var ti,ei=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};dt&&!p(dt.crypto)&&crypto.getRandomValues&&(ei=t=>crypto.getRandomValues(t));class ii{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||(ei(this.M),this.O=0),this.M[this.O++]}}var ri=()=>(ti||(ti=new Qe)).generate(),si="",ni=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function ai(t,e){if(e){var i=function(t,e){if(void 0===e&&(e=pt),si)return si;if(!e)return"";if(["localhost","127.0.0.1"].includes(t))return"";for(var i=t.split("."),r=Math.min(i.length,8),s="dmn_chk_"+ri().toString();!si&&r--;){var n=i.slice(r).join("."),a=s+"=1;domain=."+n+";path=/";e.cookie=a+";max-age=3",e.cookie.includes(s)&&(e.cookie=a+";max-age=0",si=n)}return si}(t);if(!i){var r=(t=>{var e=t.match(ni);return e?e[0]:""})(t);r!==i&&mt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var oi={R:()=>!!pt,D(t){mt.error("cookieStore error: "+t)},A(t){if(pt){try{for(var e=t+"=",i=pt.cookie.split(";").filter((t=>t.length)),r=0;i.length>r;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(e))return decodeURIComponent(s.substring(e.length,s.length))}}catch(t){}return null}},F(t){var e;try{e=JSON.parse(oi.A(t))||{}}catch(t){}return e},N(t,e,i,r,s){if(pt)try{var n="",a="",o=ai(pt.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}s&&(a="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return u.length>3686.4&&mt.warn("cookieStore warning: large cookie, len="+u.length),pt.cookie=u,u}catch(t){return}},q(t,e){if(null!=pt&&pt.cookie)try{oi.N(t,"",-1,e)}catch(t){return}}},li=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ui=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...li],hi="<masked>",vi=["li_fat_id"];function di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}var ci=yt("[Web Vitals]"),fi=9e5,pi=yt("[RemoteConfig]");class gi{constructor(t){this._instance=t}get remoteConfig(){var t;return null==(t=bt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.config}Mr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.loadExternalDependency?null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",(()=>t(this.remoteConfig))):t()}Pr(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(e){t(e.json)}})}load(){try{if(this.remoteConfig)return pi.info("Using preloaded remote config",this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void pi.warn("Remote config is disabled. Falling back to local config.");this.Mr((t=>{if(!t)return pi.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pr((t=>{this.Rr(t),this.Or()}));this.Rr(t),this.Or()}))}catch(t){pi.error("Error loading remote config",t)}}stop(){this.Fr&&(clearInterval(this.Fr),this.Fr=void 0)}refresh(){!this._instance.Lr()&&pt&&"hidden"!==pt.visibilityState&&this._instance.reloadFeatureFlags()}Or(){var t;if(!this.Fr){var e=null!==(t=this._instance.config.remote_config_refresh_interval_ms)&&void 0!==t?t:3e5;0!==e&&(this.Fr=setInterval((()=>{this.refresh()}),e))}}Rr(t){var e;t||pi.error("Failed to fetch remote config from PostHog."),this._instance.Rr(null!=t?t:{}),!1!==(null==t?void 0:t.hasFeatureFlags)&&(this._instance.config.advanced_disable_feature_flags_on_first_load||null==(e=this._instance.featureFlags)||e.ensureFlagsLoaded())}}var bi="disabled",_i="lazy_loading",mi="awaiting_config",yi="missing_config",wi="base64",xi=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}},Ei={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=>xi(e,t))))),not_regex:(t,e)=>e.every((e=>t.every((t=>!xi(e,t))))),icontains:(t,e)=>e.map(ki).some((e=>t.map(ki).some((t=>e.includes(t))))),not_icontains:(t,e)=>e.map(ki).every((e=>t.map(ki).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)))}))},ki=t=>t.toLowerCase();function Si(t,e){return!t||Object.entries(t).every((t=>{var[i,r]=t,s=null==e?void 0:e[i];if(p(s)||b(s))return!1;var n=[String(s)],a=Ei[r.operator];return!!a&&a(r.values,n)}))}yt("[SessionRecording]"),yt("[SessionRecording]");var Fi="[SessionRecording]",Ci=yt(Fi),Ri=yt("[Heatmaps]");function Pi(t){return f(t)&&"clientX"in t&&"clientY"in t&&m(t.clientX)&&m(t.clientY)}var $i=yt("[Product Tours]"),Ii=["$set_once","$set"],Ti=yt("[SiteApps]"),Oi="Error while initializing PostHog app with config id ",Ai="events",ji="cancelEvents",Li=yt("[Surveys]"),Mi=["popover","widget","api"];class Di{constructor(){this.oi={}}on(t,e){return this.oi[t]||(this.oi[t]=[]),this.oi[t].push(e),()=>{this.oi[t]=this.oi[t].filter((t=>t!==e))}}emit(t,e){for(var i of this.oi[t]||[])i(e);for(var r of this.oi["*"]||[])r(t,e)}}function Ni(t,e,i){if(_(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 Ui{constructor(t){this.vn=new Di,this.fn=(t,e)=>this.pn(t,e)&&this.gn(t,e)&&this.mn(t,e)&&this.yn(t,e),this.pn=(t,e)=>null==e||!e.event||(null==t?void 0:t.event)===(null==e?void 0:e.event),this._instance=t,this.bn=new Set,this._n=new Set}init(){var t,e;p(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(!p(null==(e=this._instance)?void 0:e._addCaptureHook)&&(t.forEach((t=>{var e,i;null==(e=this._n)||e.add(t),null==(i=t.steps)||i.forEach((t=>{var e;null==(e=this.bn)||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.bn.has(t)||this.bn.has(null==e?void 0:e.event))&&this._n&&(null==(i=this._n)?void 0:i.size)>0&&this._n.forEach((t=>{this.wn(e,t)&&this.vn.emit("actionCaptured",t.name)}))}xn(t){this.onAction("actionCaptured",(e=>t(e)))}wn(t,e){if(null==(null==e?void 0:e.steps))return!1;for(var i of e.steps)if(this.fn(t,i))return!0;return!1}onAction(t,e){return this.vn.on(t,e)}gn(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(!Ni(r,e.url,e.url_matching||"contains"))return!1}return!0}mn(t,e){return!!this.Sn(t,e)&&!!this.kn(t,e)&&!!this.Cn(t,e)}Sn(t,e){var i;if(null==e||!e.href)return!0;var r=this.In(t);if(r.length>0)return r.some((t=>Ni(t.href,e.href,e.href_matching||"exact")));var s,n=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!n&&Ni((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",e.href,e.href_matching||"exact")}kn(t,e){var i;if(null==e||!e.text)return!0;var r=this.In(t);if(r.length>0)return r.some((t=>Ni(t.text,e.text,e.text_matching||"exact")||Ni(t.$el_text,e.text,e.text_matching||"exact")));var s,n,a,o=(null==t||null==(i=t.properties)?void 0:i.$elements_chain)||"";return!!o&&(s=function(t){for(var e,i=[],r=/(?::|")text="(.*?)"/g;!_(e=r.exec(t));)i.includes(e[1])||i.push(e[1]);return i}(o),n=e.text,a=e.text_matching||"exact",s.some((t=>Ni(t,n,a))))}Cn(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}In(t){var e;return null==(null==t||null==(e=t.properties)?void 0:e.$elements)?[]:null==t?void 0:t.properties.$elements}yn(t,e){return null==e||!e.properties||0===e.properties.length||Si(e.properties.reduce(((t,e)=>{var i=d(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 zi{constructor(t){this._instance=t,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(t,e){return!!t&&Si(t.propertyFilters,null==e?void 0:e.properties)}Rn(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}On(t,e,i){var r=(i===Ai?this.Tn:this.En).get(t),s=[];return this.Ln((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.Pn(n,e)}))}register(t){var e;p(null==(e=this._instance)?void 0:e._addCaptureHook)||(this.Fn(t),this.An(t))}An(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.Nn&&(this.Nn=new Ui(this._instance),this.Nn.init(),this.Nn.xn((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.Nn)||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.Mn.get(e.name);i&&i.push(t.id),this.Mn.set(e.name,i||[t.id])}})))})))}Fn(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.Tn=this.Rn(t,Ai),this.En=this.Rn(t,ji))}onEvent(t,e){var i,r=this.le(),s=this.$n(),n=this.Dn(),a=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===t&&e&&a.length>0){var o,l;r.info("event matched, removing item from activated items",{event:t,eventPayload:e,existingActivatedItems:a});var u=(null==e||null==(o=e.properties)?void 0:o.$survey_id)||(null==e||null==(l=e.properties)?void 0:l.$product_tour_id);if(u){var h=a.indexOf(u);0>h||(a.splice(h,1),this.qn(a))}}else{if(this.En.has(t)){var v=this.On(t,e,ji);v.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:v.map((t=>t.id))}),v.forEach((t=>{var e=a.indexOf(t.id);0>e||a.splice(e,1),this.jn(t.id)})),this.qn(a))}if(this.Tn.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Tn.get(t)});var d=this.On(t,e,Ai);this.qn(a.concat(d.map((t=>t.id))||[]))}}}onAction(t){var e,i=this.$n(),r=(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[i])||[];this.Mn.has(t)&&this.qn(r.concat(this.Mn.get(t)||[]))}qn(t){var e=this.le(),i=[...new Set(t)].filter((t=>!this.Hn(t)));e.info("updating activated items",{activatedItems:i}),this.Un(i)}getActivatedIds(){var t,e=this.$n();return(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[e])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}}class Hi extends zi{constructor(t){super(t)}$n(){return qt}Dn(){return"survey shown"}Ln(t){var e;null==(e=this._instance)||e.getSurveys(t)}jn(t){var e;null==(e=this._instance)||e.cancelPendingSurvey(t)}le(){return Li}Un(t){var e;null==(e=this._instance)||null==(e=e.persistence)||e.register({[qt]:t})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}var Vi="SDK is not enabled or survey functionality is not yet loaded",Wi="Disabled. Not loading surveys.",Bi=null!=dt&&dt.location?Ue(dt.location.hash,"__posthog")||Ue(location.hash,"state"):null,Ji="_postHogToolbarParams",qi=yt("[Toolbar]"),Gi=yt("[FeatureFlags]"),Ki=yt("[FeatureFlags]",{debugEnabled:!0}),Yi="\" failed. Feature flags didn't load in time.",Xi=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},Zi=t=>{var e={};for(var[i,r]of Et(t||{}))r&&(e[i]=r);return e},Qi=yt("[Error tracking]"),tr="Refusing to render web experiment since the viewer is a likely bot",er={icontains:(t,e)=>!!dt&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!dt&&-1===e.href.toLowerCase().indexOf(t.toLowerCase()),regex:(t,e)=>!!dt&&xi(e.href,t),not_regex:(t,e)=>!!dt&&!xi(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class ir{get qt(){return this._instance.config}constructor(t){var e=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(t){void 0===t&&(t=!1),e.getWebExperiments((t=>{ir.zn("retrieved web experiments from the server"),e.Vn=new Map,t.forEach((t=>{if(t.feature_flag_key){var i;e.Vn&&(ir.zn("setting flag key ",t.feature_flag_key," to web experiment ",t),null==(i=e.Vn)||i.set(t.feature_flag_key,t));var r=e._instance.getFeatureFlag(t.feature_flag_key);g(r)&&t.variants[r]&&e.Wn(t.name,r,t.variants[r].transforms)}else if(t.variants)for(var s in t.variants){var n=t.variants[s];ir.Zn(n)&&e.Wn(t.name,s,n.transforms)}}))}),t)},this._instance=t,this._instance.onFeatureFlags((t=>{this.onFeatureFlags(t)}))}initialize(){}onFeatureFlags(t){if(this._is_bot())ir.zn(tr);else if(!this.qt.disable_web_experiments){if(_(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();ir.zn("applying feature flags",t),t.forEach((t=>{var e;if(this.Vn&&null!=(e=this.Vn)&&e.has(t)){var i,r=this._instance.getFeatureFlag(t),s=null==(i=this.Vn)?void 0:i.get(t);r&&null!=s&&s.variants[r]&&this.Wn(s.name,r,s.variants[r].transforms)}}))}}previewWebExperiment(){var t=ir.getWindowLocation();if(null!=t&&t.search){var e=De(null==t?void 0:t.search,"__experiment_id"),i=De(null==t?void 0:t.search,"__experiment_variant");e&&i&&(ir.zn("previewing web experiments "+e+" && "+i),this.getWebExperiments((t=>{this.Gn(parseInt(e),i,t)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(t,e,i){if(this.qt.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.qt.token),method:"GET",callback:e=>t(200===e.statusCode&&e.json&&e.json.experiments||[])})}Gn(t,e,i){var r=i.filter((e=>e.id===t));r&&r.length>0&&(ir.zn("Previewing web experiment ["+r[0].name+"] with variant ["+e+"]"),this.Wn(r[0].name,e,r[0].variants[e].transforms))}static Zn(t){return!_(t.conditions)&&ir.Qn(t)&&ir.Jn(t)}static Qn(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.url))return!0;var i,r,s,n=ir.getWindowLocation();return!!n&&(null==(i=t.conditions)||!i.url||er[null!==(r=null==(s=t.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](t.conditions.url,n))}static getWindowLocation(){return null==dt?void 0:dt.location}static Jn(t){var e;if(_(t.conditions)||_(null==(e=t.conditions)?void 0:e.utm))return!0;var i=function(t,e,i){if(!pt)return{};var r,s,n,a=(r=Ne(pt.URL,[],hi),s=ui.concat([]),n={},wt(s,(function(t){var e=De(r,t);n[t]=e||null})),n),o=function(){var t={};return wt(vi,(function(e){var i=oi.A(e);t[e]=i||null})),t}();return xt(o,a)}();if(i.utm_source){var r,s,n,a,o,l,u,h,v=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,d=null==(n=t.conditions)||null==(n=n.utm)||!n.utm_source||(null==(a=t.conditions)||null==(a=a.utm)?void 0:a.utm_source)==i.utm_source,c=null==(o=t.conditions)||null==(o=o.utm)||!o.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 v&&c&&f&&d}return!1}static zn(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;e>r;r++)i[r-1]=arguments[r];mt.info("[WebExperiments] "+t,i)}Wn(t,e,i){this._is_bot()?ir.zn(tr):"control"!==e?i.forEach((i=>{if(i.selector){var r;ir.zn("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)}))}})):ir.zn("Control variants leave the page unmodified.")}_is_bot(){return ft&&this._instance?function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&a(i,e))return!0;try{var r=null==t?void 0:t.userAgentData;if(null!=r&&r.brands&&r.brands.some((t=>a(null==t?void 0:t.brand,e))))return!0}catch(t){}return!!t.webdriver}(ft,this.qt.custom_blocked_useragents):void 0}}var rr=yt("[Conversations]"),sr="Conversations not available yet.",nr={featureFlags:class{constructor(t){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(t){return this._instance.get_property(t)}us(){var t,e;return null!==(t=null==(e=this.ni)?void 0:e.wr(this.qt.feature_flag_cache_ttl_ms))&&void 0!==t&&t}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,Gi.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hs(){var t,e=null!==(t=this.qt.evaluation_contexts)&&void 0!==t?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(Gi.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ns=!0),null!=e&&e.length?e.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Gi.error("Invalid evaluation context found:",t,"Expected non-empty string"),e})):[]}cs(){return this.hs().length>0}ds(){var t=this.qt.flag_keys;if(!p(t)){if(d(t))return t.filter((t=>{var e=t&&"string"==typeof t&&t.trim().length>0;return e||Gi.error("Invalid flag key found:",t,"Expected non-empty string"),e}));Gi.error("Invalid flag_keys found:",t,"Expected array of non-empty strings")}}initialize(){var t,e,{config:i}=this._instance,r=null!==(t=null==(e=i.bootstrap)?void 0:e.featureFlags)&&void 0!==t?t:{};if(Object.keys(r).length){var s,n,a=null!==(s=null==(n=i.bootstrap)?void 0:n.featureFlagPayloads)&&void 0!==s?s:{},o=Object.keys(r).filter((t=>!!r[t])).reduce(((t,e)=>(t[e]=r[e]||!1,t)),{}),l=Object.keys(a).filter((t=>o[t])).reduce(((t,e)=>(a[e]&&(t[e]=a[e]),t)),{});this.receivedFeatureFlags({featureFlags:o,featureFlagPayloads:l})}}updateFlags(t,e,r){var s=null!=r&&r.merge?this.getFlagVariants():{},n=null!=r&&r.merge?this.getFlagPayloads():{},a=i({},s,t),o=i({},n,e),l={};for(var[u,h]of Object.entries(a)){var v="string"==typeof h;l[u]={key:u,enabled:!!v||Boolean(h),variant:v?h:void 0,reason:void 0,metadata:p(null==o?void 0:o[u])?void 0:{id:0,version:void 0,description:void 0,payload:o[u]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.os(Nt),e=this.os(Ht),r=this.os(Vt);if(!r&&!e)return t||{};var s=xt({},t||{}),n=[...new Set([...Object.keys(r||{}),...Object.keys(e||{})])];for(var a of n){var o,l,u=s[a],h=null==e?void 0:e[a],v=p(h)?null!==(o=null==u?void 0:u.enabled)&&void 0!==o&&o:!!h,d=p(h)?u.variant:"string"==typeof h?h:void 0,c=null==r?void 0:r[a],f=i({},u,{enabled:v,variant:v?null!=d?d:null==u?void 0:u.variant:void 0});v!==(null==u?void 0:u.enabled)&&(f.original_enabled=null==u?void 0:u.enabled),d!==(null==u?void 0:u.variant)&&(f.original_variant=null==u?void 0:u.variant),c&&(f.metadata=i({},null==u?void 0:u.metadata,{payload:c,original_payload:null==u||null==(l=u.metadata)?void 0:l.payload})),s[a]=f}return this.Kn||(Gi.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:r,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Lt),e=this.os(Ht);if(!e)return t||{};for(var i=xt({},t),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Kn||(Gi.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kn=!0),i}getFlagPayloads(){var t=this.os(Ut),e=this.os(Vt);if(!e)return t||{};for(var i=xt({},t||{}),r=Object.keys(e),s=0;r.length>s;s++)i[r[s]]=e[r[s]];return this.Kn||(Gi.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kn=!0),i}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.vs||(this._instance.Li.emit("featureFlagsReloading",!0),this.vs=setTimeout((()=>{this.fs()}),5))}ps(){clearTimeout(this.vs),this.vs=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.vs||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.es=t}fs(t){var e;if(this.ps(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var r=this.qt.token,s=this.os("$device_id"),n={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:i({},(null==(e=this.ni)?void 0:e.get_initial_props())||{},this.os(Wt)||{}),group_properties:this.os(Bt),timezone:di()};b(s)||p(s)||(n.$device_id=s),(null!=t&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.cs()&&(n.evaluation_contexts=this.hs());var a=this.ds();p(a)||(n.flag_keys=a);var o=!!this.qt.advanced_only_evaluate_survey_feature_flags,l=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Xn=!0,this._instance._send_request({method:"POST",url:l,data:n,compression:this.qt.disable_compression?void 0:wi,timeout:this.qt.feature_flag_request_timeout_ms,callback:t=>{var e,i,r,s=!0;if(200===t.statusCode&&(this.ts||(this.$anon_distinct_id=void 0),s=!1),this.Xn=!1,!n.disable_flags||this.ts){this.rs=!s;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.ni)||r.register({[Xt]:a}),u)Gi.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else n.disable_flags||this.receivedFeatureFlags(null!==(l=t.json)&&void 0!==l?l:{},s,{partialResponse:o}),this.ts&&(this.ts=!1,this.fs())}}})}}getFeatureFlag(t,e){var i;if(void 0===e&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){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 Gi.warn('getFeatureFlag for key "'+t+Yi)}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.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var i=this.getFlagVariants(),r=t in i,s=i[t],n=this.getFlagPayloads()[t],a=String(s),o=this.os(zt)||void 0,l=this.os(Zt)||void 0,u=this.os(Kt)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var h,v=this._instance.get_session_id(),c=this.os(Yt);v&&v!==c&&(u={},null==(h=this.ni)||h.register({[Kt]:u,[Yt]:v}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(a))){var f,g,b,_,m,y,w,x,E,k;d(u[t])?u[t].push(a):u[t]=[a],null==(f=this.ni)||f.register({[Kt]:u});var S=this.getFeatureFlagDetails(t),F=[...null!==(g=this.os(Xt))&&void 0!==g?g:[]];p(s)&&F.push("flag_missing");var C={$feature_flag:t,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(b=this.qt.bootstrap)||null==(b=b.featureFlags)?void 0:b[t])||null,$feature_flag_bootstrapped_payload:(null==(_=this.qt.bootstrap)||null==(_=_.featureFlagPayloads)?void 0:_[t])||null,$used_bootstrap_value:!this.rs};p(null==S||null==(m=S.metadata)?void 0:m.version)||(C.$feature_flag_version=S.metadata.version);var R,P=null!==(y=null==S||null==(w=S.reason)?void 0:w.description)&&void 0!==y?y:null==S||null==(x=S.reason)?void 0:x.code;P&&(C.$feature_flag_reason=P),null!=S&&null!=(E=S.metadata)&&E.id&&(C.$feature_flag_id=S.metadata.id),p(null==S?void 0:S.original_variant)&&p(null==S?void 0:S.original_enabled)||(C.$feature_flag_original_response=p(S.original_variant)?S.original_enabled:S.original_variant),null!=S&&null!=(k=S.metadata)&&k.original_payload&&(C.$feature_flag_original_payload=null==S||null==(R=S.metadata)?void 0:R.original_payload),F.length&&(C.$feature_flag_error=F.join(",")),this._instance.capture("$feature_flag_called",C)}if(r){var I=n;if(!p(n))try{I=JSON.parse(n)}catch(t){}return{key:t,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:I}}}}else Gi.warn('getFeatureFlagResult for key "'+t+Yi)}getRemoteConfigPayload(t,e){var i=this.qt.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.cs()&&(r.evaluation_contexts=this.hs());var s=this.ds();p(s)||(r.flag_keys=s),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:r,compression:this.qt.disable_compression?void 0:wi,timeout:this.qt.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.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return p(i)?void 0:!!i}Gi.warn('isFeatureEnabled for key "'+t+Yi)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,r){if(this.ni){this.Yn=!0;var s=this.getFlagVariants(),n=this.getFlagPayloads(),a=this.getFlagsWithDetails();!function(t,e,r,s,n,a){void 0===r&&(r={}),void 0===s&&(s={}),void 0===n&&(n={});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]})))):Gi.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t})(t),l=o.flags,u=o.featureFlags,h=o.featureFlagPayloads;if(u){var v=t.requestId,c=t.evaluatedAt;if(d(u)){Gi.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var f={};if(u)for(var p=0;u.length>p;p++)f[u[p]]=!0;e&&e.register({[Mt]:u,[Lt]:f})}else{var g=u,b=h,_=l;if(null!=a&&a.partialResponse)g=i({},r,g),b=i({},s,b),_=i({},n,_);else if(t.errorsWhileComputingFlags)if(l){var m=new Set(Object.keys(l).filter((t=>{var e;return!(null!=(e=l[t])&&e.failed)})));g=i({},r,Object.fromEntries(Object.entries(g).filter((t=>{var[e]=t;return m.has(e)})))),b=i({},s,Object.fromEntries(Object.entries(b||{}).filter((t=>{var[e]=t;return m.has(e)})))),_=i({},n,Object.fromEntries(Object.entries(_||{}).filter((t=>{var[e]=t;return m.has(e)}))))}else g=i({},r,g),b=i({},s,b),_=i({},n,_);e&&e.register(i({[Mt]:Object.keys(Zi(g)),[Lt]:g||{},[Ut]:b||{},[Nt]:_||{}},v?{[zt]:v}:{},c?{[Zt]:c}:{}))}}}(t,this.ni,s,n,a,r),e||(this.ss=!1),this.gs(e)}}override(t,e){void 0===e&&(e=!1),Gi.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return Gi.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===t)return this.ni.unregister(Ht),this.ni.unregister(Vt),this.gs(),Ki.info("All overrides cleared");if(d(t)){var e=Xi(t);return this.ni.register({[Ht]:e}),this.gs(),Ki.info("Flag overrides set",{flags:t})}if(t&&"object"==typeof t&&("flags"in t||"payloads"in t)){var i,r=t;if(this.Kn=Boolean(null!==(i=r.suppressWarning)&&void 0!==i&&i),"flags"in r)if(!1===r.flags)this.ni.unregister(Ht),Ki.info("Flag overrides cleared");else if(r.flags){if(d(r.flags)){var s=Xi(r.flags);this.ni.register({[Ht]:s})}else this.ni.register({[Ht]:r.flags});Ki.info("Flag overrides set",{flags:r.flags})}return"payloads"in r&&(!1===r.payloads?(this.ni.unregister(Vt),Ki.info("Payload overrides cleared")):r.payloads&&(this.ni.register({[Vt]:r.payloads}),Ki.info("Payload overrides set",{payloads:r.payloads}))),void this.gs()}if(t&&"object"==typeof t)return this.ni.register({[Ht]:t}),this.gs(),Ki.info("Flag overrides set",{flags:t});Gi.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.ys();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,r){var s,n=(this.os(Dt)||[]).find((e=>e.flagKey===t)),a={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:a};n&&(o.$early_access_feature_name=n.name),r&&(o.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=i({},this.getFlagVariants(),{[t]:e});null==(s=this.ni)||s.register({[Mt]:Object.keys(Zi(l)),[Lt]:l}),this.gs()}getEarlyAccessFeatures(t,e,i){void 0===e&&(e=!1);var r=this.os(Dt),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.qt.token+s),method:"GET",callback:e=>{var i,r;if(e.json){var s=e.json.earlyAccessFeatures;return null==(i=this.ni)||i.unregister(Dt),null==(r=this.ni)||r.register({[Dt]:s}),t(s)}}})}ys(){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)),{})}}gs(t){var{flags:e,flagVariants:i}=this.ys();this.featureFlagEventHandlers.forEach((r=>r(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.os(Wt)||{},s=(null==t?void 0:t.$set)||(null!=t&&t.$set_once?{}:t),n=null==t?void 0:t.$set_once,a={};if(n)for(var o in n)({}).hasOwnProperty.call(n,o)&&(o in r||(a[o]=n[o]));this._instance.register({[Wt]:i({},r,a,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Wt)}setGroupPropertiesForFlags(t,e){void 0===e&&(e=!0);var r=this.os(Bt)||{};0!==Object.keys(r).length&&Object.keys(r).forEach((e=>{r[e]=i({},r[e],t[e]),delete t[e]})),this._instance.register({[Bt]:i({},r,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(Bt)||{};this._instance.register({[Bt]:i({},e,{[t]:{}})})}else this._instance.unregister(Bt)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.ps(),this.Kn=!1}}},ar={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var t;return!(null==(t=this.bs)||!t.isStarted)}get status(){var t,e;return this._s===mi||this._s===yi?this._s:null!==(t=null==(e=this.bs)?void 0:e.status)&&void 0!==t?t:this._s}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this._s=bi,this.ws=void 0,this._instance=t,!this._instance.sessionManager)throw Ci.error("started without valid sessionManager"),new Error(Fi+" started without valid sessionManager. This is a bug.");if("always"===this.qt.cookieless_mode)throw new Error(Fi+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get xs(){var t,e=!(null==(t=this._instance.get_property(jt))||!t.enabled),i=!this.qt.disable_session_recording,r=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return dt&&e&&i&&!r}startIfEnabledOrStop(t){var e;if(!this.xs||null==(e=this.bs)||!e.isStarted){var i=!p(Object.assign)&&!p(Array.from);this.xs&&i?(this.Ss(t),Ci.info("starting")):(this._s=bi,this.stopRecording())}}Ss(t){var e,i,r;this.xs&&(this._s!==mi&&this._s!==yi&&(this._s=_i),null!=bt&&null!=(e=bt.__PosthogExtensions__)&&null!=(e=e.rrweb)&&e.record&&null!=(i=bt.__PosthogExtensions__)&&i.initSessionRecording?this.ks(t):null==(r=bt.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Cs,(e=>{if(e)return Ci.error("could not load recorder",e);this.ks(t)})))}stopRecording(){var t,e;null==(t=this.ws)||t.call(this),this.ws=void 0,null==(e=this.bs)||e.stop()}Is(){var t,e;null==(t=this.ws)||t.call(this),this.ws=void 0,null==(e=this.bs)||e.discard()}Ts(){var t;null==(t=this.ni)||t.unregister("$session_is_sampled")}Es(t,e){if(_(t))return null;var i,r=m(t)?t:parseFloat(t);return"number"!=typeof(i=r)||!Number.isFinite(i)||0>i||i>1?(Ci.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):r}Ms(t){if(this.ni){var e,r,s=this.ni,n=()=>{var e,r=!1===t.sessionRecording?void 0:t.sessionRecording,n=this.Es(null==(e=this.qt.session_recording)?void 0:e.sampleRate,"session_recording.sampleRate"),a=this.Es(null==r?void 0:r.sampleRate,"remote config sampleRate"),o=null!=n?n:a;_(o)&&this.Ts();var l=null==r?void 0:r.minimumDurationMilliseconds;s.register({[jt]:i({cache_timestamp:Date.now(),enabled:!!r},r,{networkPayloadCapture:i({capturePerformance:t.capturePerformance},null==r?void 0:r.networkPayloadCapture),canvasRecording:{enabled:null==r?void 0:r.recordCanvas,fps:null==r?void 0:r.canvasFps,quality:null==r?void 0:r.canvasQuality},sampleRate:o,minimumDurationMilliseconds:p(l)?null:l,endpoint:null==r?void 0:r.endpoint,triggerMatchType:null==r?void 0:r.triggerMatchType,masking:null==r?void 0:r.masking,urlTriggers:null==r?void 0:r.urlTriggers,version:null==r?void 0:r.version,triggerGroups:null==r?void 0:r.triggerGroups})})};n(),null==(e=this.ws)||e.call(this),this.ws=null==(r=this._instance.sessionManager)?void 0:r.onSessionId(n)}}onRemoteConfig(t){return"sessionRecording"in t?!1===t.sessionRecording?(this.Ms(t),void this.Is()):(this.Ms(t),void this.startIfEnabledOrStop()):(this._s===mi&&(this._s=yi,Ci.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.bs)&&i.log?this.bs.log(t,e):Ci.warn("log called before recorder was ready")}get Cs(){var t,e,i=null==(t=this._instance)||null==(t=t.persistence)?void 0:t.get_property(jt);return(null==i||null==(e=i.scriptConfig)?void 0:e.script)||"lazy-recorder"}Ps(){var t,e,i=this._instance.get_property(jt);if(!i)return!1;try{e="object"==typeof i?i:JSON.parse(i)}catch(t){return Ci.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}ks(t){var e,i;if(null==(e=bt.__PosthogExtensions__)||!e.initSessionRecording)return Ci.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.bs||(this.bs=null==(i=bt.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.bs._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ps()){if(this._s===yi||this._s===mi)return;return this._s=mi,Ci.info("persisted remote config is stale, requesting fresh config before starting"),void new gi(this._instance).load()}this._s=_i,this.bs.start(t)}onRRwebEmit(t){var e;null==(e=this.bs)||null==e.onRRwebEmit||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.bs||null==(e=this.ni)||e.register({$replay_override_linked_flag:!0}),null==(t=this.bs)||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.bs||null==(e=this.ni)||e.register({$replay_override_sampling:!0}),null==(t=this.bs)||t.overrideSampling()}overrideTrigger(t){var e,i;this.bs||null==(i=this.ni)||i.register({["url"===t?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(e=this.bs)||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return(null==(t=this.bs)?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!(null==(i=this.bs)||!i.tryAddCustomEvent(t,e))}}},or={autocapture:class{constructor(t){this.Rs=!1,this.Os=null,this.Ls=!1,this.instance=t,this.rageclicks=new Me(t.config.rageclick),this.Fs=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=f(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}As(){if(this.isBrowserSupported()){if(dt&&pt){var t=t=>{t=t||(null==dt?void 0:dt.event);try{this.Ns(t)}catch(t){He.error("Failed to capture event",t)}};if(St(pt,"submit",t,{capture:!0}),St(pt,"change",t,{capture:!0}),St(pt,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=t=>{t=t||(null==dt?void 0:dt.event);try{this.Ns(t,ze)}catch(t){He.error("Failed to capture copy/cut event",t)}};St(pt,"copy",e,{capture:!0}),St(pt,"cut",e,{capture:!0})}}}else He.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Rs&&(this.As(),this.Rs=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Ls=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ct]:!!t.autocapture_opt_out}),this.Os=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Fs=t}getElementSelectors(t){var e,i=[];return null==(e=this.Fs)||e.forEach((e=>{var r=null==pt?void 0:pt.querySelectorAll(e);null==r||r.forEach((r=>{t===r&&i.push(e)}))})),i}get isEnabled(){var t,e,i=null==(t=this.instance.persistence)?void 0:t.props[Ct];if(b(this.Os)&&!y(i)&&!this.instance.Lr())return!1;var r=null!==(e=this.Os)&&void 0!==e?e:!!i;return!!this.instance.config.autocapture&&!r}Ns(t,e){if(void 0===e&&(e="$autocapture"),this.isEnabled){var i,r=ge(t);ue(r)&&(r=r.parentNode||null),"$autocapture"===e&&"click"===t.type&&t instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||(new Date).getTime())&&function(t,e){if(!dt||xe(t))return!1;var i,r,s;if(y(e)?(i=!!e&&we,r=void 0):(i=null!==(s=null==e?void 0:e.css_selector_ignorelist)&&void 0!==s?s:we,r=null==e?void 0:e.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Ee(t,!1);return!function(t,e){if(!1===t||p(t))return!1;var i;if(!0===t)i=ye;else{if(!d(t))return!1;if(t.length>10)return mt.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{safeText:e,ariaLabel:r}=t;return i.some((t=>e.includes(t)||r.includes(t)))}))}(r,n.map((t=>{var e;return{safeText:pe(t).toLowerCase(),ariaLabel:(null==(e=t.getAttribute("aria-label"))?void 0:e.toLowerCase().trim())||""}})))&&!_e(n,i)}(r,this.instance.config.rageclick)&&this.Ns(t,"$rageclick");var s=e===ze;if(r&&function(t,e,i,r,s){var n,a,o,l;if(void 0===i&&(i=void 0),!dt||xe(t))return!1;if(null!=(n=i)&&n.url_allowlist&&!de(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&de(i.url_ignorelist))return!1;if(null!=(o=i)&&o.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some((t=>e.type===t)))return!1}var{parentIsUsefulElement:h,targetElementList:v}=Ee(t,r);if(!function(t,e){var i=null==e?void 0:e.element_allowlist;if(p(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}(v,i))return!1;if(!_e(v,null==(l=i)?void 0:l.css_selector_allowlist))return!1;var d=dt.getComputedStyle(t);if(d&&"pointer"===d.getPropertyValue("cursor")&&"click"===e.type)return!0;var c=t.tagName.toLowerCase();switch(c){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return h?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(be.indexOf(c)>-1||"true"===t.getAttribute("contenteditable"))}}(r,t,this.qt,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=Be(r,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Ls});if(a)return!1;var o=this.getElementSelectors(r);if(o&&o.length>0&&(n.$element_selectors=o),e===ze){var l,u=fe(null==dt||null==(l=dt.getSelection())?void 0:l.toString()),h=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return c(null==pt?void 0:pt.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.$s=(null==dt||null==(e=dt.location)?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(mt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ds&&this.Ds(),this.Ds=void 0,mt.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(dt&&dt.history){var i=this;null!=(t=dt.history.pushState)&&t.__posthog_wrapped__||Ye(dt.history,"pushState",(t=>function(e,r,s){t.call(this,e,r,s),i.qs("pushState")})),null!=(e=dt.history.replaceState)&&e.__posthog_wrapped__||Ye(dt.history,"replaceState",(t=>function(e,r,s){t.call(this,e,r,s),i.qs("replaceState")})),this.js()}}qs(t){try{var e,i=null==dt||null==(e=dt.location)?void 0:e.pathname;if(!i)return;i!==this.$s&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:t}),this.$s=i}catch(e){mt.error("Error capturing "+t+" pageview",e)}}js(){if(!this.Ds){var t=()=>{this.qs("popstate")};St(dt,"popstate",t),this.Ds=()=>{dt&&dt.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.Hs=!1,this.Rs=!1,this.Us=null,this.instance=t,this.Hs=!(null==(e=this.instance.persistence)||!e.props[Rt]),this.rageclicks=new Me(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return f(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return _(this.qt.capture_heatmaps)?_(this.qt.enable_heatmaps)?this.Hs:this.qt.enable_heatmaps:!1!==this.qt.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Rs)return;Ri.info("starting..."),this.Bs(),this.At()}else{var t;clearInterval(null!==(t=this.Us)&&void 0!==t?t:void 0),this.zs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Rt]:e}),this.Hs=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}Vs(t){this.Mt(t.originalEvent,"deadclick")}At(){this.Us&&clearInterval(this.Us),this.Us="visible"===(null==pt?void 0:pt.visibilityState)?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Bs(){dt&&pt&&(this.Ws=this.Zr.bind(this),St(dt,ie,this.Ws),this.Zs=t=>this.Mt(t||(null==dt?void 0:dt.event)),St(pt,"click",this.Zs,{capture:!0}),this.Gs=t=>this.Qs(t||(null==dt?void 0:dt.event)),St(pt,"mousemove",this.Gs,{capture:!0}),this.Js=new Ge(this.instance,qe,this.Vs.bind(this)),this.Js.startIfEnabledOrStop(),this.Ks=this.At.bind(this),St(pt,ee,this.Ks),this.Rs=!0)}zs(){var t;dt&&pt&&(this.Ws&&dt.removeEventListener(ie,this.Ws),this.Zs&&pt.removeEventListener("click",this.Zs,{capture:!0}),this.Gs&&pt.removeEventListener("mousemove",this.Gs,{capture:!0}),this.Ks&&pt.removeEventListener(ee,this.Ks),clearTimeout(this.Ys),null==(t=this.Js)||t.stop(),this.Rs=!1)}Xs(t,e){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(t,e,i){for(var r=t;r&&oe(r)&&!le(r,"body");){if(r===i)return!1;if(o(e,null==dt?void 0:dt.getComputedStyle(r).position))return!0;r=me(r)}return!1}(ge(t),["fixed","sticky"],s);return{x:t.clientX+(n?0:r),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var r;if(void 0===e&&(e="click"),!ae(t.target)&&Pi(t)){var s=this.Xs(t,e);null!=(r=this.rageclicks)&&r.isRageClick(t.clientX,t.clientY,(new Date).getTime())&&this.eo(i({},s,{type:"rageclick"})),this.eo(s)}}Qs(t){!ae(t.target)&&Pi(t)&&(clearTimeout(this.Ys),this.Ys=setTimeout((()=>{this.eo(this.Xs(t,"mousemove"))}),500))}eo(t){if(dt){var e=dt.location.href,i=this.qt.custom_personal_data_properties,r=this.qt.mask_personal_data_properties?[...li,...i||[]]:[],s=Ne(e,r,hi);this.M=this.M||{},this.M[s]||(this.M[s]=[]),this.M[s].push(t)}}Zr(){this.M&&!(t=>{if(f(t)){for(var e in t)if(h.call(t,e))return!1;return!0}return!1})(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Ge,webVitalsAutocapture:class{constructor(t){var e;this.Hs=!1,this.Rs=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.ro=()=>{clearTimeout(this.io),0!==this.M.metrics.length&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((t,e)=>i({},t,{["$web_vitals_"+e.name+"_event"]:i({},e),["$web_vitals_"+e.name+"_value"]:e.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=t=>{var e;this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.no();if(!p(r))if(_(null==t?void 0:t.name)||_(null==t?void 0:t.value))ci.error("Invalid metric received",t);else if(!this.so||this.so>t.value){this.M.url!==r&&(this.ro(),this.io=setTimeout(this.ro,this.flushToCaptureTimeoutMs)),p(this.M.url)&&(this.M.url=r),this.M.firstMetricTimestamp=p(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0);var s=null==(e=this._instance.sessionManager)?void 0:e.checkAndGetSessionAndWindowId(!0),n=i({},t,{$current_url:r,timestamp:Date.now()});p(s)||(n.$session_id=s.sessionId,n.$window_id=s.windowId),this.M.metrics.push(n),this.M.metrics.length===this.allowedMetrics.length&&this.ro()}else ci.error("Ignoring metric with value >= "+this.so,t)},this.oo=()=>{if(!this.Rs){var t,e,i,r,s=bt.__PosthogExtensions__;p(s)||p(s.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:e,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),t&&e&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&e(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.ht.bind(this)),this.Rs=!0):ci.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.Hs=!(null==(e=this._instance.persistence)||!e.props[Tt]),this.startIfEnabled()}get ao(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=f(this.ao)?null==(t=this.ao)?void 0:t.web_vitals_allowed_metrics:void 0;return _(i)?(null==(e=this._instance.persistence)?void 0:e.props[At])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(f(this.ao)?this.ao.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=f(this.ao)?this.ao.web_vitals_attribution:void 0;return null!=t&&t}get so(){var t=f(this.ao)&&m(this.ao.__web_vitals_max_value)?this.ao.__web_vitals_max_value:fi;return t>0&&6e4>=t?fi:t}get isEnabled(){var t=null==gt?void 0:gt.protocol;if("http:"!==t&&"https:"!==t)return ci.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=f(this.ao)?this.ao.web_vitals:y(this.ao)?this.ao:void 0;return y(e)?e:this.Hs}startIfEnabled(){this.isEnabled&&!this.Rs&&(ci.info("enabled, starting..."),this.lr(this.oo))}onRemoteConfig(t){if("capturePerformance"in t){var e=f(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=f(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Tt]:e}),this._instance.persistence.register({[At]:i})),this.Hs=e,this.startIfEnabled()}}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.postHogWebVitalsCallbacks?t():null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(e=>{e?ci.error("failed to load script",e):t()}))}no(){var t=dt?dt.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...li,...e||[]]:[];return Ne(t,i,hi)}ci.error("Could not determine current URL")}}},lr={exceptionObserver:class{constructor(t){var e,i,r;this.oo=()=>{var t;if(dt&&this.isEnabled&&null!=(t=bt.__PosthogExtensions__)&&t.errorWrappingFunctions){var e=bt.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=bt.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=bt.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.uo&&this.qt.capture_unhandled_errors&&(this.uo=e(this.captureException.bind(this))),!this.lo&&this.qt.capture_unhandled_rejections&&(this.lo=i(this.captureException.bind(this))),!this.ho&&this.qt.capture_console_errors&&(this.ho=r(this.captureException.bind(this)))}catch(t){Ke.error("failed to start",t),this.co()}}},this._instance=t,this.do=!(null==(e=this._instance.persistence)||!e.props[Pt]),this.vo=new F({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,Gt:Ke}),this.qt=this.fo(),this.startIfEnabledOrStop()}fo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return f(t)?e=i({},e,t):(p(t)?this.do:t)&&(e=i({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Ke.info("enabled"),this.co(),this.lr(this.oo)):this.co()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.errorWrappingFunctions&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",(e=>{if(e)return Ke.error("failed to load script",e);t()}))}co(){var t,e,i;null==(t=this.uo)||t.call(this),this.uo=void 0,null==(e=this.lo)||e.call(this),this.lo=void 0,null==(i=this.ho)||i.call(this),this.ho=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.do=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Pt]:this.do}),this.qt=this.fo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.fo()}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.vo.consumeRateLimit(s)?Ke.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,r;this.po=[],this.mo=new L([new G,new st,new Y,new K,new it,new et,new Z,new rt],function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),s=1;e>s;s++)r[s-1]=arguments[s];return function(e,s){void 0===s&&(s=0);for(var n=[],a=e.split("\n"),o=s;a.length>o;o++){var l=a[o];if(1024>=l.length){var u=q.test(l)?l.replace(q,"$1"):l;if(!u.match(/\S*Error: /)){for(var h of r){var v=h(u,t);if(v){n.push(v);break}}if(n.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 i({},t,{filename:t.filename||(r=e,r[r.length-1]||{}).filename,function:t.function||M});var r}))}(n)}}("web:javascript",V,J)),this._instance=t,this.po=null!==(e=null==(r=this._instance.persistence)?void 0:r.get_property($t))&&void 0!==e?e:[],this.yo=ut(this.bo()),this._o=new ht(this.yo)}onConfigChange(){this.yo=ut(this.bo()),this._o.setConfig(this.yo)}onRemoteConfig(t){var e,i,r;if("errorTracking"in t){var s=null!==(e=null==(i=t.errorTracking)?void 0:i.suppressionRules)&&void 0!==e?e:[],n=null==(r=t.errorTracking)?void 0:r.captureExtensionExceptions;this.po=s,this._instance.persistence&&this._instance.persistence.register({[$t]:this.po,[It]:n})}}get wo(){var t,e=!!this._instance.get_property(It),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(t=null!=i?i:e)&&void 0!==t&&t}buildProperties(t,e){return this.mo.buildFromUnknown(t,{syntheticException:null==e?void 0:e.syntheticException,mechanism:{handled:null==e?void 0:e.handled}})}addExceptionStep(t,e){if(this.yo.enabled)try{if(!g(t)||0===t.trim().length)return void Qi.warn("Ignoring exception step because message must be a non-empty string");var r=this.xo(e),{sanitizedProperties:s,droppedKeys:n}=function(t){if(!t)return{sanitizedProperties:{},droppedKeys:[]};var e=[];return{sanitizedProperties:Object.keys(t).reduce(((i,r)=>ot.has(r)?(e.push(r),i):(i[r]=t[r],i)),{}),droppedKeys:e}}(r);n.length>0&&Qi.warn("Ignoring reserved exception step fields",{droppedKeys:n}),this._o.add(i({[nt]:t,[at]:(new Date).toISOString()},s))}catch(t){Qi.error("Failed to add exception step. Ignoring breadcrumb.",t)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.So(e)){if(this.ko(e))return this.Co("Exception dropped: matched a suppression rule"),void Qi.info("Skipping exception capture because a suppression rule matched");if(!this.wo&&this.Io(e))return this.Co("Exception dropped: thrown by a browser extension"),void Qi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.To(e))return this.Co("Exception dropped: thrown by the PostHog SDK"),void Qi.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.yo.enabled&&_(t.$exception_steps)?this.Eo(t):t;try{var r=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",en:!0});return r&&this._o.clear(),r}catch(t){return Qi.error("Failed to capture exception event. Dropping this exception.",t),void this._o.clear()}}catch(t){return void Qi.error("Failed to process exception event. Ignoring this exception.",t)}}Eo(t){try{var e=this._o.getAttachable();return 0===e.length?t:i({},t,{$exception_steps:e})}catch(e){return Qi.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}Co(t){this.yo.enabled&&this._o.add({[nt]:t,[at]:(new Date).toISOString()})}xo(t){return f(t)?i({},t):{}}bo(){var t,e;return null!==(t=null==(e=this._instance.config.error_tracking)?void 0:e.exception_steps)&&void 0!==t?t:{}}ko(t){if(0===t.length)return!1;var e=t.reduce(((t,e)=>{var{type:i,value:r}=e;return g(i)&&i.length>0&&t.$exception_types.push(i),g(r)&&r.length>0&&t.$exception_values.push(r),t}),{$exception_types:[],$exception_values:[]});return this.po.some((t=>{var i=t.values.map((t=>{var i,r=Ei[t.operator],s=d(t.value)?t.value:[t.value],n=null!==(i=e[t.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)}));return"OR"===t.type?i.some(Boolean):i.every(Boolean)}))}Io(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://")))}To(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:[],a=n[n.length-1];return null!==(r=null==a||null==(s=a.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}So(t){return!_(t)&&d(t)}}},ur=i({productTours:class{get ni(){return this._instance.persistence}constructor(t){this.Mo=null,this.Po=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.ni&&this.ni.register({[Ot]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.Mo||(t=this._instance).config.disable_product_tours||null==(e=t.persistence)||!e.get_property(Ot)||this.lr((()=>this.Ro()))}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.generateProductTours?t():null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",(e=>{e?$i.error("Could not load product tours script",e):t()}))}Ro(){var t;!this.Mo&&null!=(t=bt.__PosthogExtensions__)&&t.generateProductTours&&(this.Mo=bt.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(void 0===e&&(e=!1),!d(this.Po)||e){var i=this.ni;if(i){var r=i.props[Gt];if(d(r)&&!e)return this.Po=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",callback:e=>{var r=e.statusCode;if(200!==r||!e.json){var s="Product Tours API could not be loaded, status: "+r;return $i.error(s),void t([],{isLoaded:!1,error:s})}var n=d(e.json.product_tours)?e.json.product_tours:[];this.Po=n,i&&i.register({[Gt]:n}),t(n,{isLoaded:!0})}})}else t(this.Po,{isLoaded:!0})}getActiveProductTours(t){_(this.Mo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Mo.getActiveProductTours(t)}showProductTour(t){var e;null==(e=this.Mo)||e.showTourById(t)}previewTour(t){this.Mo?this.Mo.previewTour(t):this.lr((()=>{var e;this.Ro(),null==(e=this.Mo)||e.previewTour(t)}))}dismissProductTour(){var t;null==(t=this.Mo)||t.dismissTour("user_clicked_skip")}nextStep(){var t;null==(t=this.Mo)||t.nextStep()}previousStep(){var t;null==(t=this.Mo)||t.previousStep()}clearCache(){var t;this.Po=null,null==(t=this.ni)||t.unregister(Gt)}resetTour(t){var e;null==(e=this.Mo)||e.resetTour(t)}resetAllTours(){var t;null==(t=this.Mo)||t.resetAllTours()}cancelPendingTour(t){var e;null==(e=this.Mo)||e.cancelPendingTour(t)}}},nr),hr={siteApps:class{constructor(t){this._instance=t,this.Oo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lo(t,e){if(e){var i=this.globalsForEvent(e);this.Oo.push(i),this.Oo.length>1e3&&(this.Oo=this.Oo.slice(10))}}get siteAppLoaders(){var t;return null==(t=bt._POSTHOG_REMOTE_CONFIG)||null==(t=t[this._instance.config.token])?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Lo.bind(this));this.Fo=()=>{t(),this.Oo=[],this.Fo=void 0}}}globalsForEvent(t){var e,r,s,n,a,o,l;if(!t)throw new Error("Event payload is required");var u={},h=this._instance.get_property("$groups")||[],v=this._instance.get_property("$stored_group_properties")||{};for(var[d,c]of Object.entries(v))u[d]={id:h[d],type:d,properties:c};var{$set_once:f,$set:p}=t;return{event:i({},function(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}(t,Ii),{properties:i({},t.properties,p?{$set:i({},null!==(e=null==(r=t.properties)?void 0:r.$set)&&void 0!==e?e:{},p)}:{},f?{$set_once:i({},null!==(s=null==(n=t.properties)?void 0:n.$set_once)&&void 0!==s?s:{},f)}:{}),elements_chain:null!==(a=null==(o=t.properties)?void 0:o.$elements_chain)&&void 0!==a?a:"",distinct_id:null==(l=t.properties)?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var i;!e.errored&&this.Oo.length&&(Ti.info("Processing "+this.Oo.length+" events for site app with id "+t.id),this.Oo.forEach((t=>null==e.processEvent?void 0:e.processEvent(t))),e.processedBuffer=!0),Object.values(this.apps).every((t=>t.processedBuffer||t.errored))&&(null==(i=this.Fo)||i.call(this))},r=!1,s=s=>{e.errored=!s,e.loaded=!0,Ti.info("Site app with id "+t.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(t){s(t)}});n&&(e.processEvent=n),r=!0}catch(e){Ti.error(Oi+t.id,e),s(!1)}if(r&&e.loaded)try{i()}catch(i){Ti.error("Error while processing buffered events PostHog app with config id "+t.id,i),e.errored=!0}}Ao(){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)}No(t){if(0!==Object.keys(this.apps).length){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(e)}catch(e){Ti.error("Error while processing event "+t.event+" for site app "+i.id,e)}}}onRemoteConfig(t){var e,i,r,s=this;if(null!=(e=this.siteAppLoaders)&&e.length)return this.isEnabled?(this.Ao(),void this._instance.on("eventCaptured",(t=>this.No(t)))):void Ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Fo)||i.call(this),null!=(r=t.siteApps)&&r.length)if(this.isEnabled){var n=function(t){var e;bt["__$$ph_site_app_"+t]=s._instance,null==(e=bt.__PosthogExtensions__)||null==e.loadSiteApp||e.loadSiteApp(s._instance,o,(e=>{if(e)return Ti.error(Oi+t,e)}))};for(var{id:a,url:o}of t.siteApps)n(a)}else Ti.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},vr={tracingHeaders:class{constructor(t){this.$o=void 0,this.Do=void 0,this.oo=()=>{var t,e,i=this.qo()||[];p(this.$o)&&(null==(t=bt.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchXHR(i,this._instance.get_distinct_id(),this._instance.sessionManager)),p(this.Do)&&(null==(e=bt.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchFetch(i,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;null!=(e=bt.__PosthogExtensions__)&&e.tracingHeadersPatchFns&&t(),null==(i=bt.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",(e=>{if(e)return Xe.error("failed to load script",e);t()}))}qo(){var t;return null!==(t=this._instance.config.addTracingHeaders)&&void 0!==t?t:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var t,e;this.qo()?this.lr(this.oo):(null==(t=this.$o)||t.call(this),null==(e=this.Do)||e.call(this),this.$o=void 0,this.Do=void 0)}}},dr=i({surveys:class{get qt(){return this._instance.config}constructor(t){this.jo=void 0,this._surveyManager=null,this.Ho=!1,this.Uo=[],this.Bo=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(_(e))return Li.warn("Flags not loaded yet. Not loading surveys.");var i=d(e);this.jo=i?e.length>0:e,Li.info("flags response received, isSurveysEnabled: "+this.jo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(null!=i&&i.startsWith("seenSurvey_")||null!=i&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((t=>localStorage.removeItem(t)))}loadIfEnabled(){if(!this._surveyManager)if(this.Ho)Li.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)Li.info(Wi);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())Li.info("Not loading surveys in cookieless mode without consent.");else{var t=null==bt?void 0:bt.__PosthogExtensions__;if(t){if(!p(this.jo)||this.qt.advanced_enable_surveys){var e=this.jo||this.qt.advanced_enable_surveys;this.Ho=!0;try{var i=t.generateSurveys;if(i)return void this.zo(i,e);var r=t.loadExternalDependency;if(!r)return void this.Vo(te);r(this._instance,"surveys",(i=>{i||!t.generateSurveys?this.Vo("Could not load surveys script",i):this.zo(t.generateSurveys,e)}))}catch(t){throw this.Vo("Error initializing surveys",t),t}finally{this.Ho=!1}}}else Li.error("PostHog Extensions not found.")}}zo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new Hi(this._instance),Li.info("Surveys loaded successfully"),this.Wo({isLoaded:!0})}Vo(t,e){Li.error(t,e),this.Wo({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Uo.push(t),this._surveyManager&&this.Wo({isLoaded:!0}),()=>{this.Uo=this.Uo.filter((e=>e!==t))}}getSurveys(t,e){if(void 0===e&&(e=!1),this.qt.disable_surveys)return Li.info(Wi),t([]);var i,r=this._instance.get_property(Jt);if(r&&!e)return t(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.Bo?this.Bo.then((e=>{var{surveys:i,context:r}=e;return t(i,r)})):("undefined"!=typeof Promise&&(this.Bo=new Promise((t=>{i=t}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:e=>{var r;this.Bo=null;var s=e.statusCode;if(200!==s||!e.json){var n="Surveys API could not be loaded, status: "+s;Li.error(n);var a={isLoaded:!1,error:n};return t([],a),void(null==i||i({surveys:[],context:a}))}var o,l=e.json.surveys||[],u=l.filter((t=>function(t){return!(!t.start_date||t.end_date)}(t)&&(function(t){var e;return!(null==(e=t.conditions)||null==(e=e.events)||null==(e=e.values)||!e.length)}(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==(o=this._surveyEventReceiver)||o.register(u)),null==(r=this._instance.persistence)||r.register({[Jt]:l});var h={isLoaded:!0};t(l,h),null==i||i({surveys:l,context:h})}}))}Wo(t){for(var e of this.Uo)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(t){Li.error("Error in survey callback",t)}}getActiveMatchingSurveys(t,e){if(void 0===e&&(e=!1),!_(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);Li.warn("init was not called")}Zo(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}Go(t){if(_(this._surveyManager))return{eligible:!1,reason:Vi};var e="string"==typeof t?this.Zo(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(_(this._surveyManager))return Li.warn("init was not called"),{visible:!1,disabledReason:Vi};var e=this.Go(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return _(this._surveyManager)?(Li.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Vi})):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.Go(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var r;if(_(this._surveyManager))Li.warn("init was not called");else{var s="string"==typeof t?this.Zo(t):t;if(null!=s&&s.id)if(Mi.includes(s.type)){var n=null==pt?void 0:pt.querySelector(e);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Li.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var t,e;Li.info("Rendering survey "+s.id+" with delay of "+(null==(t=s.appearance)?void 0:t.surveyPopupDelaySeconds)+" seconds"),null==(e=this._surveyManager)||e.renderSurvey(s,n,i),Li.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Li.warn("Survey element not found")}else Li.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Li.warn("Survey not found")}}displaySurvey(t,e){var r;if(_(this._surveyManager))Li.warn("init was not called");else{var s=this.Zo(t);if(s){var n=s;if(null!=(r=s.appearance)&&r.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=i({},s,{appearance:i({},s.appearance,{surveyPopupDelaySeconds:0})})),"popover"!==e.displayType&&e.initialResponses&&Li.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===e.ignoreConditions){var a=this.canRenderSurvey(s);if(!a.visible)return void Li.warn("Survey is not eligible to be displayed: ",a.disabledReason)}"inline"!==e.displayType?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}else Li.warn("Survey not found")}}cancelPendingSurvey(t){_(this._surveyManager)?Li.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;null==(t=this._surveyManager)||t.handlePageUnload()}}},nr),cr={toolbar:class{constructor(t){this.instance=t}Qo(t){bt.ph_toolbar_state=t}Jo(){var t;return null!==(t=bt.ph_toolbar_state)&&void 0!==t?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(void 0===t&&(t=void 0),void 0===e&&(e=void 0),void 0===i&&(i=void 0),Ft(this.instance.config))return!1;if(!dt||!pt)return!1;t=null!=t?t:dt.location,i=null!=i?i:dt.history;try{if(!e){try{dt.localStorage.setItem("test","test"),dt.localStorage.removeItem("test")}catch(t){return!1}e=null==dt?void 0:dt.localStorage}var r,s=Bi||Ue(t.hash,"__posthog")||Ue(t.hash,"state"),n=s?kt((()=>JSON.parse(atob(decodeURIComponent(s)))))||kt((()=>JSON.parse(decodeURIComponent(s)))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((r=JSON.parse(e.getItem(Ji)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(t){return!1}}Ko(t){var e=bt.ph_load_toolbar||bt.ph_load_editor;!_(e)&&c(e)?e(t,this.instance):qi.warn("No toolbar load function found")}loadToolbar(t){var e=!(null==pt||!pt.getElementById(Qt));if(!dt||e)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,s=i({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(dt.localStorage.setItem(Ji,JSON.stringify(i({},s,{source:void 0}))),2===this.Jo())this.Ko(s);else if(0===this.Jo()){var n;this.Qo(1),null==(n=bt.__PosthogExtensions__)||null==n.loadExternalDependency||n.loadExternalDependency(this.instance,"toolbar",(t=>{if(t)return qi.error("[Toolbar] Failed to load",t),void this.Qo(0);this.Qo(2),this.Ko(s)})),St(dt,"turbolinks:load",(()=>{this.Qo(0),this.loadToolbar(s)}))}return!0}Yo(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)}}},fr=i({experiments:ir},nr),pr={conversations:class{constructor(t){this.Xo=void 0,this._conversationsManager=null,this.ea=!1,this.ta=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;_(e)||(y(e)?this.Xo=e:(this.Xo=e.enabled,this.ta=e),this.loadIfEnabled())}}reset(){var t;null==(t=this._conversationsManager)||t.reset(),this._conversationsManager=null,this.Xo=void 0,this.ta=null}loadIfEnabled(){if(!(this._conversationsManager||this.ea||this._instance.config.disable_conversations||Ft(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=null==bt?void 0:bt.__PosthogExtensions__;if(t&&!p(this.Xo)&&this.Xo)if(this.ta&&this.ta.token){this.ea=!0;try{var e=t.initConversations;if(e)return this.ra(e),void(this.ea=!1);var i=t.loadExternalDependency;if(!i)return void this.ia(te);i(this._instance,"conversations",(e=>{e||!t.initConversations?this.ia("Could not load conversations script",e):this.ra(t.initConversations),this.ea=!1}))}catch(t){this.ia("Error initializing conversations",t),this.ea=!1}}else rr.error("Conversations enabled but missing token in remote config.")}}ra(t){if(this.ta)try{this._conversationsManager=t(this.ta,this._instance),rr.info("Conversations loaded successfully")}catch(t){this.ia("Error completing conversations initialization",t)}else rr.error("Cannot complete initialization: remote config is null")}ia(t,e){rr.error(t,e),this._conversationsManager=null,this.ea=!1}show(){this._conversationsManager?this._conversationsManager.show():rr.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.Xo&&!b(this._conversationsManager)}isVisible(){var t,e;return null!==(t=null==(e=this._conversationsManager)?void 0:e.isVisible())&&void 0!==t&&t}sendMessage(t,i,r){var s=this;return e((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,i,r):(rr.warn(sr),null)}))()}getMessages(t,i){var r=this;return e((function*(){return r._conversationsManager?r._conversationsManager.getMessages(t,i):(rr.warn(sr),null)}))()}markAsRead(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.markAsRead(t):(rr.warn(sr),null)}))()}getTickets(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.getTickets(t):(rr.warn(sr),null)}))()}requestRestoreLink(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.requestRestoreLink(t):(rr.warn(sr),null)}))()}restoreFromToken(t){var i=this;return e((function*(){return i._conversationsManager?i._conversationsManager.restoreFromToken(t):(rr.warn(sr),null)}))()}restoreFromUrlToken(){var t=this;return e((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(rr.warn(sr),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}ln(){var t;null==(t=this._conversationsManager)||t.setIdentity()}hn(){var t;null==(t=this._conversationsManager)||t.clearIdentity()}}},gr={logs:class{constructor(t){var e;this.na=!1,this.sa=!1,this.Gt=yt("[logs]"),this.oa=[],this.aa=0,this.ua=0,this.la=!1,this._instance=t,this._instance&&null!=(e=this._instance.config.logs)&&e.captureConsoleLogs&&(this.na=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=null==(e=t.logs)?void 0:e.captureConsoleLogs;!_(i)&&i&&(this.na=!0,this.loadIfEnabled())}reset(){this.oa=[],this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.aa=0,this.ua=0,this.la=!1}loadIfEnabled(){if(this.na&&!this.sa){var t=null==bt?void 0:bt.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(e=>{var i;e||null==(i=t.logs)||!i.initializeLogs?this.Gt.error("Could not load logs script",e):(t.logs.initializeLogs(this._instance),this.sa=!0)})):this.Gt.error(te)}else this.Gt.error("PostHog Extensions not found.")}}captureLog(t){var e,r,s,n,a,o;if(this._instance.is_capturing())if(t&&t.body){var l=null!==(e=null==(r=this._instance.config.logs)?void 0:r.flushIntervalMs)&&void 0!==e?e:3e3,u=null!==(s=null==(n=this._instance.config.logs)?void 0:n.maxLogsPerInterval)&&void 0!==s?s:1e3,h=Date.now();if(l>h-this.ua||(this.ua=h,this.aa=0,this.la=!1),u>this.aa){this.aa++;var v=function(t,e){var r=t.level||"info",{text:s,number:n}=I[r]||T,a=String(Date.now())+"000000",o={};e.distinctId&&(o.posthogDistinctId=e.distinctId),e.sessionId&&(o.sessionId=e.sessionId),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 l=i({},o,t.attributes||{}),u={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:n,severityText:s,body:{stringValue:t.body},attributes:A(l)};return t.trace_id&&(u.traceId=t.trace_id),t.span_id&&(u.spanId=t.span_id),p(t.trace_flags)||(u.flags=t.trace_flags),u}(t,this.ha());this.oa.push({record:v}),(null!==(a=null==(o=this._instance.config.logs)?void 0:o.maxBufferSize)&&void 0!==a?a:100)>this.oa.length?this.ca():this.flushLogs()}else this.la||(this.Gt.warn("captureLog dropping logs: exceeded "+u+" logs per "+l+"ms"),this.la=!0)}else this.Gt.warn("captureLog requires a body")}get logger(){return this.da||(this.da={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.da}flushLogs(t){if(this.qr&&(clearTimeout(this.qr),this.qr=void 0),0!==this.oa.length){var e=this.oa;this.oa=[];var n=this._instance.config.logs,a=i({"service.name":(null==n?void 0:n.serviceName)||"unknown_service"},(null==n?void 0:n.environment)&&{"deployment.environment":n.environment},(null==n?void 0:n.serviceVersion)&&{"service.version":n.serviceVersion},null==n?void 0:n.resourceAttributes),o=function(t,e,i,r){return{resourceLogs:[{resource:{attributes:A(e)},scopeLogs:[{scope:{name:i,version:r},logRecords:t}]}]}}(e.map((t=>t.record)),a,s,r),l=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:"POST",url:l,data:o,compression:"best-available",batchKey:"logs",transport:t})}}ca(){var t,e;this.qr||(this.qr=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),null!==(t=null==(e=this._instance.config.logs)?void 0:e.flushIntervalMs)&&void 0!==t?t:3e3))}ha(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(null!=bt&&null!=(t=bt.location)&&t.href&&(e.currentUrl=bt.location.href),this._instance.featureFlags){var r=this._instance.featureFlags.getFlags();r&&r.length>0&&(e.activeFeatureFlags=r)}return e}}},br=i({},nr,ar,or,lr,ur,hr,dr,vr,cr,fr,pr,gr),_r=nr,mr=ar,yr=or,wr=lr,xr=ur,Er=hr,kr=dr,Sr=vr,Fr=cr,Cr=fr,Rr=pr,Pr=gr;export{br as AllExtensions,yr as AnalyticsExtensions,Rr as ConversationsExtensions,wr as ErrorTrackingExtensions,Cr as ExperimentsExtensions,_r as FeatureFlagsExtensions,Pr as LogsExtensions,xr as ProductToursExtensions,mr as SessionReplayExtensions,Er as SiteAppsExtensions,kr as SurveysExtensions,Fr as ToolbarExtensions,Sr as TracingExtensions};
2
2
  //# sourceMappingURL=extension-bundles.js.map